tx · EbECQCJWH9dHyoqJQwijzhDFudbkVog2A8Ni6GzBYPbY 3N1xHtFLmVxy153ELFALTEt3HuVXvv4rnqb: -0.02800000 Waves 2022.10.13 16:42 [2270658] smart account 3N1xHtFLmVxy153ELFALTEt3HuVXvv4rnqb > SELF 0.00000000 Waves
{ "type": 13, "id": "EbECQCJWH9dHyoqJQwijzhDFudbkVog2A8Ni6GzBYPbY", "fee": 2800000, "feeAssetId": null, "timestamp": 1665668579611, "version": 1, "sender": "3N1xHtFLmVxy153ELFALTEt3HuVXvv4rnqb", "senderPublicKey": "FbottDhjAqYmSxiGz2jbuu6xQEvdqZoV43vksDrkTTgb", "proofs": [ "5bFoAnGJ4EuzimGPQeqbZ4KsggZCgoSn3eFDD5Zt7TwVFH2feNpb6vDwhKxVZwo4siNyyJYvAYgv6UzdbnjUm6dN" ], "script": "base64:BgLkJQgCEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgUKAwgBARIAEgQKAgEBEgMKAQESBAoCCAgSABIDCgEIEgUKAwEBARIECgIBARIECgIIARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCBIAEgMKAQESAwoBARIECgIIASIKbFBkZWNpbWFscyIGc2NhbGU4IgxzY2FsZThCaWdJbnQiB3NjYWxlMTgiCnplcm9CaWdJbnQiBGJpZzAiBGJpZzEiBGJpZzIiC3dhdmVzU3RyaW5nIgNTRVAiClBvb2xBY3RpdmUiD1Bvb2xQdXREaXNhYmxlZCITUG9vbE1hdGNoZXJEaXNhYmxlZCIMUG9vbFNodXRkb3duIg5pZHhQb29sQWRkcmVzcyINaWR4UG9vbFN0YXR1cyIQaWR4UG9vbExQQXNzZXRJZCINaWR4QW10QXNzZXRJZCIPaWR4UHJpY2VBc3NldElkIg5pZHhBbXRBc3NldERjbSIQaWR4UHJpY2VBc3NldERjbSIOaWR4SUFtdEFzc2V0SWQiEGlkeElQcmljZUFzc2V0SWQiDWlkeExQQXNzZXREY20iEmlkeFBvb2xBbXRBc3NldEFtdCIUa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FAmNIBnByb29mcwAACAUCY0gPc2VuZGVyUHVibGljS2V5BAJhdgkA9AMDCAUCY0gJYm9keUJ5dGVzCQCRAwIIBQJjSAZwcm9vZnMAAQUCZkEDAwMFAmF0BQJhdQcFAmF2BwYJAQJhcwMFAmF0BQJhdQUCYXYDCQABAgUCZGcCFFNldFNjcmlwdFRyYW5zYWN0aW9uBAJlcwUCZGcEAmZCCQD2AwEJAQV2YWx1ZQEIBQJlcwZzY3JpcHQEAmZDCQDbBAEJAQV2YWx1ZQEJAJ0IAgUCYUMJAQJhcQAEAmZECQDxBwEFBHRoaXMDAwkAAAIFAmZDBQJmQgkBAiE9AgUCZkQFAmZCBwYJAPQDAwgFAmZ4CWJvZHlCeXRlcwkAkQMCCAUCZngGcHJvb2ZzAAAFAmZ6CQD0AwMIBQJmeAlib2R5Qnl0ZXMJAJEDAggFAmZ4BnByb29mcwAABQJmerlLhmU=", "chainId": 84, "height": 2270658, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5xTj9tMpLxjek5WEXtt4Yw4AHupXRC57EYdhAQBKF2vW Next: FH5qLZBcg2o841kKDdkAAxR5mfB2hPzjsJDgKfM8Jynk Diff:
Old | New | Differences | |
---|---|---|---|
100 | 100 | func pa () = "%s__priceAsset" | |
101 | 101 | ||
102 | 102 | ||
103 | + | let keyFee = "%s__fee" | |
104 | + | ||
105 | + | let feeDefault = fraction(5, scale8, 10000) | |
106 | + | ||
107 | + | let fee = valueOrElse(getInteger(this, keyFee), feeDefault) | |
108 | + | ||
103 | 109 | func keyFactoryConfig () = "%s__factoryConfig" | |
104 | 110 | ||
105 | 111 | ||
124 | 130 | func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash" | |
125 | 131 | ||
126 | 132 | ||
133 | + | let keyFeeCollectorAddress = "%s__feeCollectorAddress" | |
134 | + | ||
127 | 135 | func throwOrderError (orderValid,senderValid,matcherValid) = throw(((((("order validation failed: orderValid=" + toString(orderValid)) + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid))) | |
128 | 136 | ||
129 | 137 | ||
137 | 145 | ||
138 | 146 | ||
139 | 147 | let factoryContract = addressFromStringValue(getStringOrFail(this, fc())) | |
148 | + | ||
149 | + | let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress)) | |
140 | 150 | ||
141 | 151 | func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false) | |
142 | 152 | ||
426 | 436 | } | |
427 | 437 | ||
428 | 438 | ||
439 | + | func takeFee (amount) = { | |
440 | + | let feeAmount = fraction(amount, fee, scale8) | |
441 | + | $Tuple2((amount - feeAmount), feeAmount) | |
442 | + | } | |
443 | + | ||
444 | + | ||
429 | 445 | func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = { | |
430 | 446 | let isEval = (txId == unit) | |
431 | - | let $t02148521663 = parsePoolConfig(getPoolConfig()) | |
432 | - | let poolAddress = $t02148521663._1 | |
433 | - | let poolStatus = $t02148521663._2 | |
434 | - | let lpAssetId = $t02148521663._3 | |
435 | - | let amountAssetId = $t02148521663._4 | |
436 | - | let priceAssetId = $t02148521663._5 | |
437 | - | let amountAssetDecimals = $t02148521663._6 | |
438 | - | let priceAssetDecimals = $t02148521663._7 | |
439 | - | let paymentAmount = paymentAmountRaw | |
440 | - | let balanceRaw = if ((paymentAssetId == amountAssetId)) | |
441 | - | then getAccBalance(assetIdToString(amountAssetId)) | |
447 | + | let $t02194222120 = parsePoolConfig(getPoolConfig()) | |
448 | + | let poolAddress = $t02194222120._1 | |
449 | + | let poolStatus = $t02194222120._2 | |
450 | + | let lpAssetId = $t02194222120._3 | |
451 | + | let amountAssetId = $t02194222120._4 | |
452 | + | let priceAssetId = $t02194222120._5 | |
453 | + | let amountAssetDecimals = $t02194222120._6 | |
454 | + | let priceAssetDecimals = $t02194222120._7 | |
455 | + | let amountBalanceRaw = getAccBalance(assetIdToString(amountAssetId)) | |
456 | + | let priceBalanceRaw = getAccBalance(assetIdToString(priceAssetId)) | |
457 | + | let paymentInAmountAsset = if ((paymentAssetId == amountAssetId)) | |
458 | + | then true | |
442 | 459 | else if ((paymentAssetId == priceAssetId)) | |
443 | - | then | |
460 | + | then false | |
444 | 461 | else throwErr("invalid asset") | |
445 | - | let amountToSubtract = if (isEval) | |
446 | - | then 0 | |
447 | - | else paymentAmount | |
448 | - | let balance = (balanceRaw - amountToSubtract) | |
449 | - | let balanceBigInt = toBigInt(balance) | |
462 | + | let $t02245022743 = if (isEval) | |
463 | + | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
464 | + | else if (paymentInAmountAsset) | |
465 | + | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
466 | + | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
467 | + | let amountBalanceOld = $t02245022743._1 | |
468 | + | let priceBalanceOld = $t02245022743._2 | |
469 | + | let $t02274722896 = if (paymentInAmountAsset) | |
470 | + | then $Tuple2(paymentAmountRaw, 0) | |
471 | + | else $Tuple2(0, paymentAmountRaw) | |
472 | + | let amountAssetAmountRaw = $t02274722896._1 | |
473 | + | let priceAssetAmountRaw = $t02274722896._2 | |
474 | + | let amountAssetAmount = takeFee(amountAssetAmountRaw)._1 | |
475 | + | let priceAssetAmount = takeFee(priceAssetAmountRaw)._1 | |
476 | + | let $t02301823077 = takeFee(paymentAmountRaw) | |
477 | + | let paymentAmount = $t02301823077._1 | |
478 | + | let feeAmount = $t02301823077._2 | |
479 | + | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
480 | + | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
481 | + | let curPrice = fromX18(calcPriceBigInt(toX18(priceBalanceNew, priceAssetDecimals), toX18(amountBalanceNew, amountAssetDecimals)), scale8) | |
482 | + | let paymentBalance = if (paymentInAmountAsset) | |
483 | + | then amountBalanceOld | |
484 | + | else priceBalanceOld | |
485 | + | let paymentBalanceBigInt = toBigInt(paymentBalance) | |
450 | 486 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(lpAssetId), (("asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity) | |
451 | - | let depositBigInt = toBigInt(paymentAmount) | |
452 | - | let issueAmount = ((supplyBigInt * (sqrtBigInt((scale8BigInt + ((depositBigInt * scale8BigInt) / balanceBigInt)), 8, 8, DOWN) - scale8BigInt)) / scale8BigInt) | |
453 | - | toInt(issueAmount) | |
487 | + | let chechSupply = if ((supplyBigInt > big0)) | |
488 | + | then true | |
489 | + | else throw("initial deposit requires all coins") | |
490 | + | if ((chechSupply == chechSupply)) | |
491 | + | then { | |
492 | + | let depositBigInt = toBigInt(paymentAmount) | |
493 | + | let issueAmount = toInt(((supplyBigInt * (sqrtBigInt((scale8BigInt + ((depositBigInt * scale8BigInt) / paymentBalanceBigInt)), 8, 8, DOWN) - scale8BigInt)) / scale8BigInt)) | |
494 | + | let commonState = if (isEval) | |
495 | + | then nil | |
496 | + | else [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(toString(value(userAddress)), toBase58String(value(txId))), dataPutActionInfo(amountAssetAmountRaw, priceAssetAmountRaw, issueAmount, curPrice, 0, 0, height, lastBlock.timestamp, 0, 0))] | |
497 | + | let poolProportion = fraction(priceBalanceOld, scale8, amountBalanceOld) | |
498 | + | let amountAssetPart = fraction(paymentAmountRaw, scale8, (poolProportion + scale8)) | |
499 | + | let priceAssetPart = (paymentAmountRaw - amountAssetPart) | |
500 | + | let lpAmtBoth = fraction(supplyBigInt, toBigInt(priceAssetPart), toBigInt(priceBalanceOld)) | |
501 | + | let bonus = toInt(fraction((toBigInt(issueAmount) - lpAmtBoth), scale8BigInt, lpAmtBoth)) | |
502 | + | $Tuple4(issueAmount, commonState, feeAmount, bonus) | |
503 | + | } | |
504 | + | else throw("Strict value is not equal to itself.") | |
454 | 505 | } | |
455 | 506 | ||
456 | 507 | ||
457 | 508 | func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = { | |
458 | 509 | let isEval = (txId == unit) | |
459 | - | let $ | |
460 | - | let poolAddress = $ | |
461 | - | let poolStatus = $ | |
462 | - | let lpAssetId = $ | |
463 | - | let amountAssetId = $ | |
464 | - | let priceAssetId = $ | |
465 | - | let | |
466 | - | let | |
510 | + | let $t02502725188 = parsePoolConfig(getPoolConfig()) | |
511 | + | let poolAddress = $t02502725188._1 | |
512 | + | let poolStatus = $t02502725188._2 | |
513 | + | let lpAssetId = $t02502725188._3 | |
514 | + | let amountAssetId = $t02502725188._4 | |
515 | + | let priceAssetId = $t02502725188._5 | |
516 | + | let amDecimals = $t02502725188._6 | |
517 | + | let prDecimals = $t02502725188._7 | |
467 | 518 | let checks = [if ((paymentAssetId == lpAssetId)) | |
468 | 519 | then true | |
469 | 520 | else throw("invalid lp asset")] | |
470 | 521 | if ((checks == checks)) | |
471 | 522 | then { | |
472 | - | let balanceBigInt = if ((outAssetId == amountAssetId)) | |
523 | + | let outInAmountAsset = if ((outAssetId == amountAssetId)) | |
524 | + | then true | |
525 | + | else if ((outAssetId == priceAssetId)) | |
526 | + | then false | |
527 | + | else throwErr("invalid asset") | |
528 | + | let balanceBigInt = if (outInAmountAsset) | |
473 | 529 | then toBigInt(getAccBalance(assetIdToString(amountAssetId))) | |
474 | - | else if ((outAssetId == priceAssetId)) | |
475 | - | then toBigInt(getAccBalance(assetIdToString(priceAssetId))) | |
476 | - | else throwErr("invalid asset") | |
530 | + | else toBigInt(getAccBalance(assetIdToString(priceAssetId))) | |
531 | + | let amBalanceOld = getAccBalance(assetIdToString(amountAssetId)) | |
532 | + | let prBalanceOld = getAccBalance(assetIdToString(priceAssetId)) | |
533 | + | let outBalance = if (outInAmountAsset) | |
534 | + | then amBalanceOld | |
535 | + | else prBalanceOld | |
536 | + | let outBalanceBigInt = toBigInt(outBalance) | |
477 | 537 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(lpAssetId), (("asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity) | |
478 | 538 | let redeemedBigInt = toBigInt(paymentAmount) | |
479 | - | let amount = ((balanceBigInt * (scale8BigInt - pow((scale8BigInt - ((redeemedBigInt * scale8BigInt) / supplyBigInt)), 8, big2, 0, 8, DOWN))) / scale8BigInt) | |
480 | - | toInt(amount) | |
539 | + | let amountRaw = toInt(((balanceBigInt * (scale8BigInt - pow((scale8BigInt - ((redeemedBigInt * scale8BigInt) / supplyBigInt)), 8, big2, 0, 8, DOWN))) / scale8BigInt)) | |
540 | + | let $t02625526305 = takeFee(amountRaw) | |
541 | + | let totalAmount = $t02625526305._1 | |
542 | + | let feeAmount = $t02625526305._2 | |
543 | + | let $t02630926535 = if (outInAmountAsset) | |
544 | + | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
545 | + | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
546 | + | let outAmAmount = $t02630926535._1 | |
547 | + | let outPrAmount = $t02630926535._2 | |
548 | + | let amBalanceNew = $t02630926535._3 | |
549 | + | let prBalanceNew = $t02630926535._4 | |
550 | + | let curPrX18 = calcPriceBigInt(toX18(prBalanceNew, prDecimals), toX18(amBalanceNew, amDecimals)) | |
551 | + | let curPrice = fromX18(curPrX18, scale8) | |
552 | + | let commonState = if (isEval) | |
553 | + | then nil | |
554 | + | else [StringEntry(gau(toString(value(userAddress)), toBase58String(value(txId))), dataGetActionInfo(outAmAmount, outPrAmount, paymentAmount, curPrice, height, lastBlock.timestamp)), IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice)] | |
555 | + | let r = estimateGetOperation("", assetIdToString(lpAssetId), paymentAmount, this) | |
556 | + | let sumOfGetAssets = (r._1 + r._2) | |
557 | + | let bonus = fraction((totalAmount - sumOfGetAssets), scale8, sumOfGetAssets) | |
558 | + | $Tuple4(totalAmount, commonState, feeAmount, bonus) | |
481 | 559 | } | |
482 | 560 | else throw("Strict value is not equal to itself.") | |
483 | 561 | } | |
621 | 699 | ||
622 | 700 | @Callable(i) | |
623 | 701 | func putOneTkn (minOutAmount,autoStake) = { | |
624 | - | let $ | |
625 | - | let poolAddress = $ | |
626 | - | let poolStatus = $ | |
627 | - | let lpAssetId = $ | |
628 | - | let amountAssetId = $ | |
629 | - | let priceAssetId = $ | |
630 | - | let amountAssetDecimals = $ | |
631 | - | let priceAssetDecimals = $ | |
702 | + | let $t03042630604 = parsePoolConfig(getPoolConfig()) | |
703 | + | let poolAddress = $t03042630604._1 | |
704 | + | let poolStatus = $t03042630604._2 | |
705 | + | let lpAssetId = $t03042630604._3 | |
706 | + | let amountAssetId = $t03042630604._4 | |
707 | + | let priceAssetId = $t03042630604._5 | |
708 | + | let amountAssetDecimals = $t03042630604._6 | |
709 | + | let priceAssetDecimals = $t03042630604._7 | |
632 | 710 | let isPutDisabled = if (if (isGlobalShutdown()) | |
633 | 711 | then true | |
634 | 712 | else (poolStatus == PoolPutDisabled)) | |
647 | 725 | let paymentAmount = paymentAmountRaw | |
648 | 726 | let userAddress = i.caller | |
649 | 727 | let txId = i.transactionId | |
650 | - | let emitAmount = { | |
651 | - | let emitAmountEstimated = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
652 | - | if (if ((minOutAmount > 0)) | |
653 | - | then (minOutAmount > emitAmountEstimated) | |
654 | - | else false) | |
655 | - | then throw(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
656 | - | else emitAmountEstimated | |
657 | - | } | |
728 | + | let $t03109131218 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
729 | + | let emitAmountEstimated = $t03109131218._1 | |
730 | + | let commonState = $t03109131218._2 | |
731 | + | let feeAmount = $t03109131218._3 | |
732 | + | let bonus = $t03109131218._4 | |
733 | + | let emitAmount = if (if ((minOutAmount > 0)) | |
734 | + | then (minOutAmount > emitAmountEstimated) | |
735 | + | else false) | |
736 | + | then throw(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
737 | + | else emitAmountEstimated | |
658 | 738 | let emitInv = emit(emitAmount) | |
659 | 739 | if ((emitInv == emitInv)) | |
660 | 740 | then { | |
666 | 746 | else throw("Strict value is not equal to itself.") | |
667 | 747 | } | |
668 | 748 | else [ScriptTransfer(i.caller, emitAmount, lpAssetId)] | |
669 | - | $Tuple2(lpTransfer, emitAmount) | |
749 | + | let sendFee = if ((feeAmount > 0)) | |
750 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
751 | + | else nil | |
752 | + | $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount) | |
670 | 753 | } | |
671 | 754 | else throw("Strict value is not equal to itself.") | |
672 | 755 | } | |
677 | 760 | ||
678 | 761 | @Callable(i) | |
679 | 762 | func getOneTkn (outAssetId,minOutAmount,unstakeAmount) = { | |
680 | - | let $ | |
681 | - | let poolAddress = $ | |
682 | - | let poolStatus = $ | |
683 | - | let lpAssetId = $ | |
684 | - | let amountAssetId = $ | |
685 | - | let priceAssetId = $ | |
686 | - | let amountAssetDecimals = $ | |
687 | - | let priceAssetDecimals = $ | |
763 | + | let $t03194232120 = parsePoolConfig(getPoolConfig()) | |
764 | + | let poolAddress = $t03194232120._1 | |
765 | + | let poolStatus = $t03194232120._2 | |
766 | + | let lpAssetId = $t03194232120._3 | |
767 | + | let amountAssetId = $t03194232120._4 | |
768 | + | let priceAssetId = $t03194232120._5 | |
769 | + | let amountAssetDecimals = $t03194232120._6 | |
770 | + | let priceAssetDecimals = $t03194232120._7 | |
688 | 771 | let isGetDisabled = if (isGlobalShutdown()) | |
689 | 772 | then true | |
690 | 773 | else (poolStatus == PoolShutdown) | |
700 | 783 | let paymentAmount = payment.amount | |
701 | 784 | let userAddress = i.caller | |
702 | 785 | let txId = i.transactionId | |
703 | - | let amount = { | |
704 | - | let amountEstimated = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, paymentAssetId, userAddress, txId) | |
705 | - | if (if ((minOutAmount > 0)) | |
706 | - | then (minOutAmount > amountEstimated) | |
707 | - | else false) | |
708 | - | then throw(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
709 | - | else amountEstimated | |
710 | - | } | |
786 | + | let $t03253132678 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, paymentAssetId, userAddress, txId) | |
787 | + | let amountEstimated = $t03253132678._1 | |
788 | + | let commonState = $t03253132678._2 | |
789 | + | let feeAmount = $t03253132678._3 | |
790 | + | let bonus = $t03253132678._4 | |
791 | + | let amount = if (if ((minOutAmount > 0)) | |
792 | + | then (minOutAmount > amountEstimated) | |
793 | + | else false) | |
794 | + | then throw(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
795 | + | else amountEstimated | |
711 | 796 | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
712 | 797 | if ((burnInv == burnInv)) | |
713 | 798 | then { |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let lPdecimals = 8 | |
5 | 5 | ||
6 | 6 | let scale8 = 100000000 | |
7 | 7 | ||
8 | 8 | let scale8BigInt = toBigInt(100000000) | |
9 | 9 | ||
10 | 10 | let scale18 = toBigInt(1000000000000000000) | |
11 | 11 | ||
12 | 12 | let zeroBigInt = toBigInt(0) | |
13 | 13 | ||
14 | 14 | let big0 = toBigInt(0) | |
15 | 15 | ||
16 | 16 | let big1 = toBigInt(1) | |
17 | 17 | ||
18 | 18 | let big2 = toBigInt(1) | |
19 | 19 | ||
20 | 20 | let wavesString = "WAVES" | |
21 | 21 | ||
22 | 22 | let SEP = "__" | |
23 | 23 | ||
24 | 24 | let PoolActive = 1 | |
25 | 25 | ||
26 | 26 | let PoolPutDisabled = 2 | |
27 | 27 | ||
28 | 28 | let PoolMatcherDisabled = 3 | |
29 | 29 | ||
30 | 30 | let PoolShutdown = 4 | |
31 | 31 | ||
32 | 32 | let idxPoolAddress = 1 | |
33 | 33 | ||
34 | 34 | let idxPoolStatus = 2 | |
35 | 35 | ||
36 | 36 | let idxPoolLPAssetId = 3 | |
37 | 37 | ||
38 | 38 | let idxAmtAssetId = 4 | |
39 | 39 | ||
40 | 40 | let idxPriceAssetId = 5 | |
41 | 41 | ||
42 | 42 | let idxAmtAssetDcm = 6 | |
43 | 43 | ||
44 | 44 | let idxPriceAssetDcm = 7 | |
45 | 45 | ||
46 | 46 | let idxIAmtAssetId = 8 | |
47 | 47 | ||
48 | 48 | let idxIPriceAssetId = 9 | |
49 | 49 | ||
50 | 50 | let idxLPAssetDcm = 10 | |
51 | 51 | ||
52 | 52 | let idxPoolAmtAssetAmt = 1 | |
53 | 53 | ||
54 | 54 | let idxPoolPriceAssetAmt = 2 | |
55 | 55 | ||
56 | 56 | let idxPoolLPAssetAmt = 3 | |
57 | 57 | ||
58 | 58 | let idxFactoryStakingContract = 1 | |
59 | 59 | ||
60 | 60 | let idxFactorySlippageContract = 7 | |
61 | 61 | ||
62 | 62 | func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult)) | |
63 | 63 | ||
64 | 64 | ||
65 | 65 | func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18)) | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
69 | 69 | ||
70 | 70 | ||
71 | 71 | func abs (val) = if ((zeroBigInt > val)) | |
72 | 72 | then -(val) | |
73 | 73 | else val | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | func fc () = "%s__factoryContract" | |
77 | 77 | ||
78 | 78 | ||
79 | 79 | func mpk () = "%s__managerPublicKey" | |
80 | 80 | ||
81 | 81 | ||
82 | 82 | func pmpk () = "%s__pendingManagerPublicKey" | |
83 | 83 | ||
84 | 84 | ||
85 | 85 | func pl () = "%s%s__price__last" | |
86 | 86 | ||
87 | 87 | ||
88 | 88 | func ph (h,timestamp) = makeString(["%s%s%d%d__price__history", toString(h), toString(timestamp)], SEP) | |
89 | 89 | ||
90 | 90 | ||
91 | 91 | func pau (userAddress,txId) = ((("%s%s%s__P__" + userAddress) + "__") + txId) | |
92 | 92 | ||
93 | 93 | ||
94 | 94 | func gau (userAddress,txId) = ((("%s%s%s__G__" + userAddress) + "__") + txId) | |
95 | 95 | ||
96 | 96 | ||
97 | 97 | func aa () = "%s__amountAsset" | |
98 | 98 | ||
99 | 99 | ||
100 | 100 | func pa () = "%s__priceAsset" | |
101 | 101 | ||
102 | 102 | ||
103 | + | let keyFee = "%s__fee" | |
104 | + | ||
105 | + | let feeDefault = fraction(5, scale8, 10000) | |
106 | + | ||
107 | + | let fee = valueOrElse(getInteger(this, keyFee), feeDefault) | |
108 | + | ||
103 | 109 | func keyFactoryConfig () = "%s__factoryConfig" | |
104 | 110 | ||
105 | 111 | ||
106 | 112 | func keyMatcherPub () = "%s%s__matcher__publicKey" | |
107 | 113 | ||
108 | 114 | ||
109 | 115 | func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset") | |
110 | 116 | ||
111 | 117 | ||
112 | 118 | func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config") | |
113 | 119 | ||
114 | 120 | ||
115 | 121 | func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr) | |
116 | 122 | ||
117 | 123 | ||
118 | 124 | func keyAllPoolsShutdown () = "%s__shutdown" | |
119 | 125 | ||
120 | 126 | ||
121 | 127 | func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress) | |
122 | 128 | ||
123 | 129 | ||
124 | 130 | func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash" | |
125 | 131 | ||
126 | 132 | ||
133 | + | let keyFeeCollectorAddress = "%s__feeCollectorAddress" | |
134 | + | ||
127 | 135 | func throwOrderError (orderValid,senderValid,matcherValid) = throw(((((("order validation failed: orderValid=" + toString(orderValid)) + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid))) | |
128 | 136 | ||
129 | 137 | ||
130 | 138 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
131 | 139 | ||
132 | 140 | ||
133 | 141 | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
134 | 142 | ||
135 | 143 | ||
136 | 144 | func throwErr (msg) = throw(makeString(["lp.ride:", msg], " ")) | |
137 | 145 | ||
138 | 146 | ||
139 | 147 | let factoryContract = addressFromStringValue(getStringOrFail(this, fc())) | |
148 | + | ||
149 | + | let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress)) | |
140 | 150 | ||
141 | 151 | func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false) | |
142 | 152 | ||
143 | 153 | ||
144 | 154 | func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub())) | |
145 | 155 | ||
146 | 156 | ||
147 | 157 | func getPoolConfig () = { | |
148 | 158 | let amtAsset = getStringOrFail(this, aa()) | |
149 | 159 | let priceAsset = getStringOrFail(this, pa()) | |
150 | 160 | let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset)) | |
151 | 161 | let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset)) | |
152 | 162 | split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP) | |
153 | 163 | } | |
154 | 164 | ||
155 | 165 | ||
156 | 166 | func parseAssetId (input) = if ((input == wavesString)) | |
157 | 167 | then unit | |
158 | 168 | else fromBase58String(input) | |
159 | 169 | ||
160 | 170 | ||
161 | 171 | func assetIdToString (input) = if ((input == unit)) | |
162 | 172 | then wavesString | |
163 | 173 | else toBase58String(value(input)) | |
164 | 174 | ||
165 | 175 | ||
166 | 176 | func parsePoolConfig (poolConfig) = $Tuple7(addressFromStringValue(poolConfig[idxPoolAddress]), parseIntValue(poolConfig[idxPoolStatus]), fromBase58String(poolConfig[idxPoolLPAssetId]), parseAssetId(poolConfig[idxAmtAssetId]), parseAssetId(poolConfig[idxPriceAssetId]), parseIntValue(poolConfig[idxAmtAssetDcm]), parseIntValue(poolConfig[idxPriceAssetDcm])) | |
167 | 177 | ||
168 | 178 | ||
169 | 179 | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
170 | 180 | ||
171 | 181 | ||
172 | 182 | let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address") | |
173 | 183 | ||
174 | 184 | let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address") | |
175 | 185 | ||
176 | 186 | func dataPutActionInfo (inAmtAssetAmt,inPriceAssetAmt,outLpAmt,price,slippageTolerancePassedByUser,slippageToleranceReal,txHeight,txTimestamp,slipageAmtAssetAmt,slipagePriceAssetAmt) = makeString(["%d%d%d%d%d%d%d%d%d%d", toString(inAmtAssetAmt), toString(inPriceAssetAmt), toString(outLpAmt), toString(price), toString(slippageTolerancePassedByUser), toString(slippageToleranceReal), toString(txHeight), toString(txTimestamp), toString(slipageAmtAssetAmt), toString(slipagePriceAssetAmt)], SEP) | |
177 | 187 | ||
178 | 188 | ||
179 | 189 | 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) | |
180 | 190 | ||
181 | 191 | ||
182 | 192 | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
183 | 193 | then wavesBalance(this).available | |
184 | 194 | else assetBalance(this, fromBase58String(assetId)) | |
185 | 195 | ||
186 | 196 | ||
187 | 197 | func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
188 | 198 | ||
189 | 199 | ||
190 | 200 | func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
191 | 201 | let amtAssetAmtX18 = toX18(amAmt, amAssetDcm) | |
192 | 202 | let priceAssetAmtX18 = toX18(prAmt, prAssetDcm) | |
193 | 203 | calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
194 | 204 | } | |
195 | 205 | ||
196 | 206 | ||
197 | 207 | func calcPrices (amAmt,prAmt,lpAmt) = { | |
198 | 208 | let cfg = getPoolConfig() | |
199 | 209 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
200 | 210 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
201 | 211 | let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt) | |
202 | 212 | let amAmtX18 = toX18(amAmt, amtAssetDcm) | |
203 | 213 | let prAmtX18 = toX18(prAmt, priceAssetDcm) | |
204 | 214 | let lpAmtX18 = toX18(lpAmt, scale8) | |
205 | 215 | let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18) | |
206 | 216 | let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18) | |
207 | 217 | [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18] | |
208 | 218 | } | |
209 | 219 | ||
210 | 220 | ||
211 | 221 | func calculatePrices (amAmt,prAmt,lpAmt) = { | |
212 | 222 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
213 | 223 | [fromX18(prices[0], scale8), fromX18(prices[1], scale8), fromX18(prices[2], scale8)] | |
214 | 224 | } | |
215 | 225 | ||
216 | 226 | ||
217 | 227 | func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
218 | 228 | let cfg = getPoolConfig() | |
219 | 229 | let lpAssetId = cfg[idxPoolLPAssetId] | |
220 | 230 | let amAssetId = cfg[idxAmtAssetId] | |
221 | 231 | let prAssetId = cfg[idxPriceAssetId] | |
222 | 232 | let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
223 | 233 | let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
224 | 234 | let poolStatus = cfg[idxPoolStatus] | |
225 | 235 | let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity | |
226 | 236 | if ((lpAssetId != pmtAssetId)) | |
227 | 237 | then throw("Invalid asset passed.") | |
228 | 238 | else { | |
229 | 239 | let amBalance = getAccBalance(amAssetId) | |
230 | 240 | let amBalanceX18 = toX18(amBalance, amAssetDcm) | |
231 | 241 | let prBalance = getAccBalance(prAssetId) | |
232 | 242 | let prBalanceX18 = toX18(prBalance, prAssetDcm) | |
233 | 243 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
234 | 244 | let curPrice = fromX18(curPriceX18, scale8) | |
235 | 245 | let pmtLpAmtX18 = toX18(pmtLpAmt, scale8) | |
236 | 246 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
237 | 247 | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
238 | 248 | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
239 | 249 | let outAmAmt = fromX18(outAmAmtX18, amAssetDcm) | |
240 | 250 | let outPrAmt = fromX18(outPrAmtX18, prAssetDcm) | |
241 | 251 | let state = if ((txId58 == "")) | |
242 | 252 | then nil | |
243 | 253 | else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
244 | 254 | then unit | |
245 | 255 | else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES")) | |
246 | 256 | then unit | |
247 | 257 | else fromBase58String(prAssetId)), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAmAmt, outPrAmt, pmtLpAmt, curPrice, height, lastBlock.timestamp)), IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice)] | |
248 | 258 | $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state) | |
249 | 259 | } | |
250 | 260 | } | |
251 | 261 | ||
252 | 262 | ||
253 | 263 | func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = { | |
254 | 264 | let cfg = getPoolConfig() | |
255 | 265 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
256 | 266 | let amAssetIdStr = cfg[idxAmtAssetId] | |
257 | 267 | let prAssetIdStr = cfg[idxPriceAssetId] | |
258 | 268 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
259 | 269 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
260 | 270 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
261 | 271 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
262 | 272 | let poolStatus = cfg[idxPoolStatus] | |
263 | 273 | let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
264 | 274 | let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES"))) | |
265 | 275 | let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES"))) | |
266 | 276 | if (if ((amAssetIdStr != inAmAssetIdStr)) | |
267 | 277 | then true | |
268 | 278 | else (prAssetIdStr != inPrAssetIdStr)) | |
269 | 279 | then throw("Invalid amt or price asset passed.") | |
270 | 280 | else { | |
271 | 281 | let amBalance = if (isEvaluate) | |
272 | 282 | then getAccBalance(amAssetIdStr) | |
273 | 283 | else (getAccBalance(amAssetIdStr) - inAmAssetAmt) | |
274 | 284 | let prBalance = if (isEvaluate) | |
275 | 285 | then getAccBalance(prAssetIdStr) | |
276 | 286 | else (getAccBalance(prAssetIdStr) - inPrAssetAmt) | |
277 | 287 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
278 | 288 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
279 | 289 | let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18) | |
280 | 290 | let amBalanceX18 = toX18(amBalance, amtAssetDcm) | |
281 | 291 | let prBalanceX18 = toX18(prBalance, priceAssetDcm) | |
282 | 292 | let res = if ((lpEmission == 0)) | |
283 | 293 | then { | |
284 | 294 | let curPriceX18 = zeroBigInt | |
285 | 295 | let slippageX18 = zeroBigInt | |
286 | 296 | let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN) | |
287 | 297 | $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
288 | 298 | } | |
289 | 299 | else { | |
290 | 300 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
291 | 301 | let slippageX18 = fraction(abs((curPriceX18 - userPriceX18)), scale18, curPriceX18) | |
292 | 302 | let slippageToleranceX18 = toX18(slippageTolerance, scale8) | |
293 | 303 | if (if ((curPriceX18 != zeroBigInt)) | |
294 | 304 | then (slippageX18 > slippageToleranceX18) | |
295 | 305 | else false) | |
296 | 306 | then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18))) | |
297 | 307 | else { | |
298 | 308 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
299 | 309 | let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
300 | 310 | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
301 | 311 | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
302 | 312 | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
303 | 313 | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
304 | 314 | let expAmtAssetAmtX18 = expectedAmts._1 | |
305 | 315 | let expPriceAssetAmtX18 = expectedAmts._2 | |
306 | 316 | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18) | |
307 | 317 | $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18) | |
308 | 318 | } | |
309 | 319 | } | |
310 | 320 | let calcLpAmt = res._1 | |
311 | 321 | let calcAmAssetPmt = res._2 | |
312 | 322 | let calcPrAssetPmt = res._3 | |
313 | 323 | let curPrice = fromX18(res._4, scale8) | |
314 | 324 | let slippageCalc = fromX18(res._5, scale8) | |
315 | 325 | if ((0 >= calcLpAmt)) | |
316 | 326 | then throw("Invalid calculations. LP calculated is less than zero.") | |
317 | 327 | else { | |
318 | 328 | let emitLpAmt = if (!(emitLp)) | |
319 | 329 | then 0 | |
320 | 330 | else calcLpAmt | |
321 | 331 | let amDiff = (inAmAssetAmt - calcAmAssetPmt) | |
322 | 332 | let prDiff = (inPrAssetAmt - calcPrAssetPmt) | |
323 | 333 | let commonState = [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(userAddress, txId58), dataPutActionInfo(calcAmAssetPmt, calcPrAssetPmt, emitLpAmt, curPrice, slippageTolerance, slippageCalc, height, lastBlock.timestamp, amDiff, prDiff))] | |
324 | 334 | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId) | |
325 | 335 | } | |
326 | 336 | } | |
327 | 337 | } | |
328 | 338 | ||
329 | 339 | ||
330 | 340 | func validateMatcherOrderAllowed (order) = { | |
331 | 341 | let cfg = getPoolConfig() | |
332 | 342 | let amtAssetId = cfg[idxAmtAssetId] | |
333 | 343 | let priceAssetId = cfg[idxPriceAssetId] | |
334 | 344 | let poolStatus = parseIntValue(cfg[idxPoolStatus]) | |
335 | 345 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
336 | 346 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
337 | 347 | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
338 | 348 | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
339 | 349 | let curPriceX18 = if ((order.orderType == Buy)) | |
340 | 350 | then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance) | |
341 | 351 | else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance) | |
342 | 352 | let curPrice = fromX18(curPriceX18, scale8) | |
343 | 353 | if (if (if (isGlobalShutdown()) | |
344 | 354 | then true | |
345 | 355 | else (poolStatus == PoolMatcherDisabled)) | |
346 | 356 | then true | |
347 | 357 | else (poolStatus == PoolShutdown)) | |
348 | 358 | then throw("Exchange operations disabled") | |
349 | 359 | else { | |
350 | 360 | let orderAmtAsset = order.assetPair.amountAsset | |
351 | 361 | let orderAmtAssetStr = if ((orderAmtAsset == unit)) | |
352 | 362 | then "WAVES" | |
353 | 363 | else toBase58String(value(orderAmtAsset)) | |
354 | 364 | let orderPriceAsset = order.assetPair.priceAsset | |
355 | 365 | let orderPriceAssetStr = if ((orderPriceAsset == unit)) | |
356 | 366 | then "WAVES" | |
357 | 367 | else toBase58String(value(orderPriceAsset)) | |
358 | 368 | if (if ((orderAmtAssetStr != amtAssetId)) | |
359 | 369 | then true | |
360 | 370 | else (orderPriceAssetStr != priceAssetId)) | |
361 | 371 | then throw("Wrong order assets.") | |
362 | 372 | else { | |
363 | 373 | let orderPrice = order.price | |
364 | 374 | let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm) | |
365 | 375 | let castedOrderPrice = toScale(orderPrice, scale8, priceDcm) | |
366 | 376 | let isOrderPriceValid = if ((order.orderType == Buy)) | |
367 | 377 | then (curPrice >= castedOrderPrice) | |
368 | 378 | else (castedOrderPrice >= curPrice) | |
369 | 379 | true | |
370 | 380 | } | |
371 | 381 | } | |
372 | 382 | } | |
373 | 383 | ||
374 | 384 | ||
375 | 385 | func commonGet (i) = if ((size(i.payments) != 1)) | |
376 | 386 | then throw("exactly 1 payment is expected") | |
377 | 387 | else { | |
378 | 388 | let pmt = value(i.payments[0]) | |
379 | 389 | let pmtAssetId = value(pmt.assetId) | |
380 | 390 | let pmtAmt = pmt.amount | |
381 | 391 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
382 | 392 | let outAmAmt = res._1 | |
383 | 393 | let outPrAmt = res._2 | |
384 | 394 | let poolStatus = parseIntValue(res._9) | |
385 | 395 | let state = res._10 | |
386 | 396 | if (if (isGlobalShutdown()) | |
387 | 397 | then true | |
388 | 398 | else (poolStatus == PoolShutdown)) | |
389 | 399 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
390 | 400 | else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state) | |
391 | 401 | } | |
392 | 402 | ||
393 | 403 | ||
394 | 404 | func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2)) | |
395 | 405 | then throw("exactly 2 payments are expected") | |
396 | 406 | else { | |
397 | 407 | let amAssetPmt = value(i.payments[0]) | |
398 | 408 | let prAssetPmt = value(i.payments[1]) | |
399 | 409 | let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp) | |
400 | 410 | let poolStatus = parseIntValue(estPut._8) | |
401 | 411 | if (if (if (isGlobalShutdown()) | |
402 | 412 | then true | |
403 | 413 | else (poolStatus == PoolPutDisabled)) | |
404 | 414 | then true | |
405 | 415 | else (poolStatus == PoolShutdown)) | |
406 | 416 | then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus))) | |
407 | 417 | else estPut | |
408 | 418 | } | |
409 | 419 | ||
410 | 420 | ||
411 | 421 | func emit (amount) = { | |
412 | 422 | let emitInv = invoke(factoryContract, "emit", [amount], nil) | |
413 | 423 | if ((emitInv == emitInv)) | |
414 | 424 | then { | |
415 | 425 | let emitInvLegacy = match emitInv { | |
416 | 426 | case legacyFactoryContract: Address => | |
417 | 427 | invoke(legacyFactoryContract, "emit", [amount], nil) | |
418 | 428 | case _ => | |
419 | 429 | unit | |
420 | 430 | } | |
421 | 431 | if ((emitInvLegacy == emitInvLegacy)) | |
422 | 432 | then amount | |
423 | 433 | else throw("Strict value is not equal to itself.") | |
424 | 434 | } | |
425 | 435 | else throw("Strict value is not equal to itself.") | |
426 | 436 | } | |
427 | 437 | ||
428 | 438 | ||
439 | + | func takeFee (amount) = { | |
440 | + | let feeAmount = fraction(amount, fee, scale8) | |
441 | + | $Tuple2((amount - feeAmount), feeAmount) | |
442 | + | } | |
443 | + | ||
444 | + | ||
429 | 445 | func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = { | |
430 | 446 | let isEval = (txId == unit) | |
431 | - | let $t02148521663 = parsePoolConfig(getPoolConfig()) | |
432 | - | let poolAddress = $t02148521663._1 | |
433 | - | let poolStatus = $t02148521663._2 | |
434 | - | let lpAssetId = $t02148521663._3 | |
435 | - | let amountAssetId = $t02148521663._4 | |
436 | - | let priceAssetId = $t02148521663._5 | |
437 | - | let amountAssetDecimals = $t02148521663._6 | |
438 | - | let priceAssetDecimals = $t02148521663._7 | |
439 | - | let paymentAmount = paymentAmountRaw | |
440 | - | let balanceRaw = if ((paymentAssetId == amountAssetId)) | |
441 | - | then getAccBalance(assetIdToString(amountAssetId)) | |
447 | + | let $t02194222120 = parsePoolConfig(getPoolConfig()) | |
448 | + | let poolAddress = $t02194222120._1 | |
449 | + | let poolStatus = $t02194222120._2 | |
450 | + | let lpAssetId = $t02194222120._3 | |
451 | + | let amountAssetId = $t02194222120._4 | |
452 | + | let priceAssetId = $t02194222120._5 | |
453 | + | let amountAssetDecimals = $t02194222120._6 | |
454 | + | let priceAssetDecimals = $t02194222120._7 | |
455 | + | let amountBalanceRaw = getAccBalance(assetIdToString(amountAssetId)) | |
456 | + | let priceBalanceRaw = getAccBalance(assetIdToString(priceAssetId)) | |
457 | + | let paymentInAmountAsset = if ((paymentAssetId == amountAssetId)) | |
458 | + | then true | |
442 | 459 | else if ((paymentAssetId == priceAssetId)) | |
443 | - | then | |
460 | + | then false | |
444 | 461 | else throwErr("invalid asset") | |
445 | - | let amountToSubtract = if (isEval) | |
446 | - | then 0 | |
447 | - | else paymentAmount | |
448 | - | let balance = (balanceRaw - amountToSubtract) | |
449 | - | let balanceBigInt = toBigInt(balance) | |
462 | + | let $t02245022743 = if (isEval) | |
463 | + | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
464 | + | else if (paymentInAmountAsset) | |
465 | + | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
466 | + | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
467 | + | let amountBalanceOld = $t02245022743._1 | |
468 | + | let priceBalanceOld = $t02245022743._2 | |
469 | + | let $t02274722896 = if (paymentInAmountAsset) | |
470 | + | then $Tuple2(paymentAmountRaw, 0) | |
471 | + | else $Tuple2(0, paymentAmountRaw) | |
472 | + | let amountAssetAmountRaw = $t02274722896._1 | |
473 | + | let priceAssetAmountRaw = $t02274722896._2 | |
474 | + | let amountAssetAmount = takeFee(amountAssetAmountRaw)._1 | |
475 | + | let priceAssetAmount = takeFee(priceAssetAmountRaw)._1 | |
476 | + | let $t02301823077 = takeFee(paymentAmountRaw) | |
477 | + | let paymentAmount = $t02301823077._1 | |
478 | + | let feeAmount = $t02301823077._2 | |
479 | + | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
480 | + | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
481 | + | let curPrice = fromX18(calcPriceBigInt(toX18(priceBalanceNew, priceAssetDecimals), toX18(amountBalanceNew, amountAssetDecimals)), scale8) | |
482 | + | let paymentBalance = if (paymentInAmountAsset) | |
483 | + | then amountBalanceOld | |
484 | + | else priceBalanceOld | |
485 | + | let paymentBalanceBigInt = toBigInt(paymentBalance) | |
450 | 486 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(lpAssetId), (("asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity) | |
451 | - | let depositBigInt = toBigInt(paymentAmount) | |
452 | - | let issueAmount = ((supplyBigInt * (sqrtBigInt((scale8BigInt + ((depositBigInt * scale8BigInt) / balanceBigInt)), 8, 8, DOWN) - scale8BigInt)) / scale8BigInt) | |
453 | - | toInt(issueAmount) | |
487 | + | let chechSupply = if ((supplyBigInt > big0)) | |
488 | + | then true | |
489 | + | else throw("initial deposit requires all coins") | |
490 | + | if ((chechSupply == chechSupply)) | |
491 | + | then { | |
492 | + | let depositBigInt = toBigInt(paymentAmount) | |
493 | + | let issueAmount = toInt(((supplyBigInt * (sqrtBigInt((scale8BigInt + ((depositBigInt * scale8BigInt) / paymentBalanceBigInt)), 8, 8, DOWN) - scale8BigInt)) / scale8BigInt)) | |
494 | + | let commonState = if (isEval) | |
495 | + | then nil | |
496 | + | else [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(toString(value(userAddress)), toBase58String(value(txId))), dataPutActionInfo(amountAssetAmountRaw, priceAssetAmountRaw, issueAmount, curPrice, 0, 0, height, lastBlock.timestamp, 0, 0))] | |
497 | + | let poolProportion = fraction(priceBalanceOld, scale8, amountBalanceOld) | |
498 | + | let amountAssetPart = fraction(paymentAmountRaw, scale8, (poolProportion + scale8)) | |
499 | + | let priceAssetPart = (paymentAmountRaw - amountAssetPart) | |
500 | + | let lpAmtBoth = fraction(supplyBigInt, toBigInt(priceAssetPart), toBigInt(priceBalanceOld)) | |
501 | + | let bonus = toInt(fraction((toBigInt(issueAmount) - lpAmtBoth), scale8BigInt, lpAmtBoth)) | |
502 | + | $Tuple4(issueAmount, commonState, feeAmount, bonus) | |
503 | + | } | |
504 | + | else throw("Strict value is not equal to itself.") | |
454 | 505 | } | |
455 | 506 | ||
456 | 507 | ||
457 | 508 | func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = { | |
458 | 509 | let isEval = (txId == unit) | |
459 | - | let $ | |
460 | - | let poolAddress = $ | |
461 | - | let poolStatus = $ | |
462 | - | let lpAssetId = $ | |
463 | - | let amountAssetId = $ | |
464 | - | let priceAssetId = $ | |
465 | - | let | |
466 | - | let | |
510 | + | let $t02502725188 = parsePoolConfig(getPoolConfig()) | |
511 | + | let poolAddress = $t02502725188._1 | |
512 | + | let poolStatus = $t02502725188._2 | |
513 | + | let lpAssetId = $t02502725188._3 | |
514 | + | let amountAssetId = $t02502725188._4 | |
515 | + | let priceAssetId = $t02502725188._5 | |
516 | + | let amDecimals = $t02502725188._6 | |
517 | + | let prDecimals = $t02502725188._7 | |
467 | 518 | let checks = [if ((paymentAssetId == lpAssetId)) | |
468 | 519 | then true | |
469 | 520 | else throw("invalid lp asset")] | |
470 | 521 | if ((checks == checks)) | |
471 | 522 | then { | |
472 | - | let balanceBigInt = if ((outAssetId == amountAssetId)) | |
523 | + | let outInAmountAsset = if ((outAssetId == amountAssetId)) | |
524 | + | then true | |
525 | + | else if ((outAssetId == priceAssetId)) | |
526 | + | then false | |
527 | + | else throwErr("invalid asset") | |
528 | + | let balanceBigInt = if (outInAmountAsset) | |
473 | 529 | then toBigInt(getAccBalance(assetIdToString(amountAssetId))) | |
474 | - | else if ((outAssetId == priceAssetId)) | |
475 | - | then toBigInt(getAccBalance(assetIdToString(priceAssetId))) | |
476 | - | else throwErr("invalid asset") | |
530 | + | else toBigInt(getAccBalance(assetIdToString(priceAssetId))) | |
531 | + | let amBalanceOld = getAccBalance(assetIdToString(amountAssetId)) | |
532 | + | let prBalanceOld = getAccBalance(assetIdToString(priceAssetId)) | |
533 | + | let outBalance = if (outInAmountAsset) | |
534 | + | then amBalanceOld | |
535 | + | else prBalanceOld | |
536 | + | let outBalanceBigInt = toBigInt(outBalance) | |
477 | 537 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(lpAssetId), (("asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity) | |
478 | 538 | let redeemedBigInt = toBigInt(paymentAmount) | |
479 | - | let amount = ((balanceBigInt * (scale8BigInt - pow((scale8BigInt - ((redeemedBigInt * scale8BigInt) / supplyBigInt)), 8, big2, 0, 8, DOWN))) / scale8BigInt) | |
480 | - | toInt(amount) | |
539 | + | let amountRaw = toInt(((balanceBigInt * (scale8BigInt - pow((scale8BigInt - ((redeemedBigInt * scale8BigInt) / supplyBigInt)), 8, big2, 0, 8, DOWN))) / scale8BigInt)) | |
540 | + | let $t02625526305 = takeFee(amountRaw) | |
541 | + | let totalAmount = $t02625526305._1 | |
542 | + | let feeAmount = $t02625526305._2 | |
543 | + | let $t02630926535 = if (outInAmountAsset) | |
544 | + | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
545 | + | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
546 | + | let outAmAmount = $t02630926535._1 | |
547 | + | let outPrAmount = $t02630926535._2 | |
548 | + | let amBalanceNew = $t02630926535._3 | |
549 | + | let prBalanceNew = $t02630926535._4 | |
550 | + | let curPrX18 = calcPriceBigInt(toX18(prBalanceNew, prDecimals), toX18(amBalanceNew, amDecimals)) | |
551 | + | let curPrice = fromX18(curPrX18, scale8) | |
552 | + | let commonState = if (isEval) | |
553 | + | then nil | |
554 | + | else [StringEntry(gau(toString(value(userAddress)), toBase58String(value(txId))), dataGetActionInfo(outAmAmount, outPrAmount, paymentAmount, curPrice, height, lastBlock.timestamp)), IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice)] | |
555 | + | let r = estimateGetOperation("", assetIdToString(lpAssetId), paymentAmount, this) | |
556 | + | let sumOfGetAssets = (r._1 + r._2) | |
557 | + | let bonus = fraction((totalAmount - sumOfGetAssets), scale8, sumOfGetAssets) | |
558 | + | $Tuple4(totalAmount, commonState, feeAmount, bonus) | |
481 | 559 | } | |
482 | 560 | else throw("Strict value is not equal to itself.") | |
483 | 561 | } | |
484 | 562 | ||
485 | 563 | ||
486 | 564 | func managerPublicKeyOrUnit () = match getString(mpk()) { | |
487 | 565 | case s: String => | |
488 | 566 | fromBase58String(s) | |
489 | 567 | case _: Unit => | |
490 | 568 | unit | |
491 | 569 | case _ => | |
492 | 570 | throw("Match error") | |
493 | 571 | } | |
494 | 572 | ||
495 | 573 | ||
496 | 574 | func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) { | |
497 | 575 | case s: String => | |
498 | 576 | fromBase58String(s) | |
499 | 577 | case _: Unit => | |
500 | 578 | unit | |
501 | 579 | case _ => | |
502 | 580 | throw("Match error") | |
503 | 581 | } | |
504 | 582 | ||
505 | 583 | ||
506 | 584 | func mustManager (i) = { | |
507 | 585 | let pd = throw("Permission denied") | |
508 | 586 | match managerPublicKeyOrUnit() { | |
509 | 587 | case pk: ByteVector => | |
510 | 588 | if ((i.callerPublicKey == pk)) | |
511 | 589 | then true | |
512 | 590 | else pd | |
513 | 591 | case _: Unit => | |
514 | 592 | if ((i.caller == this)) | |
515 | 593 | then true | |
516 | 594 | else pd | |
517 | 595 | case _ => | |
518 | 596 | throw("Match error") | |
519 | 597 | } | |
520 | 598 | } | |
521 | 599 | ||
522 | 600 | ||
523 | 601 | @Callable(i) | |
524 | 602 | func setManager (pendingManagerPublicKey) = { | |
525 | 603 | let checkCaller = mustManager(i) | |
526 | 604 | if ((checkCaller == checkCaller)) | |
527 | 605 | then { | |
528 | 606 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
529 | 607 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
530 | 608 | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
531 | 609 | else throw("Strict value is not equal to itself.") | |
532 | 610 | } | |
533 | 611 | else throw("Strict value is not equal to itself.") | |
534 | 612 | } | |
535 | 613 | ||
536 | 614 | ||
537 | 615 | ||
538 | 616 | @Callable(i) | |
539 | 617 | func confirmManager () = { | |
540 | 618 | let pm = pendingManagerPublicKeyOrUnit() | |
541 | 619 | let hasPM = if (isDefined(pm)) | |
542 | 620 | then true | |
543 | 621 | else throw("No pending manager") | |
544 | 622 | if ((hasPM == hasPM)) | |
545 | 623 | then { | |
546 | 624 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
547 | 625 | then true | |
548 | 626 | else throw("You are not pending manager") | |
549 | 627 | if ((checkPM == checkPM)) | |
550 | 628 | then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())] | |
551 | 629 | else throw("Strict value is not equal to itself.") | |
552 | 630 | } | |
553 | 631 | else throw("Strict value is not equal to itself.") | |
554 | 632 | } | |
555 | 633 | ||
556 | 634 | ||
557 | 635 | ||
558 | 636 | @Callable(i) | |
559 | 637 | func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance)) | |
560 | 638 | then throw("Invalid slippageTolerance passed") | |
561 | 639 | else { | |
562 | 640 | let estPut = commonPut(i, slippageTolerance, true) | |
563 | 641 | let emitLpAmt = estPut._2 | |
564 | 642 | let lpAssetId = estPut._7 | |
565 | 643 | let state = estPut._9 | |
566 | 644 | let amDiff = estPut._10 | |
567 | 645 | let prDiff = estPut._11 | |
568 | 646 | let amId = estPut._12 | |
569 | 647 | let prId = estPut._13 | |
570 | 648 | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
571 | 649 | if ((emitInv == emitInv)) | |
572 | 650 | then { | |
573 | 651 | let emitInvLegacy = match emitInv { | |
574 | 652 | case legacyFactoryContract: Address => | |
575 | 653 | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
576 | 654 | case _ => | |
577 | 655 | unit | |
578 | 656 | } | |
579 | 657 | if ((emitInvLegacy == emitInvLegacy)) | |
580 | 658 | then { | |
581 | 659 | let slippageAInv = if ((amDiff > 0)) | |
582 | 660 | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
583 | 661 | else nil | |
584 | 662 | if ((slippageAInv == slippageAInv)) | |
585 | 663 | then { | |
586 | 664 | let slippagePInv = if ((prDiff > 0)) | |
587 | 665 | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
588 | 666 | else nil | |
589 | 667 | if ((slippagePInv == slippagePInv)) | |
590 | 668 | then { | |
591 | 669 | let lpTransfer = if (shouldAutoStake) | |
592 | 670 | then { | |
593 | 671 | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
594 | 672 | if ((slpStakeInv == slpStakeInv)) | |
595 | 673 | then nil | |
596 | 674 | else throw("Strict value is not equal to itself.") | |
597 | 675 | } | |
598 | 676 | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
599 | 677 | (state ++ lpTransfer) | |
600 | 678 | } | |
601 | 679 | else throw("Strict value is not equal to itself.") | |
602 | 680 | } | |
603 | 681 | else throw("Strict value is not equal to itself.") | |
604 | 682 | } | |
605 | 683 | else throw("Strict value is not equal to itself.") | |
606 | 684 | } | |
607 | 685 | else throw("Strict value is not equal to itself.") | |
608 | 686 | } | |
609 | 687 | ||
610 | 688 | ||
611 | 689 | ||
612 | 690 | @Callable(i) | |
613 | 691 | func putForFree (maxSlippage) = if ((0 > maxSlippage)) | |
614 | 692 | then throw("Invalid value passed") | |
615 | 693 | else { | |
616 | 694 | let estPut = commonPut(i, maxSlippage, false) | |
617 | 695 | estPut._9 | |
618 | 696 | } | |
619 | 697 | ||
620 | 698 | ||
621 | 699 | ||
622 | 700 | @Callable(i) | |
623 | 701 | func putOneTkn (minOutAmount,autoStake) = { | |
624 | - | let $ | |
625 | - | let poolAddress = $ | |
626 | - | let poolStatus = $ | |
627 | - | let lpAssetId = $ | |
628 | - | let amountAssetId = $ | |
629 | - | let priceAssetId = $ | |
630 | - | let amountAssetDecimals = $ | |
631 | - | let priceAssetDecimals = $ | |
702 | + | let $t03042630604 = parsePoolConfig(getPoolConfig()) | |
703 | + | let poolAddress = $t03042630604._1 | |
704 | + | let poolStatus = $t03042630604._2 | |
705 | + | let lpAssetId = $t03042630604._3 | |
706 | + | let amountAssetId = $t03042630604._4 | |
707 | + | let priceAssetId = $t03042630604._5 | |
708 | + | let amountAssetDecimals = $t03042630604._6 | |
709 | + | let priceAssetDecimals = $t03042630604._7 | |
632 | 710 | let isPutDisabled = if (if (isGlobalShutdown()) | |
633 | 711 | then true | |
634 | 712 | else (poolStatus == PoolPutDisabled)) | |
635 | 713 | then true | |
636 | 714 | else (poolStatus == PoolShutdown) | |
637 | 715 | let checks = [if (!(isPutDisabled)) | |
638 | 716 | then true | |
639 | 717 | else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1)) | |
640 | 718 | then true | |
641 | 719 | else throwErr("exactly 1 payment are expected")] | |
642 | 720 | if ((checks == checks)) | |
643 | 721 | then { | |
644 | 722 | let payment = i.payments[0] | |
645 | 723 | let paymentAssetId = payment.assetId | |
646 | 724 | let paymentAmountRaw = payment.amount | |
647 | 725 | let paymentAmount = paymentAmountRaw | |
648 | 726 | let userAddress = i.caller | |
649 | 727 | let txId = i.transactionId | |
650 | - | let emitAmount = { | |
651 | - | let emitAmountEstimated = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
652 | - | if (if ((minOutAmount > 0)) | |
653 | - | then (minOutAmount > emitAmountEstimated) | |
654 | - | else false) | |
655 | - | then throw(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
656 | - | else emitAmountEstimated | |
657 | - | } | |
728 | + | let $t03109131218 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
729 | + | let emitAmountEstimated = $t03109131218._1 | |
730 | + | let commonState = $t03109131218._2 | |
731 | + | let feeAmount = $t03109131218._3 | |
732 | + | let bonus = $t03109131218._4 | |
733 | + | let emitAmount = if (if ((minOutAmount > 0)) | |
734 | + | then (minOutAmount > emitAmountEstimated) | |
735 | + | else false) | |
736 | + | then throw(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
737 | + | else emitAmountEstimated | |
658 | 738 | let emitInv = emit(emitAmount) | |
659 | 739 | if ((emitInv == emitInv)) | |
660 | 740 | then { | |
661 | 741 | let lpTransfer = if (autoStake) | |
662 | 742 | then { | |
663 | 743 | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitAmount)]) | |
664 | 744 | if ((stakeInv == stakeInv)) | |
665 | 745 | then nil | |
666 | 746 | else throw("Strict value is not equal to itself.") | |
667 | 747 | } | |
668 | 748 | else [ScriptTransfer(i.caller, emitAmount, lpAssetId)] | |
669 | - | $Tuple2(lpTransfer, emitAmount) | |
749 | + | let sendFee = if ((feeAmount > 0)) | |
750 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
751 | + | else nil | |
752 | + | $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount) | |
670 | 753 | } | |
671 | 754 | else throw("Strict value is not equal to itself.") | |
672 | 755 | } | |
673 | 756 | else throw("Strict value is not equal to itself.") | |
674 | 757 | } | |
675 | 758 | ||
676 | 759 | ||
677 | 760 | ||
678 | 761 | @Callable(i) | |
679 | 762 | func getOneTkn (outAssetId,minOutAmount,unstakeAmount) = { | |
680 | - | let $ | |
681 | - | let poolAddress = $ | |
682 | - | let poolStatus = $ | |
683 | - | let lpAssetId = $ | |
684 | - | let amountAssetId = $ | |
685 | - | let priceAssetId = $ | |
686 | - | let amountAssetDecimals = $ | |
687 | - | let priceAssetDecimals = $ | |
763 | + | let $t03194232120 = parsePoolConfig(getPoolConfig()) | |
764 | + | let poolAddress = $t03194232120._1 | |
765 | + | let poolStatus = $t03194232120._2 | |
766 | + | let lpAssetId = $t03194232120._3 | |
767 | + | let amountAssetId = $t03194232120._4 | |
768 | + | let priceAssetId = $t03194232120._5 | |
769 | + | let amountAssetDecimals = $t03194232120._6 | |
770 | + | let priceAssetDecimals = $t03194232120._7 | |
688 | 771 | let isGetDisabled = if (isGlobalShutdown()) | |
689 | 772 | then true | |
690 | 773 | else (poolStatus == PoolShutdown) | |
691 | 774 | let checks = [if (!(isGetDisabled)) | |
692 | 775 | then true | |
693 | 776 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1)) | |
694 | 777 | then true | |
695 | 778 | else throwErr("exactly 1 payment are expected")] | |
696 | 779 | if ((checks == checks)) | |
697 | 780 | then { | |
698 | 781 | let payment = i.payments[0] | |
699 | 782 | let paymentAssetId = payment.assetId | |
700 | 783 | let paymentAmount = payment.amount | |
701 | 784 | let userAddress = i.caller | |
702 | 785 | let txId = i.transactionId | |
703 | - | let amount = { | |
704 | - | let amountEstimated = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, paymentAssetId, userAddress, txId) | |
705 | - | if (if ((minOutAmount > 0)) | |
706 | - | then (minOutAmount > amountEstimated) | |
707 | - | else false) | |
708 | - | then throw(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
709 | - | else amountEstimated | |
710 | - | } | |
786 | + | let $t03253132678 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, paymentAssetId, userAddress, txId) | |
787 | + | let amountEstimated = $t03253132678._1 | |
788 | + | let commonState = $t03253132678._2 | |
789 | + | let feeAmount = $t03253132678._3 | |
790 | + | let bonus = $t03253132678._4 | |
791 | + | let amount = if (if ((minOutAmount > 0)) | |
792 | + | then (minOutAmount > amountEstimated) | |
793 | + | else false) | |
794 | + | then throw(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
795 | + | else amountEstimated | |
711 | 796 | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
712 | 797 | if ((burnInv == burnInv)) | |
713 | 798 | then { | |
714 | 799 | let assetTransfer = [ScriptTransfer(userAddress, amount, parseAssetId(outAssetId))] | |
715 | 800 | $Tuple2(assetTransfer, amount) | |
716 | 801 | } | |
717 | 802 | else throw("Strict value is not equal to itself.") | |
718 | 803 | } | |
719 | 804 | else throw("Strict value is not equal to itself.") | |
720 | 805 | } | |
721 | 806 | ||
722 | 807 | ||
723 | 808 | ||
724 | 809 | @Callable(i) | |
725 | 810 | func get () = { | |
726 | 811 | let res = commonGet(i) | |
727 | 812 | let outAmtAmt = res._1 | |
728 | 813 | let outPrAmt = res._2 | |
729 | 814 | let pmtAmt = res._3 | |
730 | 815 | let pmtAssetId = res._4 | |
731 | 816 | let state = res._5 | |
732 | 817 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
733 | 818 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
734 | 819 | then state | |
735 | 820 | else throw("Strict value is not equal to itself.") | |
736 | 821 | } | |
737 | 822 | ||
738 | 823 | ||
739 | 824 | ||
740 | 825 | @Callable(i) | |
741 | 826 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
742 | 827 | let res = commonGet(i) | |
743 | 828 | let outAmAmt = res._1 | |
744 | 829 | let outPrAmt = res._2 | |
745 | 830 | let pmtAmt = res._3 | |
746 | 831 | let pmtAssetId = res._4 | |
747 | 832 | let state = res._5 | |
748 | 833 | if ((noLessThenAmtAsset > outAmAmt)) | |
749 | 834 | then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
750 | 835 | else if ((noLessThenPriceAsset > outPrAmt)) | |
751 | 836 | then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
752 | 837 | else { | |
753 | 838 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
754 | 839 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
755 | 840 | then state | |
756 | 841 | else throw("Strict value is not equal to itself.") | |
757 | 842 | } | |
758 | 843 | } | |
759 | 844 | ||
760 | 845 | ||
761 | 846 | ||
762 | 847 | @Callable(i) | |
763 | 848 | func unstakeAndGet (amount) = { | |
764 | 849 | let checkPayments = if ((size(i.payments) != 0)) | |
765 | 850 | then throw("No payments are expected") | |
766 | 851 | else true | |
767 | 852 | if ((checkPayments == checkPayments)) | |
768 | 853 | then { | |
769 | 854 | let cfg = getPoolConfig() | |
770 | 855 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
771 | 856 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil) | |
772 | 857 | if ((unstakeInv == unstakeInv)) | |
773 | 858 | then { | |
774 | 859 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
775 | 860 | let poolStatus = parseIntValue(res._9) | |
776 | 861 | let state = res._10 | |
777 | 862 | let checkPoolStatus = if (if (isGlobalShutdown()) | |
778 | 863 | then true | |
779 | 864 | else (poolStatus == PoolShutdown)) | |
780 | 865 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
781 | 866 | else true | |
782 | 867 | if ((checkPoolStatus == checkPoolStatus)) | |
783 | 868 | then { | |
784 | 869 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
785 | 870 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
786 | 871 | then state | |
787 | 872 | else throw("Strict value is not equal to itself.") | |
788 | 873 | } | |
789 | 874 | else throw("Strict value is not equal to itself.") | |
790 | 875 | } | |
791 | 876 | else throw("Strict value is not equal to itself.") | |
792 | 877 | } | |
793 | 878 | else throw("Strict value is not equal to itself.") | |
794 | 879 | } | |
795 | 880 | ||
796 | 881 | ||
797 | 882 | ||
798 | 883 | @Callable(i) | |
799 | 884 | func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract))) | |
800 | 885 | then throw("permissions denied") | |
801 | 886 | else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success") | |
802 | 887 | ||
803 | 888 | ||
804 | 889 | ||
805 | 890 | @Callable(i) | |
806 | 891 | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig()) | |
807 | 892 | ||
808 | 893 | ||
809 | 894 | ||
810 | 895 | @Callable(i) | |
811 | 896 | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
812 | 897 | ||
813 | 898 | ||
814 | 899 | ||
815 | 900 | @Callable(i) | |
816 | 901 | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
817 | 902 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
818 | 903 | $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])]) | |
819 | 904 | } | |
820 | 905 | ||
821 | 906 | ||
822 | 907 | ||
823 | 908 | @Callable(i) | |
824 | 909 | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult))) | |
825 | 910 | ||
826 | 911 | ||
827 | 912 | ||
828 | 913 | @Callable(i) | |
829 | 914 | func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult)) | |
830 | 915 | ||
831 | 916 | ||
832 | 917 | ||
833 | 918 | @Callable(i) | |
834 | 919 | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
835 | 920 | ||
836 | 921 | ||
837 | 922 | ||
838 | 923 | @Callable(i) | |
839 | 924 | func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp)) | |
840 | 925 | ||
841 | 926 | ||
842 | 927 | ||
843 | 928 | @Callable(i) | |
844 | 929 | func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
845 | 930 | let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress)) | |
846 | 931 | $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10)) | |
847 | 932 | } | |
848 | 933 | ||
849 | 934 | ||
850 | 935 | ||
851 | 936 | @Callable(i) | |
852 | 937 | func statsREADONLY () = { | |
853 | 938 | let cfg = getPoolConfig() | |
854 | 939 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
855 | 940 | let amtAssetId = cfg[idxAmtAssetId] | |
856 | 941 | let priceAssetId = cfg[idxPriceAssetId] | |
857 | 942 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
858 | 943 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
859 | 944 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
860 | 945 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
861 | 946 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
862 | 947 | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
863 | 948 | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
864 | 949 | let pricesList = if ((poolLPBalance == 0)) | |
865 | 950 | then [zeroBigInt, zeroBigInt, zeroBigInt] | |
866 | 951 | else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance) | |
867 | 952 | let curPrice = 0 | |
868 | 953 | let lpAmtAssetShare = fromX18(pricesList[1], scale8) | |
869 | 954 | let lpPriceAssetShare = fromX18(pricesList[2], scale8) | |
870 | 955 | let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this)))) | |
871 | 956 | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d", toString(accAmtAssetBalance), toString(accPriceAssetBalance), toString(poolLPBalance), toString(curPrice), toString(lpAmtAssetShare), toString(lpPriceAssetShare), toString(poolWeight)], SEP)) | |
872 | 957 | } | |
873 | 958 | ||
874 | 959 | ||
875 | 960 | ||
876 | 961 | @Callable(i) | |
877 | 962 | func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = { | |
878 | 963 | let cfg = getPoolConfig() | |
879 | 964 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
880 | 965 | let amAssetIdStr = cfg[idxAmtAssetId] | |
881 | 966 | let amAssetId = fromBase58String(amAssetIdStr) | |
882 | 967 | let prAssetIdStr = cfg[idxPriceAssetId] | |
883 | 968 | let prAssetId = fromBase58String(prAssetIdStr) | |
884 | 969 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
885 | 970 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
886 | 971 | let poolStatus = cfg[idxPoolStatus] | |
887 | 972 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
888 | 973 | let accAmtAssetBalance = getAccBalance(amAssetIdStr) | |
889 | 974 | let accPriceAssetBalance = getAccBalance(prAssetIdStr) | |
890 | 975 | let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm) | |
891 | 976 | let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm) | |
892 | 977 | let curPriceX18 = if ((poolLPBalance == 0)) | |
893 | 978 | then zeroBigInt | |
894 | 979 | else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
895 | 980 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
896 | 981 | let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
897 | 982 | let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm) | |
898 | 983 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
899 | 984 | let calcLpAmt = estPut._1 | |
900 | 985 | let curPriceCalc = estPut._3 | |
901 | 986 | let amBalance = estPut._4 | |
902 | 987 | let prBalance = estPut._5 | |
903 | 988 | let lpEmission = estPut._6 | |
904 | 989 | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d%d", toString(calcLpAmt), toString(fromX18(curPriceX18, scale8)), toString(amBalance), toString(prBalance), toString(lpEmission), poolStatus, toString(inAmAssetAmt), toString(inPrAssetAmt)], SEP)) | |
905 | 990 | } | |
906 | 991 | ||
907 | 992 | ||
908 | 993 | ||
909 | 994 | @Callable(i) | |
910 | 995 | func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = { | |
911 | 996 | let cfg = getPoolConfig() | |
912 | 997 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
913 | 998 | let amAssetIdStr = cfg[idxAmtAssetId] | |
914 | 999 | let amAssetId = fromBase58String(amAssetIdStr) | |
915 | 1000 | let prAssetIdStr = cfg[idxPriceAssetId] | |
916 | 1001 | let prAssetId = fromBase58String(prAssetIdStr) | |
917 | 1002 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
918 | 1003 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
919 | 1004 | let poolStatus = cfg[idxPoolStatus] | |
920 | 1005 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
921 | 1006 | let amBalanceRaw = getAccBalance(amAssetIdStr) | |
922 | 1007 | let prBalanceRaw = getAccBalance(prAssetIdStr) | |
923 | 1008 | let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm) | |
924 | 1009 | let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm) | |
925 | 1010 | let curPriceX18 = if ((poolLPBalance == 0)) | |
926 | 1011 | then zeroBigInt | |
927 | 1012 | else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18) | |
928 | 1013 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
929 | 1014 | let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
930 | 1015 | let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm) | |
931 | 1016 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
932 | 1017 | let calcLpAmt = estPut._1 | |
933 | 1018 | let curPriceCalc = estPut._3 | |
934 | 1019 | let amBalance = estPut._4 | |
935 | 1020 | let prBalance = estPut._5 | |
936 | 1021 | let lpEmission = estPut._6 | |
937 | 1022 | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d%d", toString(calcLpAmt), toString(fromX18(curPriceX18, scale8)), toString(amBalance), toString(prBalance), toString(lpEmission), poolStatus, toString(inAmAssetAmt), toString(inPrAssetAmt)], SEP)) | |
938 | 1023 | } | |
939 | 1024 | ||
940 | 1025 | ||
941 | 1026 | ||
942 | 1027 | @Callable(i) | |
943 | 1028 | func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = { | |
944 | 1029 | let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this) | |
945 | 1030 | let outAmAmt = res._1 | |
946 | 1031 | let outPrAmt = res._2 | |
947 | 1032 | let amBalance = res._5 | |
948 | 1033 | let prBalance = res._6 | |
949 | 1034 | let lpEmission = res._7 | |
950 | 1035 | let curPrice = res._8 | |
951 | 1036 | let poolStatus = parseIntValue(res._9) | |
952 | 1037 | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d", toString(outAmAmt), toString(outPrAmt), toString(amBalance), toString(prBalance), toString(lpEmission), toString(curPrice), toString(poolStatus)], SEP)) | |
953 | 1038 | } | |
954 | 1039 | ||
955 | 1040 | ||
956 | 1041 | @Verifier(tx) | |
957 | 1042 | func verify () = { | |
958 | 1043 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
959 | 1044 | case pk: ByteVector => | |
960 | 1045 | pk | |
961 | 1046 | case _: Unit => | |
962 | 1047 | tx.senderPublicKey | |
963 | 1048 | case _ => | |
964 | 1049 | throw("Match error") | |
965 | 1050 | } | |
966 | 1051 | match tx { | |
967 | 1052 | case order: Order => | |
968 | 1053 | let matcherPub = getMatcherPubOrFail() | |
969 | 1054 | let orderValid = validateMatcherOrderAllowed(order) | |
970 | 1055 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
971 | 1056 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
972 | 1057 | if (if (if (orderValid) | |
973 | 1058 | then senderValid | |
974 | 1059 | else false) | |
975 | 1060 | then matcherValid | |
976 | 1061 | else false) | |
977 | 1062 | then true | |
978 | 1063 | else throwOrderError(orderValid, senderValid, matcherValid) | |
979 | 1064 | case s: SetScriptTransaction => | |
980 | 1065 | let newHash = blake2b256(value(s.script)) | |
981 | 1066 | let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash()))) | |
982 | 1067 | let currentHash = scriptHash(this) | |
983 | 1068 | if (if ((allowedHash == newHash)) | |
984 | 1069 | then (currentHash != newHash) | |
985 | 1070 | else false) | |
986 | 1071 | then true | |
987 | 1072 | else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
988 | 1073 | case _ => | |
989 | 1074 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
990 | 1075 | } | |
991 | 1076 | } | |
992 | 1077 |
github/deemru/w8io/169f3d6 95.60 ms ◑