tx · FNWkTV653gmr263qxLoq4ApYm4ieUuLYqGSii2ZmfktJ 3NAYA6kg7zqKjXc1AYGVi3FfawRbUULFzC1: -0.03300000 Waves 2022.12.05 14:30 [2347000] smart account 3NAYA6kg7zqKjXc1AYGVi3FfawRbUULFzC1 > SELF 0.00000000 Waves
{ "type": 13, "id": "FNWkTV653gmr263qxLoq4ApYm4ieUuLYqGSii2ZmfktJ", "fee": 3300000, "feeAssetId": null, "timestamp": 1670239761113, "version": 1, "sender": "3NAYA6kg7zqKjXc1AYGVi3FfawRbUULFzC1", "senderPublicKey": "7GiECPCqZ7JvTb1VfaViHDJj2avcCTMMR2nPfA48MFiY", "proofs": [ "4dcytWCbCpZCucgjE7o6tGwEavNiY3ojU7LjxiYsx7NNkTu7pus4TiRcguJmRgb5vULp3BftoMZRihoAc219mhwG" ], "script": "base64:BgLqKwgCEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgQKAggBEgQKAggBEgQKAggBEgUKAwEIARIAEgQKAgEBEgMKAQESBQoDAQEBEgQKAggIEgASABIDCgEIEgUKAwEBARIECgIBARIECgIIARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCBIAEgMKAQESAwoBARIECgIIASIKbFBkZWNpbWFscyIGc2NhbGU4IgxzY2FsZThCaWdJbnQiB3NjYWxlMTgiCnplcm9CaWdJbnQiBGJpZzAiBGJpZzEiBGJpZzIiC3dhdmVzU3RyaW5nIgNTRVAiClBvb2xBY3RpdmUiD1Bvb2xQdXREaXNhYmxlZCITUG9vbE1hdGNoZXJEaXNhYmxlZCIMUG9vbFNodXRkb3duIg5pZHhQb29sQWRkcmVzcyINaWR4UG9vbFN0YXR1cyIQaWR4UG9vbExQQXNzZXRJZCINaWR4QW10QXNzZXRJZCIPaWR4UHJpY2VBc3NldElkIg5pZHhBbXRBc3NldERjbSIQaWR4UHJpY2VBc3NldERjbSIOaWR4SUFtdEFzc2V0SWQiEGlkeElQcmljZUFzc2V0SWQiDWlkeExQQXNzZXREY20iEml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ded", "spentComplexity": 0 } View: original | compacted Prev: ACwmb28DWXafbFwvmCLjMDehnrNz3hN3LHmywDFY4ScG Next: J2pmBkBmb2ijAdNMdctgwyWcLkJg3BJvXjt8yWyKS686 Diff:
Old | New | Differences | |
---|---|---|---|
1144 | 1144 | else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1145 | 1145 | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1146 | 1146 | then { | |
1147 | - | let $t04271742772 = refreshKLpInternal(0, 0, 0) | |
1148 | - | let actions = $t04271742772._1 | |
1149 | - | let updatedKLp = $t04271742772._2 | |
1147 | + | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
1148 | + | let $t04284342907 = refreshKLpInternal(0, 0, 0) | |
1149 | + | let kLpUpdateActions = $t04284342907._1 | |
1150 | + | let updatedKLp = $t04284342907._2 | |
1151 | + | let actions = if ((kLp != updatedKLp)) | |
1152 | + | then kLpUpdateActions | |
1153 | + | else throwErr("nothing to refresh") | |
1150 | 1154 | $Tuple2(actions, toString(updatedKLp)) | |
1151 | 1155 | } | |
1152 | 1156 | else throw("Strict value is not equal to itself.") |
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 calcKLp (amountBalance,priceBalance,lpEmission) = { | |
377 | 377 | let updatedKLp = fraction(pow((amountBalance * priceBalance), 0, toBigInt(5), 1, 0, DOWN), scale18, lpEmission) | |
378 | 378 | updatedKLp | |
379 | 379 | } | |
380 | 380 | ||
381 | 381 | ||
382 | 382 | func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
383 | 383 | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
384 | 384 | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
385 | 385 | let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta) | |
386 | 386 | let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
387 | 387 | let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))] | |
388 | 388 | $Tuple2(actions, updatedKLp) | |
389 | 389 | } | |
390 | 390 | ||
391 | 391 | ||
392 | 392 | func validateMatcherOrderAllowed (order) = { | |
393 | 393 | let amountAssetAmount = order.amount | |
394 | 394 | let priceAssetAmount = fraction(order.amount, order.price, scale8) | |
395 | 395 | let $t01955919771 = if ((order.orderType == Buy)) | |
396 | 396 | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
397 | 397 | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
398 | 398 | let amountAssetBalanceDelta = $t01955919771._1 | |
399 | 399 | let priceAssetBalanceDelta = $t01955919771._2 | |
400 | 400 | if (if (if (isGlobalShutdown()) | |
401 | 401 | then true | |
402 | 402 | else (cfgPoolStatus == PoolMatcherDisabled)) | |
403 | 403 | then true | |
404 | 404 | else (cfgPoolStatus == PoolShutdown)) | |
405 | 405 | then throw("Exchange operations disabled") | |
406 | 406 | else if (if ((order.assetPair.amountAsset != cfgAmountAssetId)) | |
407 | 407 | then true | |
408 | 408 | else (order.assetPair.priceAsset != cfgPriceAssetId)) | |
409 | 409 | then throw("Wrong order assets.") | |
410 | 410 | else { | |
411 | 411 | let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp")) | |
412 | 412 | let $t02024220342 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
413 | 413 | let unusedActions = $t02024220342._1 | |
414 | 414 | let kLpNew = $t02024220342._2 | |
415 | 415 | let isOrderValid = (kLpNew > kLp) | |
416 | 416 | isOrderValid | |
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 $t02302623319 = 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 = $t02302623319._1 | |
496 | 496 | let priceBalanceOld = $t02302623319._2 | |
497 | 497 | let $t02332323472 = if (paymentInAmountAsset) | |
498 | 498 | then $Tuple2(paymentAmountRaw, 0) | |
499 | 499 | else $Tuple2(0, paymentAmountRaw) | |
500 | 500 | let amountAssetAmountRaw = $t02332323472._1 | |
501 | 501 | let priceAssetAmountRaw = $t02332323472._2 | |
502 | 502 | let amountAssetAmount = takeFee(amountAssetAmountRaw)._1 | |
503 | 503 | let priceAssetAmount = takeFee(priceAssetAmountRaw)._1 | |
504 | 504 | let $t02359423653 = takeFee(paymentAmountRaw) | |
505 | 505 | let paymentAmount = $t02359423653._1 | |
506 | 506 | let feeAmount = $t02359423653._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 $t02513025297 = if (paymentInAmountAsset) | |
530 | 530 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
531 | 531 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
532 | 532 | let amount = $t02513025297._1 | |
533 | 533 | let balance = $t02513025297._2 | |
534 | 534 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
535 | 535 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
536 | 536 | } | |
537 | 537 | $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset) | |
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 $t02689926949 = takeFee(amountRaw) | |
568 | 568 | let totalAmount = $t02689926949._1 | |
569 | 569 | let feeAmount = $t02689926949._2 | |
570 | 570 | let $t02695327179 = if (outInAmountAsset) | |
571 | 571 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
572 | 572 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
573 | 573 | let outAmAmount = $t02695327179._1 | |
574 | 574 | let outPrAmount = $t02695327179._2 | |
575 | 575 | let amBalanceNew = $t02695327179._3 | |
576 | 576 | let prBalanceNew = $t02695327179._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 | $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset) | |
589 | 589 | } | |
590 | 590 | else throw("Strict value is not equal to itself.") | |
591 | 591 | } | |
592 | 592 | ||
593 | 593 | ||
594 | 594 | func managerPublicKeyOrUnit () = match getString(mpk()) { | |
595 | 595 | case s: String => | |
596 | 596 | fromBase58String(s) | |
597 | 597 | case _: Unit => | |
598 | 598 | unit | |
599 | 599 | case _ => | |
600 | 600 | throw("Match error") | |
601 | 601 | } | |
602 | 602 | ||
603 | 603 | ||
604 | 604 | func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) { | |
605 | 605 | case s: String => | |
606 | 606 | fromBase58String(s) | |
607 | 607 | case _: Unit => | |
608 | 608 | unit | |
609 | 609 | case _ => | |
610 | 610 | throw("Match error") | |
611 | 611 | } | |
612 | 612 | ||
613 | 613 | ||
614 | 614 | func isManager (i) = match managerPublicKeyOrUnit() { | |
615 | 615 | case pk: ByteVector => | |
616 | 616 | (i.callerPublicKey == pk) | |
617 | 617 | case _: Unit => | |
618 | 618 | (i.caller == this) | |
619 | 619 | case _ => | |
620 | 620 | throw("Match error") | |
621 | 621 | } | |
622 | 622 | ||
623 | 623 | ||
624 | 624 | func mustManager (i) = { | |
625 | 625 | let pd = throw("Permission denied") | |
626 | 626 | match managerPublicKeyOrUnit() { | |
627 | 627 | case pk: ByteVector => | |
628 | 628 | if ((i.callerPublicKey == pk)) | |
629 | 629 | then true | |
630 | 630 | else pd | |
631 | 631 | case _: Unit => | |
632 | 632 | if ((i.caller == this)) | |
633 | 633 | then true | |
634 | 634 | else pd | |
635 | 635 | case _ => | |
636 | 636 | throw("Match error") | |
637 | 637 | } | |
638 | 638 | } | |
639 | 639 | ||
640 | 640 | ||
641 | 641 | @Callable(i) | |
642 | 642 | func setManager (pendingManagerPublicKey) = { | |
643 | 643 | let checkCaller = mustManager(i) | |
644 | 644 | if ((checkCaller == checkCaller)) | |
645 | 645 | then { | |
646 | 646 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
647 | 647 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
648 | 648 | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
649 | 649 | else throw("Strict value is not equal to itself.") | |
650 | 650 | } | |
651 | 651 | else throw("Strict value is not equal to itself.") | |
652 | 652 | } | |
653 | 653 | ||
654 | 654 | ||
655 | 655 | ||
656 | 656 | @Callable(i) | |
657 | 657 | func confirmManager () = { | |
658 | 658 | let pm = pendingManagerPublicKeyOrUnit() | |
659 | 659 | let hasPM = if (isDefined(pm)) | |
660 | 660 | then true | |
661 | 661 | else throw("No pending manager") | |
662 | 662 | if ((hasPM == hasPM)) | |
663 | 663 | then { | |
664 | 664 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
665 | 665 | then true | |
666 | 666 | else throw("You are not pending manager") | |
667 | 667 | if ((checkPM == checkPM)) | |
668 | 668 | then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())] | |
669 | 669 | else throw("Strict value is not equal to itself.") | |
670 | 670 | } | |
671 | 671 | else throw("Strict value is not equal to itself.") | |
672 | 672 | } | |
673 | 673 | ||
674 | 674 | ||
675 | 675 | ||
676 | 676 | @Callable(i) | |
677 | 677 | func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance)) | |
678 | 678 | then throw("Invalid slippageTolerance passed") | |
679 | 679 | else { | |
680 | 680 | let estPut = commonPut(i, slippageTolerance, true) | |
681 | 681 | let emitLpAmt = estPut._2 | |
682 | 682 | let lpAssetId = estPut._7 | |
683 | 683 | let state = estPut._9 | |
684 | 684 | let amDiff = estPut._10 | |
685 | 685 | let prDiff = estPut._11 | |
686 | 686 | let amId = estPut._12 | |
687 | 687 | let prId = estPut._13 | |
688 | 688 | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
689 | 689 | if ((emitInv == emitInv)) | |
690 | 690 | then { | |
691 | 691 | let emitInvLegacy = match emitInv { | |
692 | 692 | case legacyFactoryContract: Address => | |
693 | 693 | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
694 | 694 | case _ => | |
695 | 695 | unit | |
696 | 696 | } | |
697 | 697 | if ((emitInvLegacy == emitInvLegacy)) | |
698 | 698 | then { | |
699 | 699 | let slippageAInv = if ((amDiff > 0)) | |
700 | 700 | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
701 | 701 | else nil | |
702 | 702 | if ((slippageAInv == slippageAInv)) | |
703 | 703 | then { | |
704 | 704 | let slippagePInv = if ((prDiff > 0)) | |
705 | 705 | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
706 | 706 | else nil | |
707 | 707 | if ((slippagePInv == slippagePInv)) | |
708 | 708 | then { | |
709 | 709 | let lpTransfer = if (shouldAutoStake) | |
710 | 710 | then { | |
711 | 711 | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
712 | 712 | if ((slpStakeInv == slpStakeInv)) | |
713 | 713 | then nil | |
714 | 714 | else throw("Strict value is not equal to itself.") | |
715 | 715 | } | |
716 | 716 | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
717 | 717 | let $t03113031195 = refreshKLpInternal(0, 0, 0) | |
718 | 718 | let refreshKLpActions = $t03113031195._1 | |
719 | 719 | let updatedKLp = $t03113031195._2 | |
720 | 720 | ((state ++ lpTransfer) ++ refreshKLpActions) | |
721 | 721 | } | |
722 | 722 | else throw("Strict value is not equal to itself.") | |
723 | 723 | } | |
724 | 724 | else throw("Strict value is not equal to itself.") | |
725 | 725 | } | |
726 | 726 | else throw("Strict value is not equal to itself.") | |
727 | 727 | } | |
728 | 728 | else throw("Strict value is not equal to itself.") | |
729 | 729 | } | |
730 | 730 | ||
731 | 731 | ||
732 | 732 | ||
733 | 733 | @Callable(i) | |
734 | 734 | func putForFree (maxSlippage) = if ((0 > maxSlippage)) | |
735 | 735 | then throw("Invalid value passed") | |
736 | 736 | else { | |
737 | 737 | let estPut = commonPut(i, maxSlippage, false) | |
738 | 738 | let state = estPut._9 | |
739 | 739 | let $t03148131546 = refreshKLpInternal(0, 0, 0) | |
740 | 740 | let refreshKLpActions = $t03148131546._1 | |
741 | 741 | let updatedKLp = $t03148131546._2 | |
742 | 742 | (state ++ refreshKLpActions) | |
743 | 743 | } | |
744 | 744 | ||
745 | 745 | ||
746 | 746 | ||
747 | 747 | @Callable(i) | |
748 | 748 | func putOneTkn (minOutAmount,autoStake) = { | |
749 | 749 | let isPoolOneTokenOperationsDisabled = { | |
750 | 750 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
751 | 751 | if ($isInstanceOf(@, "Boolean")) | |
752 | 752 | then @ | |
753 | 753 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
754 | 754 | } | |
755 | 755 | let isPutDisabled = if (if (if (isGlobalShutdown()) | |
756 | 756 | then true | |
757 | 757 | else (cfgPoolStatus == PoolPutDisabled)) | |
758 | 758 | then true | |
759 | 759 | else (cfgPoolStatus == PoolShutdown)) | |
760 | 760 | then true | |
761 | 761 | else isPoolOneTokenOperationsDisabled | |
762 | 762 | let checks = [if (if (!(isPutDisabled)) | |
763 | 763 | then true | |
764 | 764 | else isManager(i)) | |
765 | 765 | then true | |
766 | 766 | else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1)) | |
767 | 767 | then true | |
768 | 768 | else throwErr("exactly 1 payment are expected")] | |
769 | 769 | if ((checks == checks)) | |
770 | 770 | then { | |
771 | 771 | let payment = i.payments[0] | |
772 | 772 | let paymentAssetId = payment.assetId | |
773 | 773 | let paymentAmountRaw = payment.amount | |
774 | 774 | let userAddress = i.caller | |
775 | 775 | let txId = i.transactionId | |
776 | 776 | let $t03232232474 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
777 | 777 | if (($t03232232474 == $t03232232474)) | |
778 | 778 | then { | |
779 | 779 | let paymentInAmountAsset = $t03232232474._5 | |
780 | 780 | let bonus = $t03232232474._4 | |
781 | 781 | let feeAmount = $t03232232474._3 | |
782 | 782 | let commonState = $t03232232474._2 | |
783 | 783 | let emitAmountEstimated = $t03232232474._1 | |
784 | 784 | let emitAmount = if (if ((minOutAmount > 0)) | |
785 | 785 | then (minOutAmount > emitAmountEstimated) | |
786 | 786 | else false) | |
787 | 787 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
788 | 788 | else emitAmountEstimated | |
789 | 789 | let emitInv = emit(emitAmount) | |
790 | 790 | if ((emitInv == emitInv)) | |
791 | 791 | then { | |
792 | 792 | let lpTransfer = if (autoStake) | |
793 | 793 | then { | |
794 | 794 | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
795 | 795 | if ((stakeInv == stakeInv)) | |
796 | 796 | then nil | |
797 | 797 | else throw("Strict value is not equal to itself.") | |
798 | 798 | } | |
799 | 799 | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
800 | 800 | let sendFee = if ((feeAmount > 0)) | |
801 | 801 | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
802 | 802 | else nil | |
803 | 803 | let $t03306033257 = if ((this == feeCollectorAddress)) | |
804 | 804 | then $Tuple2(0, 0) | |
805 | 805 | else if (paymentInAmountAsset) | |
806 | 806 | then $Tuple2(-(feeAmount), 0) | |
807 | 807 | else $Tuple2(0, -(feeAmount)) | |
808 | 808 | let amountAssetBalanceDelta = $t03306033257._1 | |
809 | 809 | let priceAssetBalanceDelta = $t03306033257._2 | |
810 | 810 | let $t03326033368 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
811 | 811 | let refreshKLpActions = $t03326033368._1 | |
812 | 812 | let updatedKLp = $t03326033368._2 | |
813 | 813 | $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
814 | 814 | } | |
815 | 815 | else throw("Strict value is not equal to itself.") | |
816 | 816 | } | |
817 | 817 | else throw("Strict value is not equal to itself.") | |
818 | 818 | } | |
819 | 819 | else throw("Strict value is not equal to itself.") | |
820 | 820 | } | |
821 | 821 | ||
822 | 822 | ||
823 | 823 | ||
824 | 824 | @Callable(i) | |
825 | 825 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
826 | 826 | let $t03356133718 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
827 | 827 | let emitAmountEstimated = $t03356133718._1 | |
828 | 828 | let commonState = $t03356133718._2 | |
829 | 829 | let feeAmount = $t03356133718._3 | |
830 | 830 | let bonus = $t03356133718._4 | |
831 | 831 | let paymentInAmountAsset = $t03356133718._5 | |
832 | 832 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
833 | 833 | } | |
834 | 834 | ||
835 | 835 | ||
836 | 836 | ||
837 | 837 | @Callable(i) | |
838 | 838 | func getOneTkn (outAssetIdStr,minOutAmount) = { | |
839 | 839 | let isPoolOneTokenOperationsDisabled = { | |
840 | 840 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
841 | 841 | if ($isInstanceOf(@, "Boolean")) | |
842 | 842 | then @ | |
843 | 843 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
844 | 844 | } | |
845 | 845 | let isGetDisabled = if (if (isGlobalShutdown()) | |
846 | 846 | then true | |
847 | 847 | else (cfgPoolStatus == PoolShutdown)) | |
848 | 848 | then true | |
849 | 849 | else isPoolOneTokenOperationsDisabled | |
850 | 850 | let checks = [if (if (!(isGetDisabled)) | |
851 | 851 | then true | |
852 | 852 | else isManager(i)) | |
853 | 853 | then true | |
854 | 854 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1)) | |
855 | 855 | then true | |
856 | 856 | else throwErr("exactly 1 payment are expected")] | |
857 | 857 | if ((checks == checks)) | |
858 | 858 | then { | |
859 | 859 | let outAssetId = parseAssetId(outAssetIdStr) | |
860 | 860 | let payment = i.payments[0] | |
861 | 861 | let paymentAssetId = payment.assetId | |
862 | 862 | let paymentAmount = payment.amount | |
863 | 863 | let userAddress = i.caller | |
864 | 864 | let txId = i.transactionId | |
865 | 865 | let $t03452334676 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
866 | 866 | if (($t03452334676 == $t03452334676)) | |
867 | 867 | then { | |
868 | 868 | let outInAmountAsset = $t03452334676._5 | |
869 | 869 | let bonus = $t03452334676._4 | |
870 | 870 | let feeAmount = $t03452334676._3 | |
871 | 871 | let commonState = $t03452334676._2 | |
872 | 872 | let amountEstimated = $t03452334676._1 | |
873 | 873 | let amount = if (if ((minOutAmount > 0)) | |
874 | 874 | then (minOutAmount > amountEstimated) | |
875 | 875 | else false) | |
876 | 876 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
877 | 877 | else amountEstimated | |
878 | 878 | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
879 | 879 | if ((burnInv == burnInv)) | |
880 | 880 | then { | |
881 | 881 | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
882 | 882 | let sendFee = if ((feeAmount > 0)) | |
883 | 883 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
884 | 884 | else nil | |
885 | 885 | let $t03517635423 = { | |
886 | 886 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
887 | 887 | then 0 | |
888 | 888 | else feeAmount | |
889 | 889 | if (outInAmountAsset) | |
890 | 890 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
891 | 891 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
892 | 892 | } | |
893 | 893 | let amountAssetBalanceDelta = $t03517635423._1 | |
894 | 894 | let priceAssetBalanceDelta = $t03517635423._2 | |
895 | 895 | let $t03542635534 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
896 | 896 | let refreshKLpActions = $t03542635534._1 | |
897 | 897 | let updatedKLp = $t03542635534._2 | |
898 | 898 | $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
899 | 899 | } | |
900 | 900 | else throw("Strict value is not equal to itself.") | |
901 | 901 | } | |
902 | 902 | else throw("Strict value is not equal to itself.") | |
903 | 903 | } | |
904 | 904 | else throw("Strict value is not equal to itself.") | |
905 | 905 | } | |
906 | 906 | ||
907 | 907 | ||
908 | 908 | ||
909 | 909 | @Callable(i) | |
910 | 910 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
911 | 911 | let $t03571835874 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
912 | 912 | let amountEstimated = $t03571835874._1 | |
913 | 913 | let commonState = $t03571835874._2 | |
914 | 914 | let feeAmount = $t03571835874._3 | |
915 | 915 | let bonus = $t03571835874._4 | |
916 | 916 | let outInAmountAsset = $t03571835874._5 | |
917 | 917 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
918 | 918 | } | |
919 | 919 | ||
920 | 920 | ||
921 | 921 | ||
922 | 922 | @Callable(i) | |
923 | 923 | func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = { | |
924 | 924 | let isPoolOneTokenOperationsDisabled = { | |
925 | 925 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
926 | 926 | if ($isInstanceOf(@, "Boolean")) | |
927 | 927 | then @ | |
928 | 928 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
929 | 929 | } | |
930 | 930 | let isGetDisabled = if (if (isGlobalShutdown()) | |
931 | 931 | then true | |
932 | 932 | else (cfgPoolStatus == PoolShutdown)) | |
933 | 933 | then true | |
934 | 934 | else isPoolOneTokenOperationsDisabled | |
935 | 935 | let checks = [if (if (!(isGetDisabled)) | |
936 | 936 | then true | |
937 | 937 | else isManager(i)) | |
938 | 938 | then true | |
939 | 939 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
940 | 940 | then true | |
941 | 941 | else throwErr("no payments are expected")] | |
942 | 942 | if ((checks == checks)) | |
943 | 943 | then { | |
944 | 944 | let outAssetId = parseAssetId(outAssetIdStr) | |
945 | 945 | let userAddress = i.caller | |
946 | 946 | let txId = i.transactionId | |
947 | 947 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
948 | 948 | if ((unstakeInv == unstakeInv)) | |
949 | 949 | then { | |
950 | 950 | let $t03669936850 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
951 | 951 | if (($t03669936850 == $t03669936850)) | |
952 | 952 | then { | |
953 | 953 | let outInAmountAsset = $t03669936850._5 | |
954 | 954 | let bonus = $t03669936850._4 | |
955 | 955 | let feeAmount = $t03669936850._3 | |
956 | 956 | let commonState = $t03669936850._2 | |
957 | 957 | let amountEstimated = $t03669936850._1 | |
958 | 958 | let amount = if (if ((minOutAmount > 0)) | |
959 | 959 | then (minOutAmount > amountEstimated) | |
960 | 960 | else false) | |
961 | 961 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
962 | 962 | else amountEstimated | |
963 | 963 | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
964 | 964 | if ((burnInv == burnInv)) | |
965 | 965 | then { | |
966 | 966 | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
967 | 967 | let sendFee = if ((feeAmount > 0)) | |
968 | 968 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
969 | 969 | else nil | |
970 | 970 | let $t03734537592 = { | |
971 | 971 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
972 | 972 | then 0 | |
973 | 973 | else feeAmount | |
974 | 974 | if (outInAmountAsset) | |
975 | 975 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
976 | 976 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
977 | 977 | } | |
978 | 978 | let amountAssetBalanceDelta = $t03734537592._1 | |
979 | 979 | let priceAssetBalanceDelta = $t03734537592._2 | |
980 | 980 | let $t03759537703 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
981 | 981 | let refreshKLpActions = $t03759537703._1 | |
982 | 982 | let updatedKLp = $t03759537703._2 | |
983 | 983 | $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
984 | 984 | } | |
985 | 985 | else throw("Strict value is not equal to itself.") | |
986 | 986 | } | |
987 | 987 | else throw("Strict value is not equal to itself.") | |
988 | 988 | } | |
989 | 989 | else throw("Strict value is not equal to itself.") | |
990 | 990 | } | |
991 | 991 | else throw("Strict value is not equal to itself.") | |
992 | 992 | } | |
993 | 993 | ||
994 | 994 | ||
995 | 995 | ||
996 | 996 | @Callable(i) | |
997 | 997 | func get () = { | |
998 | 998 | let res = commonGet(i) | |
999 | 999 | let outAmtAmt = res._1 | |
1000 | 1000 | let outPrAmt = res._2 | |
1001 | 1001 | let pmtAmt = res._3 | |
1002 | 1002 | let pmtAssetId = res._4 | |
1003 | 1003 | let state = res._5 | |
1004 | 1004 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1005 | 1005 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1006 | 1006 | then { | |
1007 | 1007 | let $t03849538577 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1008 | 1008 | let refreshKLpActions = $t03849538577._1 | |
1009 | 1009 | let updatedKLp = $t03849538577._2 | |
1010 | 1010 | (state ++ refreshKLpActions) | |
1011 | 1011 | } | |
1012 | 1012 | else throw("Strict value is not equal to itself.") | |
1013 | 1013 | } | |
1014 | 1014 | ||
1015 | 1015 | ||
1016 | 1016 | ||
1017 | 1017 | @Callable(i) | |
1018 | 1018 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
1019 | 1019 | let res = commonGet(i) | |
1020 | 1020 | let outAmAmt = res._1 | |
1021 | 1021 | let outPrAmt = res._2 | |
1022 | 1022 | let pmtAmt = res._3 | |
1023 | 1023 | let pmtAssetId = res._4 | |
1024 | 1024 | let state = res._5 | |
1025 | 1025 | if ((noLessThenAmtAsset > outAmAmt)) | |
1026 | 1026 | then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
1027 | 1027 | else if ((noLessThenPriceAsset > outPrAmt)) | |
1028 | 1028 | then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
1029 | 1029 | else { | |
1030 | 1030 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1031 | 1031 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1032 | 1032 | then { | |
1033 | 1033 | let $t03937339454 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1034 | 1034 | let refreshKLpActions = $t03937339454._1 | |
1035 | 1035 | let updatedKLp = $t03937339454._2 | |
1036 | 1036 | (state ++ refreshKLpActions) | |
1037 | 1037 | } | |
1038 | 1038 | else throw("Strict value is not equal to itself.") | |
1039 | 1039 | } | |
1040 | 1040 | } | |
1041 | 1041 | ||
1042 | 1042 | ||
1043 | 1043 | ||
1044 | 1044 | @Callable(i) | |
1045 | 1045 | func unstakeAndGet (amount) = { | |
1046 | 1046 | let checkPayments = if ((size(i.payments) != 0)) | |
1047 | 1047 | then throw("No payments are expected") | |
1048 | 1048 | else true | |
1049 | 1049 | if ((checkPayments == checkPayments)) | |
1050 | 1050 | then { | |
1051 | 1051 | let cfg = getPoolConfig() | |
1052 | 1052 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1053 | 1053 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1054 | 1054 | if ((unstakeInv == unstakeInv)) | |
1055 | 1055 | then { | |
1056 | 1056 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1057 | 1057 | let outAmAmt = res._1 | |
1058 | 1058 | let outPrAmt = res._2 | |
1059 | 1059 | let poolStatus = parseIntValue(res._9) | |
1060 | 1060 | let state = res._10 | |
1061 | 1061 | let checkPoolStatus = if (if (isGlobalShutdown()) | |
1062 | 1062 | then true | |
1063 | 1063 | else (poolStatus == PoolShutdown)) | |
1064 | 1064 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
1065 | 1065 | else true | |
1066 | 1066 | if ((checkPoolStatus == checkPoolStatus)) | |
1067 | 1067 | then { | |
1068 | 1068 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1069 | 1069 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1070 | 1070 | then { | |
1071 | 1071 | let $t04042740508 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1072 | 1072 | let refreshKLpActions = $t04042740508._1 | |
1073 | 1073 | let updatedKLp = $t04042740508._2 | |
1074 | 1074 | (state ++ refreshKLpActions) | |
1075 | 1075 | } | |
1076 | 1076 | else throw("Strict value is not equal to itself.") | |
1077 | 1077 | } | |
1078 | 1078 | else throw("Strict value is not equal to itself.") | |
1079 | 1079 | } | |
1080 | 1080 | else throw("Strict value is not equal to itself.") | |
1081 | 1081 | } | |
1082 | 1082 | else throw("Strict value is not equal to itself.") | |
1083 | 1083 | } | |
1084 | 1084 | ||
1085 | 1085 | ||
1086 | 1086 | ||
1087 | 1087 | @Callable(i) | |
1088 | 1088 | func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = { | |
1089 | 1089 | let isGetDisabled = if (isGlobalShutdown()) | |
1090 | 1090 | then true | |
1091 | 1091 | else (cfgPoolStatus == PoolShutdown) | |
1092 | 1092 | let checks = [if (!(isGetDisabled)) | |
1093 | 1093 | then true | |
1094 | 1094 | else throw("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1095 | 1095 | then true | |
1096 | 1096 | else throw("no payments are expected")] | |
1097 | 1097 | if ((checks == checks)) | |
1098 | 1098 | then { | |
1099 | 1099 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1100 | 1100 | if ((unstakeInv == unstakeInv)) | |
1101 | 1101 | then { | |
1102 | 1102 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1103 | 1103 | let outAmAmt = res._1 | |
1104 | 1104 | let outPrAmt = res._2 | |
1105 | 1105 | let state = res._10 | |
1106 | 1106 | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1107 | 1107 | then true | |
1108 | 1108 | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1109 | 1109 | then true | |
1110 | 1110 | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1111 | 1111 | if ((checkAmounts == checkAmounts)) | |
1112 | 1112 | then { | |
1113 | 1113 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1114 | 1114 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1115 | 1115 | then { | |
1116 | 1116 | let $t04164841729 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1117 | 1117 | let refreshKLpActions = $t04164841729._1 | |
1118 | 1118 | let updatedKLp = $t04164841729._2 | |
1119 | 1119 | (state ++ refreshKLpActions) | |
1120 | 1120 | } | |
1121 | 1121 | else throw("Strict value is not equal to itself.") | |
1122 | 1122 | } | |
1123 | 1123 | else throw("Strict value is not equal to itself.") | |
1124 | 1124 | } | |
1125 | 1125 | else throw("Strict value is not equal to itself.") | |
1126 | 1126 | } | |
1127 | 1127 | else throw("Strict value is not equal to itself.") | |
1128 | 1128 | } | |
1129 | 1129 | ||
1130 | 1130 | ||
1131 | 1131 | ||
1132 | 1132 | @Callable(i) | |
1133 | 1133 | func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract))) | |
1134 | 1134 | then throw("permissions denied") | |
1135 | 1135 | else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success") | |
1136 | 1136 | ||
1137 | 1137 | ||
1138 | 1138 | ||
1139 | 1139 | @Callable(i) | |
1140 | 1140 | func refreshKLp () = { | |
1141 | 1141 | let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0) | |
1142 | 1142 | let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay)) | |
1143 | 1143 | then unit | |
1144 | 1144 | else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1145 | 1145 | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1146 | 1146 | then { | |
1147 | - | let $t04271742772 = refreshKLpInternal(0, 0, 0) | |
1148 | - | let actions = $t04271742772._1 | |
1149 | - | let updatedKLp = $t04271742772._2 | |
1147 | + | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
1148 | + | let $t04284342907 = refreshKLpInternal(0, 0, 0) | |
1149 | + | let kLpUpdateActions = $t04284342907._1 | |
1150 | + | let updatedKLp = $t04284342907._2 | |
1151 | + | let actions = if ((kLp != updatedKLp)) | |
1152 | + | then kLpUpdateActions | |
1153 | + | else throwErr("nothing to refresh") | |
1150 | 1154 | $Tuple2(actions, toString(updatedKLp)) | |
1151 | 1155 | } | |
1152 | 1156 | else throw("Strict value is not equal to itself.") | |
1153 | 1157 | } | |
1154 | 1158 | ||
1155 | 1159 | ||
1156 | 1160 | ||
1157 | 1161 | @Callable(i) | |
1158 | 1162 | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig()) | |
1159 | 1163 | ||
1160 | 1164 | ||
1161 | 1165 | ||
1162 | 1166 | @Callable(i) | |
1163 | 1167 | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
1164 | 1168 | ||
1165 | 1169 | ||
1166 | 1170 | ||
1167 | 1171 | @Callable(i) | |
1168 | 1172 | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
1169 | 1173 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
1170 | 1174 | $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])]) | |
1171 | 1175 | } | |
1172 | 1176 | ||
1173 | 1177 | ||
1174 | 1178 | ||
1175 | 1179 | @Callable(i) | |
1176 | 1180 | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult))) | |
1177 | 1181 | ||
1178 | 1182 | ||
1179 | 1183 | ||
1180 | 1184 | @Callable(i) | |
1181 | 1185 | func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult)) | |
1182 | 1186 | ||
1183 | 1187 | ||
1184 | 1188 | ||
1185 | 1189 | @Callable(i) | |
1186 | 1190 | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
1187 | 1191 | ||
1188 | 1192 | ||
1189 | 1193 | ||
1190 | 1194 | @Callable(i) | |
1191 | 1195 | func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp)) | |
1192 | 1196 | ||
1193 | 1197 | ||
1194 | 1198 | ||
1195 | 1199 | @Callable(i) | |
1196 | 1200 | func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
1197 | 1201 | let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress)) | |
1198 | 1202 | $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10)) | |
1199 | 1203 | } | |
1200 | 1204 | ||
1201 | 1205 | ||
1202 | 1206 | ||
1203 | 1207 | @Callable(i) | |
1204 | 1208 | func statsREADONLY () = { | |
1205 | 1209 | let cfg = getPoolConfig() | |
1206 | 1210 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1207 | 1211 | let amtAssetId = cfg[idxAmtAssetId] | |
1208 | 1212 | let priceAssetId = cfg[idxPriceAssetId] | |
1209 | 1213 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
1210 | 1214 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
1211 | 1215 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1212 | 1216 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1213 | 1217 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1214 | 1218 | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
1215 | 1219 | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
1216 | 1220 | let pricesList = if ((poolLPBalance == 0)) | |
1217 | 1221 | then [zeroBigInt, zeroBigInt, zeroBigInt] | |
1218 | 1222 | else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance) | |
1219 | 1223 | let curPrice = 0 | |
1220 | 1224 | let lpAmtAssetShare = fromX18(pricesList[1], scale8) | |
1221 | 1225 | let lpPriceAssetShare = fromX18(pricesList[2], scale8) | |
1222 | 1226 | let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this)))) | |
1223 | 1227 | $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)) | |
1224 | 1228 | } | |
1225 | 1229 | ||
1226 | 1230 | ||
1227 | 1231 | ||
1228 | 1232 | @Callable(i) | |
1229 | 1233 | func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = { | |
1230 | 1234 | let cfg = getPoolConfig() | |
1231 | 1235 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1232 | 1236 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1233 | 1237 | let amAssetId = fromBase58String(amAssetIdStr) | |
1234 | 1238 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1235 | 1239 | let prAssetId = fromBase58String(prAssetIdStr) | |
1236 | 1240 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1237 | 1241 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1238 | 1242 | let poolStatus = cfg[idxPoolStatus] | |
1239 | 1243 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1240 | 1244 | let accAmtAssetBalance = getAccBalance(amAssetIdStr) | |
1241 | 1245 | let accPriceAssetBalance = getAccBalance(prAssetIdStr) | |
1242 | 1246 | let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm) | |
1243 | 1247 | let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm) | |
1244 | 1248 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1245 | 1249 | then zeroBigInt | |
1246 | 1250 | else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
1247 | 1251 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
1248 | 1252 | let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
1249 | 1253 | let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm) | |
1250 | 1254 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1251 | 1255 | let calcLpAmt = estPut._1 | |
1252 | 1256 | let curPriceCalc = estPut._3 | |
1253 | 1257 | let amBalance = estPut._4 | |
1254 | 1258 | let prBalance = estPut._5 | |
1255 | 1259 | let lpEmission = estPut._6 | |
1256 | 1260 | $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)) | |
1257 | 1261 | } | |
1258 | 1262 | ||
1259 | 1263 | ||
1260 | 1264 | ||
1261 | 1265 | @Callable(i) | |
1262 | 1266 | func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = { | |
1263 | 1267 | let cfg = getPoolConfig() | |
1264 | 1268 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1265 | 1269 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1266 | 1270 | let amAssetId = fromBase58String(amAssetIdStr) | |
1267 | 1271 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1268 | 1272 | let prAssetId = fromBase58String(prAssetIdStr) | |
1269 | 1273 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1270 | 1274 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1271 | 1275 | let poolStatus = cfg[idxPoolStatus] | |
1272 | 1276 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1273 | 1277 | let amBalanceRaw = getAccBalance(amAssetIdStr) | |
1274 | 1278 | let prBalanceRaw = getAccBalance(prAssetIdStr) | |
1275 | 1279 | let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm) | |
1276 | 1280 | let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm) | |
1277 | 1281 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1278 | 1282 | then zeroBigInt | |
1279 | 1283 | else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18) | |
1280 | 1284 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
1281 | 1285 | let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
1282 | 1286 | let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm) | |
1283 | 1287 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1284 | 1288 | let calcLpAmt = estPut._1 | |
1285 | 1289 | let curPriceCalc = estPut._3 | |
1286 | 1290 | let amBalance = estPut._4 | |
1287 | 1291 | let prBalance = estPut._5 | |
1288 | 1292 | let lpEmission = estPut._6 | |
1289 | 1293 | $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)) | |
1290 | 1294 | } | |
1291 | 1295 | ||
1292 | 1296 | ||
1293 | 1297 | ||
1294 | 1298 | @Callable(i) | |
1295 | 1299 | func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = { | |
1296 | 1300 | let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this) | |
1297 | 1301 | let outAmAmt = res._1 | |
1298 | 1302 | let outPrAmt = res._2 | |
1299 | 1303 | let amBalance = res._5 | |
1300 | 1304 | let prBalance = res._6 | |
1301 | 1305 | let lpEmission = res._7 | |
1302 | 1306 | let curPrice = res._8 | |
1303 | 1307 | let poolStatus = parseIntValue(res._9) | |
1304 | 1308 | $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)) | |
1305 | 1309 | } | |
1306 | 1310 | ||
1307 | 1311 | ||
1308 | 1312 | @Verifier(tx) | |
1309 | 1313 | func verify () = { | |
1310 | 1314 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
1311 | 1315 | case pk: ByteVector => | |
1312 | 1316 | pk | |
1313 | 1317 | case _: Unit => | |
1314 | 1318 | tx.senderPublicKey | |
1315 | 1319 | case _ => | |
1316 | 1320 | throw("Match error") | |
1317 | 1321 | } | |
1318 | 1322 | match tx { | |
1319 | 1323 | case order: Order => | |
1320 | 1324 | let matcherPub = getMatcherPubOrFail() | |
1321 | 1325 | let orderValid = validateMatcherOrderAllowed(order) | |
1322 | 1326 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1323 | 1327 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1324 | 1328 | if (if (if (orderValid) | |
1325 | 1329 | then senderValid | |
1326 | 1330 | else false) | |
1327 | 1331 | then matcherValid | |
1328 | 1332 | else false) | |
1329 | 1333 | then true | |
1330 | 1334 | else throwOrderError(orderValid, senderValid, matcherValid) | |
1331 | 1335 | case s: SetScriptTransaction => | |
1332 | 1336 | let newHash = blake2b256(value(s.script)) | |
1333 | 1337 | let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash()))) | |
1334 | 1338 | let currentHash = scriptHash(this) | |
1335 | 1339 | if (if ((allowedHash == newHash)) | |
1336 | 1340 | then (currentHash != newHash) | |
1337 | 1341 | else false) | |
1338 | 1342 | then true | |
1339 | 1343 | else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1340 | 1344 | case _ => | |
1341 | 1345 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1342 | 1346 | } | |
1343 | 1347 | } | |
1344 | 1348 |
github/deemru/w8io/026f985 104.21 ms ◑