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