tx · QhyD6sxJaRxskakWGM7NJJ152C6U4LaAZjFyP5JjMEg 3NAefciWv6f9fWvEXdGgpHfanJFG8HqfjuT: -0.03400000 Waves 2023.01.26 14:16 [2421866] smart account 3NAefciWv6f9fWvEXdGgpHfanJFG8HqfjuT > SELF 0.00000000 Waves
{ "type": 13, "id": "QhyD6sxJaRxskakWGM7NJJ152C6U4LaAZjFyP5JjMEg", "fee": 3400000, "feeAssetId": null, "timestamp": 1674731776167, "version": 1, "sender": "3NAefciWv6f9fWvEXdGgpHfanJFG8HqfjuT", "senderPublicKey": "D1BL65meykxFZTCuq7jq9HSGLLnWvQamQPUNrguW5w39", "proofs": [ "4WuGH8mE65Vy3mXm5xesag23gP77fN5pkEMiJaMZu1ZTNYazoBp3RVSQY7mo7WAyEAmjJSz4gZH8TqLiQ1rLGFLU" ], "script": "base64:BgLpIwgCEgQKAgEEEgYKBAEEAQgSAwoBCBIDCgEIEgASBAoCAQQSBAoCAQQSAwoBARIAEgQKAggBEgQKAggBEgQKAggBEgQKAgEBEgMKAQESBQoDAQEBEgUKAwEIARIECgIBCBIECgIBCBIECgIICBIECgIICBIECgIIARIAEgMKAQgSBQoDAQEBEgQKAggBEgQKAgEBEgQKAggIEgsKCQgBAQIBAggEBBIGCgQICAEIIgZzY2FsZTgiDHNjYWxlOEJpZ0ludCIHc2NhbGUxOCIKemVyb0JpZ0ludCIEYmlnMCIEYmlnMSIEYmlnMiIKc2xpcHBhZ2U0RCILd2F2ZXNTdHJpbmciBUFtdWx0IgVEY29udiIDU0VQIgVFTVBUWSIKUG9vbEFjdGl2ZSIKUG9vbFB1dERpcyIOUG9vbE1hdGNoZXJEaXMiDFBvb2xTaHV0ZG93biIOaWR4UG9vbEFkZHJlc3MiCWlkeFBvb2xTdCIJaWR4TFBBc0lkIglpZHhBbUFzSWQiCWlkeFByQXNJZCILaWR4QW10QXNEY20iDWlkeFByaWNlQXNEY20iC2lkeElBbXRBc0lkIg1pZHhJUHJpY2VBc0lkIg9pZHh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MJAJEDAggFAmhiBnByb29mcwAABQJoZEv/uPg=", "chainId": 84, "height": 2421866, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: y2xAZqHSSZoMLkEiTRrbdVA3ek1zEzksZQPpDnKufjP Next: 7pm1GFwfpJbAC9UrvdyoncCpDpnYBz2Jf1VyoiPwVXR2 Diff:
Old | New | Differences | |
---|---|---|---|
14 | 14 | let big1 = toBigInt(1) | |
15 | 15 | ||
16 | 16 | let big2 = toBigInt(2) | |
17 | - | ||
18 | - | let big3 = toBigInt(3) | |
19 | - | ||
20 | - | let big4 = toBigInt(4) | |
21 | 17 | ||
22 | 18 | let slippage4D = toBigInt((scale8 - ((scale8 * 1) / scale8))) | |
23 | 19 | ||
70 | 66 | func t1 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult)) | |
71 | 67 | ||
72 | 68 | ||
73 | - | func t1BigInt (origVal,origScaleMult) = fraction(origVal, scale18, origScaleMult) | |
74 | - | ||
75 | - | ||
76 | 69 | func f1 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18)) | |
77 | - | ||
78 | - | ||
79 | - | func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round)) | |
80 | - | ||
81 | - | ||
82 | - | func t2 (origVal,origScaleMult) = fraction(origVal, scale18, toBigInt(origScaleMult)) | |
83 | - | ||
84 | - | ||
85 | - | func f2 (val,resultScaleMult) = fraction(val, toBigInt(resultScaleMult), scale18) | |
86 | 70 | ||
87 | 71 | ||
88 | 72 | func ts (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
131 | 115 | func ada () = "%s__addonAddr" | |
132 | 116 | ||
133 | 117 | ||
134 | - | ||
118 | + | func swapContract () = "%s__swapContract" | |
135 | 119 | ||
136 | - | let fee = valueOrElse(getInteger(this, keyFee), feeDefault) | |
137 | - | ||
138 | - | let keyDLp = makeString(["%s", "dLp"], SEP) | |
139 | - | ||
140 | - | let keyDLpRefreshedHeight = makeString(["%s", "dLpRefreshedHeight"], SEP) | |
141 | - | ||
142 | - | let keyDLpRefreshDelay = makeString(["%s", "refreshDLpDelay"], SEP) | |
143 | - | ||
144 | - | let dLpRefreshDelayDefault = 30 | |
145 | - | ||
146 | - | let dLpRefreshDelay = valueOrElse(getInteger(this, keyDLpRefreshDelay), dLpRefreshDelayDefault) | |
147 | 120 | ||
148 | 121 | func fcfg () = "%s__factoryConfig" | |
149 | 122 | ||
166 | 139 | func keyFeeCollectorAddress () = "%s__feeCollectorAddress" | |
167 | 140 | ||
168 | 141 | ||
169 | - | func throwOrderError (orderValid,orderValidInfo,senderValid,matcherValid) = throw((((((((("order validation failed: orderValid=" + toString(orderValid)) + " (") + orderValidInfo) + ")") + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid))) | |
142 | + | func toe (orV,sendrV,matchV) = throw(((((("Failed: ordValid=" + toString(orV)) + " sndrValid=") + toString(sendrV)) + " mtchrValid=") + toString(matchV))) | |
143 | + | ||
144 | + | ||
145 | + | func str (val) = match val { | |
146 | + | case valStr: String => | |
147 | + | valStr | |
148 | + | case _ => | |
149 | + | throw("fail cast to String") | |
150 | + | } | |
170 | 151 | ||
171 | 152 | ||
172 | 153 | func strf (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
176 | 157 | ||
177 | 158 | ||
178 | 159 | func throwErr (msg) = throw(makeString(["lp_stable.ride:", msg], " ")) | |
179 | - | ||
180 | - | ||
181 | - | func fmtErr (msg) = makeString(["lp_stable.ride:", msg], " ") | |
182 | 160 | ||
183 | 161 | ||
184 | 162 | let fca = addressFromStringValue(strf(this, fc())) | |
226 | 204 | else toBase58String(value(input)) | |
227 | 205 | ||
228 | 206 | ||
229 | - | func parsePoolConfig (poolConfig) = $ | |
207 | + | func parsePoolConfig (poolConfig) = $Tuple7(addressFromStringValue(poolConfig[idxPoolAddress]), parseIntValue(poolConfig[idxPoolSt]), fromBase58String(poolConfig[idxLPAsId]), parseAssetId(poolConfig[idxAmAsId]), parseAssetId(poolConfig[idxPrAsId]), parseIntValue(poolConfig[idxAmtAsDcm]), parseIntValue(poolConfig[idxPriceAsDcm])) | |
230 | 208 | ||
231 | 209 | ||
232 | 210 | let poolConfigParsed = parsePoolConfig(gpc()) | |
233 | 211 | ||
234 | - | let $ | |
212 | + | let $t069527138 = poolConfigParsed | |
235 | 213 | ||
236 | - | let cfgPoolAddress = $ | |
214 | + | let cfgPoolAddress = $t069527138._1 | |
237 | 215 | ||
238 | - | let cfgPoolStatus = $ | |
216 | + | let cfgPoolStatus = $t069527138._2 | |
239 | 217 | ||
240 | - | let cfgLpAssetId = $ | |
218 | + | let cfgLpAssetId = $t069527138._3 | |
241 | 219 | ||
242 | - | let cfgAmountAssetId = $ | |
220 | + | let cfgAmountAssetId = $t069527138._4 | |
243 | 221 | ||
244 | - | let cfgPriceAssetId = $ | |
222 | + | let cfgPriceAssetId = $t069527138._5 | |
245 | 223 | ||
246 | - | let cfgAmountAssetDecimals = $ | |
224 | + | let cfgAmountAssetDecimals = $t069527138._6 | |
247 | 225 | ||
248 | - | let cfgPriceAssetDecimals = $t079658194._7 | |
249 | - | ||
250 | - | let cfgInAmountAssedId = $t079658194._8 | |
251 | - | ||
252 | - | let cfgInPriceAssetId = $t079658194._9 | |
226 | + | let cfgPriceAssetDecimals = $t069527138._7 | |
253 | 227 | ||
254 | 228 | func gfc () = split(strf(fca, fcfg()), SEP) | |
255 | 229 | ||
276 | 250 | ||
277 | 251 | ||
278 | 252 | func cpbi (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
279 | - | ||
280 | - | ||
281 | - | func cpbir (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round) | |
282 | 253 | ||
283 | 254 | ||
284 | 255 | func vad (A1,A2,slippage) = { | |
309 | 280 | ||
310 | 281 | ||
311 | 282 | func calcPrices (amAmt,prAmt,lpAmt) = { | |
312 | - | let amtAsDcm = cfgAmountAssetDecimals | |
313 | - | let prAsDcm = cfgPriceAssetDecimals | |
283 | + | let cfg = gpc() | |
284 | + | let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
285 | + | let prAsDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
314 | 286 | let priceX18 = pcp(amtAsDcm, prAsDcm, amAmt, prAmt) | |
315 | 287 | let amAmtX18 = t1(amAmt, amtAsDcm) | |
316 | 288 | let prAmtX18 = t1(prAmt, prAsDcm) | |
335 | 307 | } | |
336 | 308 | ||
337 | 309 | ||
338 | - | func getD (xp) = { | |
339 | - | let xp0 = xp[0] | |
340 | - | let xp1 = xp[1] | |
341 | - | let s = (xp0 + xp1) | |
342 | - | if ((s == big0)) | |
343 | - | then big0 | |
344 | - | else { | |
345 | - | let a = parseIntValue(A) | |
346 | - | let ann = (a * 2) | |
347 | - | let p = fraction(xp0, xp1, big1) | |
348 | - | let xp0_xp1_n_n = fraction(p, big4, big1) | |
349 | - | let ann_s = fraction(toBigInt(ann), s, big1) | |
350 | - | let ann_1 = toBigInt((ann - 1)) | |
351 | - | func calcDNext (d) = { | |
352 | - | let dd = fraction(d, d, big1) | |
353 | - | let ddd = fraction(dd, d, big1) | |
354 | - | let dp = fraction(ddd, big1, xp0_xp1_n_n) | |
355 | - | fraction((ann_s + fraction(dp, big2, big1)), d, (fraction(ann_1, d, big1) + fraction(big3, dp, big1))) | |
356 | - | } | |
357 | - | ||
358 | - | func calc (acc,i) = if (acc._2) | |
359 | - | then acc | |
360 | - | else { | |
361 | - | let d = acc._1 | |
362 | - | let dNext = calcDNext(d) | |
363 | - | let dDiffRaw = (dNext - value(d)) | |
364 | - | let dDiff = if ((big0 > dDiffRaw)) | |
365 | - | then -(dDiffRaw) | |
366 | - | else dDiffRaw | |
367 | - | if ((big1 >= dDiff)) | |
368 | - | then $Tuple2(dNext, true) | |
369 | - | else $Tuple2(dNext, false) | |
370 | - | } | |
371 | - | ||
372 | - | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
373 | - | let $t01269112739 = { | |
374 | - | let $l = arr | |
375 | - | let $s = size($l) | |
376 | - | let $acc0 = $Tuple2(s, false) | |
377 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
378 | - | then $a | |
379 | - | else calc($a, $l[$i]) | |
380 | - | ||
381 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
382 | - | then $a | |
383 | - | else throw("List size exceeds 15") | |
384 | - | ||
385 | - | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15) | |
386 | - | } | |
387 | - | let d = $t01269112739._1 | |
388 | - | let found = $t01269112739._2 | |
389 | - | if (found) | |
390 | - | then d | |
391 | - | else throw(("D calculation error, D = " + toString(d))) | |
392 | - | } | |
393 | - | } | |
394 | - | ||
395 | - | ||
396 | 310 | func ego (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
397 | - | let lpId = cfgLpAssetId | |
398 | - | let amId = toBase58String(value(cfgAmountAssetId)) | |
399 | - | let prId = toBase58String(value(cfgPriceAssetId)) | |
400 | - | let amDcm = cfgAmountAssetDecimals | |
401 | - | let prDcm = cfgPriceAssetDecimals | |
402 | - | let sts = toString(cfgPoolStatus) | |
403 | - | let lpEmiss = valueOrErrorMessage(assetInfo(lpId), "Wrong LP id").quantity | |
404 | - | if ((toBase58String(lpId) != pmtAssetId)) | |
311 | + | let cfg = gpc() | |
312 | + | let lpId = cfg[idxLPAsId] | |
313 | + | let amId = cfg[idxAmAsId] | |
314 | + | let prId = cfg[idxPrAsId] | |
315 | + | let amDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
316 | + | let prDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
317 | + | let sts = cfg[idxPoolSt] | |
318 | + | let lpEmiss = valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "Wrong LP id").quantity | |
319 | + | if ((lpId != pmtAssetId)) | |
405 | 320 | then throw("Wrong pmt asset") | |
406 | 321 | else { | |
407 | 322 | let amBalance = getAccBalance(amId) | |
414 | 329 | let lpEmissX18 = t1(lpEmiss, scale8) | |
415 | 330 | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissX18) | |
416 | 331 | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissX18) | |
417 | - | let outAmAmt = | |
418 | - | let outPrAmt = | |
332 | + | let outAmAmt = f1(outAmAmtX18, amDcm) | |
333 | + | let outPrAmt = f1(outPrAmtX18, prDcm) | |
419 | 334 | let state = if ((txId58 == "")) | |
420 | 335 | then nil | |
421 | 336 | else [ScriptTransfer(userAddress, outAmAmt, if ((amId == "WAVES")) | |
429 | 344 | ||
430 | 345 | ||
431 | 346 | func epo (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,userAddress,isEval,emitLp,isOneAsset,validateSlippage,pmtAmt,pmtId) = { | |
432 | - | let lpId = cfgLpAssetId | |
433 | - | let amIdStr = toBase58String(value(cfgAmountAssetId)) | |
434 | - | let prIdStr = toBase58String(value(cfgPriceAssetId)) | |
435 | - | let inAmIdStr = cfgInAmountAssedId | |
436 | - | let inPrIdStr = cfgInPriceAssetId | |
437 | - | let amtDcm = cfgAmountAssetDecimals | |
438 | - | let priceDcm = cfgPriceAssetDecimals | |
439 | - | let sts = toString(cfgPoolStatus) | |
347 | + | let cfg = gpc() | |
348 | + | let lpId = fromBase58String(cfg[idxLPAsId]) | |
349 | + | let amIdStr = cfg[idxAmAsId] | |
350 | + | let prIdStr = cfg[idxPrAsId] | |
351 | + | let inAmIdStr = cfg[idxIAmtAsId] | |
352 | + | let inPrIdStr = cfg[idxIPriceAsId] | |
353 | + | let amtDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
354 | + | let priceDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
355 | + | let sts = cfg[idxPoolSt] | |
440 | 356 | let lpEm = valueOrErrorMessage(assetInfo(lpId), "Wr lp as").quantity | |
441 | 357 | let amBalance = if (isEval) | |
442 | 358 | then getAccBalance(amIdStr) | |
461 | 377 | let userPriceX18 = cpbi(inPrAssetAmtX18, inAmAssetAmtX18) | |
462 | 378 | let amBalanceX18 = t1(amBalance, amtDcm) | |
463 | 379 | let prBalanceX18 = t1(prBalance, priceDcm) | |
464 | - | let D0 = getD([amBalanceX18, prBalanceX18]) | |
465 | 380 | let r = if ((lpEm == 0)) | |
466 | 381 | then { | |
467 | - | let D1 = getD([(amBalanceX18 + inAmAssetAmtX18), (prBalanceX18 + inPrAssetAmtX18)]) | |
468 | - | let checkD = if ((D1 > D0)) | |
469 | - | then true | |
470 | - | else throw("D1 should be greater than D0") | |
471 | - | if ((checkD == checkD)) | |
472 | - | then { | |
473 | - | let curPriceX18 = zeroBigInt | |
474 | - | let slippageX18 = zeroBigInt | |
475 | - | let lpAmtX18 = D1 | |
476 | - | $Tuple5(f1(lpAmtX18, scale8), f1(inAmAssetAmtX18, amtDcm), f1(inPrAssetAmtX18, priceDcm), cpbi((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
477 | - | } | |
478 | - | else throw("Strict value is not equal to itself.") | |
382 | + | let curPriceX18 = zeroBigInt | |
383 | + | let slippageX18 = zeroBigInt | |
384 | + | let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN) | |
385 | + | $Tuple5(f1(lpAmtX18, scale8), f1(inAmAssetAmtX18, amtDcm), f1(inPrAssetAmtX18, priceDcm), cpbi((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
479 | 386 | } | |
480 | 387 | else { | |
481 | 388 | let curPriceX18 = cpbi(prBalanceX18, amBalanceX18) | |
489 | 396 | then throw(((("Price slippage " + toString(slippageRealX18)) + " > ") + toString(slippageX18))) | |
490 | 397 | else { | |
491 | 398 | let lpEmissionX18 = t1(lpEm, scale8) | |
492 | - | let prViaAmX18 = fraction(inAmAssetAmtX18, | |
493 | - | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, | |
399 | + | let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
400 | + | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
494 | 401 | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
495 | 402 | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
496 | 403 | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
497 | 404 | let expAmtAssetAmtX18 = expectedAmts._1 | |
498 | 405 | let expPriceAssetAmtX18 = expectedAmts._2 | |
499 | - | let D1 = getD([(amBalanceX18 + expAmtAssetAmtX18), (prBalanceX18 + expPriceAssetAmtX18)]) | |
500 | - | let checkD = if ((D1 > D0)) | |
501 | - | then true | |
502 | - | else throw("D1 should be greater than D0") | |
503 | - | if ((checkD == checkD)) | |
504 | - | then { | |
505 | - | let lpAmtX18 = fraction(lpEmissionX18, (D1 - D0), D0) | |
506 | - | $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceDcm, CEILING), curPriceX18, slippageX18) | |
507 | - | } | |
508 | - | else throw("Strict value is not equal to itself.") | |
406 | + | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18) | |
407 | + | $Tuple5(f1(lpAmtX18, scale8), f1(expAmtAssetAmtX18, amtDcm), f1(expPriceAssetAmtX18, priceDcm), curPriceX18, slippageX18) | |
509 | 408 | } | |
510 | 409 | } | |
511 | 410 | let calcLpAmt = r._1 | |
521 | 420 | else calcLpAmt | |
522 | 421 | let amDiff = (inAmAmt - calcAmAssetPmt) | |
523 | 422 | let prDiff = (inPrAmt - calcPrAssetPmt) | |
524 | - | let $ | |
423 | + | let $t01760517950 = if (if (isOneAsset) | |
525 | 424 | then (pmtId == amIdStr) | |
526 | 425 | else false) | |
527 | 426 | then $Tuple2(pmtAmt, 0) | |
530 | 429 | else false) | |
531 | 430 | then $Tuple2(0, pmtAmt) | |
532 | 431 | else $Tuple2(calcAmAssetPmt, calcPrAssetPmt) | |
533 | - | let writeAmAmt = $ | |
534 | - | let writePrAmt = $ | |
432 | + | let writeAmAmt = $t01760517950._1 | |
433 | + | let writePrAmt = $t01760517950._2 | |
535 | 434 | let commonState = [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(userAddress, txId58), dataPutActionInfo(writeAmAmt, writePrAmt, emitLpAmt, curPrice, slippage, slippageCalc, height, lastBlock.timestamp, amDiff, prDiff))] | |
536 | 435 | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEm, lpId, sts, commonState, amDiff, prDiff, inAmId, inPrId) | |
537 | 436 | } | |
538 | 437 | } | |
539 | 438 | ||
540 | 439 | ||
541 | - | func getYD (xp,i,D) = { | |
542 | - | let n = big2 | |
543 | - | let x = xp[if ((i == 0)) | |
544 | - | then 1 | |
545 | - | else 0] | |
546 | - | let aPrecision = parseBigIntValue(Amult) | |
547 | - | let a = (parseBigIntValue(A) * aPrecision) | |
548 | - | let s = x | |
549 | - | let ann = (a * n) | |
550 | - | let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n)) | |
551 | - | let b = ((s + ((D * aPrecision) / ann)) - D) | |
552 | - | func calc (acc,cur) = { | |
553 | - | let $t02211822138 = acc | |
554 | - | let y = $t02211822138._1 | |
555 | - | let found = $t02211822138._2 | |
556 | - | if ((found != unit)) | |
557 | - | then acc | |
558 | - | else { | |
559 | - | let yNext = (((y * y) + c) / ((big2 * y) + b)) | |
560 | - | let yDiff = absBigInt((yNext - value(y))) | |
561 | - | if ((big1 >= yDiff)) | |
562 | - | then $Tuple2(yNext, cur) | |
563 | - | else $Tuple2(yNext, unit) | |
564 | - | } | |
565 | - | } | |
566 | - | ||
567 | - | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
568 | - | let $t02244522492 = { | |
569 | - | let $l = arr | |
570 | - | let $s = size($l) | |
571 | - | let $acc0 = $Tuple2(D, unit) | |
572 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
573 | - | then $a | |
574 | - | else calc($a, $l[$i]) | |
575 | - | ||
576 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
577 | - | then $a | |
578 | - | else throw("List size exceeds 15") | |
579 | - | ||
580 | - | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15) | |
581 | - | } | |
582 | - | let y = $t02244522492._1 | |
583 | - | let found = $t02244522492._2 | |
584 | - | if ((found != unit)) | |
585 | - | then y | |
586 | - | else throw(("Y calculation error, Y = " + toString(y))) | |
587 | - | } | |
588 | - | ||
589 | - | ||
590 | - | func calcDLp (amountBalance,priceBalance,lpEmission) = { | |
591 | - | let updatedDLp = fraction(getD([t1BigInt(amountBalance, toBigInt(cfgAmountAssetDecimals)), t1BigInt(priceBalance, toBigInt(cfgPriceAssetDecimals))]), scale18, lpEmission) | |
592 | - | if ((lpEmission == big0)) | |
593 | - | then big0 | |
594 | - | else updatedDLp | |
595 | - | } | |
596 | - | ||
597 | - | ||
598 | - | func calcCurrentDLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = { | |
599 | - | let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta) | |
600 | - | let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta) | |
601 | - | let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta) | |
602 | - | let currentDLp = calcDLp(amountAssetBalance, priceAssetBalance, lpAssetEmission) | |
603 | - | currentDLp | |
604 | - | } | |
605 | - | ||
606 | - | ||
607 | - | func refreshDLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
608 | - | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
609 | - | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
610 | - | let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta) | |
611 | - | let updatedDLp = calcDLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
612 | - | let actions = [IntegerEntry(keyDLpRefreshedHeight, height), StringEntry(keyDLp, toString(updatedDLp))] | |
613 | - | $Tuple2(actions, updatedDLp) | |
614 | - | } | |
615 | - | ||
616 | - | ||
617 | - | func validateUpdatedDLp (oldDLp,updatedDLp) = if ((updatedDLp >= oldDLp)) | |
618 | - | then true | |
619 | - | else throwErr("updated DLp lower than current DLp") | |
620 | - | ||
621 | - | ||
622 | - | func validateMatcherOrderAllowed (order) = { | |
623 | - | let amountAssetBalance = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
624 | - | let priceAssetBalance = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
625 | - | let amountAssetAmount = order.amount | |
626 | - | let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR) | |
627 | - | let $t02469024902 = if ((order.orderType == Buy)) | |
628 | - | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
629 | - | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
630 | - | let amountAssetBalanceDelta = $t02469024902._1 | |
631 | - | let priceAssetBalanceDelta = $t02469024902._2 | |
440 | + | func moa (order) = { | |
441 | + | let cfg = gpc() | |
442 | + | let amtAsId = cfg[idxAmAsId] | |
443 | + | let prAsId = cfg[idxPrAsId] | |
444 | + | let sts = parseIntValue(cfg[idxPoolSt]) | |
445 | + | let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
446 | + | let prAsDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
447 | + | let accAmtAsBalance = getAccBalance(amtAsId) | |
448 | + | let accPrAsBalance = getAccBalance(prAsId) | |
449 | + | let curPriceX18 = if ((order.orderType == Buy)) | |
450 | + | then pcp(amtAsDcm, prAsDcm, (accAmtAsBalance + order.amount), accPrAsBalance) | |
451 | + | else pcp(amtAsDcm, prAsDcm, (accAmtAsBalance - order.amount), accPrAsBalance) | |
452 | + | let curPrice = f1(curPriceX18, scale8) | |
632 | 453 | if (if (if (igs()) | |
633 | 454 | then true | |
634 | - | else ( | |
455 | + | else (sts == PoolMatcherDis)) | |
635 | 456 | then true | |
636 | - | else ( | |
457 | + | else (sts == PoolShutdown)) | |
637 | 458 | then throw("Admin blocked") | |
638 | - | else if (if ((order.assetPair.amountAsset != cfgAmountAssetId)) | |
639 | - | then true | |
640 | - | else (order.assetPair.priceAsset != cfgPriceAssetId)) | |
641 | - | then throw("Wr assets") | |
642 | - | else { | |
643 | - | let dLp = parseBigIntValue(valueOrElse(getString(this, keyDLp), "0")) | |
644 | - | let $t02524425344 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
645 | - | let unusedActions = $t02524425344._1 | |
646 | - | let dLpNew = $t02524425344._2 | |
647 | - | let isOrderValid = (dLpNew >= dLp) | |
648 | - | let info = makeString(["dLp=", toString(dLp), " dLpNew=", toString(dLpNew), " amountAssetBalance=", toString(amountAssetBalance), " priceAssetBalance=", toString(priceAssetBalance), " amountAssetBalanceDelta=", toString(amountAssetBalanceDelta), " priceAssetBalanceDelta=", toString(priceAssetBalanceDelta)], "") | |
649 | - | $Tuple2(isOrderValid, info) | |
650 | - | } | |
459 | + | else { | |
460 | + | let orAmtAsset = order.assetPair.amountAsset | |
461 | + | let orAmtAsStr = if ((orAmtAsset == unit)) | |
462 | + | then "WAVES" | |
463 | + | else toBase58String(value(orAmtAsset)) | |
464 | + | let orPrAsset = order.assetPair.priceAsset | |
465 | + | let orPrAsStr = if ((orPrAsset == unit)) | |
466 | + | then "WAVES" | |
467 | + | else toBase58String(value(orPrAsset)) | |
468 | + | if (if ((orAmtAsStr != amtAsId)) | |
469 | + | then true | |
470 | + | else (orPrAsStr != prAsId)) | |
471 | + | then throw("Wr assets") | |
472 | + | else { | |
473 | + | let orderPrice = order.price | |
474 | + | let priceDcm = fraction(scale8, prAsDcm, amtAsDcm) | |
475 | + | let castOrderPrice = ts(orderPrice, scale8, priceDcm) | |
476 | + | let isOrderPriceValid = if ((order.orderType == Buy)) | |
477 | + | then (curPrice >= castOrderPrice) | |
478 | + | else (castOrderPrice >= curPrice) | |
479 | + | true | |
480 | + | } | |
481 | + | } | |
651 | 482 | } | |
652 | 483 | ||
653 | 484 | ||
683 | 514 | } | |
684 | 515 | ||
685 | 516 | ||
517 | + | func getD (xp) = { | |
518 | + | let n = big2 | |
519 | + | let xp0 = xp[0] | |
520 | + | let xp1 = xp[1] | |
521 | + | let aPrecision = parseBigIntValue(Amult) | |
522 | + | let a = (parseBigIntValue(A) * aPrecision) | |
523 | + | let s = (xp0 + xp1) | |
524 | + | if ((s == big0)) | |
525 | + | then big0 | |
526 | + | else { | |
527 | + | let ann = (a * n) | |
528 | + | let xp0_xp1_n_n = (((xp0 * xp1) * n) * n) | |
529 | + | let ann_s_aPrecision = ((ann * s) / aPrecision) | |
530 | + | let ann_aPrecision = (ann - aPrecision) | |
531 | + | let n1 = (n + big1) | |
532 | + | func calc (acc,cur) = { | |
533 | + | let $t02250222522 = acc | |
534 | + | let d = $t02250222522._1 | |
535 | + | let found = $t02250222522._2 | |
536 | + | if ((found != unit)) | |
537 | + | then acc | |
538 | + | else { | |
539 | + | let dp = (((d * d) * d) / xp0_xp1_n_n) | |
540 | + | let dNext = (((ann_s_aPrecision + (dp * n)) * d) / (((ann_aPrecision * d) / aPrecision) + (n1 * dp))) | |
541 | + | let dDiff = absBigInt((dNext - value(d))) | |
542 | + | if ((big1 >= dDiff)) | |
543 | + | then $Tuple2(dNext, cur) | |
544 | + | else $Tuple2(dNext, unit) | |
545 | + | } | |
546 | + | } | |
547 | + | ||
548 | + | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
549 | + | let $t02294322990 = { | |
550 | + | let $l = arr | |
551 | + | let $s = size($l) | |
552 | + | let $acc0 = $Tuple2(s, unit) | |
553 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
554 | + | then $a | |
555 | + | else calc($a, $l[$i]) | |
556 | + | ||
557 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
558 | + | then $a | |
559 | + | else throw("List size exceeds 15") | |
560 | + | ||
561 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15) | |
562 | + | } | |
563 | + | let d = $t02294322990._1 | |
564 | + | let found = $t02294322990._2 | |
565 | + | if ((found != unit)) | |
566 | + | then d | |
567 | + | else throw(("D calculation error, D = " + toString(d))) | |
568 | + | } | |
569 | + | } | |
570 | + | ||
571 | + | ||
572 | + | func getYD (xp,i,D) = { | |
573 | + | let n = big2 | |
574 | + | let x = xp[if ((i == 0)) | |
575 | + | then 1 | |
576 | + | else 0] | |
577 | + | let aPrecision = parseBigIntValue(Amult) | |
578 | + | let a = (parseBigIntValue(A) * aPrecision) | |
579 | + | let s = x | |
580 | + | let ann = (a * n) | |
581 | + | let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n)) | |
582 | + | let b = ((s + ((D * aPrecision) / ann)) - D) | |
583 | + | func calc (acc,cur) = { | |
584 | + | let $t02349023510 = acc | |
585 | + | let y = $t02349023510._1 | |
586 | + | let found = $t02349023510._2 | |
587 | + | if ((found != unit)) | |
588 | + | then acc | |
589 | + | else { | |
590 | + | let yNext = (((y * y) + c) / ((big2 * y) + b)) | |
591 | + | let yDiff = absBigInt((yNext - value(y))) | |
592 | + | if ((big1 >= yDiff)) | |
593 | + | then $Tuple2(yNext, cur) | |
594 | + | else $Tuple2(yNext, unit) | |
595 | + | } | |
596 | + | } | |
597 | + | ||
598 | + | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
599 | + | let $t02381723864 = { | |
600 | + | let $l = arr | |
601 | + | let $s = size($l) | |
602 | + | let $acc0 = $Tuple2(D, unit) | |
603 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
604 | + | then $a | |
605 | + | else calc($a, $l[$i]) | |
606 | + | ||
607 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
608 | + | then $a | |
609 | + | else throw("List size exceeds 15") | |
610 | + | ||
611 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15) | |
612 | + | } | |
613 | + | let y = $t02381723864._1 | |
614 | + | let found = $t02381723864._2 | |
615 | + | if ((found != unit)) | |
616 | + | then y | |
617 | + | else throw(("Y calculation error, Y = " + toString(y))) | |
618 | + | } | |
619 | + | ||
620 | + | ||
686 | 621 | func calcPutOneTkn (pmtAmtRaw,pmtAssetId,userAddress,txId,withTakeFee) = { | |
687 | - | let amId = toBase58String(value(cfgAmountAssetId)) | |
688 | - | let prId = toBase58String(value(cfgPriceAssetId)) | |
689 | - | let lpId = cfgLpAssetId | |
690 | - | let amtDcm = cfgAmountAssetDecimals | |
691 | - | let priceDcm = cfgPriceAssetDecimals | |
692 | - | let lpAssetEmission = toBigInt(valueOrErrorMessage(assetInfo(lpId), "invalid lp asset").quantity) | |
622 | + | let poolConfig = gpc() | |
623 | + | let amId = poolConfig[idxAmAsId] | |
624 | + | let prId = poolConfig[idxPrAsId] | |
625 | + | let lpId = poolConfig[idxLPAsId] | |
626 | + | let amtDcm = parseIntValue(poolConfig[idxAmtAsDcm]) | |
627 | + | let priceDcm = parseIntValue(poolConfig[idxPriceAsDcm]) | |
628 | + | let lpAssetEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity) | |
693 | 629 | let chechEmission = if ((lpAssetEmission > big0)) | |
694 | 630 | then true | |
695 | 631 | else throw("initial deposit requires all coins") | |
697 | 633 | then { | |
698 | 634 | let amBalance = getAccBalance(amId) | |
699 | 635 | let prBalance = getAccBalance(prId) | |
700 | - | let $ | |
636 | + | let $t02464725109 = if ((txId == "")) | |
701 | 637 | then $Tuple2(amBalance, prBalance) | |
702 | 638 | else if ((pmtAssetId == amId)) | |
703 | 639 | then if ((pmtAmtRaw > amBalance)) | |
708 | 644 | then throw("invalid payment amount") | |
709 | 645 | else $Tuple2(amBalance, (prBalance - pmtAmtRaw)) | |
710 | 646 | else throw("wrong pmtAssetId") | |
711 | - | let amBalanceOld = $ | |
712 | - | let prBalanceOld = $ | |
713 | - | let $ | |
647 | + | let amBalanceOld = $t02464725109._1 | |
648 | + | let prBalanceOld = $t02464725109._2 | |
649 | + | let $t02511525291 = if ((pmtAssetId == amId)) | |
714 | 650 | then $Tuple2(pmtAmtRaw, 0) | |
715 | 651 | else if ((pmtAssetId == prId)) | |
716 | 652 | then $Tuple2(0, pmtAmtRaw) | |
717 | 653 | else throw("invalid payment") | |
718 | - | let amAmountRaw = $ | |
719 | - | let prAmountRaw = $ | |
720 | - | let $ | |
654 | + | let amAmountRaw = $t02511525291._1 | |
655 | + | let prAmountRaw = $t02511525291._2 | |
656 | + | let $t02529525549 = if (withTakeFee) | |
721 | 657 | then $Tuple3(takeFee(amAmountRaw, inFee)._1, takeFee(prAmountRaw, inFee)._1, takeFee(pmtAmtRaw, inFee)._2) | |
722 | 658 | else $Tuple3(amAmountRaw, prAmountRaw, 0) | |
723 | - | let amAmount = $ | |
724 | - | let prAmount = $ | |
725 | - | let feeAmount = $ | |
659 | + | let amAmount = $t02529525549._1 | |
660 | + | let prAmount = $t02529525549._2 | |
661 | + | let feeAmount = $t02529525549._3 | |
726 | 662 | let amBalanceNew = (amBalanceOld + amAmount) | |
727 | 663 | let prBalanceNew = (prBalanceOld + prAmount) | |
728 | - | let D0 = getD([ | |
729 | - | let D1 = getD([ | |
664 | + | let D0 = getD([toBigInt(amBalanceOld), toBigInt(prBalanceOld)]) | |
665 | + | let D1 = getD([toBigInt(amBalanceNew), toBigInt(prBalanceNew)]) | |
730 | 666 | let checkD = if ((D1 > D0)) | |
731 | 667 | then true | |
732 | 668 | else throw() | |
733 | 669 | if ((checkD == checkD)) | |
734 | 670 | then { | |
735 | - | let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0 | |
671 | + | let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0) | |
736 | 672 | let curPrice = f1(cpbi(t1(prBalanceNew, priceDcm), t1(amBalanceNew, amtDcm)), scale8) | |
737 | 673 | let commonState = [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(userAddress, txId), dataPutActionInfo(amAmountRaw, prAmountRaw, toInt(lpAmount), curPrice, 0, 0, height, lastBlock.timestamp, 0, 0))] | |
738 | 674 | let poolProportion = fraction(prBalanceOld, scale8, amBalanceOld) | |
749 | 685 | ||
750 | 686 | ||
751 | 687 | func getOneTknV2Internal (outAssetId,minOutAmount,payments,caller,originCaller,transactionId) = { | |
752 | - | let lpId = toBase58String(value(cfgLpAssetId)) | |
753 | - | let amId = toBase58String(value(cfgAmountAssetId)) | |
754 | - | let prId = toBase58String(value(cfgPriceAssetId)) | |
755 | - | let amDecimals = cfgAmountAssetDecimals | |
756 | - | let prDecimals = cfgPriceAssetDecimals | |
757 | - | let poolStatus = cfgPoolStatus | |
688 | + | let poolConfig = gpc() | |
689 | + | let lpId = poolConfig[idxLPAsId] | |
690 | + | let amId = poolConfig[idxAmAsId] | |
691 | + | let prId = poolConfig[idxPrAsId] | |
692 | + | let amDecimals = parseIntValue(poolConfig[idxAmtAsDcm]) | |
693 | + | let prDecimals = parseIntValue(poolConfig[idxPriceAsDcm]) | |
694 | + | let poolStatus = poolConfig[idxPoolSt] | |
758 | 695 | let userAddress = if ((caller == restContract)) | |
759 | 696 | then originCaller | |
760 | 697 | else caller | |
761 | 698 | let pmt = value(payments[0]) | |
762 | 699 | let pmtAssetId = value(pmt.assetId) | |
763 | 700 | let pmtAmt = pmt.amount | |
764 | - | let currentDLp = calcCurrentDLp(big0, big0, big0) | |
765 | - | if ((currentDLp == currentDLp)) | |
766 | - | then { | |
767 | - | let txId58 = toBase58String(transactionId) | |
768 | - | if ((lpId != toBase58String(pmtAssetId))) | |
769 | - | then throw("Wrong LP") | |
770 | - | else { | |
771 | - | let amBalance = getAccBalance(amId) | |
772 | - | let prBalance = getAccBalance(prId) | |
773 | - | let $t03097931090 = { | |
774 | - | let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil) | |
775 | - | if ($isInstanceOf(@, "(Int, Int)")) | |
776 | - | then @ | |
777 | - | else throw(($getType(@) + " couldn't be cast to (Int, Int)")) | |
778 | - | } | |
779 | - | if (($t03097931090 == $t03097931090)) | |
701 | + | let txId58 = toBase58String(transactionId) | |
702 | + | if ((lpId != toBase58String(pmtAssetId))) | |
703 | + | then throw("Wrong LP") | |
704 | + | else { | |
705 | + | let amBalance = getAccBalance(amId) | |
706 | + | let prBalance = getAccBalance(prId) | |
707 | + | let $t02755127662 = { | |
708 | + | let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil) | |
709 | + | if ($isInstanceOf(@, "(Int, Int)")) | |
710 | + | then @ | |
711 | + | else throw(($getType(@) + " couldn't be cast to (Int, Int)")) | |
712 | + | } | |
713 | + | if (($t02755127662 == $t02755127662)) | |
714 | + | then { | |
715 | + | let feeAmount = $t02755127662._2 | |
716 | + | let totalGet = $t02755127662._1 | |
717 | + | let totalAmount = if (if ((minOutAmount > 0)) | |
718 | + | then (minOutAmount > totalGet) | |
719 | + | else false) | |
720 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
721 | + | else totalGet | |
722 | + | let $t02785228159 = if ((outAssetId == amId)) | |
723 | + | then $Tuple4(totalAmount, 0, ((amBalance - totalAmount) - feeAmount), prBalance) | |
724 | + | else if ((outAssetId == prId)) | |
725 | + | then $Tuple4(0, totalAmount, amBalance, ((prBalance - totalAmount) - feeAmount)) | |
726 | + | else throw("invalid out asset id") | |
727 | + | let outAm = $t02785228159._1 | |
728 | + | let outPr = $t02785228159._2 | |
729 | + | let amBalanceNew = $t02785228159._3 | |
730 | + | let prBalanceNew = $t02785228159._4 | |
731 | + | let curPrX18 = cpbi(t1(prBalanceNew, prDecimals), t1(amBalanceNew, amDecimals)) | |
732 | + | let curPr = f1(curPrX18, scale8) | |
733 | + | let outAssetIdOrWaves = if ((outAssetId == "WAVES")) | |
734 | + | then unit | |
735 | + | else fromBase58String(outAssetId) | |
736 | + | let sendFeeToMatcher = if ((feeAmount > 0)) | |
737 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)] | |
738 | + | else nil | |
739 | + | let state = ([ScriptTransfer(userAddress, totalAmount, outAssetIdOrWaves), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, pmtAmt, curPr, height, lastBlock.timestamp)), IntegerEntry(pl(), curPr), IntegerEntry(ph(height, lastBlock.timestamp), curPr)] ++ sendFeeToMatcher) | |
740 | + | if ((state == state)) | |
780 | 741 | then { | |
781 | - | let feeAmount = $t03097931090._2 | |
782 | - | let totalGet = $t03097931090._1 | |
783 | - | let totalAmount = if (if ((minOutAmount > 0)) | |
784 | - | then (minOutAmount > totalGet) | |
785 | - | else false) | |
786 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
787 | - | else totalGet | |
788 | - | let $t03128031587 = if ((outAssetId == amId)) | |
789 | - | then $Tuple4(totalAmount, 0, ((amBalance - totalAmount) - feeAmount), prBalance) | |
790 | - | else if ((outAssetId == prId)) | |
791 | - | then $Tuple4(0, totalAmount, amBalance, ((prBalance - totalAmount) - feeAmount)) | |
792 | - | else throw("invalid out asset id") | |
793 | - | let outAm = $t03128031587._1 | |
794 | - | let outPr = $t03128031587._2 | |
795 | - | let amBalanceNew = $t03128031587._3 | |
796 | - | let prBalanceNew = $t03128031587._4 | |
797 | - | let curPrX18 = cpbi(t1(prBalanceNew, prDecimals), t1(amBalanceNew, amDecimals)) | |
798 | - | let curPr = f1(curPrX18, scale8) | |
799 | - | let outAssetIdOrWaves = if ((outAssetId == "WAVES")) | |
800 | - | then unit | |
801 | - | else fromBase58String(outAssetId) | |
802 | - | let sendFeeToMatcher = if ((feeAmount > 0)) | |
803 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)] | |
804 | - | else nil | |
805 | - | let state = ([ScriptTransfer(userAddress, totalAmount, outAssetIdOrWaves), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, pmtAmt, curPr, height, lastBlock.timestamp)), IntegerEntry(pl(), curPr), IntegerEntry(ph(height, lastBlock.timestamp), curPr)] ++ sendFeeToMatcher) | |
806 | - | if ((state == state)) | |
807 | - | then { | |
808 | - | let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
809 | - | if ((burn == burn)) | |
810 | - | then { | |
811 | - | let $t03237232722 = { | |
812 | - | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
813 | - | then 0 | |
814 | - | else feeAmount | |
815 | - | let outInAmountAsset = if ((parseAssetId(outAssetId) == cfgAmountAssetId)) | |
816 | - | then true | |
817 | - | else false | |
818 | - | if (outInAmountAsset) | |
819 | - | then $Tuple2(-((totalGet + feeAmountForCalc)), 0) | |
820 | - | else $Tuple2(0, -((totalGet + feeAmountForCalc))) | |
821 | - | } | |
822 | - | let amountAssetBalanceDelta = $t03237232722._1 | |
823 | - | let priceAssetBalanceDelta = $t03237232722._2 | |
824 | - | let $t03272532833 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
825 | - | let refreshDLpActions = $t03272532833._1 | |
826 | - | let updatedDLp = $t03272532833._2 | |
827 | - | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
828 | - | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
829 | - | then $Tuple2((state ++ refreshDLpActions), totalAmount) | |
830 | - | else throw("Strict value is not equal to itself.") | |
831 | - | } | |
832 | - | else throw("Strict value is not equal to itself.") | |
833 | - | } | |
742 | + | let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
743 | + | if ((burn == burn)) | |
744 | + | then $Tuple2(state, totalAmount) | |
834 | 745 | else throw("Strict value is not equal to itself.") | |
835 | 746 | } | |
836 | 747 | else throw("Strict value is not equal to itself.") | |
837 | 748 | } | |
749 | + | else throw("Strict value is not equal to itself.") | |
838 | 750 | } | |
839 | - | else throw("Strict value is not equal to itself.") | |
840 | 751 | } | |
841 | 752 | ||
842 | 753 | ||
884 | 795 | case _ => | |
885 | 796 | throw("Match error") | |
886 | 797 | } | |
798 | + | ||
799 | + | ||
800 | + | func getY (isReverse,D,poolAmountInBalance) = { | |
801 | + | let poolConfig = gpc() | |
802 | + | let amId = poolConfig[idxAmAsId] | |
803 | + | let prId = poolConfig[idxPrAsId] | |
804 | + | let n = big2 | |
805 | + | let aPrecision = parseBigIntValue(Amult) | |
806 | + | let a = (parseBigIntValue(A) * aPrecision) | |
807 | + | let xp = if ((isReverse == false)) | |
808 | + | then [(toBigInt(getAccBalance(amId)) - poolAmountInBalance), toBigInt(getAccBalance(prId))] | |
809 | + | else [(toBigInt(getAccBalance(prId)) - poolAmountInBalance), toBigInt(getAccBalance(amId))] | |
810 | + | let x = xp[0] | |
811 | + | let s = x | |
812 | + | let ann = (a * n) | |
813 | + | let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n)) | |
814 | + | let b = ((s + ((D * aPrecision) / ann)) - D) | |
815 | + | func calc (acc,cur) = { | |
816 | + | let $t03029130311 = acc | |
817 | + | let y = $t03029130311._1 | |
818 | + | let found = $t03029130311._2 | |
819 | + | if ((found != unit)) | |
820 | + | then acc | |
821 | + | else { | |
822 | + | let yNext = (((y * y) + c) / ((big2 * y) + b)) | |
823 | + | let yDiff = absBigInt((yNext - value(y))) | |
824 | + | if ((big1 >= yDiff)) | |
825 | + | then $Tuple2(yNext, cur) | |
826 | + | else $Tuple2(yNext, unit) | |
827 | + | } | |
828 | + | } | |
829 | + | ||
830 | + | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
831 | + | let $t03064230689 = { | |
832 | + | let $l = arr | |
833 | + | let $s = size($l) | |
834 | + | let $acc0 = $Tuple2(D, unit) | |
835 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
836 | + | then $a | |
837 | + | else calc($a, $l[$i]) | |
838 | + | ||
839 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
840 | + | then $a | |
841 | + | else throw("List size exceeds 15") | |
842 | + | ||
843 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15) | |
844 | + | } | |
845 | + | let y = $t03064230689._1 | |
846 | + | let found = $t03064230689._2 | |
847 | + | if ((found != unit)) | |
848 | + | then y | |
849 | + | else throw(("Y calculation error, Y = " + toString(y))) | |
850 | + | } | |
851 | + | ||
852 | + | ||
853 | + | @Callable(i) | |
854 | + | func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse) = { | |
855 | + | let $t03091031506 = if ((isReverse == false)) | |
856 | + | then { | |
857 | + | let assetOut = strf(this, pa()) | |
858 | + | let poolAmountInBalance = (toBigInt(getAccBalance(strf(this, aa()))) + toBigInt(cleanAmountIn)) | |
859 | + | $Tuple2(assetOut, poolAmountInBalance) | |
860 | + | } | |
861 | + | else { | |
862 | + | let assetOut = strf(this, aa()) | |
863 | + | let poolAmountInBalance = (toBigInt(getAccBalance(strf(this, pa()))) + toBigInt(cleanAmountIn)) | |
864 | + | $Tuple2(assetOut, poolAmountInBalance) | |
865 | + | } | |
866 | + | let assetOut = $t03091031506._1 | |
867 | + | let poolAmountInBalance = $t03091031506._2 | |
868 | + | let poolConfig = gpc() | |
869 | + | let amId = poolConfig[idxAmAsId] | |
870 | + | let prId = poolConfig[idxPrAsId] | |
871 | + | let xp = [toBigInt(getAccBalance(amId)), toBigInt(getAccBalance(prId))] | |
872 | + | let D = getD(xp) | |
873 | + | let y = getY(isReverse, D, poolAmountInBalance) | |
874 | + | let dy = ((toBigInt(getAccBalance(assetOut)) - y) - toBigInt(1)) | |
875 | + | let totalGetRaw = max([0, toInt(dy)]) | |
876 | + | $Tuple2(nil, totalGetRaw) | |
877 | + | } | |
878 | + | ||
879 | + | ||
880 | + | ||
881 | + | @Callable(i) | |
882 | + | func calculateAmountOutForSwapAndSendTokens (cleanAmountIn,isReverse,amountOutMin,addressTo) = { | |
883 | + | let checks = [if ((value(i.payments[0]).amount >= cleanAmountIn)) | |
884 | + | then true | |
885 | + | else throwErr("Wrong amount"), if ((i.caller == addressFromStringValue(strf(this, swapContract())))) | |
886 | + | then true | |
887 | + | else throwErr("Permission denied")] | |
888 | + | if ((checks == checks)) | |
889 | + | then { | |
890 | + | let pmt = value(i.payments[0]) | |
891 | + | let assetIn = if ((pmt.assetId == unit)) | |
892 | + | then toBase58String(toBytes("WAVES")) | |
893 | + | else toBase58String(value(pmt.assetId)) | |
894 | + | let $t03256432958 = if ((isReverse == false)) | |
895 | + | then { | |
896 | + | let assetOut = strf(this, pa()) | |
897 | + | let poolAmountInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount) | |
898 | + | $Tuple2(assetOut, poolAmountInBalance) | |
899 | + | } | |
900 | + | else { | |
901 | + | let assetOut = strf(this, aa()) | |
902 | + | let poolAmountInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount) | |
903 | + | $Tuple2(assetOut, poolAmountInBalance) | |
904 | + | } | |
905 | + | let assetOut = $t03256432958._1 | |
906 | + | let poolAmountInBalance = $t03256432958._2 | |
907 | + | let poolConfig = gpc() | |
908 | + | let amId = poolConfig[idxAmAsId] | |
909 | + | let prId = poolConfig[idxPrAsId] | |
910 | + | let xp = [(toBigInt(getAccBalance(amId)) - toBigInt(value(i.payments[0]).amount)), toBigInt(getAccBalance(prId))] | |
911 | + | let D = getD(xp) | |
912 | + | let y = getY(isReverse, D, toBigInt(poolAmountInBalance)) | |
913 | + | let dy = ((toBigInt(getAccBalance(assetOut)) - y) - toBigInt(1)) | |
914 | + | let totalGetRaw = max([0, toInt(dy)]) | |
915 | + | let checkMin = if ((totalGetRaw >= amountOutMin)) | |
916 | + | then true | |
917 | + | else throw("Exchange result is fewer coins than expected") | |
918 | + | if ((checkMin == checkMin)) | |
919 | + | then [ScriptTransfer(addressFromStringValue(addressTo), totalGetRaw, if ((assetIn == "WAVES")) | |
920 | + | then unit | |
921 | + | else fromBase58String(assetOut))] | |
922 | + | else throw("Strict value is not equal to itself.") | |
923 | + | } | |
924 | + | else throw("Strict value is not equal to itself.") | |
925 | + | } | |
926 | + | ||
887 | 927 | ||
888 | 928 | ||
889 | 929 | @Callable(i) | |
941 | 981 | else if ((size(i.payments) != 2)) | |
942 | 982 | then throw("2 pmnts expd") | |
943 | 983 | else { | |
944 | - | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
945 | - | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
946 | - | let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amAssetPmt) | |
947 | - | if ((amountAssetBalance == amountAssetBalance)) | |
984 | + | let e = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], slip, true, false, true, 0, "") | |
985 | + | let emitLpAmt = e._2 | |
986 | + | let lpAssetId = e._7 | |
987 | + | let state = e._9 | |
988 | + | let amDiff = e._10 | |
989 | + | let prDiff = e._11 | |
990 | + | let amId = e._12 | |
991 | + | let prId = e._13 | |
992 | + | let r = invoke(fca, "emit", [emitLpAmt], nil) | |
993 | + | if ((r == r)) | |
948 | 994 | then { | |
949 | - | let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - prAssetPmt) | |
950 | - | if ((priceAssetBalance == priceAssetBalance)) | |
995 | + | let el = match r { | |
996 | + | case legacy: Address => | |
997 | + | invoke(legacy, "emit", [emitLpAmt], nil) | |
998 | + | case _ => | |
999 | + | unit | |
1000 | + | } | |
1001 | + | if ((el == el)) | |
951 | 1002 | then { | |
952 | - | let lpAssetEmission = toBigInt(value(assetInfo(cfgLpAssetId)).quantity) | |
953 | - | if ((lpAssetEmission == lpAssetEmission)) | |
1003 | + | let sa = if ((amDiff > 0)) | |
1004 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)]) | |
1005 | + | else nil | |
1006 | + | if ((sa == sa)) | |
954 | 1007 | then { | |
955 | - | let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
956 | - | if ((currentDLp == currentDLp)) | |
1008 | + | let sp = if ((prDiff > 0)) | |
1009 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)]) | |
1010 | + | else nil | |
1011 | + | if ((sp == sp)) | |
957 | 1012 | then { | |
958 | - | let e = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], slip, true, false, true, 0, "") | |
959 | - | let emitLpAmt = e._2 | |
960 | - | let lpAssetId = e._7 | |
961 | - | let state = e._9 | |
962 | - | let amDiff = e._10 | |
963 | - | let prDiff = e._11 | |
964 | - | let amId = e._12 | |
965 | - | let prId = e._13 | |
966 | - | let r = invoke(fca, "emit", [emitLpAmt], nil) | |
967 | - | if ((r == r)) | |
1013 | + | let lpTrnsfr = if (autoStake) | |
968 | 1014 | then { | |
969 | - | let el = match r { | |
970 | - | case legacy: Address => | |
971 | - | invoke(legacy, "emit", [emitLpAmt], nil) | |
972 | - | case _ => | |
973 | - | unit | |
974 | - | } | |
975 | - | if ((el == el)) | |
976 | - | then { | |
977 | - | let sa = if ((amDiff > 0)) | |
978 | - | then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)]) | |
979 | - | else nil | |
980 | - | if ((sa == sa)) | |
981 | - | then { | |
982 | - | let sp = if ((prDiff > 0)) | |
983 | - | then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)]) | |
984 | - | else nil | |
985 | - | if ((sp == sp)) | |
986 | - | then { | |
987 | - | let lpTrnsfr = if (autoStake) | |
988 | - | then { | |
989 | - | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
990 | - | if ((ss == ss)) | |
991 | - | then nil | |
992 | - | else throw("Strict value is not equal to itself.") | |
993 | - | } | |
994 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
995 | - | let $t03698237124 = refreshDLpInternal(0, 0, 0) | |
996 | - | let refreshDLpActions = $t03698237124._1 | |
997 | - | let updatedDLp = $t03698237124._2 | |
998 | - | let check = if ((updatedDLp >= currentDLp)) | |
999 | - | then true | |
1000 | - | else throwErr(makeString(["updated DLp lower than current DLp", toString(amountAssetBalance), toString(priceAssetBalance), toString(lpAssetEmission), toString(currentDLp), toString(updatedDLp), toString(amDiff), toString(prDiff)], " ")) | |
1001 | - | if ((check == check)) | |
1002 | - | then { | |
1003 | - | let lpAssetEmissionAfter = value(assetInfo(cfgLpAssetId)).quantity | |
1004 | - | if ((lpAssetEmissionAfter == lpAssetEmissionAfter)) | |
1005 | - | then ((state ++ lpTrnsfr) ++ refreshDLpActions) | |
1006 | - | else throw("Strict value is not equal to itself.") | |
1007 | - | } | |
1008 | - | else throw("Strict value is not equal to itself.") | |
1009 | - | } | |
1010 | - | else throw("Strict value is not equal to itself.") | |
1011 | - | } | |
1012 | - | else throw("Strict value is not equal to itself.") | |
1013 | - | } | |
1015 | + | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
1016 | + | if ((ss == ss)) | |
1017 | + | then nil | |
1014 | 1018 | else throw("Strict value is not equal to itself.") | |
1015 | 1019 | } | |
1016 | - | else throw("Strict value is not equal to itself.") | |
1020 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
1021 | + | (state ++ lpTrnsfr) | |
1017 | 1022 | } | |
1018 | 1023 | else throw("Strict value is not equal to itself.") | |
1019 | 1024 | } | |
1051 | 1056 | else throwErr("exactly 1 payment are expected")] | |
1052 | 1057 | if ((checks == checks)) | |
1053 | 1058 | then { | |
1054 | - | let amId = toBase58String(value(cfgAmountAssetId)) | |
1055 | - | let prId = toBase58String(value(cfgPriceAssetId)) | |
1056 | - | let lpId = cfgLpAssetId | |
1057 | - | let amDecimals = cfgAmountAssetDecimals | |
1058 | - | let prDecimals = cfgPriceAssetDecimals | |
1059 | + | let poolConfig = gpc() | |
1060 | + | let amId = poolConfig[idxAmAsId] | |
1061 | + | let prId = poolConfig[idxPrAsId] | |
1062 | + | let lpId = fromBase58String(poolConfig[idxLPAsId]) | |
1063 | + | let amDecimals = parseIntValue(poolConfig[idxAmtAsDcm]) | |
1064 | + | let prDecimals = parseIntValue(poolConfig[idxPriceAsDcm]) | |
1059 | 1065 | let userAddress = if ((i.caller == this)) | |
1060 | 1066 | then i.originCaller | |
1061 | 1067 | else i.caller | |
1062 | 1068 | let pmt = value(i.payments[0]) | |
1063 | 1069 | let pmtAssetId = toBase58String(value(pmt.assetId)) | |
1064 | 1070 | let pmtAmt = pmt.amount | |
1065 | - | let currentDLp = if ((pmt.assetId == cfgAmountAssetId)) | |
1066 | - | then calcCurrentDLp(toBigInt(pmtAmt), toBigInt(0), toBigInt(0)) | |
1067 | - | else calcCurrentDLp(toBigInt(0), toBigInt(pmtAmt), toBigInt(0)) | |
1068 | - | if ((currentDLp == currentDLp)) | |
1071 | + | let $t03777737935 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true) | |
1072 | + | if (($t03777737935 == $t03777737935)) | |
1069 | 1073 | then { | |
1070 | - | let $t03876538923 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true) | |
1071 | - | if (($t03876538923 == $t03876538923)) | |
1074 | + | let feeAmount = $t03777737935._3 | |
1075 | + | let state = $t03777737935._2 | |
1076 | + | let estimLP = $t03777737935._1 | |
1077 | + | let emitLpAmt = if (if ((minOutAmount > 0)) | |
1078 | + | then (minOutAmount > estimLP) | |
1079 | + | else false) | |
1080 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1081 | + | else estimLP | |
1082 | + | let e = invoke(fca, "emit", [emitLpAmt], nil) | |
1083 | + | if ((e == e)) | |
1072 | 1084 | then { | |
1073 | - | let feeAmount = $t03876538923._3 | |
1074 | - | let state = $t03876538923._2 | |
1075 | - | let estimLP = $t03876538923._1 | |
1076 | - | let emitLpAmt = if (if ((minOutAmount > 0)) | |
1077 | - | then (minOutAmount > estimLP) | |
1078 | - | else false) | |
1079 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1080 | - | else estimLP | |
1081 | - | let e = invoke(fca, "emit", [emitLpAmt], nil) | |
1082 | - | if ((e == e)) | |
1085 | + | let el = match e { | |
1086 | + | case legacy: Address => | |
1087 | + | invoke(legacy, "emit", [emitLpAmt], nil) | |
1088 | + | case _ => | |
1089 | + | unit | |
1090 | + | } | |
1091 | + | if ((el == el)) | |
1083 | 1092 | then { | |
1084 | - | let el = match e { | |
1085 | - | case legacy: Address => | |
1086 | - | invoke(legacy, "emit", [emitLpAmt], nil) | |
1087 | - | case _ => | |
1088 | - | unit | |
1089 | - | } | |
1090 | - | if ((el == el)) | |
1093 | + | let lpTrnsfr = if (autoStake) | |
1091 | 1094 | then { | |
1092 | - | let lpTrnsfr = if (autoStake) | |
1093 | - | then { | |
1094 | - | let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)]) | |
1095 | - | if ((ss == ss)) | |
1096 | - | then nil | |
1097 | - | else throw("Strict value is not equal to itself.") | |
1098 | - | } | |
1099 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpId)] | |
1100 | - | let sendFeeToMatcher = if ((feeAmount > 0)) | |
1101 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))] | |
1102 | - | else nil | |
1103 | - | let $t03973840087 = if ((this == feeCollectorAddress)) | |
1104 | - | then $Tuple2(0, 0) | |
1105 | - | else { | |
1106 | - | let paymentInAmountAsset = if ((pmt.assetId == cfgAmountAssetId)) | |
1107 | - | then true | |
1108 | - | else false | |
1109 | - | if (paymentInAmountAsset) | |
1110 | - | then $Tuple2(-(feeAmount), 0) | |
1111 | - | else $Tuple2(0, -(feeAmount)) | |
1112 | - | } | |
1113 | - | let amountAssetBalanceDelta = $t03973840087._1 | |
1114 | - | let priceAssetBalanceDelta = $t03973840087._2 | |
1115 | - | let $t04009040198 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1116 | - | let refreshDLpActions = $t04009040198._1 | |
1117 | - | let updatedDLp = $t04009040198._2 | |
1118 | - | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1119 | - | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1120 | - | then $Tuple2((((state ++ lpTrnsfr) ++ sendFeeToMatcher) ++ refreshDLpActions), emitLpAmt) | |
1095 | + | let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)]) | |
1096 | + | if ((ss == ss)) | |
1097 | + | then nil | |
1121 | 1098 | else throw("Strict value is not equal to itself.") | |
1122 | 1099 | } | |
1123 | - | else throw("Strict value is not equal to itself.") | |
1100 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpId)] | |
1101 | + | let sendFeeToMatcher = if ((feeAmount > 0)) | |
1102 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))] | |
1103 | + | else nil | |
1104 | + | $Tuple2(((state ++ lpTrnsfr) ++ sendFeeToMatcher), emitLpAmt) | |
1124 | 1105 | } | |
1125 | 1106 | else throw("Strict value is not equal to itself.") | |
1126 | 1107 | } | |
1140 | 1121 | then throw("2 pmnts expd") | |
1141 | 1122 | else { | |
1142 | 1123 | let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], maxSlpg, false, false, true, 0, "") | |
1143 | - | let state = estPut._9 | |
1144 | - | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
1145 | - | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
1146 | - | let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
1147 | - | if ((currentDLp == currentDLp)) | |
1148 | - | then { | |
1149 | - | let $t04122841293 = refreshDLpInternal(0, 0, 0) | |
1150 | - | let refreshDLpActions = $t04122841293._1 | |
1151 | - | let updatedDLp = $t04122841293._2 | |
1152 | - | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1153 | - | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1154 | - | then (state ++ refreshDLpActions) | |
1155 | - | else throw("Strict value is not equal to itself.") | |
1156 | - | } | |
1157 | - | else throw("Strict value is not equal to itself.") | |
1124 | + | estPut._9 | |
1158 | 1125 | } | |
1159 | 1126 | ||
1160 | 1127 | ||
1161 | 1128 | ||
1162 | 1129 | @Callable(i) | |
1163 | 1130 | func get () = { | |
1164 | - | let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1165 | - | if ((currentDLp == currentDLp)) | |
1166 | - | then { | |
1167 | - | let r = cg(i) | |
1168 | - | let outAmtAmt = r._1 | |
1169 | - | let outPrAmt = r._2 | |
1170 | - | let pmtAmt = r._3 | |
1171 | - | let pmtAssetId = r._4 | |
1172 | - | let state = r._5 | |
1173 | - | let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1174 | - | if ((b == b)) | |
1175 | - | then { | |
1176 | - | let $t04246642548 = refreshDLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1177 | - | let refreshDLpActions = $t04246642548._1 | |
1178 | - | let updatedDLp = $t04246642548._2 | |
1179 | - | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1180 | - | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1181 | - | then (state ++ refreshDLpActions) | |
1182 | - | else throw("Strict value is not equal to itself.") | |
1183 | - | } | |
1184 | - | else throw("Strict value is not equal to itself.") | |
1185 | - | } | |
1131 | + | let r = cg(i) | |
1132 | + | let outAmtAmt = r._1 | |
1133 | + | let outPrAmt = r._2 | |
1134 | + | let pmtAmt = r._3 | |
1135 | + | let pmtAssetId = r._4 | |
1136 | + | let state = r._5 | |
1137 | + | let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1138 | + | if ((b == b)) | |
1139 | + | then state | |
1186 | 1140 | else throw("Strict value is not equal to itself.") | |
1187 | 1141 | } | |
1188 | 1142 | ||
1210 | 1164 | else throwErr("exactly 1 payment are expected")] | |
1211 | 1165 | if ((checks == checks)) | |
1212 | 1166 | then { | |
1213 | - | let $ | |
1214 | - | let state = $ | |
1215 | - | let totalAmount = $ | |
1167 | + | let $t04055740712 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId) | |
1168 | + | let state = $t04055740712._1 | |
1169 | + | let totalAmount = $t04055740712._2 | |
1216 | 1170 | $Tuple2(state, totalAmount) | |
1217 | 1171 | } | |
1218 | 1172 | else throw("Strict value is not equal to itself.") | |
1221 | 1175 | ||
1222 | 1176 | ||
1223 | 1177 | @Callable(i) | |
1224 | - | func refreshDLp () = { | |
1225 | - | let lastRefreshedBlockHeight = valueOrElse(getInteger(keyDLpRefreshedHeight), 0) | |
1226 | - | let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= dLpRefreshDelay)) | |
1227 | - | then unit | |
1228 | - | else throwErr(makeString([toString(dLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1229 | - | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1230 | - | then { | |
1231 | - | let dLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyDLp), "0")), fmtErr("invalid dLp")) | |
1232 | - | let $t04384543909 = refreshDLpInternal(0, 0, 0) | |
1233 | - | let dLpUpdateActions = $t04384543909._1 | |
1234 | - | let updatedDLp = $t04384543909._2 | |
1235 | - | let actions = if ((dLp != updatedDLp)) | |
1236 | - | then dLpUpdateActions | |
1237 | - | else throwErr("nothing to refresh") | |
1238 | - | $Tuple2(actions, toString(updatedDLp)) | |
1239 | - | } | |
1240 | - | else throw("Strict value is not equal to itself.") | |
1241 | - | } | |
1242 | - | ||
1243 | - | ||
1244 | - | ||
1245 | - | @Callable(i) | |
1246 | 1178 | func getOneTknV2READONLY (outAssetId,lpAssetAmount) = { | |
1247 | - | let amId = toBase58String(value(cfgAmountAssetId)) | |
1248 | - | let prId = toBase58String(value(cfgPriceAssetId)) | |
1249 | - | let lpId = toBase58String(value(cfgLpAssetId)) | |
1179 | + | let poolConfig = gpc() | |
1180 | + | let amId = poolConfig[idxAmAsId] | |
1181 | + | let prId = poolConfig[idxPrAsId] | |
1182 | + | let lpId = poolConfig[idxLPAsId] | |
1250 | 1183 | let xp = [toBigInt(getAccBalance(amId)), toBigInt(getAccBalance(prId))] | |
1251 | 1184 | let lpEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity) | |
1252 | 1185 | let D0 = getD(xp) | |
1259 | 1192 | let newY = getYD(xp, index, D1) | |
1260 | 1193 | let dy = (xp[index] - newY) | |
1261 | 1194 | let totalGetRaw = max([0, toInt((dy - big1))]) | |
1262 | - | let $ | |
1263 | - | let totalGet = $ | |
1264 | - | let feeAmount = $ | |
1195 | + | let $t04150241557 = takeFee(totalGetRaw, outFee) | |
1196 | + | let totalGet = $t04150241557._1 | |
1197 | + | let feeAmount = $t04150241557._2 | |
1265 | 1198 | $Tuple2(nil, $Tuple2(totalGet, feeAmount)) | |
1266 | 1199 | } | |
1267 | 1200 | ||
1269 | 1202 | ||
1270 | 1203 | @Callable(i) | |
1271 | 1204 | func getOneTknV2WithBonusREADONLY (outAssetId,lpAssetAmount) = { | |
1272 | - | let amId = toBase58String(value(cfgAmountAssetId)) | |
1273 | - | let prId = toBase58String(value(cfgPriceAssetId)) | |
1274 | - | let lpId = toBase58String(value(cfgLpAssetId)) | |
1205 | + | let poolConfig = gpc() | |
1206 | + | let amId = poolConfig[idxAmAsId] | |
1207 | + | let prId = poolConfig[idxPrAsId] | |
1208 | + | let lpId = poolConfig[idxLPAsId] | |
1275 | 1209 | let amBalance = getAccBalance(amId) | |
1276 | 1210 | let prBalance = getAccBalance(prId) | |
1277 | - | let $ | |
1211 | + | let $t04190242017 = { | |
1278 | 1212 | let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, lpAssetAmount], nil) | |
1279 | 1213 | if ($isInstanceOf(@, "(Int, Int)")) | |
1280 | 1214 | then @ | |
1281 | 1215 | else throw(($getType(@) + " couldn't be cast to (Int, Int)")) | |
1282 | 1216 | } | |
1283 | - | let totalGet = $ | |
1284 | - | let feeAmount = $ | |
1217 | + | let totalGet = $t04190242017._1 | |
1218 | + | let feeAmount = $t04190242017._2 | |
1285 | 1219 | let r = ego("", lpId, lpAssetAmount, this) | |
1286 | 1220 | let outAmAmt = r._1 | |
1287 | 1221 | let outPrAmt = r._2 | |
1309 | 1243 | else if ((noLessThenPriceAsset > outPrAmt)) | |
1310 | 1244 | then throw(((("Failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
1311 | 1245 | else { | |
1312 | - | let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1313 | - | if ((currentDLp == currentDLp)) | |
1314 | - | then { | |
1315 | - | let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1316 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1317 | - | then { | |
1318 | - | let $t04655046631 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1319 | - | let refreshDLpActions = $t04655046631._1 | |
1320 | - | let updatedDLp = $t04655046631._2 | |
1321 | - | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1322 | - | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1323 | - | then (state ++ refreshDLpActions) | |
1324 | - | else throw("Strict value is not equal to itself.") | |
1325 | - | } | |
1326 | - | else throw("Strict value is not equal to itself.") | |
1327 | - | } | |
1246 | + | let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1247 | + | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1248 | + | then state | |
1328 | 1249 | else throw("Strict value is not equal to itself.") | |
1329 | 1250 | } | |
1330 | 1251 | } | |
1338 | 1259 | else true | |
1339 | 1260 | if ((checkPayments == checkPayments)) | |
1340 | 1261 | then { | |
1262 | + | let cfg = gpc() | |
1341 | 1263 | let factoryCfg = gfc() | |
1342 | - | let lpAssetId = | |
1264 | + | let lpAssetId = fromBase58String(cfg[idxLPAsId]) | |
1343 | 1265 | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr") | |
1344 | - | let | |
1345 | - | if (( | |
1266 | + | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1267 | + | if ((unstakeInv == unstakeInv)) | |
1346 | 1268 | then { | |
1347 | - | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1348 | - | if ((unstakeInv == unstakeInv)) | |
1269 | + | let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1270 | + | let sts = parseIntValue(r._9) | |
1271 | + | let state = r._10 | |
1272 | + | let v = if (if (igs()) | |
1273 | + | then true | |
1274 | + | else (sts == PoolShutdown)) | |
1275 | + | then throw(("Blocked: " + toString(sts))) | |
1276 | + | else true | |
1277 | + | if ((v == v)) | |
1349 | 1278 | then { | |
1350 | - | let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1351 | - | let outAmAmt = r._1 | |
1352 | - | let outPrAmt = r._2 | |
1353 | - | let sts = parseIntValue(r._9) | |
1354 | - | let state = r._10 | |
1355 | - | let v = if (if (igs()) | |
1356 | - | then true | |
1357 | - | else (sts == PoolShutdown)) | |
1358 | - | then throw(("Blocked: " + toString(sts))) | |
1359 | - | else true | |
1360 | - | if ((v == v)) | |
1361 | - | then { | |
1362 | - | let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1363 | - | if ((burnA == burnA)) | |
1364 | - | then { | |
1365 | - | let $t04765847739 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1366 | - | let refreshDLpActions = $t04765847739._1 | |
1367 | - | let updatedDLp = $t04765847739._2 | |
1368 | - | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1369 | - | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1370 | - | then (state ++ refreshDLpActions) | |
1371 | - | else throw("Strict value is not equal to itself.") | |
1372 | - | } | |
1373 | - | else throw("Strict value is not equal to itself.") | |
1374 | - | } | |
1279 | + | let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1280 | + | if ((burnA == burnA)) | |
1281 | + | then state | |
1375 | 1282 | else throw("Strict value is not equal to itself.") | |
1376 | 1283 | } | |
1377 | 1284 | else throw("Strict value is not equal to itself.") | |
1395 | 1302 | else throw("no payments are expected")] | |
1396 | 1303 | if ((checks == checks)) | |
1397 | 1304 | then { | |
1398 | - | let | |
1399 | - | if (( | |
1305 | + | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1306 | + | if ((unstakeInv == unstakeInv)) | |
1400 | 1307 | then { | |
1401 | - | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1402 | - | if ((unstakeInv == unstakeInv)) | |
1308 | + | let res = ego(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1309 | + | let outAmAmt = res._1 | |
1310 | + | let outPrAmt = res._2 | |
1311 | + | let state = res._10 | |
1312 | + | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1313 | + | then true | |
1314 | + | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1315 | + | then true | |
1316 | + | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1317 | + | if ((checkAmounts == checkAmounts)) | |
1403 | 1318 | then { | |
1404 | - | let res = ego(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1405 | - | let outAmAmt = res._1 | |
1406 | - | let outPrAmt = res._2 | |
1407 | - | let state = res._10 | |
1408 | - | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1409 | - | then true | |
1410 | - | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1411 | - | then true | |
1412 | - | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1413 | - | if ((checkAmounts == checkAmounts)) | |
1414 | - | then { | |
1415 | - | let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1416 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1417 | - | then { | |
1418 | - | let $t04899049071 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1419 | - | let refreshDLpActions = $t04899049071._1 | |
1420 | - | let updatedDLp = $t04899049071._2 | |
1421 | - | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1422 | - | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1423 | - | then (state ++ refreshDLpActions) | |
1424 | - | else throw("Strict value is not equal to itself.") | |
1425 | - | } | |
1426 | - | else throw("Strict value is not equal to itself.") | |
1427 | - | } | |
1319 | + | let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1320 | + | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1321 | + | then state | |
1428 | 1322 | else throw("Strict value is not equal to itself.") | |
1429 | 1323 | } | |
1430 | 1324 | else throw("Strict value is not equal to itself.") | |
1458 | 1352 | else throwErr("no payments are expected")] | |
1459 | 1353 | if ((checks == checks)) | |
1460 | 1354 | then { | |
1355 | + | let cfg = gpc() | |
1461 | 1356 | let factoryCfg = gfc() | |
1462 | - | let lpAssetId = | |
1357 | + | let lpAssetId = fromBase58String(cfg[idxLPAsId]) | |
1463 | 1358 | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr") | |
1464 | 1359 | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), unstakeAmount], nil) | |
1465 | 1360 | if ((unstakeInv == unstakeInv)) | |
1466 | 1361 | then { | |
1467 | - | let $ | |
1468 | - | let state = $ | |
1469 | - | let totalAmount = $ | |
1362 | + | let $t04585546043 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId) | |
1363 | + | let state = $t04585546043._1 | |
1364 | + | let totalAmount = $t04585546043._2 | |
1470 | 1365 | $Tuple2(state, totalAmount) | |
1471 | 1366 | } | |
1472 | 1367 | else throw("Strict value is not equal to itself.") | |
1478 | 1373 | ||
1479 | 1374 | @Callable(i) | |
1480 | 1375 | func putOneTknV2WithBonusREADONLY (paymentAmountRaw,paymentAssetId) = { | |
1481 | - | let $t05028250385 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true) | |
1482 | - | let lpAmount = $t05028250385._1 | |
1483 | - | let state = $t05028250385._2 | |
1484 | - | let feeAmount = $t05028250385._3 | |
1485 | - | let bonus = $t05028250385._4 | |
1376 | + | let poolConfig = gpc() | |
1377 | + | let amId = poolConfig[idxAmAsId] | |
1378 | + | let prId = poolConfig[idxPrAsId] | |
1379 | + | let lpId = poolConfig[idxLPAsId] | |
1380 | + | let $t04630246405 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true) | |
1381 | + | let lpAmount = $t04630246405._1 | |
1382 | + | let state = $t04630246405._2 | |
1383 | + | let feeAmount = $t04630246405._3 | |
1384 | + | let bonus = $t04630246405._4 | |
1486 | 1385 | $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus)) | |
1487 | 1386 | } | |
1488 | 1387 | ||
1490 | 1389 | ||
1491 | 1390 | @Callable(i) | |
1492 | 1391 | func putOneTknV2WithoutTakeFeeREADONLY (paymentAmountRaw,paymentAssetId) = { | |
1493 | - | let $t05053350637 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false) | |
1494 | - | let lpAmount = $t05053350637._1 | |
1495 | - | let state = $t05053350637._2 | |
1496 | - | let feeAmount = $t05053350637._3 | |
1497 | - | let bonus = $t05053350637._4 | |
1392 | + | let poolConfig = gpc() | |
1393 | + | let amId = poolConfig[idxAmAsId] | |
1394 | + | let prId = poolConfig[idxPrAsId] | |
1395 | + | let lpId = poolConfig[idxLPAsId] | |
1396 | + | let $t04668446788 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false) | |
1397 | + | let lpAmount = $t04668446788._1 | |
1398 | + | let state = $t04668446788._2 | |
1399 | + | let feeAmount = $t04668446788._3 | |
1400 | + | let bonus = $t04668446788._4 | |
1498 | 1401 | $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus)) | |
1499 | 1402 | } | |
1500 | 1403 | ||
1579 | 1482 | match tx { | |
1580 | 1483 | case order: Order => | |
1581 | 1484 | let matcherPub = mp() | |
1582 | - | let $t05342953498 = validateMatcherOrderAllowed(order) | |
1583 | - | let orderValid = $t05342953498._1 | |
1584 | - | let orderValidInfo = $t05342953498._2 | |
1485 | + | let orderValid = moa(order) | |
1585 | 1486 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1586 | 1487 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1587 | 1488 | if (if (if (orderValid) | |
1590 | 1491 | then matcherValid | |
1591 | 1492 | else false) | |
1592 | 1493 | then true | |
1593 | - | else | |
1494 | + | else toe(orderValid, senderValid, matcherValid) | |
1594 | 1495 | case s: SetScriptTransaction => | |
1595 | - | if (sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)) | |
1496 | + | let newHash = blake2b256(value(s.script)) | |
1497 | + | let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash()))) | |
1498 | + | let currentHash = scriptHash(this) | |
1499 | + | if (if ((allowedHash == newHash)) | |
1500 | + | then (currentHash != newHash) | |
1501 | + | else false) | |
1596 | 1502 | then true | |
1597 | - | else { | |
1598 | - | let newHash = blake2b256(value(s.script)) | |
1599 | - | let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash()))) | |
1600 | - | let currentHash = scriptHash(this) | |
1601 | - | if ((allowedHash == newHash)) | |
1602 | - | then (currentHash != newHash) | |
1603 | - | else false | |
1604 | - | } | |
1503 | + | else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1605 | 1504 | case _ => | |
1606 | 1505 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1607 | 1506 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let scale8 = 100000000 | |
5 | 5 | ||
6 | 6 | let scale8BigInt = toBigInt(100000000) | |
7 | 7 | ||
8 | 8 | let scale18 = toBigInt(1000000000000000000) | |
9 | 9 | ||
10 | 10 | let zeroBigInt = toBigInt(0) | |
11 | 11 | ||
12 | 12 | let big0 = toBigInt(0) | |
13 | 13 | ||
14 | 14 | let big1 = toBigInt(1) | |
15 | 15 | ||
16 | 16 | let big2 = toBigInt(2) | |
17 | - | ||
18 | - | let big3 = toBigInt(3) | |
19 | - | ||
20 | - | let big4 = toBigInt(4) | |
21 | 17 | ||
22 | 18 | let slippage4D = toBigInt((scale8 - ((scale8 * 1) / scale8))) | |
23 | 19 | ||
24 | 20 | let wavesString = "WAVES" | |
25 | 21 | ||
26 | 22 | let Amult = "100" | |
27 | 23 | ||
28 | 24 | let Dconv = "1" | |
29 | 25 | ||
30 | 26 | let SEP = "__" | |
31 | 27 | ||
32 | 28 | let EMPTY = "" | |
33 | 29 | ||
34 | 30 | let PoolActive = 1 | |
35 | 31 | ||
36 | 32 | let PoolPutDis = 2 | |
37 | 33 | ||
38 | 34 | let PoolMatcherDis = 3 | |
39 | 35 | ||
40 | 36 | let PoolShutdown = 4 | |
41 | 37 | ||
42 | 38 | let idxPoolAddress = 1 | |
43 | 39 | ||
44 | 40 | let idxPoolSt = 2 | |
45 | 41 | ||
46 | 42 | let idxLPAsId = 3 | |
47 | 43 | ||
48 | 44 | let idxAmAsId = 4 | |
49 | 45 | ||
50 | 46 | let idxPrAsId = 5 | |
51 | 47 | ||
52 | 48 | let idxAmtAsDcm = 6 | |
53 | 49 | ||
54 | 50 | let idxPriceAsDcm = 7 | |
55 | 51 | ||
56 | 52 | let idxIAmtAsId = 8 | |
57 | 53 | ||
58 | 54 | let idxIPriceAsId = 9 | |
59 | 55 | ||
60 | 56 | let idxFactStakCntr = 1 | |
61 | 57 | ||
62 | 58 | let idxFactoryRestCntr = 6 | |
63 | 59 | ||
64 | 60 | let idxFactSlippCntr = 7 | |
65 | 61 | ||
66 | 62 | let idxFactGwxRewCntr = 10 | |
67 | 63 | ||
68 | 64 | let feeDefault = fraction(10, scale8, 10000) | |
69 | 65 | ||
70 | 66 | func t1 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult)) | |
71 | 67 | ||
72 | 68 | ||
73 | - | func t1BigInt (origVal,origScaleMult) = fraction(origVal, scale18, origScaleMult) | |
74 | - | ||
75 | - | ||
76 | 69 | func f1 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18)) | |
77 | - | ||
78 | - | ||
79 | - | func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round)) | |
80 | - | ||
81 | - | ||
82 | - | func t2 (origVal,origScaleMult) = fraction(origVal, scale18, toBigInt(origScaleMult)) | |
83 | - | ||
84 | - | ||
85 | - | func f2 (val,resultScaleMult) = fraction(val, toBigInt(resultScaleMult), scale18) | |
86 | 70 | ||
87 | 71 | ||
88 | 72 | func ts (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
89 | 73 | ||
90 | 74 | ||
91 | 75 | func abs (val) = if ((zeroBigInt > val)) | |
92 | 76 | then -(val) | |
93 | 77 | else val | |
94 | 78 | ||
95 | 79 | ||
96 | 80 | func absBigInt (val) = if ((zeroBigInt > val)) | |
97 | 81 | then -(val) | |
98 | 82 | else val | |
99 | 83 | ||
100 | 84 | ||
101 | 85 | func fc () = "%s__factoryContract" | |
102 | 86 | ||
103 | 87 | ||
104 | 88 | func mpk () = "%s__managerPublicKey" | |
105 | 89 | ||
106 | 90 | ||
107 | 91 | func pmpk () = "%s__pendingManagerPublicKey" | |
108 | 92 | ||
109 | 93 | ||
110 | 94 | func pl () = "%s%s__price__last" | |
111 | 95 | ||
112 | 96 | ||
113 | 97 | func ph (h,t) = makeString(["%s%s%d%d__price__history", toString(h), toString(t)], SEP) | |
114 | 98 | ||
115 | 99 | ||
116 | 100 | func pau (ua,txId) = ((("%s%s%s__P__" + ua) + "__") + txId) | |
117 | 101 | ||
118 | 102 | ||
119 | 103 | func gau (ua,txId) = ((("%s%s%s__G__" + ua) + "__") + txId) | |
120 | 104 | ||
121 | 105 | ||
122 | 106 | func aa () = "%s__amountAsset" | |
123 | 107 | ||
124 | 108 | ||
125 | 109 | func pa () = "%s__priceAsset" | |
126 | 110 | ||
127 | 111 | ||
128 | 112 | func amp () = "%s__amp" | |
129 | 113 | ||
130 | 114 | ||
131 | 115 | func ada () = "%s__addonAddr" | |
132 | 116 | ||
133 | 117 | ||
134 | - | ||
118 | + | func swapContract () = "%s__swapContract" | |
135 | 119 | ||
136 | - | let fee = valueOrElse(getInteger(this, keyFee), feeDefault) | |
137 | - | ||
138 | - | let keyDLp = makeString(["%s", "dLp"], SEP) | |
139 | - | ||
140 | - | let keyDLpRefreshedHeight = makeString(["%s", "dLpRefreshedHeight"], SEP) | |
141 | - | ||
142 | - | let keyDLpRefreshDelay = makeString(["%s", "refreshDLpDelay"], SEP) | |
143 | - | ||
144 | - | let dLpRefreshDelayDefault = 30 | |
145 | - | ||
146 | - | let dLpRefreshDelay = valueOrElse(getInteger(this, keyDLpRefreshDelay), dLpRefreshDelayDefault) | |
147 | 120 | ||
148 | 121 | func fcfg () = "%s__factoryConfig" | |
149 | 122 | ||
150 | 123 | ||
151 | 124 | func mtpk () = "%s%s__matcher__publicKey" | |
152 | 125 | ||
153 | 126 | ||
154 | 127 | func pc (iAmtAs,iPrAs) = (((("%d%d%s__" + iAmtAs) + "__") + iPrAs) + "__config") | |
155 | 128 | ||
156 | 129 | ||
157 | 130 | func mba (bAStr) = ("%s%s%s__mappings__baseAsset2internalId__" + bAStr) | |
158 | 131 | ||
159 | 132 | ||
160 | 133 | func aps () = "%s__shutdown" | |
161 | 134 | ||
162 | 135 | ||
163 | 136 | func keyAllowedLpStableScriptHash () = "%s__allowedLpStableScriptHash" | |
164 | 137 | ||
165 | 138 | ||
166 | 139 | func keyFeeCollectorAddress () = "%s__feeCollectorAddress" | |
167 | 140 | ||
168 | 141 | ||
169 | - | func throwOrderError (orderValid,orderValidInfo,senderValid,matcherValid) = throw((((((((("order validation failed: orderValid=" + toString(orderValid)) + " (") + orderValidInfo) + ")") + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid))) | |
142 | + | func toe (orV,sendrV,matchV) = throw(((((("Failed: ordValid=" + toString(orV)) + " sndrValid=") + toString(sendrV)) + " mtchrValid=") + toString(matchV))) | |
143 | + | ||
144 | + | ||
145 | + | func str (val) = match val { | |
146 | + | case valStr: String => | |
147 | + | valStr | |
148 | + | case _ => | |
149 | + | throw("fail cast to String") | |
150 | + | } | |
170 | 151 | ||
171 | 152 | ||
172 | 153 | func strf (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
173 | 154 | ||
174 | 155 | ||
175 | 156 | func intf (addr,key) = valueOrErrorMessage(getInteger(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
176 | 157 | ||
177 | 158 | ||
178 | 159 | func throwErr (msg) = throw(makeString(["lp_stable.ride:", msg], " ")) | |
179 | - | ||
180 | - | ||
181 | - | func fmtErr (msg) = makeString(["lp_stable.ride:", msg], " ") | |
182 | 160 | ||
183 | 161 | ||
184 | 162 | let fca = addressFromStringValue(strf(this, fc())) | |
185 | 163 | ||
186 | 164 | let inFee = { | |
187 | 165 | let @ = invoke(fca, "getInFeeREADONLY", [toString(this)], nil) | |
188 | 166 | if ($isInstanceOf(@, "Int")) | |
189 | 167 | then @ | |
190 | 168 | else throw(($getType(@) + " couldn't be cast to Int")) | |
191 | 169 | } | |
192 | 170 | ||
193 | 171 | let outFee = { | |
194 | 172 | let @ = invoke(fca, "getOutFeeREADONLY", [toString(this)], nil) | |
195 | 173 | if ($isInstanceOf(@, "Int")) | |
196 | 174 | then @ | |
197 | 175 | else throw(($getType(@) + " couldn't be cast to Int")) | |
198 | 176 | } | |
199 | 177 | ||
200 | 178 | let A = strf(this, amp()) | |
201 | 179 | ||
202 | 180 | func igs () = valueOrElse(getBoolean(fca, aps()), false) | |
203 | 181 | ||
204 | 182 | ||
205 | 183 | func mp () = fromBase58String(strf(fca, mtpk())) | |
206 | 184 | ||
207 | 185 | ||
208 | 186 | let feeCollectorAddress = addressFromStringValue(strf(fca, keyFeeCollectorAddress())) | |
209 | 187 | ||
210 | 188 | func gpc () = { | |
211 | 189 | let amtAs = strf(this, aa()) | |
212 | 190 | let priceAs = strf(this, pa()) | |
213 | 191 | let iPriceAs = intf(fca, mba(priceAs)) | |
214 | 192 | let iAmtAs = intf(fca, mba(amtAs)) | |
215 | 193 | split(strf(fca, pc(toString(iAmtAs), toString(iPriceAs))), SEP) | |
216 | 194 | } | |
217 | 195 | ||
218 | 196 | ||
219 | 197 | func parseAssetId (input) = if ((input == wavesString)) | |
220 | 198 | then unit | |
221 | 199 | else fromBase58String(input) | |
222 | 200 | ||
223 | 201 | ||
224 | 202 | func assetIdToString (input) = if ((input == unit)) | |
225 | 203 | then wavesString | |
226 | 204 | else toBase58String(value(input)) | |
227 | 205 | ||
228 | 206 | ||
229 | - | func parsePoolConfig (poolConfig) = $ | |
207 | + | func parsePoolConfig (poolConfig) = $Tuple7(addressFromStringValue(poolConfig[idxPoolAddress]), parseIntValue(poolConfig[idxPoolSt]), fromBase58String(poolConfig[idxLPAsId]), parseAssetId(poolConfig[idxAmAsId]), parseAssetId(poolConfig[idxPrAsId]), parseIntValue(poolConfig[idxAmtAsDcm]), parseIntValue(poolConfig[idxPriceAsDcm])) | |
230 | 208 | ||
231 | 209 | ||
232 | 210 | let poolConfigParsed = parsePoolConfig(gpc()) | |
233 | 211 | ||
234 | - | let $ | |
212 | + | let $t069527138 = poolConfigParsed | |
235 | 213 | ||
236 | - | let cfgPoolAddress = $ | |
214 | + | let cfgPoolAddress = $t069527138._1 | |
237 | 215 | ||
238 | - | let cfgPoolStatus = $ | |
216 | + | let cfgPoolStatus = $t069527138._2 | |
239 | 217 | ||
240 | - | let cfgLpAssetId = $ | |
218 | + | let cfgLpAssetId = $t069527138._3 | |
241 | 219 | ||
242 | - | let cfgAmountAssetId = $ | |
220 | + | let cfgAmountAssetId = $t069527138._4 | |
243 | 221 | ||
244 | - | let cfgPriceAssetId = $ | |
222 | + | let cfgPriceAssetId = $t069527138._5 | |
245 | 223 | ||
246 | - | let cfgAmountAssetDecimals = $ | |
224 | + | let cfgAmountAssetDecimals = $t069527138._6 | |
247 | 225 | ||
248 | - | let cfgPriceAssetDecimals = $t079658194._7 | |
249 | - | ||
250 | - | let cfgInAmountAssedId = $t079658194._8 | |
251 | - | ||
252 | - | let cfgInPriceAssetId = $t079658194._9 | |
226 | + | let cfgPriceAssetDecimals = $t069527138._7 | |
253 | 227 | ||
254 | 228 | func gfc () = split(strf(fca, fcfg()), SEP) | |
255 | 229 | ||
256 | 230 | ||
257 | 231 | let factoryConfig = gfc() | |
258 | 232 | ||
259 | 233 | let stakingContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactStakCntr]), "Invalid staking contract address") | |
260 | 234 | ||
261 | 235 | let slipageContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactSlippCntr]), "Invalid slipage contract address") | |
262 | 236 | ||
263 | 237 | let gwxContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactGwxRewCntr]), "Invalid gwx contract address") | |
264 | 238 | ||
265 | 239 | let restContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactoryRestCntr]), "Invalid gwx contract address") | |
266 | 240 | ||
267 | 241 | func dataPutActionInfo (inAmtAssetAmt,inPriceAssetAmt,outLpAmt,price,slipByUser,slippageReal,txHeight,txTimestamp,slipageAmAmt,slipagePrAmt) = makeString(["%d%d%d%d%d%d%d%d%d%d", toString(inAmtAssetAmt), toString(inPriceAssetAmt), toString(outLpAmt), toString(price), toString(slipByUser), toString(slippageReal), toString(txHeight), toString(txTimestamp), toString(slipageAmAmt), toString(slipagePrAmt)], SEP) | |
268 | 242 | ||
269 | 243 | ||
270 | 244 | 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) | |
271 | 245 | ||
272 | 246 | ||
273 | 247 | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
274 | 248 | then wavesBalance(this).available | |
275 | 249 | else assetBalance(this, fromBase58String(assetId)) | |
276 | 250 | ||
277 | 251 | ||
278 | 252 | func cpbi (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
279 | - | ||
280 | - | ||
281 | - | func cpbir (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round) | |
282 | 253 | ||
283 | 254 | ||
284 | 255 | func vad (A1,A2,slippage) = { | |
285 | 256 | let diff = fraction((A1 - A2), scale8BigInt, A2) | |
286 | 257 | let pass = ((slippage - abs(diff)) > zeroBigInt) | |
287 | 258 | if (!(pass)) | |
288 | 259 | then throw(("Big slpg: " + toString(diff))) | |
289 | 260 | else $Tuple2(pass, min([A1, A2])) | |
290 | 261 | } | |
291 | 262 | ||
292 | 263 | ||
293 | 264 | func vd (D1,D0,slpg) = { | |
294 | 265 | let diff = fraction(D0, scale8BigInt, D1) | |
295 | 266 | let fail = (slpg > diff) | |
296 | 267 | if (if (fail) | |
297 | 268 | then true | |
298 | 269 | else (D0 > D1)) | |
299 | 270 | then throw(((((((toString(D0) + " ") + toString(D1)) + " ") + toString(diff)) + " ") + toString(slpg))) | |
300 | 271 | else fail | |
301 | 272 | } | |
302 | 273 | ||
303 | 274 | ||
304 | 275 | func pcp (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
305 | 276 | let amtAsAmtX18 = t1(amAmt, amAssetDcm) | |
306 | 277 | let prAsAmtX18 = t1(prAmt, prAssetDcm) | |
307 | 278 | cpbi(prAsAmtX18, amtAsAmtX18) | |
308 | 279 | } | |
309 | 280 | ||
310 | 281 | ||
311 | 282 | func calcPrices (amAmt,prAmt,lpAmt) = { | |
312 | - | let amtAsDcm = cfgAmountAssetDecimals | |
313 | - | let prAsDcm = cfgPriceAssetDecimals | |
283 | + | let cfg = gpc() | |
284 | + | let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
285 | + | let prAsDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
314 | 286 | let priceX18 = pcp(amtAsDcm, prAsDcm, amAmt, prAmt) | |
315 | 287 | let amAmtX18 = t1(amAmt, amtAsDcm) | |
316 | 288 | let prAmtX18 = t1(prAmt, prAsDcm) | |
317 | 289 | let lpAmtX18 = t1(lpAmt, scale8) | |
318 | 290 | let lpPrInAmAsX18 = cpbi(amAmtX18, lpAmtX18) | |
319 | 291 | let lpPrInPrAsX18 = cpbi(prAmtX18, lpAmtX18) | |
320 | 292 | [priceX18, lpPrInAmAsX18, lpPrInPrAsX18] | |
321 | 293 | } | |
322 | 294 | ||
323 | 295 | ||
324 | 296 | func calculatePrices (amAmt,prAmt,lpAmt) = { | |
325 | 297 | let p = calcPrices(amAmt, prAmt, lpAmt) | |
326 | 298 | [f1(p[0], scale8), f1(p[1], scale8), f1(p[2], scale8)] | |
327 | 299 | } | |
328 | 300 | ||
329 | 301 | ||
330 | 302 | func takeFee (amount,fee) = { | |
331 | 303 | let feeAmount = if ((fee == 0)) | |
332 | 304 | then 0 | |
333 | 305 | else fraction(amount, fee, scale8) | |
334 | 306 | $Tuple2((amount - feeAmount), feeAmount) | |
335 | 307 | } | |
336 | 308 | ||
337 | 309 | ||
338 | - | func getD (xp) = { | |
339 | - | let xp0 = xp[0] | |
340 | - | let xp1 = xp[1] | |
341 | - | let s = (xp0 + xp1) | |
342 | - | if ((s == big0)) | |
343 | - | then big0 | |
344 | - | else { | |
345 | - | let a = parseIntValue(A) | |
346 | - | let ann = (a * 2) | |
347 | - | let p = fraction(xp0, xp1, big1) | |
348 | - | let xp0_xp1_n_n = fraction(p, big4, big1) | |
349 | - | let ann_s = fraction(toBigInt(ann), s, big1) | |
350 | - | let ann_1 = toBigInt((ann - 1)) | |
351 | - | func calcDNext (d) = { | |
352 | - | let dd = fraction(d, d, big1) | |
353 | - | let ddd = fraction(dd, d, big1) | |
354 | - | let dp = fraction(ddd, big1, xp0_xp1_n_n) | |
355 | - | fraction((ann_s + fraction(dp, big2, big1)), d, (fraction(ann_1, d, big1) + fraction(big3, dp, big1))) | |
356 | - | } | |
357 | - | ||
358 | - | func calc (acc,i) = if (acc._2) | |
359 | - | then acc | |
360 | - | else { | |
361 | - | let d = acc._1 | |
362 | - | let dNext = calcDNext(d) | |
363 | - | let dDiffRaw = (dNext - value(d)) | |
364 | - | let dDiff = if ((big0 > dDiffRaw)) | |
365 | - | then -(dDiffRaw) | |
366 | - | else dDiffRaw | |
367 | - | if ((big1 >= dDiff)) | |
368 | - | then $Tuple2(dNext, true) | |
369 | - | else $Tuple2(dNext, false) | |
370 | - | } | |
371 | - | ||
372 | - | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
373 | - | let $t01269112739 = { | |
374 | - | let $l = arr | |
375 | - | let $s = size($l) | |
376 | - | let $acc0 = $Tuple2(s, false) | |
377 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
378 | - | then $a | |
379 | - | else calc($a, $l[$i]) | |
380 | - | ||
381 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
382 | - | then $a | |
383 | - | else throw("List size exceeds 15") | |
384 | - | ||
385 | - | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15) | |
386 | - | } | |
387 | - | let d = $t01269112739._1 | |
388 | - | let found = $t01269112739._2 | |
389 | - | if (found) | |
390 | - | then d | |
391 | - | else throw(("D calculation error, D = " + toString(d))) | |
392 | - | } | |
393 | - | } | |
394 | - | ||
395 | - | ||
396 | 310 | func ego (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
397 | - | let lpId = cfgLpAssetId | |
398 | - | let amId = toBase58String(value(cfgAmountAssetId)) | |
399 | - | let prId = toBase58String(value(cfgPriceAssetId)) | |
400 | - | let amDcm = cfgAmountAssetDecimals | |
401 | - | let prDcm = cfgPriceAssetDecimals | |
402 | - | let sts = toString(cfgPoolStatus) | |
403 | - | let lpEmiss = valueOrErrorMessage(assetInfo(lpId), "Wrong LP id").quantity | |
404 | - | if ((toBase58String(lpId) != pmtAssetId)) | |
311 | + | let cfg = gpc() | |
312 | + | let lpId = cfg[idxLPAsId] | |
313 | + | let amId = cfg[idxAmAsId] | |
314 | + | let prId = cfg[idxPrAsId] | |
315 | + | let amDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
316 | + | let prDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
317 | + | let sts = cfg[idxPoolSt] | |
318 | + | let lpEmiss = valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "Wrong LP id").quantity | |
319 | + | if ((lpId != pmtAssetId)) | |
405 | 320 | then throw("Wrong pmt asset") | |
406 | 321 | else { | |
407 | 322 | let amBalance = getAccBalance(amId) | |
408 | 323 | let amBalanceX18 = t1(amBalance, amDcm) | |
409 | 324 | let prBalance = getAccBalance(prId) | |
410 | 325 | let prBalanceX18 = t1(prBalance, prDcm) | |
411 | 326 | let curPriceX18 = cpbi(prBalanceX18, amBalanceX18) | |
412 | 327 | let curPrice = f1(curPriceX18, scale8) | |
413 | 328 | let pmtLpAmtX18 = t1(pmtLpAmt, scale8) | |
414 | 329 | let lpEmissX18 = t1(lpEmiss, scale8) | |
415 | 330 | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissX18) | |
416 | 331 | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissX18) | |
417 | - | let outAmAmt = | |
418 | - | let outPrAmt = | |
332 | + | let outAmAmt = f1(outAmAmtX18, amDcm) | |
333 | + | let outPrAmt = f1(outPrAmtX18, prDcm) | |
419 | 334 | let state = if ((txId58 == "")) | |
420 | 335 | then nil | |
421 | 336 | else [ScriptTransfer(userAddress, outAmAmt, if ((amId == "WAVES")) | |
422 | 337 | then unit | |
423 | 338 | else fromBase58String(amId)), ScriptTransfer(userAddress, outPrAmt, if ((prId == "WAVES")) | |
424 | 339 | then unit | |
425 | 340 | else fromBase58String(prId)), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAmAmt, outPrAmt, pmtLpAmt, curPrice, height, lastBlock.timestamp)), IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice)] | |
426 | 341 | $Tuple10(outAmAmt, outPrAmt, amId, prId, amBalance, prBalance, lpEmiss, curPriceX18, sts, state) | |
427 | 342 | } | |
428 | 343 | } | |
429 | 344 | ||
430 | 345 | ||
431 | 346 | func epo (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,userAddress,isEval,emitLp,isOneAsset,validateSlippage,pmtAmt,pmtId) = { | |
432 | - | let lpId = cfgLpAssetId | |
433 | - | let amIdStr = toBase58String(value(cfgAmountAssetId)) | |
434 | - | let prIdStr = toBase58String(value(cfgPriceAssetId)) | |
435 | - | let inAmIdStr = cfgInAmountAssedId | |
436 | - | let inPrIdStr = cfgInPriceAssetId | |
437 | - | let amtDcm = cfgAmountAssetDecimals | |
438 | - | let priceDcm = cfgPriceAssetDecimals | |
439 | - | let sts = toString(cfgPoolStatus) | |
347 | + | let cfg = gpc() | |
348 | + | let lpId = fromBase58String(cfg[idxLPAsId]) | |
349 | + | let amIdStr = cfg[idxAmAsId] | |
350 | + | let prIdStr = cfg[idxPrAsId] | |
351 | + | let inAmIdStr = cfg[idxIAmtAsId] | |
352 | + | let inPrIdStr = cfg[idxIPriceAsId] | |
353 | + | let amtDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
354 | + | let priceDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
355 | + | let sts = cfg[idxPoolSt] | |
440 | 356 | let lpEm = valueOrErrorMessage(assetInfo(lpId), "Wr lp as").quantity | |
441 | 357 | let amBalance = if (isEval) | |
442 | 358 | then getAccBalance(amIdStr) | |
443 | 359 | else if (if (isOneAsset) | |
444 | 360 | then (pmtId == amIdStr) | |
445 | 361 | else false) | |
446 | 362 | then (getAccBalance(amIdStr) - pmtAmt) | |
447 | 363 | else if (isOneAsset) | |
448 | 364 | then getAccBalance(amIdStr) | |
449 | 365 | else (getAccBalance(amIdStr) - inAmAmt) | |
450 | 366 | let prBalance = if (isEval) | |
451 | 367 | then getAccBalance(prIdStr) | |
452 | 368 | else if (if (isOneAsset) | |
453 | 369 | then (pmtId == prIdStr) | |
454 | 370 | else false) | |
455 | 371 | then (getAccBalance(prIdStr) - pmtAmt) | |
456 | 372 | else if (isOneAsset) | |
457 | 373 | then getAccBalance(prIdStr) | |
458 | 374 | else (getAccBalance(prIdStr) - inPrAmt) | |
459 | 375 | let inAmAssetAmtX18 = t1(inAmAmt, amtDcm) | |
460 | 376 | let inPrAssetAmtX18 = t1(inPrAmt, priceDcm) | |
461 | 377 | let userPriceX18 = cpbi(inPrAssetAmtX18, inAmAssetAmtX18) | |
462 | 378 | let amBalanceX18 = t1(amBalance, amtDcm) | |
463 | 379 | let prBalanceX18 = t1(prBalance, priceDcm) | |
464 | - | let D0 = getD([amBalanceX18, prBalanceX18]) | |
465 | 380 | let r = if ((lpEm == 0)) | |
466 | 381 | then { | |
467 | - | let D1 = getD([(amBalanceX18 + inAmAssetAmtX18), (prBalanceX18 + inPrAssetAmtX18)]) | |
468 | - | let checkD = if ((D1 > D0)) | |
469 | - | then true | |
470 | - | else throw("D1 should be greater than D0") | |
471 | - | if ((checkD == checkD)) | |
472 | - | then { | |
473 | - | let curPriceX18 = zeroBigInt | |
474 | - | let slippageX18 = zeroBigInt | |
475 | - | let lpAmtX18 = D1 | |
476 | - | $Tuple5(f1(lpAmtX18, scale8), f1(inAmAssetAmtX18, amtDcm), f1(inPrAssetAmtX18, priceDcm), cpbi((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
477 | - | } | |
478 | - | else throw("Strict value is not equal to itself.") | |
382 | + | let curPriceX18 = zeroBigInt | |
383 | + | let slippageX18 = zeroBigInt | |
384 | + | let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN) | |
385 | + | $Tuple5(f1(lpAmtX18, scale8), f1(inAmAssetAmtX18, amtDcm), f1(inPrAssetAmtX18, priceDcm), cpbi((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
479 | 386 | } | |
480 | 387 | else { | |
481 | 388 | let curPriceX18 = cpbi(prBalanceX18, amBalanceX18) | |
482 | 389 | let slippageRealX18 = fraction(abs((curPriceX18 - userPriceX18)), scale18, curPriceX18) | |
483 | 390 | let slippageX18 = t1(slippage, scale8) | |
484 | 391 | if (if (if (validateSlippage) | |
485 | 392 | then (curPriceX18 != zeroBigInt) | |
486 | 393 | else false) | |
487 | 394 | then (slippageRealX18 > slippageX18) | |
488 | 395 | else false) | |
489 | 396 | then throw(((("Price slippage " + toString(slippageRealX18)) + " > ") + toString(slippageX18))) | |
490 | 397 | else { | |
491 | 398 | let lpEmissionX18 = t1(lpEm, scale8) | |
492 | - | let prViaAmX18 = fraction(inAmAssetAmtX18, | |
493 | - | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, | |
399 | + | let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
400 | + | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
494 | 401 | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
495 | 402 | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
496 | 403 | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
497 | 404 | let expAmtAssetAmtX18 = expectedAmts._1 | |
498 | 405 | let expPriceAssetAmtX18 = expectedAmts._2 | |
499 | - | let D1 = getD([(amBalanceX18 + expAmtAssetAmtX18), (prBalanceX18 + expPriceAssetAmtX18)]) | |
500 | - | let checkD = if ((D1 > D0)) | |
501 | - | then true | |
502 | - | else throw("D1 should be greater than D0") | |
503 | - | if ((checkD == checkD)) | |
504 | - | then { | |
505 | - | let lpAmtX18 = fraction(lpEmissionX18, (D1 - D0), D0) | |
506 | - | $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceDcm, CEILING), curPriceX18, slippageX18) | |
507 | - | } | |
508 | - | else throw("Strict value is not equal to itself.") | |
406 | + | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18) | |
407 | + | $Tuple5(f1(lpAmtX18, scale8), f1(expAmtAssetAmtX18, amtDcm), f1(expPriceAssetAmtX18, priceDcm), curPriceX18, slippageX18) | |
509 | 408 | } | |
510 | 409 | } | |
511 | 410 | let calcLpAmt = r._1 | |
512 | 411 | let calcAmAssetPmt = r._2 | |
513 | 412 | let calcPrAssetPmt = r._3 | |
514 | 413 | let curPrice = f1(r._4, scale8) | |
515 | 414 | let slippageCalc = f1(r._5, scale8) | |
516 | 415 | if ((0 >= calcLpAmt)) | |
517 | 416 | then throw("LP <= 0") | |
518 | 417 | else { | |
519 | 418 | let emitLpAmt = if (!(emitLp)) | |
520 | 419 | then 0 | |
521 | 420 | else calcLpAmt | |
522 | 421 | let amDiff = (inAmAmt - calcAmAssetPmt) | |
523 | 422 | let prDiff = (inPrAmt - calcPrAssetPmt) | |
524 | - | let $ | |
423 | + | let $t01760517950 = if (if (isOneAsset) | |
525 | 424 | then (pmtId == amIdStr) | |
526 | 425 | else false) | |
527 | 426 | then $Tuple2(pmtAmt, 0) | |
528 | 427 | else if (if (isOneAsset) | |
529 | 428 | then (pmtId == prIdStr) | |
530 | 429 | else false) | |
531 | 430 | then $Tuple2(0, pmtAmt) | |
532 | 431 | else $Tuple2(calcAmAssetPmt, calcPrAssetPmt) | |
533 | - | let writeAmAmt = $ | |
534 | - | let writePrAmt = $ | |
432 | + | let writeAmAmt = $t01760517950._1 | |
433 | + | let writePrAmt = $t01760517950._2 | |
535 | 434 | let commonState = [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(userAddress, txId58), dataPutActionInfo(writeAmAmt, writePrAmt, emitLpAmt, curPrice, slippage, slippageCalc, height, lastBlock.timestamp, amDiff, prDiff))] | |
536 | 435 | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEm, lpId, sts, commonState, amDiff, prDiff, inAmId, inPrId) | |
537 | 436 | } | |
538 | 437 | } | |
539 | 438 | ||
540 | 439 | ||
541 | - | func getYD (xp,i,D) = { | |
542 | - | let n = big2 | |
543 | - | let x = xp[if ((i == 0)) | |
544 | - | then 1 | |
545 | - | else 0] | |
546 | - | let aPrecision = parseBigIntValue(Amult) | |
547 | - | let a = (parseBigIntValue(A) * aPrecision) | |
548 | - | let s = x | |
549 | - | let ann = (a * n) | |
550 | - | let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n)) | |
551 | - | let b = ((s + ((D * aPrecision) / ann)) - D) | |
552 | - | func calc (acc,cur) = { | |
553 | - | let $t02211822138 = acc | |
554 | - | let y = $t02211822138._1 | |
555 | - | let found = $t02211822138._2 | |
556 | - | if ((found != unit)) | |
557 | - | then acc | |
558 | - | else { | |
559 | - | let yNext = (((y * y) + c) / ((big2 * y) + b)) | |
560 | - | let yDiff = absBigInt((yNext - value(y))) | |
561 | - | if ((big1 >= yDiff)) | |
562 | - | then $Tuple2(yNext, cur) | |
563 | - | else $Tuple2(yNext, unit) | |
564 | - | } | |
565 | - | } | |
566 | - | ||
567 | - | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
568 | - | let $t02244522492 = { | |
569 | - | let $l = arr | |
570 | - | let $s = size($l) | |
571 | - | let $acc0 = $Tuple2(D, unit) | |
572 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
573 | - | then $a | |
574 | - | else calc($a, $l[$i]) | |
575 | - | ||
576 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
577 | - | then $a | |
578 | - | else throw("List size exceeds 15") | |
579 | - | ||
580 | - | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15) | |
581 | - | } | |
582 | - | let y = $t02244522492._1 | |
583 | - | let found = $t02244522492._2 | |
584 | - | if ((found != unit)) | |
585 | - | then y | |
586 | - | else throw(("Y calculation error, Y = " + toString(y))) | |
587 | - | } | |
588 | - | ||
589 | - | ||
590 | - | func calcDLp (amountBalance,priceBalance,lpEmission) = { | |
591 | - | let updatedDLp = fraction(getD([t1BigInt(amountBalance, toBigInt(cfgAmountAssetDecimals)), t1BigInt(priceBalance, toBigInt(cfgPriceAssetDecimals))]), scale18, lpEmission) | |
592 | - | if ((lpEmission == big0)) | |
593 | - | then big0 | |
594 | - | else updatedDLp | |
595 | - | } | |
596 | - | ||
597 | - | ||
598 | - | func calcCurrentDLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = { | |
599 | - | let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta) | |
600 | - | let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta) | |
601 | - | let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta) | |
602 | - | let currentDLp = calcDLp(amountAssetBalance, priceAssetBalance, lpAssetEmission) | |
603 | - | currentDLp | |
604 | - | } | |
605 | - | ||
606 | - | ||
607 | - | func refreshDLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
608 | - | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
609 | - | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
610 | - | let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta) | |
611 | - | let updatedDLp = calcDLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
612 | - | let actions = [IntegerEntry(keyDLpRefreshedHeight, height), StringEntry(keyDLp, toString(updatedDLp))] | |
613 | - | $Tuple2(actions, updatedDLp) | |
614 | - | } | |
615 | - | ||
616 | - | ||
617 | - | func validateUpdatedDLp (oldDLp,updatedDLp) = if ((updatedDLp >= oldDLp)) | |
618 | - | then true | |
619 | - | else throwErr("updated DLp lower than current DLp") | |
620 | - | ||
621 | - | ||
622 | - | func validateMatcherOrderAllowed (order) = { | |
623 | - | let amountAssetBalance = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
624 | - | let priceAssetBalance = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
625 | - | let amountAssetAmount = order.amount | |
626 | - | let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR) | |
627 | - | let $t02469024902 = if ((order.orderType == Buy)) | |
628 | - | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
629 | - | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
630 | - | let amountAssetBalanceDelta = $t02469024902._1 | |
631 | - | let priceAssetBalanceDelta = $t02469024902._2 | |
440 | + | func moa (order) = { | |
441 | + | let cfg = gpc() | |
442 | + | let amtAsId = cfg[idxAmAsId] | |
443 | + | let prAsId = cfg[idxPrAsId] | |
444 | + | let sts = parseIntValue(cfg[idxPoolSt]) | |
445 | + | let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
446 | + | let prAsDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
447 | + | let accAmtAsBalance = getAccBalance(amtAsId) | |
448 | + | let accPrAsBalance = getAccBalance(prAsId) | |
449 | + | let curPriceX18 = if ((order.orderType == Buy)) | |
450 | + | then pcp(amtAsDcm, prAsDcm, (accAmtAsBalance + order.amount), accPrAsBalance) | |
451 | + | else pcp(amtAsDcm, prAsDcm, (accAmtAsBalance - order.amount), accPrAsBalance) | |
452 | + | let curPrice = f1(curPriceX18, scale8) | |
632 | 453 | if (if (if (igs()) | |
633 | 454 | then true | |
634 | - | else ( | |
455 | + | else (sts == PoolMatcherDis)) | |
635 | 456 | then true | |
636 | - | else ( | |
457 | + | else (sts == PoolShutdown)) | |
637 | 458 | then throw("Admin blocked") | |
638 | - | else if (if ((order.assetPair.amountAsset != cfgAmountAssetId)) | |
639 | - | then true | |
640 | - | else (order.assetPair.priceAsset != cfgPriceAssetId)) | |
641 | - | then throw("Wr assets") | |
642 | - | else { | |
643 | - | let dLp = parseBigIntValue(valueOrElse(getString(this, keyDLp), "0")) | |
644 | - | let $t02524425344 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
645 | - | let unusedActions = $t02524425344._1 | |
646 | - | let dLpNew = $t02524425344._2 | |
647 | - | let isOrderValid = (dLpNew >= dLp) | |
648 | - | let info = makeString(["dLp=", toString(dLp), " dLpNew=", toString(dLpNew), " amountAssetBalance=", toString(amountAssetBalance), " priceAssetBalance=", toString(priceAssetBalance), " amountAssetBalanceDelta=", toString(amountAssetBalanceDelta), " priceAssetBalanceDelta=", toString(priceAssetBalanceDelta)], "") | |
649 | - | $Tuple2(isOrderValid, info) | |
650 | - | } | |
459 | + | else { | |
460 | + | let orAmtAsset = order.assetPair.amountAsset | |
461 | + | let orAmtAsStr = if ((orAmtAsset == unit)) | |
462 | + | then "WAVES" | |
463 | + | else toBase58String(value(orAmtAsset)) | |
464 | + | let orPrAsset = order.assetPair.priceAsset | |
465 | + | let orPrAsStr = if ((orPrAsset == unit)) | |
466 | + | then "WAVES" | |
467 | + | else toBase58String(value(orPrAsset)) | |
468 | + | if (if ((orAmtAsStr != amtAsId)) | |
469 | + | then true | |
470 | + | else (orPrAsStr != prAsId)) | |
471 | + | then throw("Wr assets") | |
472 | + | else { | |
473 | + | let orderPrice = order.price | |
474 | + | let priceDcm = fraction(scale8, prAsDcm, amtAsDcm) | |
475 | + | let castOrderPrice = ts(orderPrice, scale8, priceDcm) | |
476 | + | let isOrderPriceValid = if ((order.orderType == Buy)) | |
477 | + | then (curPrice >= castOrderPrice) | |
478 | + | else (castOrderPrice >= curPrice) | |
479 | + | true | |
480 | + | } | |
481 | + | } | |
651 | 482 | } | |
652 | 483 | ||
653 | 484 | ||
654 | 485 | func cg (i) = if ((size(i.payments) != 1)) | |
655 | 486 | then throw("1 pmnt exp") | |
656 | 487 | else { | |
657 | 488 | let pmt = value(i.payments[0]) | |
658 | 489 | let pmtAssetId = value(pmt.assetId) | |
659 | 490 | let pmtAmt = pmt.amount | |
660 | 491 | let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
661 | 492 | let outAmAmt = r._1 | |
662 | 493 | let outPrAmt = r._2 | |
663 | 494 | let sts = parseIntValue(r._9) | |
664 | 495 | let state = r._10 | |
665 | 496 | if (if (igs()) | |
666 | 497 | then true | |
667 | 498 | else (sts == PoolShutdown)) | |
668 | 499 | then throw(("Admin blocked: " + toString(sts))) | |
669 | 500 | else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state) | |
670 | 501 | } | |
671 | 502 | ||
672 | 503 | ||
673 | 504 | func cp (caller,txId,amAsPmt,prAsPmt,slippage,emitLp,isOneAsset,validateSlippage,pmtAmt,pmtId) = { | |
674 | 505 | let r = epo(txId, slippage, value(amAsPmt).amount, value(amAsPmt).assetId, value(prAsPmt).amount, value(prAsPmt).assetId, caller, (txId == ""), emitLp, isOneAsset, validateSlippage, pmtAmt, pmtId) | |
675 | 506 | let sts = parseIntValue(r._8) | |
676 | 507 | if (if (if (igs()) | |
677 | 508 | then true | |
678 | 509 | else (sts == PoolPutDis)) | |
679 | 510 | then true | |
680 | 511 | else (sts == PoolShutdown)) | |
681 | 512 | then throw(("Blocked:" + toString(sts))) | |
682 | 513 | else r | |
683 | 514 | } | |
684 | 515 | ||
685 | 516 | ||
517 | + | func getD (xp) = { | |
518 | + | let n = big2 | |
519 | + | let xp0 = xp[0] | |
520 | + | let xp1 = xp[1] | |
521 | + | let aPrecision = parseBigIntValue(Amult) | |
522 | + | let a = (parseBigIntValue(A) * aPrecision) | |
523 | + | let s = (xp0 + xp1) | |
524 | + | if ((s == big0)) | |
525 | + | then big0 | |
526 | + | else { | |
527 | + | let ann = (a * n) | |
528 | + | let xp0_xp1_n_n = (((xp0 * xp1) * n) * n) | |
529 | + | let ann_s_aPrecision = ((ann * s) / aPrecision) | |
530 | + | let ann_aPrecision = (ann - aPrecision) | |
531 | + | let n1 = (n + big1) | |
532 | + | func calc (acc,cur) = { | |
533 | + | let $t02250222522 = acc | |
534 | + | let d = $t02250222522._1 | |
535 | + | let found = $t02250222522._2 | |
536 | + | if ((found != unit)) | |
537 | + | then acc | |
538 | + | else { | |
539 | + | let dp = (((d * d) * d) / xp0_xp1_n_n) | |
540 | + | let dNext = (((ann_s_aPrecision + (dp * n)) * d) / (((ann_aPrecision * d) / aPrecision) + (n1 * dp))) | |
541 | + | let dDiff = absBigInt((dNext - value(d))) | |
542 | + | if ((big1 >= dDiff)) | |
543 | + | then $Tuple2(dNext, cur) | |
544 | + | else $Tuple2(dNext, unit) | |
545 | + | } | |
546 | + | } | |
547 | + | ||
548 | + | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
549 | + | let $t02294322990 = { | |
550 | + | let $l = arr | |
551 | + | let $s = size($l) | |
552 | + | let $acc0 = $Tuple2(s, unit) | |
553 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
554 | + | then $a | |
555 | + | else calc($a, $l[$i]) | |
556 | + | ||
557 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
558 | + | then $a | |
559 | + | else throw("List size exceeds 15") | |
560 | + | ||
561 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15) | |
562 | + | } | |
563 | + | let d = $t02294322990._1 | |
564 | + | let found = $t02294322990._2 | |
565 | + | if ((found != unit)) | |
566 | + | then d | |
567 | + | else throw(("D calculation error, D = " + toString(d))) | |
568 | + | } | |
569 | + | } | |
570 | + | ||
571 | + | ||
572 | + | func getYD (xp,i,D) = { | |
573 | + | let n = big2 | |
574 | + | let x = xp[if ((i == 0)) | |
575 | + | then 1 | |
576 | + | else 0] | |
577 | + | let aPrecision = parseBigIntValue(Amult) | |
578 | + | let a = (parseBigIntValue(A) * aPrecision) | |
579 | + | let s = x | |
580 | + | let ann = (a * n) | |
581 | + | let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n)) | |
582 | + | let b = ((s + ((D * aPrecision) / ann)) - D) | |
583 | + | func calc (acc,cur) = { | |
584 | + | let $t02349023510 = acc | |
585 | + | let y = $t02349023510._1 | |
586 | + | let found = $t02349023510._2 | |
587 | + | if ((found != unit)) | |
588 | + | then acc | |
589 | + | else { | |
590 | + | let yNext = (((y * y) + c) / ((big2 * y) + b)) | |
591 | + | let yDiff = absBigInt((yNext - value(y))) | |
592 | + | if ((big1 >= yDiff)) | |
593 | + | then $Tuple2(yNext, cur) | |
594 | + | else $Tuple2(yNext, unit) | |
595 | + | } | |
596 | + | } | |
597 | + | ||
598 | + | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
599 | + | let $t02381723864 = { | |
600 | + | let $l = arr | |
601 | + | let $s = size($l) | |
602 | + | let $acc0 = $Tuple2(D, unit) | |
603 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
604 | + | then $a | |
605 | + | else calc($a, $l[$i]) | |
606 | + | ||
607 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
608 | + | then $a | |
609 | + | else throw("List size exceeds 15") | |
610 | + | ||
611 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15) | |
612 | + | } | |
613 | + | let y = $t02381723864._1 | |
614 | + | let found = $t02381723864._2 | |
615 | + | if ((found != unit)) | |
616 | + | then y | |
617 | + | else throw(("Y calculation error, Y = " + toString(y))) | |
618 | + | } | |
619 | + | ||
620 | + | ||
686 | 621 | func calcPutOneTkn (pmtAmtRaw,pmtAssetId,userAddress,txId,withTakeFee) = { | |
687 | - | let amId = toBase58String(value(cfgAmountAssetId)) | |
688 | - | let prId = toBase58String(value(cfgPriceAssetId)) | |
689 | - | let lpId = cfgLpAssetId | |
690 | - | let amtDcm = cfgAmountAssetDecimals | |
691 | - | let priceDcm = cfgPriceAssetDecimals | |
692 | - | let lpAssetEmission = toBigInt(valueOrErrorMessage(assetInfo(lpId), "invalid lp asset").quantity) | |
622 | + | let poolConfig = gpc() | |
623 | + | let amId = poolConfig[idxAmAsId] | |
624 | + | let prId = poolConfig[idxPrAsId] | |
625 | + | let lpId = poolConfig[idxLPAsId] | |
626 | + | let amtDcm = parseIntValue(poolConfig[idxAmtAsDcm]) | |
627 | + | let priceDcm = parseIntValue(poolConfig[idxPriceAsDcm]) | |
628 | + | let lpAssetEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity) | |
693 | 629 | let chechEmission = if ((lpAssetEmission > big0)) | |
694 | 630 | then true | |
695 | 631 | else throw("initial deposit requires all coins") | |
696 | 632 | if ((chechEmission == chechEmission)) | |
697 | 633 | then { | |
698 | 634 | let amBalance = getAccBalance(amId) | |
699 | 635 | let prBalance = getAccBalance(prId) | |
700 | - | let $ | |
636 | + | let $t02464725109 = if ((txId == "")) | |
701 | 637 | then $Tuple2(amBalance, prBalance) | |
702 | 638 | else if ((pmtAssetId == amId)) | |
703 | 639 | then if ((pmtAmtRaw > amBalance)) | |
704 | 640 | then throw("invalid payment amount") | |
705 | 641 | else $Tuple2((amBalance - pmtAmtRaw), prBalance) | |
706 | 642 | else if ((pmtAssetId == prId)) | |
707 | 643 | then if ((pmtAmtRaw > prBalance)) | |
708 | 644 | then throw("invalid payment amount") | |
709 | 645 | else $Tuple2(amBalance, (prBalance - pmtAmtRaw)) | |
710 | 646 | else throw("wrong pmtAssetId") | |
711 | - | let amBalanceOld = $ | |
712 | - | let prBalanceOld = $ | |
713 | - | let $ | |
647 | + | let amBalanceOld = $t02464725109._1 | |
648 | + | let prBalanceOld = $t02464725109._2 | |
649 | + | let $t02511525291 = if ((pmtAssetId == amId)) | |
714 | 650 | then $Tuple2(pmtAmtRaw, 0) | |
715 | 651 | else if ((pmtAssetId == prId)) | |
716 | 652 | then $Tuple2(0, pmtAmtRaw) | |
717 | 653 | else throw("invalid payment") | |
718 | - | let amAmountRaw = $ | |
719 | - | let prAmountRaw = $ | |
720 | - | let $ | |
654 | + | let amAmountRaw = $t02511525291._1 | |
655 | + | let prAmountRaw = $t02511525291._2 | |
656 | + | let $t02529525549 = if (withTakeFee) | |
721 | 657 | then $Tuple3(takeFee(amAmountRaw, inFee)._1, takeFee(prAmountRaw, inFee)._1, takeFee(pmtAmtRaw, inFee)._2) | |
722 | 658 | else $Tuple3(amAmountRaw, prAmountRaw, 0) | |
723 | - | let amAmount = $ | |
724 | - | let prAmount = $ | |
725 | - | let feeAmount = $ | |
659 | + | let amAmount = $t02529525549._1 | |
660 | + | let prAmount = $t02529525549._2 | |
661 | + | let feeAmount = $t02529525549._3 | |
726 | 662 | let amBalanceNew = (amBalanceOld + amAmount) | |
727 | 663 | let prBalanceNew = (prBalanceOld + prAmount) | |
728 | - | let D0 = getD([ | |
729 | - | let D1 = getD([ | |
664 | + | let D0 = getD([toBigInt(amBalanceOld), toBigInt(prBalanceOld)]) | |
665 | + | let D1 = getD([toBigInt(amBalanceNew), toBigInt(prBalanceNew)]) | |
730 | 666 | let checkD = if ((D1 > D0)) | |
731 | 667 | then true | |
732 | 668 | else throw() | |
733 | 669 | if ((checkD == checkD)) | |
734 | 670 | then { | |
735 | - | let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0 | |
671 | + | let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0) | |
736 | 672 | let curPrice = f1(cpbi(t1(prBalanceNew, priceDcm), t1(amBalanceNew, amtDcm)), scale8) | |
737 | 673 | let commonState = [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(userAddress, txId), dataPutActionInfo(amAmountRaw, prAmountRaw, toInt(lpAmount), curPrice, 0, 0, height, lastBlock.timestamp, 0, 0))] | |
738 | 674 | let poolProportion = fraction(prBalanceOld, scale8, amBalanceOld) | |
739 | 675 | let amountAssetPart = fraction(pmtAmtRaw, scale8, (poolProportion + scale8)) | |
740 | 676 | let priceAssetPart = (pmtAmtRaw - amountAssetPart) | |
741 | 677 | let lpAmtBoth = fraction(lpAssetEmission, toBigInt(priceAssetPart), toBigInt(prBalanceOld)) | |
742 | 678 | let bonus = toInt(fraction((lpAmount - lpAmtBoth), scale8BigInt, lpAmtBoth)) | |
743 | 679 | $Tuple4(toInt(lpAmount), commonState, feeAmount, bonus) | |
744 | 680 | } | |
745 | 681 | else throw("Strict value is not equal to itself.") | |
746 | 682 | } | |
747 | 683 | else throw("Strict value is not equal to itself.") | |
748 | 684 | } | |
749 | 685 | ||
750 | 686 | ||
751 | 687 | func getOneTknV2Internal (outAssetId,minOutAmount,payments,caller,originCaller,transactionId) = { | |
752 | - | let lpId = toBase58String(value(cfgLpAssetId)) | |
753 | - | let amId = toBase58String(value(cfgAmountAssetId)) | |
754 | - | let prId = toBase58String(value(cfgPriceAssetId)) | |
755 | - | let amDecimals = cfgAmountAssetDecimals | |
756 | - | let prDecimals = cfgPriceAssetDecimals | |
757 | - | let poolStatus = cfgPoolStatus | |
688 | + | let poolConfig = gpc() | |
689 | + | let lpId = poolConfig[idxLPAsId] | |
690 | + | let amId = poolConfig[idxAmAsId] | |
691 | + | let prId = poolConfig[idxPrAsId] | |
692 | + | let amDecimals = parseIntValue(poolConfig[idxAmtAsDcm]) | |
693 | + | let prDecimals = parseIntValue(poolConfig[idxPriceAsDcm]) | |
694 | + | let poolStatus = poolConfig[idxPoolSt] | |
758 | 695 | let userAddress = if ((caller == restContract)) | |
759 | 696 | then originCaller | |
760 | 697 | else caller | |
761 | 698 | let pmt = value(payments[0]) | |
762 | 699 | let pmtAssetId = value(pmt.assetId) | |
763 | 700 | let pmtAmt = pmt.amount | |
764 | - | let currentDLp = calcCurrentDLp(big0, big0, big0) | |
765 | - | if ((currentDLp == currentDLp)) | |
766 | - | then { | |
767 | - | let txId58 = toBase58String(transactionId) | |
768 | - | if ((lpId != toBase58String(pmtAssetId))) | |
769 | - | then throw("Wrong LP") | |
770 | - | else { | |
771 | - | let amBalance = getAccBalance(amId) | |
772 | - | let prBalance = getAccBalance(prId) | |
773 | - | let $t03097931090 = { | |
774 | - | let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil) | |
775 | - | if ($isInstanceOf(@, "(Int, Int)")) | |
776 | - | then @ | |
777 | - | else throw(($getType(@) + " couldn't be cast to (Int, Int)")) | |
778 | - | } | |
779 | - | if (($t03097931090 == $t03097931090)) | |
701 | + | let txId58 = toBase58String(transactionId) | |
702 | + | if ((lpId != toBase58String(pmtAssetId))) | |
703 | + | then throw("Wrong LP") | |
704 | + | else { | |
705 | + | let amBalance = getAccBalance(amId) | |
706 | + | let prBalance = getAccBalance(prId) | |
707 | + | let $t02755127662 = { | |
708 | + | let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil) | |
709 | + | if ($isInstanceOf(@, "(Int, Int)")) | |
710 | + | then @ | |
711 | + | else throw(($getType(@) + " couldn't be cast to (Int, Int)")) | |
712 | + | } | |
713 | + | if (($t02755127662 == $t02755127662)) | |
714 | + | then { | |
715 | + | let feeAmount = $t02755127662._2 | |
716 | + | let totalGet = $t02755127662._1 | |
717 | + | let totalAmount = if (if ((minOutAmount > 0)) | |
718 | + | then (minOutAmount > totalGet) | |
719 | + | else false) | |
720 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
721 | + | else totalGet | |
722 | + | let $t02785228159 = if ((outAssetId == amId)) | |
723 | + | then $Tuple4(totalAmount, 0, ((amBalance - totalAmount) - feeAmount), prBalance) | |
724 | + | else if ((outAssetId == prId)) | |
725 | + | then $Tuple4(0, totalAmount, amBalance, ((prBalance - totalAmount) - feeAmount)) | |
726 | + | else throw("invalid out asset id") | |
727 | + | let outAm = $t02785228159._1 | |
728 | + | let outPr = $t02785228159._2 | |
729 | + | let amBalanceNew = $t02785228159._3 | |
730 | + | let prBalanceNew = $t02785228159._4 | |
731 | + | let curPrX18 = cpbi(t1(prBalanceNew, prDecimals), t1(amBalanceNew, amDecimals)) | |
732 | + | let curPr = f1(curPrX18, scale8) | |
733 | + | let outAssetIdOrWaves = if ((outAssetId == "WAVES")) | |
734 | + | then unit | |
735 | + | else fromBase58String(outAssetId) | |
736 | + | let sendFeeToMatcher = if ((feeAmount > 0)) | |
737 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)] | |
738 | + | else nil | |
739 | + | let state = ([ScriptTransfer(userAddress, totalAmount, outAssetIdOrWaves), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, pmtAmt, curPr, height, lastBlock.timestamp)), IntegerEntry(pl(), curPr), IntegerEntry(ph(height, lastBlock.timestamp), curPr)] ++ sendFeeToMatcher) | |
740 | + | if ((state == state)) | |
780 | 741 | then { | |
781 | - | let feeAmount = $t03097931090._2 | |
782 | - | let totalGet = $t03097931090._1 | |
783 | - | let totalAmount = if (if ((minOutAmount > 0)) | |
784 | - | then (minOutAmount > totalGet) | |
785 | - | else false) | |
786 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
787 | - | else totalGet | |
788 | - | let $t03128031587 = if ((outAssetId == amId)) | |
789 | - | then $Tuple4(totalAmount, 0, ((amBalance - totalAmount) - feeAmount), prBalance) | |
790 | - | else if ((outAssetId == prId)) | |
791 | - | then $Tuple4(0, totalAmount, amBalance, ((prBalance - totalAmount) - feeAmount)) | |
792 | - | else throw("invalid out asset id") | |
793 | - | let outAm = $t03128031587._1 | |
794 | - | let outPr = $t03128031587._2 | |
795 | - | let amBalanceNew = $t03128031587._3 | |
796 | - | let prBalanceNew = $t03128031587._4 | |
797 | - | let curPrX18 = cpbi(t1(prBalanceNew, prDecimals), t1(amBalanceNew, amDecimals)) | |
798 | - | let curPr = f1(curPrX18, scale8) | |
799 | - | let outAssetIdOrWaves = if ((outAssetId == "WAVES")) | |
800 | - | then unit | |
801 | - | else fromBase58String(outAssetId) | |
802 | - | let sendFeeToMatcher = if ((feeAmount > 0)) | |
803 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)] | |
804 | - | else nil | |
805 | - | let state = ([ScriptTransfer(userAddress, totalAmount, outAssetIdOrWaves), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, pmtAmt, curPr, height, lastBlock.timestamp)), IntegerEntry(pl(), curPr), IntegerEntry(ph(height, lastBlock.timestamp), curPr)] ++ sendFeeToMatcher) | |
806 | - | if ((state == state)) | |
807 | - | then { | |
808 | - | let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
809 | - | if ((burn == burn)) | |
810 | - | then { | |
811 | - | let $t03237232722 = { | |
812 | - | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
813 | - | then 0 | |
814 | - | else feeAmount | |
815 | - | let outInAmountAsset = if ((parseAssetId(outAssetId) == cfgAmountAssetId)) | |
816 | - | then true | |
817 | - | else false | |
818 | - | if (outInAmountAsset) | |
819 | - | then $Tuple2(-((totalGet + feeAmountForCalc)), 0) | |
820 | - | else $Tuple2(0, -((totalGet + feeAmountForCalc))) | |
821 | - | } | |
822 | - | let amountAssetBalanceDelta = $t03237232722._1 | |
823 | - | let priceAssetBalanceDelta = $t03237232722._2 | |
824 | - | let $t03272532833 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
825 | - | let refreshDLpActions = $t03272532833._1 | |
826 | - | let updatedDLp = $t03272532833._2 | |
827 | - | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
828 | - | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
829 | - | then $Tuple2((state ++ refreshDLpActions), totalAmount) | |
830 | - | else throw("Strict value is not equal to itself.") | |
831 | - | } | |
832 | - | else throw("Strict value is not equal to itself.") | |
833 | - | } | |
742 | + | let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
743 | + | if ((burn == burn)) | |
744 | + | then $Tuple2(state, totalAmount) | |
834 | 745 | else throw("Strict value is not equal to itself.") | |
835 | 746 | } | |
836 | 747 | else throw("Strict value is not equal to itself.") | |
837 | 748 | } | |
749 | + | else throw("Strict value is not equal to itself.") | |
838 | 750 | } | |
839 | - | else throw("Strict value is not equal to itself.") | |
840 | 751 | } | |
841 | 752 | ||
842 | 753 | ||
843 | 754 | func m () = match getString(mpk()) { | |
844 | 755 | case s: String => | |
845 | 756 | fromBase58String(s) | |
846 | 757 | case _: Unit => | |
847 | 758 | unit | |
848 | 759 | case _ => | |
849 | 760 | throw("Match error") | |
850 | 761 | } | |
851 | 762 | ||
852 | 763 | ||
853 | 764 | func pm () = match getString(pmpk()) { | |
854 | 765 | case s: String => | |
855 | 766 | fromBase58String(s) | |
856 | 767 | case _: Unit => | |
857 | 768 | unit | |
858 | 769 | case _ => | |
859 | 770 | throw("Match error") | |
860 | 771 | } | |
861 | 772 | ||
862 | 773 | ||
863 | 774 | let pd = throw("Permission denied") | |
864 | 775 | ||
865 | 776 | func isManager (i) = match m() { | |
866 | 777 | case pk: ByteVector => | |
867 | 778 | (i.callerPublicKey == pk) | |
868 | 779 | case _: Unit => | |
869 | 780 | (i.caller == this) | |
870 | 781 | case _ => | |
871 | 782 | throw("Match error") | |
872 | 783 | } | |
873 | 784 | ||
874 | 785 | ||
875 | 786 | func mm (i) = match m() { | |
876 | 787 | case pk: ByteVector => | |
877 | 788 | if ((i.callerPublicKey == pk)) | |
878 | 789 | then true | |
879 | 790 | else pd | |
880 | 791 | case _: Unit => | |
881 | 792 | if ((i.caller == this)) | |
882 | 793 | then true | |
883 | 794 | else pd | |
884 | 795 | case _ => | |
885 | 796 | throw("Match error") | |
886 | 797 | } | |
798 | + | ||
799 | + | ||
800 | + | func getY (isReverse,D,poolAmountInBalance) = { | |
801 | + | let poolConfig = gpc() | |
802 | + | let amId = poolConfig[idxAmAsId] | |
803 | + | let prId = poolConfig[idxPrAsId] | |
804 | + | let n = big2 | |
805 | + | let aPrecision = parseBigIntValue(Amult) | |
806 | + | let a = (parseBigIntValue(A) * aPrecision) | |
807 | + | let xp = if ((isReverse == false)) | |
808 | + | then [(toBigInt(getAccBalance(amId)) - poolAmountInBalance), toBigInt(getAccBalance(prId))] | |
809 | + | else [(toBigInt(getAccBalance(prId)) - poolAmountInBalance), toBigInt(getAccBalance(amId))] | |
810 | + | let x = xp[0] | |
811 | + | let s = x | |
812 | + | let ann = (a * n) | |
813 | + | let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n)) | |
814 | + | let b = ((s + ((D * aPrecision) / ann)) - D) | |
815 | + | func calc (acc,cur) = { | |
816 | + | let $t03029130311 = acc | |
817 | + | let y = $t03029130311._1 | |
818 | + | let found = $t03029130311._2 | |
819 | + | if ((found != unit)) | |
820 | + | then acc | |
821 | + | else { | |
822 | + | let yNext = (((y * y) + c) / ((big2 * y) + b)) | |
823 | + | let yDiff = absBigInt((yNext - value(y))) | |
824 | + | if ((big1 >= yDiff)) | |
825 | + | then $Tuple2(yNext, cur) | |
826 | + | else $Tuple2(yNext, unit) | |
827 | + | } | |
828 | + | } | |
829 | + | ||
830 | + | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
831 | + | let $t03064230689 = { | |
832 | + | let $l = arr | |
833 | + | let $s = size($l) | |
834 | + | let $acc0 = $Tuple2(D, unit) | |
835 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
836 | + | then $a | |
837 | + | else calc($a, $l[$i]) | |
838 | + | ||
839 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
840 | + | then $a | |
841 | + | else throw("List size exceeds 15") | |
842 | + | ||
843 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15) | |
844 | + | } | |
845 | + | let y = $t03064230689._1 | |
846 | + | let found = $t03064230689._2 | |
847 | + | if ((found != unit)) | |
848 | + | then y | |
849 | + | else throw(("Y calculation error, Y = " + toString(y))) | |
850 | + | } | |
851 | + | ||
852 | + | ||
853 | + | @Callable(i) | |
854 | + | func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse) = { | |
855 | + | let $t03091031506 = if ((isReverse == false)) | |
856 | + | then { | |
857 | + | let assetOut = strf(this, pa()) | |
858 | + | let poolAmountInBalance = (toBigInt(getAccBalance(strf(this, aa()))) + toBigInt(cleanAmountIn)) | |
859 | + | $Tuple2(assetOut, poolAmountInBalance) | |
860 | + | } | |
861 | + | else { | |
862 | + | let assetOut = strf(this, aa()) | |
863 | + | let poolAmountInBalance = (toBigInt(getAccBalance(strf(this, pa()))) + toBigInt(cleanAmountIn)) | |
864 | + | $Tuple2(assetOut, poolAmountInBalance) | |
865 | + | } | |
866 | + | let assetOut = $t03091031506._1 | |
867 | + | let poolAmountInBalance = $t03091031506._2 | |
868 | + | let poolConfig = gpc() | |
869 | + | let amId = poolConfig[idxAmAsId] | |
870 | + | let prId = poolConfig[idxPrAsId] | |
871 | + | let xp = [toBigInt(getAccBalance(amId)), toBigInt(getAccBalance(prId))] | |
872 | + | let D = getD(xp) | |
873 | + | let y = getY(isReverse, D, poolAmountInBalance) | |
874 | + | let dy = ((toBigInt(getAccBalance(assetOut)) - y) - toBigInt(1)) | |
875 | + | let totalGetRaw = max([0, toInt(dy)]) | |
876 | + | $Tuple2(nil, totalGetRaw) | |
877 | + | } | |
878 | + | ||
879 | + | ||
880 | + | ||
881 | + | @Callable(i) | |
882 | + | func calculateAmountOutForSwapAndSendTokens (cleanAmountIn,isReverse,amountOutMin,addressTo) = { | |
883 | + | let checks = [if ((value(i.payments[0]).amount >= cleanAmountIn)) | |
884 | + | then true | |
885 | + | else throwErr("Wrong amount"), if ((i.caller == addressFromStringValue(strf(this, swapContract())))) | |
886 | + | then true | |
887 | + | else throwErr("Permission denied")] | |
888 | + | if ((checks == checks)) | |
889 | + | then { | |
890 | + | let pmt = value(i.payments[0]) | |
891 | + | let assetIn = if ((pmt.assetId == unit)) | |
892 | + | then toBase58String(toBytes("WAVES")) | |
893 | + | else toBase58String(value(pmt.assetId)) | |
894 | + | let $t03256432958 = if ((isReverse == false)) | |
895 | + | then { | |
896 | + | let assetOut = strf(this, pa()) | |
897 | + | let poolAmountInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount) | |
898 | + | $Tuple2(assetOut, poolAmountInBalance) | |
899 | + | } | |
900 | + | else { | |
901 | + | let assetOut = strf(this, aa()) | |
902 | + | let poolAmountInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount) | |
903 | + | $Tuple2(assetOut, poolAmountInBalance) | |
904 | + | } | |
905 | + | let assetOut = $t03256432958._1 | |
906 | + | let poolAmountInBalance = $t03256432958._2 | |
907 | + | let poolConfig = gpc() | |
908 | + | let amId = poolConfig[idxAmAsId] | |
909 | + | let prId = poolConfig[idxPrAsId] | |
910 | + | let xp = [(toBigInt(getAccBalance(amId)) - toBigInt(value(i.payments[0]).amount)), toBigInt(getAccBalance(prId))] | |
911 | + | let D = getD(xp) | |
912 | + | let y = getY(isReverse, D, toBigInt(poolAmountInBalance)) | |
913 | + | let dy = ((toBigInt(getAccBalance(assetOut)) - y) - toBigInt(1)) | |
914 | + | let totalGetRaw = max([0, toInt(dy)]) | |
915 | + | let checkMin = if ((totalGetRaw >= amountOutMin)) | |
916 | + | then true | |
917 | + | else throw("Exchange result is fewer coins than expected") | |
918 | + | if ((checkMin == checkMin)) | |
919 | + | then [ScriptTransfer(addressFromStringValue(addressTo), totalGetRaw, if ((assetIn == "WAVES")) | |
920 | + | then unit | |
921 | + | else fromBase58String(assetOut))] | |
922 | + | else throw("Strict value is not equal to itself.") | |
923 | + | } | |
924 | + | else throw("Strict value is not equal to itself.") | |
925 | + | } | |
926 | + | ||
887 | 927 | ||
888 | 928 | ||
889 | 929 | @Callable(i) | |
890 | 930 | func constructor (fc) = { | |
891 | 931 | let c = mm(i) | |
892 | 932 | if ((c == c)) | |
893 | 933 | then [StringEntry(fc(), fc)] | |
894 | 934 | else throw("Strict value is not equal to itself.") | |
895 | 935 | } | |
896 | 936 | ||
897 | 937 | ||
898 | 938 | ||
899 | 939 | @Callable(i) | |
900 | 940 | func setManager (pendingManagerPublicKey) = { | |
901 | 941 | let c = mm(i) | |
902 | 942 | if ((c == c)) | |
903 | 943 | then { | |
904 | 944 | let cm = fromBase58String(pendingManagerPublicKey) | |
905 | 945 | if ((cm == cm)) | |
906 | 946 | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
907 | 947 | else throw("Strict value is not equal to itself.") | |
908 | 948 | } | |
909 | 949 | else throw("Strict value is not equal to itself.") | |
910 | 950 | } | |
911 | 951 | ||
912 | 952 | ||
913 | 953 | ||
914 | 954 | @Callable(i) | |
915 | 955 | func confirmManager () = { | |
916 | 956 | let p = pm() | |
917 | 957 | let hpm = if (isDefined(p)) | |
918 | 958 | then true | |
919 | 959 | else throw("No pending manager") | |
920 | 960 | if ((hpm == hpm)) | |
921 | 961 | then { | |
922 | 962 | let cpm = if ((i.callerPublicKey == value(p))) | |
923 | 963 | then true | |
924 | 964 | else throw("You are not pending manager") | |
925 | 965 | if ((cpm == cpm)) | |
926 | 966 | then [StringEntry(mpk(), toBase58String(value(p))), DeleteEntry(pmpk())] | |
927 | 967 | else throw("Strict value is not equal to itself.") | |
928 | 968 | } | |
929 | 969 | else throw("Strict value is not equal to itself.") | |
930 | 970 | } | |
931 | 971 | ||
932 | 972 | ||
933 | 973 | ||
934 | 974 | @Callable(i) | |
935 | 975 | func put (slip,autoStake) = { | |
936 | 976 | let factCfg = gfc() | |
937 | 977 | let stakingCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactStakCntr]), "Wr st addr") | |
938 | 978 | let slipCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactSlippCntr]), "Wr sl addr") | |
939 | 979 | if ((0 > slip)) | |
940 | 980 | then throw("Wrong slippage") | |
941 | 981 | else if ((size(i.payments) != 2)) | |
942 | 982 | then throw("2 pmnts expd") | |
943 | 983 | else { | |
944 | - | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
945 | - | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
946 | - | let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amAssetPmt) | |
947 | - | if ((amountAssetBalance == amountAssetBalance)) | |
984 | + | let e = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], slip, true, false, true, 0, "") | |
985 | + | let emitLpAmt = e._2 | |
986 | + | let lpAssetId = e._7 | |
987 | + | let state = e._9 | |
988 | + | let amDiff = e._10 | |
989 | + | let prDiff = e._11 | |
990 | + | let amId = e._12 | |
991 | + | let prId = e._13 | |
992 | + | let r = invoke(fca, "emit", [emitLpAmt], nil) | |
993 | + | if ((r == r)) | |
948 | 994 | then { | |
949 | - | let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - prAssetPmt) | |
950 | - | if ((priceAssetBalance == priceAssetBalance)) | |
995 | + | let el = match r { | |
996 | + | case legacy: Address => | |
997 | + | invoke(legacy, "emit", [emitLpAmt], nil) | |
998 | + | case _ => | |
999 | + | unit | |
1000 | + | } | |
1001 | + | if ((el == el)) | |
951 | 1002 | then { | |
952 | - | let lpAssetEmission = toBigInt(value(assetInfo(cfgLpAssetId)).quantity) | |
953 | - | if ((lpAssetEmission == lpAssetEmission)) | |
1003 | + | let sa = if ((amDiff > 0)) | |
1004 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)]) | |
1005 | + | else nil | |
1006 | + | if ((sa == sa)) | |
954 | 1007 | then { | |
955 | - | let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
956 | - | if ((currentDLp == currentDLp)) | |
1008 | + | let sp = if ((prDiff > 0)) | |
1009 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)]) | |
1010 | + | else nil | |
1011 | + | if ((sp == sp)) | |
957 | 1012 | then { | |
958 | - | let e = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], slip, true, false, true, 0, "") | |
959 | - | let emitLpAmt = e._2 | |
960 | - | let lpAssetId = e._7 | |
961 | - | let state = e._9 | |
962 | - | let amDiff = e._10 | |
963 | - | let prDiff = e._11 | |
964 | - | let amId = e._12 | |
965 | - | let prId = e._13 | |
966 | - | let r = invoke(fca, "emit", [emitLpAmt], nil) | |
967 | - | if ((r == r)) | |
1013 | + | let lpTrnsfr = if (autoStake) | |
968 | 1014 | then { | |
969 | - | let el = match r { | |
970 | - | case legacy: Address => | |
971 | - | invoke(legacy, "emit", [emitLpAmt], nil) | |
972 | - | case _ => | |
973 | - | unit | |
974 | - | } | |
975 | - | if ((el == el)) | |
976 | - | then { | |
977 | - | let sa = if ((amDiff > 0)) | |
978 | - | then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)]) | |
979 | - | else nil | |
980 | - | if ((sa == sa)) | |
981 | - | then { | |
982 | - | let sp = if ((prDiff > 0)) | |
983 | - | then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)]) | |
984 | - | else nil | |
985 | - | if ((sp == sp)) | |
986 | - | then { | |
987 | - | let lpTrnsfr = if (autoStake) | |
988 | - | then { | |
989 | - | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
990 | - | if ((ss == ss)) | |
991 | - | then nil | |
992 | - | else throw("Strict value is not equal to itself.") | |
993 | - | } | |
994 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
995 | - | let $t03698237124 = refreshDLpInternal(0, 0, 0) | |
996 | - | let refreshDLpActions = $t03698237124._1 | |
997 | - | let updatedDLp = $t03698237124._2 | |
998 | - | let check = if ((updatedDLp >= currentDLp)) | |
999 | - | then true | |
1000 | - | else throwErr(makeString(["updated DLp lower than current DLp", toString(amountAssetBalance), toString(priceAssetBalance), toString(lpAssetEmission), toString(currentDLp), toString(updatedDLp), toString(amDiff), toString(prDiff)], " ")) | |
1001 | - | if ((check == check)) | |
1002 | - | then { | |
1003 | - | let lpAssetEmissionAfter = value(assetInfo(cfgLpAssetId)).quantity | |
1004 | - | if ((lpAssetEmissionAfter == lpAssetEmissionAfter)) | |
1005 | - | then ((state ++ lpTrnsfr) ++ refreshDLpActions) | |
1006 | - | else throw("Strict value is not equal to itself.") | |
1007 | - | } | |
1008 | - | else throw("Strict value is not equal to itself.") | |
1009 | - | } | |
1010 | - | else throw("Strict value is not equal to itself.") | |
1011 | - | } | |
1012 | - | else throw("Strict value is not equal to itself.") | |
1013 | - | } | |
1015 | + | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
1016 | + | if ((ss == ss)) | |
1017 | + | then nil | |
1014 | 1018 | else throw("Strict value is not equal to itself.") | |
1015 | 1019 | } | |
1016 | - | else throw("Strict value is not equal to itself.") | |
1020 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
1021 | + | (state ++ lpTrnsfr) | |
1017 | 1022 | } | |
1018 | 1023 | else throw("Strict value is not equal to itself.") | |
1019 | 1024 | } | |
1020 | 1025 | else throw("Strict value is not equal to itself.") | |
1021 | 1026 | } | |
1022 | 1027 | else throw("Strict value is not equal to itself.") | |
1023 | 1028 | } | |
1024 | 1029 | else throw("Strict value is not equal to itself.") | |
1025 | 1030 | } | |
1026 | 1031 | } | |
1027 | 1032 | ||
1028 | 1033 | ||
1029 | 1034 | ||
1030 | 1035 | @Callable(i) | |
1031 | 1036 | func putOneTknV2 (minOutAmount,autoStake) = { | |
1032 | 1037 | let isPoolOneTokenOperationsDisabled = { | |
1033 | 1038 | let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
1034 | 1039 | if ($isInstanceOf(@, "Boolean")) | |
1035 | 1040 | then @ | |
1036 | 1041 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
1037 | 1042 | } | |
1038 | 1043 | let isPutDisabled = if (if (if (igs()) | |
1039 | 1044 | then true | |
1040 | 1045 | else (cfgPoolStatus == PoolPutDis)) | |
1041 | 1046 | then true | |
1042 | 1047 | else (cfgPoolStatus == PoolShutdown)) | |
1043 | 1048 | then true | |
1044 | 1049 | else isPoolOneTokenOperationsDisabled | |
1045 | 1050 | let checks = [if (if (!(isPutDisabled)) | |
1046 | 1051 | then true | |
1047 | 1052 | else isManager(i)) | |
1048 | 1053 | then true | |
1049 | 1054 | else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1)) | |
1050 | 1055 | then true | |
1051 | 1056 | else throwErr("exactly 1 payment are expected")] | |
1052 | 1057 | if ((checks == checks)) | |
1053 | 1058 | then { | |
1054 | - | let amId = toBase58String(value(cfgAmountAssetId)) | |
1055 | - | let prId = toBase58String(value(cfgPriceAssetId)) | |
1056 | - | let lpId = cfgLpAssetId | |
1057 | - | let amDecimals = cfgAmountAssetDecimals | |
1058 | - | let prDecimals = cfgPriceAssetDecimals | |
1059 | + | let poolConfig = gpc() | |
1060 | + | let amId = poolConfig[idxAmAsId] | |
1061 | + | let prId = poolConfig[idxPrAsId] | |
1062 | + | let lpId = fromBase58String(poolConfig[idxLPAsId]) | |
1063 | + | let amDecimals = parseIntValue(poolConfig[idxAmtAsDcm]) | |
1064 | + | let prDecimals = parseIntValue(poolConfig[idxPriceAsDcm]) | |
1059 | 1065 | let userAddress = if ((i.caller == this)) | |
1060 | 1066 | then i.originCaller | |
1061 | 1067 | else i.caller | |
1062 | 1068 | let pmt = value(i.payments[0]) | |
1063 | 1069 | let pmtAssetId = toBase58String(value(pmt.assetId)) | |
1064 | 1070 | let pmtAmt = pmt.amount | |
1065 | - | let currentDLp = if ((pmt.assetId == cfgAmountAssetId)) | |
1066 | - | then calcCurrentDLp(toBigInt(pmtAmt), toBigInt(0), toBigInt(0)) | |
1067 | - | else calcCurrentDLp(toBigInt(0), toBigInt(pmtAmt), toBigInt(0)) | |
1068 | - | if ((currentDLp == currentDLp)) | |
1071 | + | let $t03777737935 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true) | |
1072 | + | if (($t03777737935 == $t03777737935)) | |
1069 | 1073 | then { | |
1070 | - | let $t03876538923 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true) | |
1071 | - | if (($t03876538923 == $t03876538923)) | |
1074 | + | let feeAmount = $t03777737935._3 | |
1075 | + | let state = $t03777737935._2 | |
1076 | + | let estimLP = $t03777737935._1 | |
1077 | + | let emitLpAmt = if (if ((minOutAmount > 0)) | |
1078 | + | then (minOutAmount > estimLP) | |
1079 | + | else false) | |
1080 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1081 | + | else estimLP | |
1082 | + | let e = invoke(fca, "emit", [emitLpAmt], nil) | |
1083 | + | if ((e == e)) | |
1072 | 1084 | then { | |
1073 | - | let feeAmount = $t03876538923._3 | |
1074 | - | let state = $t03876538923._2 | |
1075 | - | let estimLP = $t03876538923._1 | |
1076 | - | let emitLpAmt = if (if ((minOutAmount > 0)) | |
1077 | - | then (minOutAmount > estimLP) | |
1078 | - | else false) | |
1079 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1080 | - | else estimLP | |
1081 | - | let e = invoke(fca, "emit", [emitLpAmt], nil) | |
1082 | - | if ((e == e)) | |
1085 | + | let el = match e { | |
1086 | + | case legacy: Address => | |
1087 | + | invoke(legacy, "emit", [emitLpAmt], nil) | |
1088 | + | case _ => | |
1089 | + | unit | |
1090 | + | } | |
1091 | + | if ((el == el)) | |
1083 | 1092 | then { | |
1084 | - | let el = match e { | |
1085 | - | case legacy: Address => | |
1086 | - | invoke(legacy, "emit", [emitLpAmt], nil) | |
1087 | - | case _ => | |
1088 | - | unit | |
1089 | - | } | |
1090 | - | if ((el == el)) | |
1093 | + | let lpTrnsfr = if (autoStake) | |
1091 | 1094 | then { | |
1092 | - | let lpTrnsfr = if (autoStake) | |
1093 | - | then { | |
1094 | - | let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)]) | |
1095 | - | if ((ss == ss)) | |
1096 | - | then nil | |
1097 | - | else throw("Strict value is not equal to itself.") | |
1098 | - | } | |
1099 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpId)] | |
1100 | - | let sendFeeToMatcher = if ((feeAmount > 0)) | |
1101 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))] | |
1102 | - | else nil | |
1103 | - | let $t03973840087 = if ((this == feeCollectorAddress)) | |
1104 | - | then $Tuple2(0, 0) | |
1105 | - | else { | |
1106 | - | let paymentInAmountAsset = if ((pmt.assetId == cfgAmountAssetId)) | |
1107 | - | then true | |
1108 | - | else false | |
1109 | - | if (paymentInAmountAsset) | |
1110 | - | then $Tuple2(-(feeAmount), 0) | |
1111 | - | else $Tuple2(0, -(feeAmount)) | |
1112 | - | } | |
1113 | - | let amountAssetBalanceDelta = $t03973840087._1 | |
1114 | - | let priceAssetBalanceDelta = $t03973840087._2 | |
1115 | - | let $t04009040198 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1116 | - | let refreshDLpActions = $t04009040198._1 | |
1117 | - | let updatedDLp = $t04009040198._2 | |
1118 | - | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1119 | - | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1120 | - | then $Tuple2((((state ++ lpTrnsfr) ++ sendFeeToMatcher) ++ refreshDLpActions), emitLpAmt) | |
1095 | + | let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)]) | |
1096 | + | if ((ss == ss)) | |
1097 | + | then nil | |
1121 | 1098 | else throw("Strict value is not equal to itself.") | |
1122 | 1099 | } | |
1123 | - | else throw("Strict value is not equal to itself.") | |
1100 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpId)] | |
1101 | + | let sendFeeToMatcher = if ((feeAmount > 0)) | |
1102 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))] | |
1103 | + | else nil | |
1104 | + | $Tuple2(((state ++ lpTrnsfr) ++ sendFeeToMatcher), emitLpAmt) | |
1124 | 1105 | } | |
1125 | 1106 | else throw("Strict value is not equal to itself.") | |
1126 | 1107 | } | |
1127 | 1108 | else throw("Strict value is not equal to itself.") | |
1128 | 1109 | } | |
1129 | 1110 | else throw("Strict value is not equal to itself.") | |
1130 | 1111 | } | |
1131 | 1112 | else throw("Strict value is not equal to itself.") | |
1132 | 1113 | } | |
1133 | 1114 | ||
1134 | 1115 | ||
1135 | 1116 | ||
1136 | 1117 | @Callable(i) | |
1137 | 1118 | func putForFree (maxSlpg) = if ((0 > maxSlpg)) | |
1138 | 1119 | then throw("Wrong slpg") | |
1139 | 1120 | else if ((size(i.payments) != 2)) | |
1140 | 1121 | then throw("2 pmnts expd") | |
1141 | 1122 | else { | |
1142 | 1123 | let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], maxSlpg, false, false, true, 0, "") | |
1143 | - | let state = estPut._9 | |
1144 | - | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
1145 | - | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
1146 | - | let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
1147 | - | if ((currentDLp == currentDLp)) | |
1148 | - | then { | |
1149 | - | let $t04122841293 = refreshDLpInternal(0, 0, 0) | |
1150 | - | let refreshDLpActions = $t04122841293._1 | |
1151 | - | let updatedDLp = $t04122841293._2 | |
1152 | - | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1153 | - | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1154 | - | then (state ++ refreshDLpActions) | |
1155 | - | else throw("Strict value is not equal to itself.") | |
1156 | - | } | |
1157 | - | else throw("Strict value is not equal to itself.") | |
1124 | + | estPut._9 | |
1158 | 1125 | } | |
1159 | 1126 | ||
1160 | 1127 | ||
1161 | 1128 | ||
1162 | 1129 | @Callable(i) | |
1163 | 1130 | func get () = { | |
1164 | - | let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1165 | - | if ((currentDLp == currentDLp)) | |
1166 | - | then { | |
1167 | - | let r = cg(i) | |
1168 | - | let outAmtAmt = r._1 | |
1169 | - | let outPrAmt = r._2 | |
1170 | - | let pmtAmt = r._3 | |
1171 | - | let pmtAssetId = r._4 | |
1172 | - | let state = r._5 | |
1173 | - | let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1174 | - | if ((b == b)) | |
1175 | - | then { | |
1176 | - | let $t04246642548 = refreshDLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1177 | - | let refreshDLpActions = $t04246642548._1 | |
1178 | - | let updatedDLp = $t04246642548._2 | |
1179 | - | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1180 | - | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1181 | - | then (state ++ refreshDLpActions) | |
1182 | - | else throw("Strict value is not equal to itself.") | |
1183 | - | } | |
1184 | - | else throw("Strict value is not equal to itself.") | |
1185 | - | } | |
1131 | + | let r = cg(i) | |
1132 | + | let outAmtAmt = r._1 | |
1133 | + | let outPrAmt = r._2 | |
1134 | + | let pmtAmt = r._3 | |
1135 | + | let pmtAssetId = r._4 | |
1136 | + | let state = r._5 | |
1137 | + | let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1138 | + | if ((b == b)) | |
1139 | + | then state | |
1186 | 1140 | else throw("Strict value is not equal to itself.") | |
1187 | 1141 | } | |
1188 | 1142 | ||
1189 | 1143 | ||
1190 | 1144 | ||
1191 | 1145 | @Callable(i) | |
1192 | 1146 | func getOneTknV2 (outAssetId,minOutAmount) = { | |
1193 | 1147 | let isPoolOneTokenOperationsDisabled = { | |
1194 | 1148 | let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
1195 | 1149 | if ($isInstanceOf(@, "Boolean")) | |
1196 | 1150 | then @ | |
1197 | 1151 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
1198 | 1152 | } | |
1199 | 1153 | let isGetDisabled = if (if (igs()) | |
1200 | 1154 | then true | |
1201 | 1155 | else (cfgPoolStatus == PoolShutdown)) | |
1202 | 1156 | then true | |
1203 | 1157 | else isPoolOneTokenOperationsDisabled | |
1204 | 1158 | let checks = [if (if (!(isGetDisabled)) | |
1205 | 1159 | then true | |
1206 | 1160 | else isManager(i)) | |
1207 | 1161 | then true | |
1208 | 1162 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1)) | |
1209 | 1163 | then true | |
1210 | 1164 | else throwErr("exactly 1 payment are expected")] | |
1211 | 1165 | if ((checks == checks)) | |
1212 | 1166 | then { | |
1213 | - | let $ | |
1214 | - | let state = $ | |
1215 | - | let totalAmount = $ | |
1167 | + | let $t04055740712 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId) | |
1168 | + | let state = $t04055740712._1 | |
1169 | + | let totalAmount = $t04055740712._2 | |
1216 | 1170 | $Tuple2(state, totalAmount) | |
1217 | 1171 | } | |
1218 | 1172 | else throw("Strict value is not equal to itself.") | |
1219 | 1173 | } | |
1220 | 1174 | ||
1221 | 1175 | ||
1222 | 1176 | ||
1223 | 1177 | @Callable(i) | |
1224 | - | func refreshDLp () = { | |
1225 | - | let lastRefreshedBlockHeight = valueOrElse(getInteger(keyDLpRefreshedHeight), 0) | |
1226 | - | let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= dLpRefreshDelay)) | |
1227 | - | then unit | |
1228 | - | else throwErr(makeString([toString(dLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1229 | - | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1230 | - | then { | |
1231 | - | let dLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyDLp), "0")), fmtErr("invalid dLp")) | |
1232 | - | let $t04384543909 = refreshDLpInternal(0, 0, 0) | |
1233 | - | let dLpUpdateActions = $t04384543909._1 | |
1234 | - | let updatedDLp = $t04384543909._2 | |
1235 | - | let actions = if ((dLp != updatedDLp)) | |
1236 | - | then dLpUpdateActions | |
1237 | - | else throwErr("nothing to refresh") | |
1238 | - | $Tuple2(actions, toString(updatedDLp)) | |
1239 | - | } | |
1240 | - | else throw("Strict value is not equal to itself.") | |
1241 | - | } | |
1242 | - | ||
1243 | - | ||
1244 | - | ||
1245 | - | @Callable(i) | |
1246 | 1178 | func getOneTknV2READONLY (outAssetId,lpAssetAmount) = { | |
1247 | - | let amId = toBase58String(value(cfgAmountAssetId)) | |
1248 | - | let prId = toBase58String(value(cfgPriceAssetId)) | |
1249 | - | let lpId = toBase58String(value(cfgLpAssetId)) | |
1179 | + | let poolConfig = gpc() | |
1180 | + | let amId = poolConfig[idxAmAsId] | |
1181 | + | let prId = poolConfig[idxPrAsId] | |
1182 | + | let lpId = poolConfig[idxLPAsId] | |
1250 | 1183 | let xp = [toBigInt(getAccBalance(amId)), toBigInt(getAccBalance(prId))] | |
1251 | 1184 | let lpEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity) | |
1252 | 1185 | let D0 = getD(xp) | |
1253 | 1186 | let D1 = (D0 - fraction(toBigInt(lpAssetAmount), D0, lpEmission)) | |
1254 | 1187 | let index = if ((outAssetId == amId)) | |
1255 | 1188 | then 0 | |
1256 | 1189 | else if ((outAssetId == prId)) | |
1257 | 1190 | then 1 | |
1258 | 1191 | else throw("invalid out asset id") | |
1259 | 1192 | let newY = getYD(xp, index, D1) | |
1260 | 1193 | let dy = (xp[index] - newY) | |
1261 | 1194 | let totalGetRaw = max([0, toInt((dy - big1))]) | |
1262 | - | let $ | |
1263 | - | let totalGet = $ | |
1264 | - | let feeAmount = $ | |
1195 | + | let $t04150241557 = takeFee(totalGetRaw, outFee) | |
1196 | + | let totalGet = $t04150241557._1 | |
1197 | + | let feeAmount = $t04150241557._2 | |
1265 | 1198 | $Tuple2(nil, $Tuple2(totalGet, feeAmount)) | |
1266 | 1199 | } | |
1267 | 1200 | ||
1268 | 1201 | ||
1269 | 1202 | ||
1270 | 1203 | @Callable(i) | |
1271 | 1204 | func getOneTknV2WithBonusREADONLY (outAssetId,lpAssetAmount) = { | |
1272 | - | let amId = toBase58String(value(cfgAmountAssetId)) | |
1273 | - | let prId = toBase58String(value(cfgPriceAssetId)) | |
1274 | - | let lpId = toBase58String(value(cfgLpAssetId)) | |
1205 | + | let poolConfig = gpc() | |
1206 | + | let amId = poolConfig[idxAmAsId] | |
1207 | + | let prId = poolConfig[idxPrAsId] | |
1208 | + | let lpId = poolConfig[idxLPAsId] | |
1275 | 1209 | let amBalance = getAccBalance(amId) | |
1276 | 1210 | let prBalance = getAccBalance(prId) | |
1277 | - | let $ | |
1211 | + | let $t04190242017 = { | |
1278 | 1212 | let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, lpAssetAmount], nil) | |
1279 | 1213 | if ($isInstanceOf(@, "(Int, Int)")) | |
1280 | 1214 | then @ | |
1281 | 1215 | else throw(($getType(@) + " couldn't be cast to (Int, Int)")) | |
1282 | 1216 | } | |
1283 | - | let totalGet = $ | |
1284 | - | let feeAmount = $ | |
1217 | + | let totalGet = $t04190242017._1 | |
1218 | + | let feeAmount = $t04190242017._2 | |
1285 | 1219 | let r = ego("", lpId, lpAssetAmount, this) | |
1286 | 1220 | let outAmAmt = r._1 | |
1287 | 1221 | let outPrAmt = r._2 | |
1288 | 1222 | let sumOfGetAssets = (outAmAmt + outPrAmt) | |
1289 | 1223 | let bonus = if ((sumOfGetAssets == 0)) | |
1290 | 1224 | then if ((totalGet == 0)) | |
1291 | 1225 | then 0 | |
1292 | 1226 | else throw("bonus calculation error") | |
1293 | 1227 | else fraction((totalGet - sumOfGetAssets), scale8, sumOfGetAssets) | |
1294 | 1228 | $Tuple2(nil, $Tuple3(totalGet, feeAmount, bonus)) | |
1295 | 1229 | } | |
1296 | 1230 | ||
1297 | 1231 | ||
1298 | 1232 | ||
1299 | 1233 | @Callable(i) | |
1300 | 1234 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
1301 | 1235 | let r = cg(i) | |
1302 | 1236 | let outAmAmt = r._1 | |
1303 | 1237 | let outPrAmt = r._2 | |
1304 | 1238 | let pmtAmt = r._3 | |
1305 | 1239 | let pmtAssetId = r._4 | |
1306 | 1240 | let state = r._5 | |
1307 | 1241 | if ((noLessThenAmtAsset > outAmAmt)) | |
1308 | 1242 | then throw(((("Failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
1309 | 1243 | else if ((noLessThenPriceAsset > outPrAmt)) | |
1310 | 1244 | then throw(((("Failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
1311 | 1245 | else { | |
1312 | - | let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1313 | - | if ((currentDLp == currentDLp)) | |
1314 | - | then { | |
1315 | - | let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1316 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1317 | - | then { | |
1318 | - | let $t04655046631 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1319 | - | let refreshDLpActions = $t04655046631._1 | |
1320 | - | let updatedDLp = $t04655046631._2 | |
1321 | - | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1322 | - | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1323 | - | then (state ++ refreshDLpActions) | |
1324 | - | else throw("Strict value is not equal to itself.") | |
1325 | - | } | |
1326 | - | else throw("Strict value is not equal to itself.") | |
1327 | - | } | |
1246 | + | let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1247 | + | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1248 | + | then state | |
1328 | 1249 | else throw("Strict value is not equal to itself.") | |
1329 | 1250 | } | |
1330 | 1251 | } | |
1331 | 1252 | ||
1332 | 1253 | ||
1333 | 1254 | ||
1334 | 1255 | @Callable(i) | |
1335 | 1256 | func unstakeAndGet (amount) = { | |
1336 | 1257 | let checkPayments = if ((size(i.payments) != 0)) | |
1337 | 1258 | then throw("No pmnts expd") | |
1338 | 1259 | else true | |
1339 | 1260 | if ((checkPayments == checkPayments)) | |
1340 | 1261 | then { | |
1262 | + | let cfg = gpc() | |
1341 | 1263 | let factoryCfg = gfc() | |
1342 | - | let lpAssetId = | |
1264 | + | let lpAssetId = fromBase58String(cfg[idxLPAsId]) | |
1343 | 1265 | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr") | |
1344 | - | let | |
1345 | - | if (( | |
1266 | + | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1267 | + | if ((unstakeInv == unstakeInv)) | |
1346 | 1268 | then { | |
1347 | - | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1348 | - | if ((unstakeInv == unstakeInv)) | |
1269 | + | let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1270 | + | let sts = parseIntValue(r._9) | |
1271 | + | let state = r._10 | |
1272 | + | let v = if (if (igs()) | |
1273 | + | then true | |
1274 | + | else (sts == PoolShutdown)) | |
1275 | + | then throw(("Blocked: " + toString(sts))) | |
1276 | + | else true | |
1277 | + | if ((v == v)) | |
1349 | 1278 | then { | |
1350 | - | let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1351 | - | let outAmAmt = r._1 | |
1352 | - | let outPrAmt = r._2 | |
1353 | - | let sts = parseIntValue(r._9) | |
1354 | - | let state = r._10 | |
1355 | - | let v = if (if (igs()) | |
1356 | - | then true | |
1357 | - | else (sts == PoolShutdown)) | |
1358 | - | then throw(("Blocked: " + toString(sts))) | |
1359 | - | else true | |
1360 | - | if ((v == v)) | |
1361 | - | then { | |
1362 | - | let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1363 | - | if ((burnA == burnA)) | |
1364 | - | then { | |
1365 | - | let $t04765847739 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1366 | - | let refreshDLpActions = $t04765847739._1 | |
1367 | - | let updatedDLp = $t04765847739._2 | |
1368 | - | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1369 | - | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1370 | - | then (state ++ refreshDLpActions) | |
1371 | - | else throw("Strict value is not equal to itself.") | |
1372 | - | } | |
1373 | - | else throw("Strict value is not equal to itself.") | |
1374 | - | } | |
1279 | + | let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1280 | + | if ((burnA == burnA)) | |
1281 | + | then state | |
1375 | 1282 | else throw("Strict value is not equal to itself.") | |
1376 | 1283 | } | |
1377 | 1284 | else throw("Strict value is not equal to itself.") | |
1378 | 1285 | } | |
1379 | 1286 | else throw("Strict value is not equal to itself.") | |
1380 | 1287 | } | |
1381 | 1288 | else throw("Strict value is not equal to itself.") | |
1382 | 1289 | } | |
1383 | 1290 | ||
1384 | 1291 | ||
1385 | 1292 | ||
1386 | 1293 | @Callable(i) | |
1387 | 1294 | func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = { | |
1388 | 1295 | let isGetDisabled = if (igs()) | |
1389 | 1296 | then true | |
1390 | 1297 | else (cfgPoolStatus == PoolShutdown) | |
1391 | 1298 | let checks = [if (!(isGetDisabled)) | |
1392 | 1299 | then true | |
1393 | 1300 | else throw("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1394 | 1301 | then true | |
1395 | 1302 | else throw("no payments are expected")] | |
1396 | 1303 | if ((checks == checks)) | |
1397 | 1304 | then { | |
1398 | - | let | |
1399 | - | if (( | |
1305 | + | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1306 | + | if ((unstakeInv == unstakeInv)) | |
1400 | 1307 | then { | |
1401 | - | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1402 | - | if ((unstakeInv == unstakeInv)) | |
1308 | + | let res = ego(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1309 | + | let outAmAmt = res._1 | |
1310 | + | let outPrAmt = res._2 | |
1311 | + | let state = res._10 | |
1312 | + | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1313 | + | then true | |
1314 | + | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1315 | + | then true | |
1316 | + | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1317 | + | if ((checkAmounts == checkAmounts)) | |
1403 | 1318 | then { | |
1404 | - | let res = ego(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1405 | - | let outAmAmt = res._1 | |
1406 | - | let outPrAmt = res._2 | |
1407 | - | let state = res._10 | |
1408 | - | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1409 | - | then true | |
1410 | - | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1411 | - | then true | |
1412 | - | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1413 | - | if ((checkAmounts == checkAmounts)) | |
1414 | - | then { | |
1415 | - | let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1416 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1417 | - | then { | |
1418 | - | let $t04899049071 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1419 | - | let refreshDLpActions = $t04899049071._1 | |
1420 | - | let updatedDLp = $t04899049071._2 | |
1421 | - | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1422 | - | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1423 | - | then (state ++ refreshDLpActions) | |
1424 | - | else throw("Strict value is not equal to itself.") | |
1425 | - | } | |
1426 | - | else throw("Strict value is not equal to itself.") | |
1427 | - | } | |
1319 | + | let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1320 | + | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1321 | + | then state | |
1428 | 1322 | else throw("Strict value is not equal to itself.") | |
1429 | 1323 | } | |
1430 | 1324 | else throw("Strict value is not equal to itself.") | |
1431 | 1325 | } | |
1432 | 1326 | else throw("Strict value is not equal to itself.") | |
1433 | 1327 | } | |
1434 | 1328 | else throw("Strict value is not equal to itself.") | |
1435 | 1329 | } | |
1436 | 1330 | ||
1437 | 1331 | ||
1438 | 1332 | ||
1439 | 1333 | @Callable(i) | |
1440 | 1334 | func unstakeAndGetOneTknV2 (unstakeAmount,outAssetId,minOutAmount) = { | |
1441 | 1335 | let isPoolOneTokenOperationsDisabled = { | |
1442 | 1336 | let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
1443 | 1337 | if ($isInstanceOf(@, "Boolean")) | |
1444 | 1338 | then @ | |
1445 | 1339 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
1446 | 1340 | } | |
1447 | 1341 | let isGetDisabled = if (if (igs()) | |
1448 | 1342 | then true | |
1449 | 1343 | else (cfgPoolStatus == PoolShutdown)) | |
1450 | 1344 | then true | |
1451 | 1345 | else isPoolOneTokenOperationsDisabled | |
1452 | 1346 | let checks = [if (if (!(isGetDisabled)) | |
1453 | 1347 | then true | |
1454 | 1348 | else isManager(i)) | |
1455 | 1349 | then true | |
1456 | 1350 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1457 | 1351 | then true | |
1458 | 1352 | else throwErr("no payments are expected")] | |
1459 | 1353 | if ((checks == checks)) | |
1460 | 1354 | then { | |
1355 | + | let cfg = gpc() | |
1461 | 1356 | let factoryCfg = gfc() | |
1462 | - | let lpAssetId = | |
1357 | + | let lpAssetId = fromBase58String(cfg[idxLPAsId]) | |
1463 | 1358 | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr") | |
1464 | 1359 | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), unstakeAmount], nil) | |
1465 | 1360 | if ((unstakeInv == unstakeInv)) | |
1466 | 1361 | then { | |
1467 | - | let $ | |
1468 | - | let state = $ | |
1469 | - | let totalAmount = $ | |
1362 | + | let $t04585546043 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId) | |
1363 | + | let state = $t04585546043._1 | |
1364 | + | let totalAmount = $t04585546043._2 | |
1470 | 1365 | $Tuple2(state, totalAmount) | |
1471 | 1366 | } | |
1472 | 1367 | else throw("Strict value is not equal to itself.") | |
1473 | 1368 | } | |
1474 | 1369 | else throw("Strict value is not equal to itself.") | |
1475 | 1370 | } | |
1476 | 1371 | ||
1477 | 1372 | ||
1478 | 1373 | ||
1479 | 1374 | @Callable(i) | |
1480 | 1375 | func putOneTknV2WithBonusREADONLY (paymentAmountRaw,paymentAssetId) = { | |
1481 | - | let $t05028250385 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true) | |
1482 | - | let lpAmount = $t05028250385._1 | |
1483 | - | let state = $t05028250385._2 | |
1484 | - | let feeAmount = $t05028250385._3 | |
1485 | - | let bonus = $t05028250385._4 | |
1376 | + | let poolConfig = gpc() | |
1377 | + | let amId = poolConfig[idxAmAsId] | |
1378 | + | let prId = poolConfig[idxPrAsId] | |
1379 | + | let lpId = poolConfig[idxLPAsId] | |
1380 | + | let $t04630246405 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true) | |
1381 | + | let lpAmount = $t04630246405._1 | |
1382 | + | let state = $t04630246405._2 | |
1383 | + | let feeAmount = $t04630246405._3 | |
1384 | + | let bonus = $t04630246405._4 | |
1486 | 1385 | $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus)) | |
1487 | 1386 | } | |
1488 | 1387 | ||
1489 | 1388 | ||
1490 | 1389 | ||
1491 | 1390 | @Callable(i) | |
1492 | 1391 | func putOneTknV2WithoutTakeFeeREADONLY (paymentAmountRaw,paymentAssetId) = { | |
1493 | - | let $t05053350637 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false) | |
1494 | - | let lpAmount = $t05053350637._1 | |
1495 | - | let state = $t05053350637._2 | |
1496 | - | let feeAmount = $t05053350637._3 | |
1497 | - | let bonus = $t05053350637._4 | |
1392 | + | let poolConfig = gpc() | |
1393 | + | let amId = poolConfig[idxAmAsId] | |
1394 | + | let prId = poolConfig[idxPrAsId] | |
1395 | + | let lpId = poolConfig[idxLPAsId] | |
1396 | + | let $t04668446788 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false) | |
1397 | + | let lpAmount = $t04668446788._1 | |
1398 | + | let state = $t04668446788._2 | |
1399 | + | let feeAmount = $t04668446788._3 | |
1400 | + | let bonus = $t04668446788._4 | |
1498 | 1401 | $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus)) | |
1499 | 1402 | } | |
1500 | 1403 | ||
1501 | 1404 | ||
1502 | 1405 | ||
1503 | 1406 | @Callable(i) | |
1504 | 1407 | func activate (amtAsStr,prAsStr) = if ((toString(i.caller) != toString(fca))) | |
1505 | 1408 | then throw("denied") | |
1506 | 1409 | else $Tuple2([StringEntry(aa(), amtAsStr), StringEntry(pa(), prAsStr)], "success") | |
1507 | 1410 | ||
1508 | 1411 | ||
1509 | 1412 | ||
1510 | 1413 | @Callable(i) | |
1511 | 1414 | func setS (k,v) = if ((toString(i.caller) != strf(this, ada()))) | |
1512 | 1415 | then pd | |
1513 | 1416 | else [StringEntry(k, v)] | |
1514 | 1417 | ||
1515 | 1418 | ||
1516 | 1419 | ||
1517 | 1420 | @Callable(i) | |
1518 | 1421 | func setI (k,v) = if ((toString(i.caller) != strf(this, ada()))) | |
1519 | 1422 | then pd | |
1520 | 1423 | else [IntegerEntry(k, v)] | |
1521 | 1424 | ||
1522 | 1425 | ||
1523 | 1426 | ||
1524 | 1427 | @Callable(i) | |
1525 | 1428 | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, gpc()) | |
1526 | 1429 | ||
1527 | 1430 | ||
1528 | 1431 | ||
1529 | 1432 | @Callable(i) | |
1530 | 1433 | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
1531 | 1434 | ||
1532 | 1435 | ||
1533 | 1436 | ||
1534 | 1437 | @Callable(i) | |
1535 | 1438 | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
1536 | 1439 | let pr = calcPrices(amAmt, prAmt, lpAmt) | |
1537 | 1440 | $Tuple2(nil, [toString(pr[0]), toString(pr[1]), toString(pr[2])]) | |
1538 | 1441 | } | |
1539 | 1442 | ||
1540 | 1443 | ||
1541 | 1444 | ||
1542 | 1445 | @Callable(i) | |
1543 | 1446 | func fromX18WrapperREADONLY (val,resScaleMult) = $Tuple2(nil, f1(parseBigIntValue(val), resScaleMult)) | |
1544 | 1447 | ||
1545 | 1448 | ||
1546 | 1449 | ||
1547 | 1450 | @Callable(i) | |
1548 | 1451 | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(t1(origVal, origScaleMult))) | |
1549 | 1452 | ||
1550 | 1453 | ||
1551 | 1454 | ||
1552 | 1455 | @Callable(i) | |
1553 | 1456 | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(cpbi(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
1554 | 1457 | ||
1555 | 1458 | ||
1556 | 1459 | ||
1557 | 1460 | @Callable(i) | |
1558 | 1461 | func estimatePutOperationWrapperREADONLY (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,usrAddr,isEval,emitLp) = $Tuple2(nil, epo(txId58, slippage, inAmAmt, inAmId, inPrAmt, inPrId, usrAddr, isEval, emitLp, true, false, 0, "")) | |
1559 | 1462 | ||
1560 | 1463 | ||
1561 | 1464 | ||
1562 | 1465 | @Callable(i) | |
1563 | 1466 | func estimateGetOperationWrapperREADONLY (txId58,pmtAsId,pmtLpAmt,usrAddr) = { | |
1564 | 1467 | let r = ego(txId58, pmtAsId, pmtLpAmt, addressFromStringValue(usrAddr)) | |
1565 | 1468 | $Tuple2(nil, $Tuple10(r._1, r._2, r._3, r._4, r._5, r._6, r._7, toString(r._8), r._9, r._10)) | |
1566 | 1469 | } | |
1567 | 1470 | ||
1568 | 1471 | ||
1569 | 1472 | @Verifier(tx) | |
1570 | 1473 | func verify () = { | |
1571 | 1474 | let targetPublicKey = match m() { | |
1572 | 1475 | case pk: ByteVector => | |
1573 | 1476 | pk | |
1574 | 1477 | case _: Unit => | |
1575 | 1478 | tx.senderPublicKey | |
1576 | 1479 | case _ => | |
1577 | 1480 | throw("Match error") | |
1578 | 1481 | } | |
1579 | 1482 | match tx { | |
1580 | 1483 | case order: Order => | |
1581 | 1484 | let matcherPub = mp() | |
1582 | - | let $t05342953498 = validateMatcherOrderAllowed(order) | |
1583 | - | let orderValid = $t05342953498._1 | |
1584 | - | let orderValidInfo = $t05342953498._2 | |
1485 | + | let orderValid = moa(order) | |
1585 | 1486 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1586 | 1487 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1587 | 1488 | if (if (if (orderValid) | |
1588 | 1489 | then senderValid | |
1589 | 1490 | else false) | |
1590 | 1491 | then matcherValid | |
1591 | 1492 | else false) | |
1592 | 1493 | then true | |
1593 | - | else | |
1494 | + | else toe(orderValid, senderValid, matcherValid) | |
1594 | 1495 | case s: SetScriptTransaction => | |
1595 | - | if (sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)) | |
1496 | + | let newHash = blake2b256(value(s.script)) | |
1497 | + | let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash()))) | |
1498 | + | let currentHash = scriptHash(this) | |
1499 | + | if (if ((allowedHash == newHash)) | |
1500 | + | then (currentHash != newHash) | |
1501 | + | else false) | |
1596 | 1502 | then true | |
1597 | - | else { | |
1598 | - | let newHash = blake2b256(value(s.script)) | |
1599 | - | let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash()))) | |
1600 | - | let currentHash = scriptHash(this) | |
1601 | - | if ((allowedHash == newHash)) | |
1602 | - | then (currentHash != newHash) | |
1603 | - | else false | |
1604 | - | } | |
1503 | + | else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1605 | 1504 | case _ => | |
1606 | 1505 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1607 | 1506 | } | |
1608 | 1507 | } | |
1609 | 1508 |
github/deemru/w8io/026f985 207.33 ms ◑