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