tx · 2WZQJkLuV6HaW6B1cZLLx9pvy5zeH9UJFxZemzS9zuWu 3N8WuBjQMQE3EL6bnrQifBKswJTBoQBioa4: -0.03400000 Waves 2022.12.06 17:12 [2348591] smart account 3N8WuBjQMQE3EL6bnrQifBKswJTBoQBioa4 > SELF 0.00000000 Waves
{ "type": 13, "id": "2WZQJkLuV6HaW6B1cZLLx9pvy5zeH9UJFxZemzS9zuWu", "fee": 3400000, "feeAssetId": null, "timestamp": 1670335792657, "version": 1, "sender": "3N8WuBjQMQE3EL6bnrQifBKswJTBoQBioa4", "senderPublicKey": "233hzBgW8CWQjBMZqjU8qQFzxHgwg2D2zYpDA7XEuNV9", "proofs": [ "4f5Zt8AsbYq3oRPVFaGKxdRvHCjsy1j7ZXorDSRokGFDBywgFUv9RgmDtqkRLPMvvsuNPi6Hro4c76LYkNcrC3wY" ], "script": "base64:BgLYLAgCEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgQKAggBEgQKAggBEgQKAggBEgUKAwEIARIAEgQKAgEBEgMKAQESBQoDAQEBEgQKAggIEgASABIDCgEIEgUKAwEBARIECgIBARIECgIIARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCBIAEgMKAQESAwoBARIECgIIASIKbFBkZWNpbWFscyIGc2NhbGU4IgxzY2FsZThCaWdJbnQiB3NjYWxlMTgiCnplcm9CaWdJbnQiBGJpZzAiBGJpZzEiBGJpZzIiC3dhdmVzU3RyaW5nIgNTRVAiClBvb2xBY3RpdmUiD1Bvb2xQdXREaXNhYmxlZCITUG9vbE1hdGNoZXJEaXNhYmxlZCIMUG9vbFNodXRkb3duIg5pZHhQb29sQWRkcmVzcyINaWR4UG9vbFN0YXR1cyIQaWR4UG9vbExQQXNzZXRJZCINaWR4QW10QXNzZXRJZCIPaWR4UHJpY2VBc3NldElkIg5pZHhBbXRBc3NldERjbSIQaWR4UHJpY2VBc3NldERjbSIOaWR4SUFtdEFzc2V0SWQiEGlkeElQcmljZUFzc2V0SWQiDWlkeExQ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IBQJneAZwcm9vZnMAAAUCZ3oAsH45", "chainId": 84, "height": 2348591, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BMWB4huJVgzt59VrVV8TwPVQDFoVyaWC469ePqK9GRyD Next: 9CbVCaFW6E8ceRXufPYCB4TALwdhsgd3tA7zuikKmACX Diff:
Old | New | Differences | |
---|---|---|---|
379 | 379 | } | |
380 | 380 | ||
381 | 381 | ||
382 | + | func calcCurrentKLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = { | |
383 | + | let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta) | |
384 | + | let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta) | |
385 | + | let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta) | |
386 | + | let currentKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpAssetEmission) | |
387 | + | currentKLp | |
388 | + | } | |
389 | + | ||
390 | + | ||
382 | 391 | func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
383 | 392 | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
384 | 393 | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
389 | 398 | } | |
390 | 399 | ||
391 | 400 | ||
392 | - | func validateUpdatedKLp (updatedKLp) = { | |
393 | - | let amountAssetBalance = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
394 | - | let priceAssetBalance = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
395 | - | let lpAssetEmission = value(assetInfo(cfgLpAssetId)).quantity | |
396 | - | let currentKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
397 | - | if ((updatedKLp >= currentKLp)) | |
398 | - | then true | |
399 | - | else throwErr("updated KLp lower than current KLp") | |
400 | - | } | |
401 | + | func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp)) | |
402 | + | then true | |
403 | + | else throwErr("updated KLp lower than current KLp") | |
401 | 404 | ||
402 | 405 | ||
403 | 406 | func validateMatcherOrderAllowed (order) = { | |
404 | 407 | let amountAssetAmount = order.amount | |
405 | 408 | let priceAssetAmount = fraction(order.amount, order.price, scale8) | |
406 | - | let $ | |
409 | + | let $t02021820430 = if ((order.orderType == Buy)) | |
407 | 410 | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
408 | 411 | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
409 | - | let amountAssetBalanceDelta = $ | |
410 | - | let priceAssetBalanceDelta = $ | |
412 | + | let amountAssetBalanceDelta = $t02021820430._1 | |
413 | + | let priceAssetBalanceDelta = $t02021820430._2 | |
411 | 414 | if (if (if (isGlobalShutdown()) | |
412 | 415 | then true | |
413 | 416 | else (cfgPoolStatus == PoolMatcherDisabled)) | |
420 | 423 | then throw("Wrong order assets.") | |
421 | 424 | else { | |
422 | 425 | let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp")) | |
423 | - | let $ | |
424 | - | let unusedActions = $ | |
425 | - | let kLpNew = $ | |
426 | + | let $t02090121001 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
427 | + | let unusedActions = $t02090121001._1 | |
428 | + | let kLpNew = $t02090121001._2 | |
426 | 429 | let isOrderValid = (kLpNew > kLp) | |
427 | 430 | isOrderValid | |
428 | 431 | } | |
498 | 501 | else if ((paymentAssetId == cfgPriceAssetId)) | |
499 | 502 | then false | |
500 | 503 | else throwErr("invalid asset") | |
501 | - | let $ | |
504 | + | let $t02368523978 = if (isEval) | |
502 | 505 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
503 | 506 | else if (paymentInAmountAsset) | |
504 | 507 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
505 | 508 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
506 | - | let amountBalanceOld = $ | |
507 | - | let priceBalanceOld = $ | |
508 | - | let $ | |
509 | + | let amountBalanceOld = $t02368523978._1 | |
510 | + | let priceBalanceOld = $t02368523978._2 | |
511 | + | let $t02398224131 = if (paymentInAmountAsset) | |
509 | 512 | then $Tuple2(paymentAmountRaw, 0) | |
510 | 513 | else $Tuple2(0, paymentAmountRaw) | |
511 | - | let amountAssetAmountRaw = $ | |
512 | - | let priceAssetAmountRaw = $ | |
514 | + | let amountAssetAmountRaw = $t02398224131._1 | |
515 | + | let priceAssetAmountRaw = $t02398224131._2 | |
513 | 516 | let amountAssetAmount = takeFee(amountAssetAmountRaw)._1 | |
514 | 517 | let priceAssetAmount = takeFee(priceAssetAmountRaw)._1 | |
515 | - | let $ | |
516 | - | let paymentAmount = $ | |
517 | - | let feeAmount = $ | |
518 | + | let $t02425324312 = takeFee(paymentAmountRaw) | |
519 | + | let paymentAmount = $t02425324312._1 | |
520 | + | let feeAmount = $t02425324312._2 | |
518 | 521 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
519 | 522 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
520 | 523 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
537 | 540 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
538 | 541 | let priceOld = fromX18(priceOldX18, scale8) | |
539 | 542 | let loss = { | |
540 | - | let $ | |
543 | + | let $t02578925956 = if (paymentInAmountAsset) | |
541 | 544 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
542 | 545 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
543 | - | let amount = $ | |
544 | - | let balance = $ | |
546 | + | let amount = $t02578925956._1 | |
547 | + | let balance = $t02578925956._2 | |
545 | 548 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
546 | 549 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
547 | 550 | } | |
575 | 578 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
576 | 579 | let redeemedBigInt = toBigInt(paymentAmount) | |
577 | 580 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
578 | - | let $ | |
579 | - | let totalAmount = $ | |
580 | - | let feeAmount = $ | |
581 | - | let $ | |
581 | + | let $t02755827608 = takeFee(amountRaw) | |
582 | + | let totalAmount = $t02755827608._1 | |
583 | + | let feeAmount = $t02755827608._2 | |
584 | + | let $t02761227838 = if (outInAmountAsset) | |
582 | 585 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
583 | 586 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
584 | - | let outAmAmount = $ | |
585 | - | let outPrAmount = $ | |
586 | - | let amBalanceNew = $ | |
587 | - | let prBalanceNew = $ | |
587 | + | let outAmAmount = $t02761227838._1 | |
588 | + | let outPrAmount = $t02761227838._2 | |
589 | + | let amBalanceNew = $t02761227838._3 | |
590 | + | let prBalanceNew = $t02761227838._4 | |
588 | 591 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
589 | 592 | let priceNew = fromX18(priceNewX18, scale8) | |
590 | 593 | let commonState = if (isEval) | |
696 | 699 | let prDiff = estPut._11 | |
697 | 700 | let amId = estPut._12 | |
698 | 701 | let prId = estPut._13 | |
699 | - | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
700 | - | if ((emitInv == emitInv)) | |
702 | + | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
703 | + | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
704 | + | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
705 | + | if ((currentKLp == currentKLp)) | |
701 | 706 | then { | |
702 | - | let emitInvLegacy = match emitInv { | |
703 | - | case legacyFactoryContract: Address => | |
704 | - | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
705 | - | case _ => | |
706 | - | unit | |
707 | - | } | |
708 | - | if ((emitInvLegacy == emitInvLegacy)) | |
707 | + | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
708 | + | if ((emitInv == emitInv)) | |
709 | 709 | then { | |
710 | - | let slippageAInv = if ((amDiff > 0)) | |
711 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
712 | - | else nil | |
713 | - | if ((slippageAInv == slippageAInv)) | |
710 | + | let emitInvLegacy = match emitInv { | |
711 | + | case legacyFactoryContract: Address => | |
712 | + | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
713 | + | case _ => | |
714 | + | unit | |
715 | + | } | |
716 | + | if ((emitInvLegacy == emitInvLegacy)) | |
714 | 717 | then { | |
715 | - | let | |
716 | - | then invoke(slippageContract, "put", nil, [AttachedPayment( | |
718 | + | let slippageAInv = if ((amDiff > 0)) | |
719 | + | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
717 | 720 | else nil | |
718 | - | if (( | |
721 | + | if ((slippageAInv == slippageAInv)) | |
719 | 722 | then { | |
720 | - | let lpTransfer = if (shouldAutoStake) | |
723 | + | let slippagePInv = if ((prDiff > 0)) | |
724 | + | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
725 | + | else nil | |
726 | + | if ((slippagePInv == slippagePInv)) | |
721 | 727 | then { | |
722 | - | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
723 | - | if ((slpStakeInv == slpStakeInv)) | |
724 | - | then nil | |
728 | + | let lpTransfer = if (shouldAutoStake) | |
729 | + | then { | |
730 | + | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
731 | + | if ((slpStakeInv == slpStakeInv)) | |
732 | + | then nil | |
733 | + | else throw("Strict value is not equal to itself.") | |
734 | + | } | |
735 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
736 | + | let $t03199032055 = refreshKLpInternal(0, 0, 0) | |
737 | + | let refreshKLpActions = $t03199032055._1 | |
738 | + | let updatedKLp = $t03199032055._2 | |
739 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
740 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
741 | + | then ((state ++ lpTransfer) ++ refreshKLpActions) | |
725 | 742 | else throw("Strict value is not equal to itself.") | |
726 | 743 | } | |
727 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
728 | - | let $t03159631661 = refreshKLpInternal(0, 0, 0) | |
729 | - | let refreshKLpActions = $t03159631661._1 | |
730 | - | let updatedKLp = $t03159631661._2 | |
731 | - | let isUpdatedKLpValid = validateUpdatedKLp(updatedKLp) | |
732 | - | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
733 | - | then ((state ++ lpTransfer) ++ refreshKLpActions) | |
734 | 744 | else throw("Strict value is not equal to itself.") | |
735 | 745 | } | |
736 | 746 | else throw("Strict value is not equal to itself.") | |
750 | 760 | else { | |
751 | 761 | let estPut = commonPut(i, maxSlippage, false) | |
752 | 762 | let state = estPut._9 | |
753 | - | let $t03201032075 = refreshKLpInternal(0, 0, 0) | |
754 | - | let refreshKLpActions = $t03201032075._1 | |
755 | - | let updatedKLp = $t03201032075._2 | |
756 | - | let isUpdatedKLpValid = validateUpdatedKLp(updatedKLp) | |
757 | - | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
758 | - | then (state ++ refreshKLpActions) | |
763 | + | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
764 | + | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
765 | + | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
766 | + | if ((currentKLp == currentKLp)) | |
767 | + | then { | |
768 | + | let $t03261732682 = refreshKLpInternal(0, 0, 0) | |
769 | + | let refreshKLpActions = $t03261732682._1 | |
770 | + | let updatedKLp = $t03261732682._2 | |
771 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
772 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
773 | + | then (state ++ refreshKLpActions) | |
774 | + | else throw("Strict value is not equal to itself.") | |
775 | + | } | |
759 | 776 | else throw("Strict value is not equal to itself.") | |
760 | 777 | } | |
761 | 778 | ||
788 | 805 | let payment = i.payments[0] | |
789 | 806 | let paymentAssetId = payment.assetId | |
790 | 807 | let paymentAmountRaw = payment.amount | |
808 | + | let currentKLp = if ((paymentAssetId == cfgAmountAssetId)) | |
809 | + | then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0)) | |
810 | + | else if ((paymentAssetId == cfgPriceAssetId)) | |
811 | + | then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0)) | |
812 | + | else throwErr("payment asset is not supported") | |
791 | 813 | let userAddress = i.caller | |
792 | 814 | let txId = i.transactionId | |
793 | - | let $ | |
794 | - | if (($ | |
815 | + | let $t03386734019 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
816 | + | if (($t03386734019 == $t03386734019)) | |
795 | 817 | then { | |
796 | - | let paymentInAmountAsset = $ | |
797 | - | let bonus = $ | |
798 | - | let feeAmount = $ | |
799 | - | let commonState = $ | |
800 | - | let emitAmountEstimated = $ | |
818 | + | let paymentInAmountAsset = $t03386734019._5 | |
819 | + | let bonus = $t03386734019._4 | |
820 | + | let feeAmount = $t03386734019._3 | |
821 | + | let commonState = $t03386734019._2 | |
822 | + | let emitAmountEstimated = $t03386734019._1 | |
801 | 823 | let emitAmount = if (if ((minOutAmount > 0)) | |
802 | 824 | then (minOutAmount > emitAmountEstimated) | |
803 | 825 | else false) | |
817 | 839 | let sendFee = if ((feeAmount > 0)) | |
818 | 840 | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
819 | 841 | else nil | |
820 | - | let $ | |
842 | + | let $t03460534802 = if ((this == feeCollectorAddress)) | |
821 | 843 | then $Tuple2(0, 0) | |
822 | 844 | else if (paymentInAmountAsset) | |
823 | 845 | then $Tuple2(-(feeAmount), 0) | |
824 | 846 | else $Tuple2(0, -(feeAmount)) | |
825 | - | let amountAssetBalanceDelta = $ | |
826 | - | let priceAssetBalanceDelta = $ | |
827 | - | let $ | |
828 | - | let refreshKLpActions = $ | |
829 | - | let updatedKLp = $ | |
830 | - | let isUpdatedKLpValid = validateUpdatedKLp(updatedKLp) | |
847 | + | let amountAssetBalanceDelta = $t03460534802._1 | |
848 | + | let priceAssetBalanceDelta = $t03460534802._2 | |
849 | + | let $t03480534913 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
850 | + | let refreshKLpActions = $t03480534913._1 | |
851 | + | let updatedKLp = $t03480534913._2 | |
852 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
831 | 853 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
832 | 854 | then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
833 | 855 | else throw("Strict value is not equal to itself.") | |
843 | 865 | ||
844 | 866 | @Callable(i) | |
845 | 867 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
846 | - | let $ | |
847 | - | let emitAmountEstimated = $ | |
848 | - | let commonState = $ | |
849 | - | let feeAmount = $ | |
850 | - | let bonus = $ | |
851 | - | let paymentInAmountAsset = $ | |
868 | + | let $t03517935336 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
869 | + | let emitAmountEstimated = $t03517935336._1 | |
870 | + | let commonState = $t03517935336._2 | |
871 | + | let feeAmount = $t03517935336._3 | |
872 | + | let bonus = $t03517935336._4 | |
873 | + | let paymentInAmountAsset = $t03517935336._5 | |
852 | 874 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
853 | 875 | } | |
854 | 876 | ||
880 | 902 | let payment = i.payments[0] | |
881 | 903 | let paymentAssetId = payment.assetId | |
882 | 904 | let paymentAmount = payment.amount | |
905 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(paymentAmount)) | |
883 | 906 | let userAddress = i.caller | |
884 | 907 | let txId = i.transactionId | |
885 | - | let $ | |
886 | - | if (($ | |
908 | + | let $t03623036383 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
909 | + | if (($t03623036383 == $t03623036383)) | |
887 | 910 | then { | |
888 | - | let outInAmountAsset = $ | |
889 | - | let bonus = $ | |
890 | - | let feeAmount = $ | |
891 | - | let commonState = $ | |
892 | - | let amountEstimated = $ | |
911 | + | let outInAmountAsset = $t03623036383._5 | |
912 | + | let bonus = $t03623036383._4 | |
913 | + | let feeAmount = $t03623036383._3 | |
914 | + | let commonState = $t03623036383._2 | |
915 | + | let amountEstimated = $t03623036383._1 | |
893 | 916 | let amount = if (if ((minOutAmount > 0)) | |
894 | 917 | then (minOutAmount > amountEstimated) | |
895 | 918 | else false) | |
902 | 925 | let sendFee = if ((feeAmount > 0)) | |
903 | 926 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
904 | 927 | else nil | |
905 | - | let $ | |
928 | + | let $t03688337130 = { | |
906 | 929 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
907 | 930 | then 0 | |
908 | 931 | else feeAmount | |
910 | 933 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
911 | 934 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
912 | 935 | } | |
913 | - | let amountAssetBalanceDelta = $ | |
914 | - | let priceAssetBalanceDelta = $ | |
915 | - | let $ | |
916 | - | let refreshKLpActions = $ | |
917 | - | let updatedKLp = $ | |
918 | - | let isUpdatedKLpValid = validateUpdatedKLp(updatedKLp) | |
936 | + | let amountAssetBalanceDelta = $t03688337130._1 | |
937 | + | let priceAssetBalanceDelta = $t03688337130._2 | |
938 | + | let $t03713337241 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
939 | + | let refreshKLpActions = $t03713337241._1 | |
940 | + | let updatedKLp = $t03713337241._2 | |
941 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
919 | 942 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
920 | 943 | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
921 | 944 | else throw("Strict value is not equal to itself.") | |
931 | 954 | ||
932 | 955 | @Callable(i) | |
933 | 956 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
934 | - | let $ | |
935 | - | let amountEstimated = $ | |
936 | - | let commonState = $ | |
937 | - | let feeAmount = $ | |
938 | - | let bonus = $ | |
939 | - | let outInAmountAsset = $ | |
957 | + | let $t03749837654 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
958 | + | let amountEstimated = $t03749837654._1 | |
959 | + | let commonState = $t03749837654._2 | |
960 | + | let feeAmount = $t03749837654._3 | |
961 | + | let bonus = $t03749837654._4 | |
962 | + | let outInAmountAsset = $t03749837654._5 | |
940 | 963 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
941 | 964 | } | |
942 | 965 | ||
967 | 990 | let outAssetId = parseAssetId(outAssetIdStr) | |
968 | 991 | let userAddress = i.caller | |
969 | 992 | let txId = i.transactionId | |
993 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
970 | 994 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
971 | 995 | if ((unstakeInv == unstakeInv)) | |
972 | 996 | then { | |
973 | - | let $ | |
974 | - | if (($ | |
997 | + | let $t03855638707 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
998 | + | if (($t03855638707 == $t03855638707)) | |
975 | 999 | then { | |
976 | - | let outInAmountAsset = $ | |
977 | - | let bonus = $ | |
978 | - | let feeAmount = $ | |
979 | - | let commonState = $ | |
980 | - | let amountEstimated = $ | |
1000 | + | let outInAmountAsset = $t03855638707._5 | |
1001 | + | let bonus = $t03855638707._4 | |
1002 | + | let feeAmount = $t03855638707._3 | |
1003 | + | let commonState = $t03855638707._2 | |
1004 | + | let amountEstimated = $t03855638707._1 | |
981 | 1005 | let amount = if (if ((minOutAmount > 0)) | |
982 | 1006 | then (minOutAmount > amountEstimated) | |
983 | 1007 | else false) | |
990 | 1014 | let sendFee = if ((feeAmount > 0)) | |
991 | 1015 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
992 | 1016 | else nil | |
993 | - | let $ | |
1017 | + | let $t03920239449 = { | |
994 | 1018 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
995 | 1019 | then 0 | |
996 | 1020 | else feeAmount | |
998 | 1022 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
999 | 1023 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1000 | 1024 | } | |
1001 | - | let amountAssetBalanceDelta = $ | |
1002 | - | let priceAssetBalanceDelta = $ | |
1003 | - | let $ | |
1004 | - | let refreshKLpActions = $ | |
1005 | - | let updatedKLp = $ | |
1006 | - | let isUpdatedKLpValid = validateUpdatedKLp(updatedKLp) | |
1025 | + | let amountAssetBalanceDelta = $t03920239449._1 | |
1026 | + | let priceAssetBalanceDelta = $t03920239449._2 | |
1027 | + | let $t03945239560 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1028 | + | let refreshKLpActions = $t03945239560._1 | |
1029 | + | let updatedKLp = $t03945239560._2 | |
1030 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1007 | 1031 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1008 | 1032 | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1009 | 1033 | else throw("Strict value is not equal to itself.") | |
1027 | 1051 | let pmtAmt = res._3 | |
1028 | 1052 | let pmtAssetId = res._4 | |
1029 | 1053 | let state = res._5 | |
1054 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt)) | |
1030 | 1055 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1031 | 1056 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1032 | 1057 | then { | |
1033 | - | let $ | |
1034 | - | let refreshKLpActions = $ | |
1035 | - | let updatedKLp = $ | |
1036 | - | let isUpdatedKLpValid = validateUpdatedKLp(updatedKLp) | |
1058 | + | let $t04050840590 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1059 | + | let refreshKLpActions = $t04050840590._1 | |
1060 | + | let updatedKLp = $t04050840590._2 | |
1061 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1037 | 1062 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1038 | 1063 | then (state ++ refreshKLpActions) | |
1039 | 1064 | else throw("Strict value is not equal to itself.") | |
1056 | 1081 | else if ((noLessThenPriceAsset > outPrAmt)) | |
1057 | 1082 | then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
1058 | 1083 | else { | |
1084 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt)) | |
1059 | 1085 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1060 | 1086 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1061 | 1087 | then { | |
1062 | - | let $ | |
1063 | - | let refreshKLpActions = $ | |
1064 | - | let updatedKLp = $ | |
1065 | - | let isUpdatedKLpValid = validateUpdatedKLp(updatedKLp) | |
1088 | + | let $t04154141622 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1089 | + | let refreshKLpActions = $t04154141622._1 | |
1090 | + | let updatedKLp = $t04154141622._2 | |
1091 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1066 | 1092 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1067 | 1093 | then (state ++ refreshKLpActions) | |
1068 | 1094 | else throw("Strict value is not equal to itself.") | |
1082 | 1108 | then { | |
1083 | 1109 | let cfg = getPoolConfig() | |
1084 | 1110 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1111 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1085 | 1112 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1086 | 1113 | if ((unstakeInv == unstakeInv)) | |
1087 | 1114 | then { | |
1100 | 1127 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1101 | 1128 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1102 | 1129 | then { | |
1103 | - | let $ | |
1104 | - | let refreshKLpActions = $ | |
1105 | - | let updatedKLp = $ | |
1106 | - | let isUpdatedKLpValid = validateUpdatedKLp(updatedKLp) | |
1130 | + | let $t04274542826 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1131 | + | let refreshKLpActions = $t04274542826._1 | |
1132 | + | let updatedKLp = $t04274542826._2 | |
1133 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1107 | 1134 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1108 | 1135 | then (state ++ refreshKLpActions) | |
1109 | 1136 | else throw("Strict value is not equal to itself.") | |
1131 | 1158 | else throw("no payments are expected")] | |
1132 | 1159 | if ((checks == checks)) | |
1133 | 1160 | then { | |
1161 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1134 | 1162 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1135 | 1163 | if ((unstakeInv == unstakeInv)) | |
1136 | 1164 | then { | |
1148 | 1176 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1149 | 1177 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1150 | 1178 | then { | |
1151 | - | let $ | |
1152 | - | let refreshKLpActions = $ | |
1153 | - | let updatedKLp = $ | |
1154 | - | let isUpdatedKLpValid = validateUpdatedKLp(updatedKLp) | |
1179 | + | let $t04411844199 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1180 | + | let refreshKLpActions = $t04411844199._1 | |
1181 | + | let updatedKLp = $t04411844199._2 | |
1182 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1155 | 1183 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1156 | 1184 | then (state ++ refreshKLpActions) | |
1157 | 1185 | else throw("Strict value is not equal to itself.") | |
1183 | 1211 | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1184 | 1212 | then { | |
1185 | 1213 | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
1186 | - | let $ | |
1187 | - | let kLpUpdateActions = $ | |
1188 | - | let updatedKLp = $ | |
1214 | + | let $t04538645450 = refreshKLpInternal(0, 0, 0) | |
1215 | + | let kLpUpdateActions = $t04538645450._1 | |
1216 | + | let updatedKLp = $t04538645450._2 | |
1189 | 1217 | let actions = if ((kLp != updatedKLp)) | |
1190 | 1218 | then kLpUpdateActions | |
1191 | 1219 | else throwErr("nothing to refresh") |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let lPdecimals = 8 | |
5 | 5 | ||
6 | 6 | let scale8 = 100000000 | |
7 | 7 | ||
8 | 8 | let scale8BigInt = toBigInt(100000000) | |
9 | 9 | ||
10 | 10 | let scale18 = toBigInt(1000000000000000000) | |
11 | 11 | ||
12 | 12 | let zeroBigInt = toBigInt(0) | |
13 | 13 | ||
14 | 14 | let big0 = toBigInt(0) | |
15 | 15 | ||
16 | 16 | let big1 = toBigInt(1) | |
17 | 17 | ||
18 | 18 | let big2 = toBigInt(2) | |
19 | 19 | ||
20 | 20 | let wavesString = "WAVES" | |
21 | 21 | ||
22 | 22 | let SEP = "__" | |
23 | 23 | ||
24 | 24 | let PoolActive = 1 | |
25 | 25 | ||
26 | 26 | let PoolPutDisabled = 2 | |
27 | 27 | ||
28 | 28 | let PoolMatcherDisabled = 3 | |
29 | 29 | ||
30 | 30 | let PoolShutdown = 4 | |
31 | 31 | ||
32 | 32 | let idxPoolAddress = 1 | |
33 | 33 | ||
34 | 34 | let idxPoolStatus = 2 | |
35 | 35 | ||
36 | 36 | let idxPoolLPAssetId = 3 | |
37 | 37 | ||
38 | 38 | let idxAmtAssetId = 4 | |
39 | 39 | ||
40 | 40 | let idxPriceAssetId = 5 | |
41 | 41 | ||
42 | 42 | let idxAmtAssetDcm = 6 | |
43 | 43 | ||
44 | 44 | let idxPriceAssetDcm = 7 | |
45 | 45 | ||
46 | 46 | let idxIAmtAssetId = 8 | |
47 | 47 | ||
48 | 48 | let idxIPriceAssetId = 9 | |
49 | 49 | ||
50 | 50 | let idxLPAssetDcm = 10 | |
51 | 51 | ||
52 | 52 | let idxPoolAmtAssetAmt = 1 | |
53 | 53 | ||
54 | 54 | let idxPoolPriceAssetAmt = 2 | |
55 | 55 | ||
56 | 56 | let idxPoolLPAssetAmt = 3 | |
57 | 57 | ||
58 | 58 | let idxFactoryStakingContract = 1 | |
59 | 59 | ||
60 | 60 | let idxFactorySlippageContract = 7 | |
61 | 61 | ||
62 | 62 | func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult)) | |
63 | 63 | ||
64 | 64 | ||
65 | 65 | func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18)) | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
69 | 69 | ||
70 | 70 | ||
71 | 71 | func abs (val) = if ((0 > val)) | |
72 | 72 | then -(val) | |
73 | 73 | else val | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | func absBigInt (val) = if ((zeroBigInt > val)) | |
77 | 77 | then -(val) | |
78 | 78 | else val | |
79 | 79 | ||
80 | 80 | ||
81 | 81 | func fc () = "%s__factoryContract" | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | func mpk () = "%s__managerPublicKey" | |
85 | 85 | ||
86 | 86 | ||
87 | 87 | func pmpk () = "%s__pendingManagerPublicKey" | |
88 | 88 | ||
89 | 89 | ||
90 | 90 | func pl () = "%s%s__price__last" | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | func ph (h,timestamp) = makeString(["%s%s%d%d__price__history", toString(h), toString(timestamp)], SEP) | |
94 | 94 | ||
95 | 95 | ||
96 | 96 | func pau (userAddress,txId) = ((("%s%s%s__P__" + userAddress) + "__") + txId) | |
97 | 97 | ||
98 | 98 | ||
99 | 99 | func gau (userAddress,txId) = ((("%s%s%s__G__" + userAddress) + "__") + txId) | |
100 | 100 | ||
101 | 101 | ||
102 | 102 | func aa () = "%s__amountAsset" | |
103 | 103 | ||
104 | 104 | ||
105 | 105 | func pa () = "%s__priceAsset" | |
106 | 106 | ||
107 | 107 | ||
108 | 108 | let keyFee = "%s__fee" | |
109 | 109 | ||
110 | 110 | let feeDefault = fraction(10, scale8, 10000) | |
111 | 111 | ||
112 | 112 | let fee = valueOrElse(getInteger(this, keyFee), feeDefault) | |
113 | 113 | ||
114 | 114 | let keyKLp = makeString(["%s", "kLp"], SEP) | |
115 | 115 | ||
116 | 116 | let keyKLpRefreshedHeight = makeString(["%s", "kLpRefreshedHeight"], SEP) | |
117 | 117 | ||
118 | 118 | let keyKLpRefreshDelay = makeString(["%s", "refreshKLpDelay"], SEP) | |
119 | 119 | ||
120 | 120 | let kLpRefreshDelayDefault = 30 | |
121 | 121 | ||
122 | 122 | let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault) | |
123 | 123 | ||
124 | 124 | func keyFactoryConfig () = "%s__factoryConfig" | |
125 | 125 | ||
126 | 126 | ||
127 | 127 | func keyMatcherPub () = "%s%s__matcher__publicKey" | |
128 | 128 | ||
129 | 129 | ||
130 | 130 | func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset") | |
131 | 131 | ||
132 | 132 | ||
133 | 133 | func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config") | |
134 | 134 | ||
135 | 135 | ||
136 | 136 | func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr) | |
137 | 137 | ||
138 | 138 | ||
139 | 139 | func keyAllPoolsShutdown () = "%s__shutdown" | |
140 | 140 | ||
141 | 141 | ||
142 | 142 | func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress) | |
143 | 143 | ||
144 | 144 | ||
145 | 145 | func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash" | |
146 | 146 | ||
147 | 147 | ||
148 | 148 | let keyFeeCollectorAddress = "%s__feeCollectorAddress" | |
149 | 149 | ||
150 | 150 | func throwOrderError (orderValid,senderValid,matcherValid) = throw(((((("order validation failed: orderValid=" + toString(orderValid)) + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid))) | |
151 | 151 | ||
152 | 152 | ||
153 | 153 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
154 | 154 | ||
155 | 155 | ||
156 | 156 | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
157 | 157 | ||
158 | 158 | ||
159 | 159 | func throwErr (msg) = throw(makeString(["lp.ride:", msg], " ")) | |
160 | 160 | ||
161 | 161 | ||
162 | 162 | func fmtErr (msg) = makeString(["lp.ride:", msg], " ") | |
163 | 163 | ||
164 | 164 | ||
165 | 165 | let factoryContract = addressFromStringValue(getStringOrFail(this, fc())) | |
166 | 166 | ||
167 | 167 | let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress)) | |
168 | 168 | ||
169 | 169 | func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false) | |
170 | 170 | ||
171 | 171 | ||
172 | 172 | func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub())) | |
173 | 173 | ||
174 | 174 | ||
175 | 175 | func getPoolConfig () = { | |
176 | 176 | let amtAsset = getStringOrFail(this, aa()) | |
177 | 177 | let priceAsset = getStringOrFail(this, pa()) | |
178 | 178 | let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset)) | |
179 | 179 | let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset)) | |
180 | 180 | split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP) | |
181 | 181 | } | |
182 | 182 | ||
183 | 183 | ||
184 | 184 | func parseAssetId (input) = if ((input == wavesString)) | |
185 | 185 | then unit | |
186 | 186 | else fromBase58String(input) | |
187 | 187 | ||
188 | 188 | ||
189 | 189 | func assetIdToString (input) = if ((input == unit)) | |
190 | 190 | then wavesString | |
191 | 191 | else toBase58String(value(input)) | |
192 | 192 | ||
193 | 193 | ||
194 | 194 | func parsePoolConfig (poolConfig) = $Tuple7(addressFromStringValue(poolConfig[idxPoolAddress]), parseIntValue(poolConfig[idxPoolStatus]), fromBase58String(poolConfig[idxPoolLPAssetId]), parseAssetId(poolConfig[idxAmtAssetId]), parseAssetId(poolConfig[idxPriceAssetId]), parseIntValue(poolConfig[idxAmtAssetDcm]), parseIntValue(poolConfig[idxPriceAssetDcm])) | |
195 | 195 | ||
196 | 196 | ||
197 | 197 | let poolConfigParsed = parsePoolConfig(getPoolConfig()) | |
198 | 198 | ||
199 | 199 | let $t079158081 = poolConfigParsed | |
200 | 200 | ||
201 | 201 | let cfgPoolAddress = $t079158081._1 | |
202 | 202 | ||
203 | 203 | let cfgPoolStatus = $t079158081._2 | |
204 | 204 | ||
205 | 205 | let cfgLpAssetId = $t079158081._3 | |
206 | 206 | ||
207 | 207 | let cfgAmountAssetId = $t079158081._4 | |
208 | 208 | ||
209 | 209 | let cfgPriceAssetId = $t079158081._5 | |
210 | 210 | ||
211 | 211 | let cfgAmountAssetDecimals = $t079158081._6 | |
212 | 212 | ||
213 | 213 | let cfgPriceAssetDecimals = $t079158081._7 | |
214 | 214 | ||
215 | 215 | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
216 | 216 | ||
217 | 217 | ||
218 | 218 | let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address") | |
219 | 219 | ||
220 | 220 | let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address") | |
221 | 221 | ||
222 | 222 | func dataPutActionInfo (inAmtAssetAmt,inPriceAssetAmt,outLpAmt,price,slippageTolerancePassedByUser,slippageToleranceReal,txHeight,txTimestamp,slipageAmtAssetAmt,slipagePriceAssetAmt) = makeString(["%d%d%d%d%d%d%d%d%d%d", toString(inAmtAssetAmt), toString(inPriceAssetAmt), toString(outLpAmt), toString(price), toString(slippageTolerancePassedByUser), toString(slippageToleranceReal), toString(txHeight), toString(txTimestamp), toString(slipageAmtAssetAmt), toString(slipagePriceAssetAmt)], SEP) | |
223 | 223 | ||
224 | 224 | ||
225 | 225 | func dataGetActionInfo (outAmtAssetAmt,outPriceAssetAmt,inLpAmt,price,txHeight,txTimestamp) = makeString(["%d%d%d%d%d%d", toString(outAmtAssetAmt), toString(outPriceAssetAmt), toString(inLpAmt), toString(price), toString(txHeight), toString(txTimestamp)], SEP) | |
226 | 226 | ||
227 | 227 | ||
228 | 228 | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
229 | 229 | then wavesBalance(this).available | |
230 | 230 | else assetBalance(this, fromBase58String(assetId)) | |
231 | 231 | ||
232 | 232 | ||
233 | 233 | func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
234 | 234 | ||
235 | 235 | ||
236 | 236 | func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
237 | 237 | let amtAssetAmtX18 = toX18(amAmt, amAssetDcm) | |
238 | 238 | let priceAssetAmtX18 = toX18(prAmt, prAssetDcm) | |
239 | 239 | calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
240 | 240 | } | |
241 | 241 | ||
242 | 242 | ||
243 | 243 | func calcPrices (amAmt,prAmt,lpAmt) = { | |
244 | 244 | let cfg = getPoolConfig() | |
245 | 245 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
246 | 246 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
247 | 247 | let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt) | |
248 | 248 | let amAmtX18 = toX18(amAmt, amtAssetDcm) | |
249 | 249 | let prAmtX18 = toX18(prAmt, priceAssetDcm) | |
250 | 250 | let lpAmtX18 = toX18(lpAmt, scale8) | |
251 | 251 | let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18) | |
252 | 252 | let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18) | |
253 | 253 | [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18] | |
254 | 254 | } | |
255 | 255 | ||
256 | 256 | ||
257 | 257 | func calculatePrices (amAmt,prAmt,lpAmt) = { | |
258 | 258 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
259 | 259 | [fromX18(prices[0], scale8), fromX18(prices[1], scale8), fromX18(prices[2], scale8)] | |
260 | 260 | } | |
261 | 261 | ||
262 | 262 | ||
263 | 263 | func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
264 | 264 | let cfg = getPoolConfig() | |
265 | 265 | let lpAssetId = cfg[idxPoolLPAssetId] | |
266 | 266 | let amAssetId = cfg[idxAmtAssetId] | |
267 | 267 | let prAssetId = cfg[idxPriceAssetId] | |
268 | 268 | let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
269 | 269 | let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
270 | 270 | let poolStatus = cfg[idxPoolStatus] | |
271 | 271 | let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity | |
272 | 272 | if ((lpAssetId != pmtAssetId)) | |
273 | 273 | then throw("Invalid asset passed.") | |
274 | 274 | else { | |
275 | 275 | let amBalance = getAccBalance(amAssetId) | |
276 | 276 | let amBalanceX18 = toX18(amBalance, amAssetDcm) | |
277 | 277 | let prBalance = getAccBalance(prAssetId) | |
278 | 278 | let prBalanceX18 = toX18(prBalance, prAssetDcm) | |
279 | 279 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
280 | 280 | let curPrice = fromX18(curPriceX18, scale8) | |
281 | 281 | let pmtLpAmtX18 = toX18(pmtLpAmt, scale8) | |
282 | 282 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
283 | 283 | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
284 | 284 | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
285 | 285 | let outAmAmt = fromX18(outAmAmtX18, amAssetDcm) | |
286 | 286 | let outPrAmt = fromX18(outPrAmtX18, prAssetDcm) | |
287 | 287 | let state = if ((txId58 == "")) | |
288 | 288 | then nil | |
289 | 289 | else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
290 | 290 | then unit | |
291 | 291 | else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES")) | |
292 | 292 | then unit | |
293 | 293 | else fromBase58String(prAssetId)), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAmAmt, outPrAmt, pmtLpAmt, curPrice, height, lastBlock.timestamp)), IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice)] | |
294 | 294 | $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state) | |
295 | 295 | } | |
296 | 296 | } | |
297 | 297 | ||
298 | 298 | ||
299 | 299 | func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = { | |
300 | 300 | let cfg = getPoolConfig() | |
301 | 301 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
302 | 302 | let amAssetIdStr = cfg[idxAmtAssetId] | |
303 | 303 | let prAssetIdStr = cfg[idxPriceAssetId] | |
304 | 304 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
305 | 305 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
306 | 306 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
307 | 307 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
308 | 308 | let poolStatus = cfg[idxPoolStatus] | |
309 | 309 | let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
310 | 310 | let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES"))) | |
311 | 311 | let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES"))) | |
312 | 312 | if (if ((amAssetIdStr != inAmAssetIdStr)) | |
313 | 313 | then true | |
314 | 314 | else (prAssetIdStr != inPrAssetIdStr)) | |
315 | 315 | then throw("Invalid amt or price asset passed.") | |
316 | 316 | else { | |
317 | 317 | let amBalance = if (isEvaluate) | |
318 | 318 | then getAccBalance(amAssetIdStr) | |
319 | 319 | else (getAccBalance(amAssetIdStr) - inAmAssetAmt) | |
320 | 320 | let prBalance = if (isEvaluate) | |
321 | 321 | then getAccBalance(prAssetIdStr) | |
322 | 322 | else (getAccBalance(prAssetIdStr) - inPrAssetAmt) | |
323 | 323 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
324 | 324 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
325 | 325 | let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18) | |
326 | 326 | let amBalanceX18 = toX18(amBalance, amtAssetDcm) | |
327 | 327 | let prBalanceX18 = toX18(prBalance, priceAssetDcm) | |
328 | 328 | let res = if ((lpEmission == 0)) | |
329 | 329 | then { | |
330 | 330 | let curPriceX18 = zeroBigInt | |
331 | 331 | let slippageX18 = zeroBigInt | |
332 | 332 | let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN) | |
333 | 333 | $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
334 | 334 | } | |
335 | 335 | else { | |
336 | 336 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
337 | 337 | let slippageX18 = fraction(absBigInt((curPriceX18 - userPriceX18)), scale18, curPriceX18) | |
338 | 338 | let slippageToleranceX18 = toX18(slippageTolerance, scale8) | |
339 | 339 | if (if ((curPriceX18 != zeroBigInt)) | |
340 | 340 | then (slippageX18 > slippageToleranceX18) | |
341 | 341 | else false) | |
342 | 342 | then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18))) | |
343 | 343 | else { | |
344 | 344 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
345 | 345 | let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
346 | 346 | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
347 | 347 | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
348 | 348 | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
349 | 349 | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
350 | 350 | let expAmtAssetAmtX18 = expectedAmts._1 | |
351 | 351 | let expPriceAssetAmtX18 = expectedAmts._2 | |
352 | 352 | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18) | |
353 | 353 | $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18) | |
354 | 354 | } | |
355 | 355 | } | |
356 | 356 | let calcLpAmt = res._1 | |
357 | 357 | let calcAmAssetPmt = res._2 | |
358 | 358 | let calcPrAssetPmt = res._3 | |
359 | 359 | let curPrice = fromX18(res._4, scale8) | |
360 | 360 | let slippageCalc = fromX18(res._5, scale8) | |
361 | 361 | if ((0 >= calcLpAmt)) | |
362 | 362 | then throw("Invalid calculations. LP calculated is less than zero.") | |
363 | 363 | else { | |
364 | 364 | let emitLpAmt = if (!(emitLp)) | |
365 | 365 | then 0 | |
366 | 366 | else calcLpAmt | |
367 | 367 | let amDiff = (inAmAssetAmt - calcAmAssetPmt) | |
368 | 368 | let prDiff = (inPrAssetAmt - calcPrAssetPmt) | |
369 | 369 | let commonState = [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(userAddress, txId58), dataPutActionInfo(calcAmAssetPmt, calcPrAssetPmt, emitLpAmt, curPrice, slippageTolerance, slippageCalc, height, lastBlock.timestamp, amDiff, prDiff))] | |
370 | 370 | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId) | |
371 | 371 | } | |
372 | 372 | } | |
373 | 373 | } | |
374 | 374 | ||
375 | 375 | ||
376 | 376 | func calcKLp (amountBalance,priceBalance,lpEmission) = { | |
377 | 377 | let updatedKLp = fraction(pow((amountBalance * priceBalance), 0, toBigInt(5), 1, 0, DOWN), scale18, lpEmission) | |
378 | 378 | updatedKLp | |
379 | 379 | } | |
380 | 380 | ||
381 | 381 | ||
382 | + | func calcCurrentKLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = { | |
383 | + | let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta) | |
384 | + | let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta) | |
385 | + | let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta) | |
386 | + | let currentKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpAssetEmission) | |
387 | + | currentKLp | |
388 | + | } | |
389 | + | ||
390 | + | ||
382 | 391 | func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
383 | 392 | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
384 | 393 | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
385 | 394 | let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta) | |
386 | 395 | let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
387 | 396 | let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))] | |
388 | 397 | $Tuple2(actions, updatedKLp) | |
389 | 398 | } | |
390 | 399 | ||
391 | 400 | ||
392 | - | func validateUpdatedKLp (updatedKLp) = { | |
393 | - | let amountAssetBalance = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
394 | - | let priceAssetBalance = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
395 | - | let lpAssetEmission = value(assetInfo(cfgLpAssetId)).quantity | |
396 | - | let currentKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
397 | - | if ((updatedKLp >= currentKLp)) | |
398 | - | then true | |
399 | - | else throwErr("updated KLp lower than current KLp") | |
400 | - | } | |
401 | + | func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp)) | |
402 | + | then true | |
403 | + | else throwErr("updated KLp lower than current KLp") | |
401 | 404 | ||
402 | 405 | ||
403 | 406 | func validateMatcherOrderAllowed (order) = { | |
404 | 407 | let amountAssetAmount = order.amount | |
405 | 408 | let priceAssetAmount = fraction(order.amount, order.price, scale8) | |
406 | - | let $ | |
409 | + | let $t02021820430 = if ((order.orderType == Buy)) | |
407 | 410 | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
408 | 411 | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
409 | - | let amountAssetBalanceDelta = $ | |
410 | - | let priceAssetBalanceDelta = $ | |
412 | + | let amountAssetBalanceDelta = $t02021820430._1 | |
413 | + | let priceAssetBalanceDelta = $t02021820430._2 | |
411 | 414 | if (if (if (isGlobalShutdown()) | |
412 | 415 | then true | |
413 | 416 | else (cfgPoolStatus == PoolMatcherDisabled)) | |
414 | 417 | then true | |
415 | 418 | else (cfgPoolStatus == PoolShutdown)) | |
416 | 419 | then throw("Exchange operations disabled") | |
417 | 420 | else if (if ((order.assetPair.amountAsset != cfgAmountAssetId)) | |
418 | 421 | then true | |
419 | 422 | else (order.assetPair.priceAsset != cfgPriceAssetId)) | |
420 | 423 | then throw("Wrong order assets.") | |
421 | 424 | else { | |
422 | 425 | let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp")) | |
423 | - | let $ | |
424 | - | let unusedActions = $ | |
425 | - | let kLpNew = $ | |
426 | + | let $t02090121001 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
427 | + | let unusedActions = $t02090121001._1 | |
428 | + | let kLpNew = $t02090121001._2 | |
426 | 429 | let isOrderValid = (kLpNew > kLp) | |
427 | 430 | isOrderValid | |
428 | 431 | } | |
429 | 432 | } | |
430 | 433 | ||
431 | 434 | ||
432 | 435 | func commonGet (i) = if ((size(i.payments) != 1)) | |
433 | 436 | then throw("exactly 1 payment is expected") | |
434 | 437 | else { | |
435 | 438 | let pmt = value(i.payments[0]) | |
436 | 439 | let pmtAssetId = value(pmt.assetId) | |
437 | 440 | let pmtAmt = pmt.amount | |
438 | 441 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
439 | 442 | let outAmAmt = res._1 | |
440 | 443 | let outPrAmt = res._2 | |
441 | 444 | let poolStatus = parseIntValue(res._9) | |
442 | 445 | let state = res._10 | |
443 | 446 | if (if (isGlobalShutdown()) | |
444 | 447 | then true | |
445 | 448 | else (poolStatus == PoolShutdown)) | |
446 | 449 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
447 | 450 | else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state) | |
448 | 451 | } | |
449 | 452 | ||
450 | 453 | ||
451 | 454 | func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2)) | |
452 | 455 | then throw("exactly 2 payments are expected") | |
453 | 456 | else { | |
454 | 457 | let amAssetPmt = value(i.payments[0]) | |
455 | 458 | let prAssetPmt = value(i.payments[1]) | |
456 | 459 | let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp) | |
457 | 460 | let poolStatus = parseIntValue(estPut._8) | |
458 | 461 | if (if (if (isGlobalShutdown()) | |
459 | 462 | then true | |
460 | 463 | else (poolStatus == PoolPutDisabled)) | |
461 | 464 | then true | |
462 | 465 | else (poolStatus == PoolShutdown)) | |
463 | 466 | then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus))) | |
464 | 467 | else estPut | |
465 | 468 | } | |
466 | 469 | ||
467 | 470 | ||
468 | 471 | func emit (amount) = { | |
469 | 472 | let emitInv = invoke(factoryContract, "emit", [amount], nil) | |
470 | 473 | if ((emitInv == emitInv)) | |
471 | 474 | then { | |
472 | 475 | let emitInvLegacy = match emitInv { | |
473 | 476 | case legacyFactoryContract: Address => | |
474 | 477 | invoke(legacyFactoryContract, "emit", [amount], nil) | |
475 | 478 | case _ => | |
476 | 479 | unit | |
477 | 480 | } | |
478 | 481 | if ((emitInvLegacy == emitInvLegacy)) | |
479 | 482 | then amount | |
480 | 483 | else throw("Strict value is not equal to itself.") | |
481 | 484 | } | |
482 | 485 | else throw("Strict value is not equal to itself.") | |
483 | 486 | } | |
484 | 487 | ||
485 | 488 | ||
486 | 489 | func takeFee (amount) = { | |
487 | 490 | let feeAmount = fraction(amount, fee, scale8) | |
488 | 491 | $Tuple2((amount - feeAmount), feeAmount) | |
489 | 492 | } | |
490 | 493 | ||
491 | 494 | ||
492 | 495 | func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = { | |
493 | 496 | let isEval = (txId == unit) | |
494 | 497 | let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
495 | 498 | let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
496 | 499 | let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId)) | |
497 | 500 | then true | |
498 | 501 | else if ((paymentAssetId == cfgPriceAssetId)) | |
499 | 502 | then false | |
500 | 503 | else throwErr("invalid asset") | |
501 | - | let $ | |
504 | + | let $t02368523978 = if (isEval) | |
502 | 505 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
503 | 506 | else if (paymentInAmountAsset) | |
504 | 507 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
505 | 508 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
506 | - | let amountBalanceOld = $ | |
507 | - | let priceBalanceOld = $ | |
508 | - | let $ | |
509 | + | let amountBalanceOld = $t02368523978._1 | |
510 | + | let priceBalanceOld = $t02368523978._2 | |
511 | + | let $t02398224131 = if (paymentInAmountAsset) | |
509 | 512 | then $Tuple2(paymentAmountRaw, 0) | |
510 | 513 | else $Tuple2(0, paymentAmountRaw) | |
511 | - | let amountAssetAmountRaw = $ | |
512 | - | let priceAssetAmountRaw = $ | |
514 | + | let amountAssetAmountRaw = $t02398224131._1 | |
515 | + | let priceAssetAmountRaw = $t02398224131._2 | |
513 | 516 | let amountAssetAmount = takeFee(amountAssetAmountRaw)._1 | |
514 | 517 | let priceAssetAmount = takeFee(priceAssetAmountRaw)._1 | |
515 | - | let $ | |
516 | - | let paymentAmount = $ | |
517 | - | let feeAmount = $ | |
518 | + | let $t02425324312 = takeFee(paymentAmountRaw) | |
519 | + | let paymentAmount = $t02425324312._1 | |
520 | + | let feeAmount = $t02425324312._2 | |
518 | 521 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
519 | 522 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
520 | 523 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
521 | 524 | let priceNew = fromX18(priceNewX18, scale8) | |
522 | 525 | let paymentBalance = if (paymentInAmountAsset) | |
523 | 526 | then amountBalanceOld | |
524 | 527 | else priceBalanceOld | |
525 | 528 | let paymentBalanceBigInt = toBigInt(paymentBalance) | |
526 | 529 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
527 | 530 | let chechSupply = if ((supplyBigInt > big0)) | |
528 | 531 | then true | |
529 | 532 | else throwErr("initial deposit requires all coins") | |
530 | 533 | if ((chechSupply == chechSupply)) | |
531 | 534 | then { | |
532 | 535 | let depositBigInt = toBigInt(paymentAmount) | |
533 | 536 | let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))]) | |
534 | 537 | let commonState = if (isEval) | |
535 | 538 | then nil | |
536 | 539 | else [IntegerEntry(pl(), priceNew), IntegerEntry(ph(height, lastBlock.timestamp), priceNew), StringEntry(pau(toString(value(userAddress)), toBase58String(value(txId))), dataPutActionInfo(amountAssetAmountRaw, priceAssetAmountRaw, issueAmount, priceNew, 0, 0, height, lastBlock.timestamp, 0, 0))] | |
537 | 540 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
538 | 541 | let priceOld = fromX18(priceOldX18, scale8) | |
539 | 542 | let loss = { | |
540 | - | let $ | |
543 | + | let $t02578925956 = if (paymentInAmountAsset) | |
541 | 544 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
542 | 545 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
543 | - | let amount = $ | |
544 | - | let balance = $ | |
546 | + | let amount = $t02578925956._1 | |
547 | + | let balance = $t02578925956._2 | |
545 | 548 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
546 | 549 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
547 | 550 | } | |
548 | 551 | $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset) | |
549 | 552 | } | |
550 | 553 | else throw("Strict value is not equal to itself.") | |
551 | 554 | } | |
552 | 555 | ||
553 | 556 | ||
554 | 557 | func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = { | |
555 | 558 | let isEval = (txId == unit) | |
556 | 559 | let checks = [if ((paymentAssetId == cfgLpAssetId)) | |
557 | 560 | then true | |
558 | 561 | else throwErr("invalid lp asset")] | |
559 | 562 | if ((checks == checks)) | |
560 | 563 | then { | |
561 | 564 | let outInAmountAsset = if ((outAssetId == cfgAmountAssetId)) | |
562 | 565 | then true | |
563 | 566 | else if ((outAssetId == cfgPriceAssetId)) | |
564 | 567 | then false | |
565 | 568 | else throwErr("invalid asset") | |
566 | 569 | let balanceBigInt = if (outInAmountAsset) | |
567 | 570 | then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) | |
568 | 571 | else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) | |
569 | 572 | let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
570 | 573 | let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
571 | 574 | let outBalance = if (outInAmountAsset) | |
572 | 575 | then amBalanceOld | |
573 | 576 | else prBalanceOld | |
574 | 577 | let outBalanceBigInt = toBigInt(outBalance) | |
575 | 578 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
576 | 579 | let redeemedBigInt = toBigInt(paymentAmount) | |
577 | 580 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
578 | - | let $ | |
579 | - | let totalAmount = $ | |
580 | - | let feeAmount = $ | |
581 | - | let $ | |
581 | + | let $t02755827608 = takeFee(amountRaw) | |
582 | + | let totalAmount = $t02755827608._1 | |
583 | + | let feeAmount = $t02755827608._2 | |
584 | + | let $t02761227838 = if (outInAmountAsset) | |
582 | 585 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
583 | 586 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
584 | - | let outAmAmount = $ | |
585 | - | let outPrAmount = $ | |
586 | - | let amBalanceNew = $ | |
587 | - | let prBalanceNew = $ | |
587 | + | let outAmAmount = $t02761227838._1 | |
588 | + | let outPrAmount = $t02761227838._2 | |
589 | + | let amBalanceNew = $t02761227838._3 | |
590 | + | let prBalanceNew = $t02761227838._4 | |
588 | 591 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
589 | 592 | let priceNew = fromX18(priceNewX18, scale8) | |
590 | 593 | let commonState = if (isEval) | |
591 | 594 | then nil | |
592 | 595 | else [StringEntry(gau(toString(value(userAddress)), toBase58String(value(txId))), dataGetActionInfo(outAmAmount, outPrAmount, paymentAmount, priceNew, height, lastBlock.timestamp)), IntegerEntry(pl(), priceNew), IntegerEntry(ph(height, lastBlock.timestamp), priceNew)] | |
593 | 596 | let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals)) | |
594 | 597 | let priceOld = fromX18(priceOldX18, scale8) | |
595 | 598 | let loss = { | |
596 | 599 | let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2) | |
597 | 600 | fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset) | |
598 | 601 | } | |
599 | 602 | $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset) | |
600 | 603 | } | |
601 | 604 | else throw("Strict value is not equal to itself.") | |
602 | 605 | } | |
603 | 606 | ||
604 | 607 | ||
605 | 608 | func managerPublicKeyOrUnit () = match getString(mpk()) { | |
606 | 609 | case s: String => | |
607 | 610 | fromBase58String(s) | |
608 | 611 | case _: Unit => | |
609 | 612 | unit | |
610 | 613 | case _ => | |
611 | 614 | throw("Match error") | |
612 | 615 | } | |
613 | 616 | ||
614 | 617 | ||
615 | 618 | func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) { | |
616 | 619 | case s: String => | |
617 | 620 | fromBase58String(s) | |
618 | 621 | case _: Unit => | |
619 | 622 | unit | |
620 | 623 | case _ => | |
621 | 624 | throw("Match error") | |
622 | 625 | } | |
623 | 626 | ||
624 | 627 | ||
625 | 628 | func isManager (i) = match managerPublicKeyOrUnit() { | |
626 | 629 | case pk: ByteVector => | |
627 | 630 | (i.callerPublicKey == pk) | |
628 | 631 | case _: Unit => | |
629 | 632 | (i.caller == this) | |
630 | 633 | case _ => | |
631 | 634 | throw("Match error") | |
632 | 635 | } | |
633 | 636 | ||
634 | 637 | ||
635 | 638 | func mustManager (i) = { | |
636 | 639 | let pd = throw("Permission denied") | |
637 | 640 | match managerPublicKeyOrUnit() { | |
638 | 641 | case pk: ByteVector => | |
639 | 642 | if ((i.callerPublicKey == pk)) | |
640 | 643 | then true | |
641 | 644 | else pd | |
642 | 645 | case _: Unit => | |
643 | 646 | if ((i.caller == this)) | |
644 | 647 | then true | |
645 | 648 | else pd | |
646 | 649 | case _ => | |
647 | 650 | throw("Match error") | |
648 | 651 | } | |
649 | 652 | } | |
650 | 653 | ||
651 | 654 | ||
652 | 655 | @Callable(i) | |
653 | 656 | func setManager (pendingManagerPublicKey) = { | |
654 | 657 | let checkCaller = mustManager(i) | |
655 | 658 | if ((checkCaller == checkCaller)) | |
656 | 659 | then { | |
657 | 660 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
658 | 661 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
659 | 662 | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
660 | 663 | else throw("Strict value is not equal to itself.") | |
661 | 664 | } | |
662 | 665 | else throw("Strict value is not equal to itself.") | |
663 | 666 | } | |
664 | 667 | ||
665 | 668 | ||
666 | 669 | ||
667 | 670 | @Callable(i) | |
668 | 671 | func confirmManager () = { | |
669 | 672 | let pm = pendingManagerPublicKeyOrUnit() | |
670 | 673 | let hasPM = if (isDefined(pm)) | |
671 | 674 | then true | |
672 | 675 | else throw("No pending manager") | |
673 | 676 | if ((hasPM == hasPM)) | |
674 | 677 | then { | |
675 | 678 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
676 | 679 | then true | |
677 | 680 | else throw("You are not pending manager") | |
678 | 681 | if ((checkPM == checkPM)) | |
679 | 682 | then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())] | |
680 | 683 | else throw("Strict value is not equal to itself.") | |
681 | 684 | } | |
682 | 685 | else throw("Strict value is not equal to itself.") | |
683 | 686 | } | |
684 | 687 | ||
685 | 688 | ||
686 | 689 | ||
687 | 690 | @Callable(i) | |
688 | 691 | func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance)) | |
689 | 692 | then throw("Invalid slippageTolerance passed") | |
690 | 693 | else { | |
691 | 694 | let estPut = commonPut(i, slippageTolerance, true) | |
692 | 695 | let emitLpAmt = estPut._2 | |
693 | 696 | let lpAssetId = estPut._7 | |
694 | 697 | let state = estPut._9 | |
695 | 698 | let amDiff = estPut._10 | |
696 | 699 | let prDiff = estPut._11 | |
697 | 700 | let amId = estPut._12 | |
698 | 701 | let prId = estPut._13 | |
699 | - | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
700 | - | if ((emitInv == emitInv)) | |
702 | + | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
703 | + | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
704 | + | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
705 | + | if ((currentKLp == currentKLp)) | |
701 | 706 | then { | |
702 | - | let emitInvLegacy = match emitInv { | |
703 | - | case legacyFactoryContract: Address => | |
704 | - | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
705 | - | case _ => | |
706 | - | unit | |
707 | - | } | |
708 | - | if ((emitInvLegacy == emitInvLegacy)) | |
707 | + | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
708 | + | if ((emitInv == emitInv)) | |
709 | 709 | then { | |
710 | - | let slippageAInv = if ((amDiff > 0)) | |
711 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
712 | - | else nil | |
713 | - | if ((slippageAInv == slippageAInv)) | |
710 | + | let emitInvLegacy = match emitInv { | |
711 | + | case legacyFactoryContract: Address => | |
712 | + | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
713 | + | case _ => | |
714 | + | unit | |
715 | + | } | |
716 | + | if ((emitInvLegacy == emitInvLegacy)) | |
714 | 717 | then { | |
715 | - | let | |
716 | - | then invoke(slippageContract, "put", nil, [AttachedPayment( | |
718 | + | let slippageAInv = if ((amDiff > 0)) | |
719 | + | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
717 | 720 | else nil | |
718 | - | if (( | |
721 | + | if ((slippageAInv == slippageAInv)) | |
719 | 722 | then { | |
720 | - | let lpTransfer = if (shouldAutoStake) | |
723 | + | let slippagePInv = if ((prDiff > 0)) | |
724 | + | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
725 | + | else nil | |
726 | + | if ((slippagePInv == slippagePInv)) | |
721 | 727 | then { | |
722 | - | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
723 | - | if ((slpStakeInv == slpStakeInv)) | |
724 | - | then nil | |
728 | + | let lpTransfer = if (shouldAutoStake) | |
729 | + | then { | |
730 | + | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
731 | + | if ((slpStakeInv == slpStakeInv)) | |
732 | + | then nil | |
733 | + | else throw("Strict value is not equal to itself.") | |
734 | + | } | |
735 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
736 | + | let $t03199032055 = refreshKLpInternal(0, 0, 0) | |
737 | + | let refreshKLpActions = $t03199032055._1 | |
738 | + | let updatedKLp = $t03199032055._2 | |
739 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
740 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
741 | + | then ((state ++ lpTransfer) ++ refreshKLpActions) | |
725 | 742 | else throw("Strict value is not equal to itself.") | |
726 | 743 | } | |
727 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
728 | - | let $t03159631661 = refreshKLpInternal(0, 0, 0) | |
729 | - | let refreshKLpActions = $t03159631661._1 | |
730 | - | let updatedKLp = $t03159631661._2 | |
731 | - | let isUpdatedKLpValid = validateUpdatedKLp(updatedKLp) | |
732 | - | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
733 | - | then ((state ++ lpTransfer) ++ refreshKLpActions) | |
734 | 744 | else throw("Strict value is not equal to itself.") | |
735 | 745 | } | |
736 | 746 | else throw("Strict value is not equal to itself.") | |
737 | 747 | } | |
738 | 748 | else throw("Strict value is not equal to itself.") | |
739 | 749 | } | |
740 | 750 | else throw("Strict value is not equal to itself.") | |
741 | 751 | } | |
742 | 752 | else throw("Strict value is not equal to itself.") | |
743 | 753 | } | |
744 | 754 | ||
745 | 755 | ||
746 | 756 | ||
747 | 757 | @Callable(i) | |
748 | 758 | func putForFree (maxSlippage) = if ((0 > maxSlippage)) | |
749 | 759 | then throw("Invalid value passed") | |
750 | 760 | else { | |
751 | 761 | let estPut = commonPut(i, maxSlippage, false) | |
752 | 762 | let state = estPut._9 | |
753 | - | let $t03201032075 = refreshKLpInternal(0, 0, 0) | |
754 | - | let refreshKLpActions = $t03201032075._1 | |
755 | - | let updatedKLp = $t03201032075._2 | |
756 | - | let isUpdatedKLpValid = validateUpdatedKLp(updatedKLp) | |
757 | - | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
758 | - | then (state ++ refreshKLpActions) | |
763 | + | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
764 | + | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
765 | + | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
766 | + | if ((currentKLp == currentKLp)) | |
767 | + | then { | |
768 | + | let $t03261732682 = refreshKLpInternal(0, 0, 0) | |
769 | + | let refreshKLpActions = $t03261732682._1 | |
770 | + | let updatedKLp = $t03261732682._2 | |
771 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
772 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
773 | + | then (state ++ refreshKLpActions) | |
774 | + | else throw("Strict value is not equal to itself.") | |
775 | + | } | |
759 | 776 | else throw("Strict value is not equal to itself.") | |
760 | 777 | } | |
761 | 778 | ||
762 | 779 | ||
763 | 780 | ||
764 | 781 | @Callable(i) | |
765 | 782 | func putOneTkn (minOutAmount,autoStake) = { | |
766 | 783 | let isPoolOneTokenOperationsDisabled = { | |
767 | 784 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
768 | 785 | if ($isInstanceOf(@, "Boolean")) | |
769 | 786 | then @ | |
770 | 787 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
771 | 788 | } | |
772 | 789 | let isPutDisabled = if (if (if (isGlobalShutdown()) | |
773 | 790 | then true | |
774 | 791 | else (cfgPoolStatus == PoolPutDisabled)) | |
775 | 792 | then true | |
776 | 793 | else (cfgPoolStatus == PoolShutdown)) | |
777 | 794 | then true | |
778 | 795 | else isPoolOneTokenOperationsDisabled | |
779 | 796 | let checks = [if (if (!(isPutDisabled)) | |
780 | 797 | then true | |
781 | 798 | else isManager(i)) | |
782 | 799 | then true | |
783 | 800 | else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1)) | |
784 | 801 | then true | |
785 | 802 | else throwErr("exactly 1 payment are expected")] | |
786 | 803 | if ((checks == checks)) | |
787 | 804 | then { | |
788 | 805 | let payment = i.payments[0] | |
789 | 806 | let paymentAssetId = payment.assetId | |
790 | 807 | let paymentAmountRaw = payment.amount | |
808 | + | let currentKLp = if ((paymentAssetId == cfgAmountAssetId)) | |
809 | + | then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0)) | |
810 | + | else if ((paymentAssetId == cfgPriceAssetId)) | |
811 | + | then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0)) | |
812 | + | else throwErr("payment asset is not supported") | |
791 | 813 | let userAddress = i.caller | |
792 | 814 | let txId = i.transactionId | |
793 | - | let $ | |
794 | - | if (($ | |
815 | + | let $t03386734019 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
816 | + | if (($t03386734019 == $t03386734019)) | |
795 | 817 | then { | |
796 | - | let paymentInAmountAsset = $ | |
797 | - | let bonus = $ | |
798 | - | let feeAmount = $ | |
799 | - | let commonState = $ | |
800 | - | let emitAmountEstimated = $ | |
818 | + | let paymentInAmountAsset = $t03386734019._5 | |
819 | + | let bonus = $t03386734019._4 | |
820 | + | let feeAmount = $t03386734019._3 | |
821 | + | let commonState = $t03386734019._2 | |
822 | + | let emitAmountEstimated = $t03386734019._1 | |
801 | 823 | let emitAmount = if (if ((minOutAmount > 0)) | |
802 | 824 | then (minOutAmount > emitAmountEstimated) | |
803 | 825 | else false) | |
804 | 826 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
805 | 827 | else emitAmountEstimated | |
806 | 828 | let emitInv = emit(emitAmount) | |
807 | 829 | if ((emitInv == emitInv)) | |
808 | 830 | then { | |
809 | 831 | let lpTransfer = if (autoStake) | |
810 | 832 | then { | |
811 | 833 | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
812 | 834 | if ((stakeInv == stakeInv)) | |
813 | 835 | then nil | |
814 | 836 | else throw("Strict value is not equal to itself.") | |
815 | 837 | } | |
816 | 838 | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
817 | 839 | let sendFee = if ((feeAmount > 0)) | |
818 | 840 | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
819 | 841 | else nil | |
820 | - | let $ | |
842 | + | let $t03460534802 = if ((this == feeCollectorAddress)) | |
821 | 843 | then $Tuple2(0, 0) | |
822 | 844 | else if (paymentInAmountAsset) | |
823 | 845 | then $Tuple2(-(feeAmount), 0) | |
824 | 846 | else $Tuple2(0, -(feeAmount)) | |
825 | - | let amountAssetBalanceDelta = $ | |
826 | - | let priceAssetBalanceDelta = $ | |
827 | - | let $ | |
828 | - | let refreshKLpActions = $ | |
829 | - | let updatedKLp = $ | |
830 | - | let isUpdatedKLpValid = validateUpdatedKLp(updatedKLp) | |
847 | + | let amountAssetBalanceDelta = $t03460534802._1 | |
848 | + | let priceAssetBalanceDelta = $t03460534802._2 | |
849 | + | let $t03480534913 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
850 | + | let refreshKLpActions = $t03480534913._1 | |
851 | + | let updatedKLp = $t03480534913._2 | |
852 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
831 | 853 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
832 | 854 | then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
833 | 855 | else throw("Strict value is not equal to itself.") | |
834 | 856 | } | |
835 | 857 | else throw("Strict value is not equal to itself.") | |
836 | 858 | } | |
837 | 859 | else throw("Strict value is not equal to itself.") | |
838 | 860 | } | |
839 | 861 | else throw("Strict value is not equal to itself.") | |
840 | 862 | } | |
841 | 863 | ||
842 | 864 | ||
843 | 865 | ||
844 | 866 | @Callable(i) | |
845 | 867 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
846 | - | let $ | |
847 | - | let emitAmountEstimated = $ | |
848 | - | let commonState = $ | |
849 | - | let feeAmount = $ | |
850 | - | let bonus = $ | |
851 | - | let paymentInAmountAsset = $ | |
868 | + | let $t03517935336 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
869 | + | let emitAmountEstimated = $t03517935336._1 | |
870 | + | let commonState = $t03517935336._2 | |
871 | + | let feeAmount = $t03517935336._3 | |
872 | + | let bonus = $t03517935336._4 | |
873 | + | let paymentInAmountAsset = $t03517935336._5 | |
852 | 874 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
853 | 875 | } | |
854 | 876 | ||
855 | 877 | ||
856 | 878 | ||
857 | 879 | @Callable(i) | |
858 | 880 | func getOneTkn (outAssetIdStr,minOutAmount) = { | |
859 | 881 | let isPoolOneTokenOperationsDisabled = { | |
860 | 882 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
861 | 883 | if ($isInstanceOf(@, "Boolean")) | |
862 | 884 | then @ | |
863 | 885 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
864 | 886 | } | |
865 | 887 | let isGetDisabled = if (if (isGlobalShutdown()) | |
866 | 888 | then true | |
867 | 889 | else (cfgPoolStatus == PoolShutdown)) | |
868 | 890 | then true | |
869 | 891 | else isPoolOneTokenOperationsDisabled | |
870 | 892 | let checks = [if (if (!(isGetDisabled)) | |
871 | 893 | then true | |
872 | 894 | else isManager(i)) | |
873 | 895 | then true | |
874 | 896 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1)) | |
875 | 897 | then true | |
876 | 898 | else throwErr("exactly 1 payment are expected")] | |
877 | 899 | if ((checks == checks)) | |
878 | 900 | then { | |
879 | 901 | let outAssetId = parseAssetId(outAssetIdStr) | |
880 | 902 | let payment = i.payments[0] | |
881 | 903 | let paymentAssetId = payment.assetId | |
882 | 904 | let paymentAmount = payment.amount | |
905 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(paymentAmount)) | |
883 | 906 | let userAddress = i.caller | |
884 | 907 | let txId = i.transactionId | |
885 | - | let $ | |
886 | - | if (($ | |
908 | + | let $t03623036383 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
909 | + | if (($t03623036383 == $t03623036383)) | |
887 | 910 | then { | |
888 | - | let outInAmountAsset = $ | |
889 | - | let bonus = $ | |
890 | - | let feeAmount = $ | |
891 | - | let commonState = $ | |
892 | - | let amountEstimated = $ | |
911 | + | let outInAmountAsset = $t03623036383._5 | |
912 | + | let bonus = $t03623036383._4 | |
913 | + | let feeAmount = $t03623036383._3 | |
914 | + | let commonState = $t03623036383._2 | |
915 | + | let amountEstimated = $t03623036383._1 | |
893 | 916 | let amount = if (if ((minOutAmount > 0)) | |
894 | 917 | then (minOutAmount > amountEstimated) | |
895 | 918 | else false) | |
896 | 919 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
897 | 920 | else amountEstimated | |
898 | 921 | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
899 | 922 | if ((burnInv == burnInv)) | |
900 | 923 | then { | |
901 | 924 | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
902 | 925 | let sendFee = if ((feeAmount > 0)) | |
903 | 926 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
904 | 927 | else nil | |
905 | - | let $ | |
928 | + | let $t03688337130 = { | |
906 | 929 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
907 | 930 | then 0 | |
908 | 931 | else feeAmount | |
909 | 932 | if (outInAmountAsset) | |
910 | 933 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
911 | 934 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
912 | 935 | } | |
913 | - | let amountAssetBalanceDelta = $ | |
914 | - | let priceAssetBalanceDelta = $ | |
915 | - | let $ | |
916 | - | let refreshKLpActions = $ | |
917 | - | let updatedKLp = $ | |
918 | - | let isUpdatedKLpValid = validateUpdatedKLp(updatedKLp) | |
936 | + | let amountAssetBalanceDelta = $t03688337130._1 | |
937 | + | let priceAssetBalanceDelta = $t03688337130._2 | |
938 | + | let $t03713337241 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
939 | + | let refreshKLpActions = $t03713337241._1 | |
940 | + | let updatedKLp = $t03713337241._2 | |
941 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
919 | 942 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
920 | 943 | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
921 | 944 | else throw("Strict value is not equal to itself.") | |
922 | 945 | } | |
923 | 946 | else throw("Strict value is not equal to itself.") | |
924 | 947 | } | |
925 | 948 | else throw("Strict value is not equal to itself.") | |
926 | 949 | } | |
927 | 950 | else throw("Strict value is not equal to itself.") | |
928 | 951 | } | |
929 | 952 | ||
930 | 953 | ||
931 | 954 | ||
932 | 955 | @Callable(i) | |
933 | 956 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
934 | - | let $ | |
935 | - | let amountEstimated = $ | |
936 | - | let commonState = $ | |
937 | - | let feeAmount = $ | |
938 | - | let bonus = $ | |
939 | - | let outInAmountAsset = $ | |
957 | + | let $t03749837654 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
958 | + | let amountEstimated = $t03749837654._1 | |
959 | + | let commonState = $t03749837654._2 | |
960 | + | let feeAmount = $t03749837654._3 | |
961 | + | let bonus = $t03749837654._4 | |
962 | + | let outInAmountAsset = $t03749837654._5 | |
940 | 963 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
941 | 964 | } | |
942 | 965 | ||
943 | 966 | ||
944 | 967 | ||
945 | 968 | @Callable(i) | |
946 | 969 | func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = { | |
947 | 970 | let isPoolOneTokenOperationsDisabled = { | |
948 | 971 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
949 | 972 | if ($isInstanceOf(@, "Boolean")) | |
950 | 973 | then @ | |
951 | 974 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
952 | 975 | } | |
953 | 976 | let isGetDisabled = if (if (isGlobalShutdown()) | |
954 | 977 | then true | |
955 | 978 | else (cfgPoolStatus == PoolShutdown)) | |
956 | 979 | then true | |
957 | 980 | else isPoolOneTokenOperationsDisabled | |
958 | 981 | let checks = [if (if (!(isGetDisabled)) | |
959 | 982 | then true | |
960 | 983 | else isManager(i)) | |
961 | 984 | then true | |
962 | 985 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
963 | 986 | then true | |
964 | 987 | else throwErr("no payments are expected")] | |
965 | 988 | if ((checks == checks)) | |
966 | 989 | then { | |
967 | 990 | let outAssetId = parseAssetId(outAssetIdStr) | |
968 | 991 | let userAddress = i.caller | |
969 | 992 | let txId = i.transactionId | |
993 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
970 | 994 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
971 | 995 | if ((unstakeInv == unstakeInv)) | |
972 | 996 | then { | |
973 | - | let $ | |
974 | - | if (($ | |
997 | + | let $t03855638707 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
998 | + | if (($t03855638707 == $t03855638707)) | |
975 | 999 | then { | |
976 | - | let outInAmountAsset = $ | |
977 | - | let bonus = $ | |
978 | - | let feeAmount = $ | |
979 | - | let commonState = $ | |
980 | - | let amountEstimated = $ | |
1000 | + | let outInAmountAsset = $t03855638707._5 | |
1001 | + | let bonus = $t03855638707._4 | |
1002 | + | let feeAmount = $t03855638707._3 | |
1003 | + | let commonState = $t03855638707._2 | |
1004 | + | let amountEstimated = $t03855638707._1 | |
981 | 1005 | let amount = if (if ((minOutAmount > 0)) | |
982 | 1006 | then (minOutAmount > amountEstimated) | |
983 | 1007 | else false) | |
984 | 1008 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
985 | 1009 | else amountEstimated | |
986 | 1010 | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
987 | 1011 | if ((burnInv == burnInv)) | |
988 | 1012 | then { | |
989 | 1013 | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
990 | 1014 | let sendFee = if ((feeAmount > 0)) | |
991 | 1015 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
992 | 1016 | else nil | |
993 | - | let $ | |
1017 | + | let $t03920239449 = { | |
994 | 1018 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
995 | 1019 | then 0 | |
996 | 1020 | else feeAmount | |
997 | 1021 | if (outInAmountAsset) | |
998 | 1022 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
999 | 1023 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1000 | 1024 | } | |
1001 | - | let amountAssetBalanceDelta = $ | |
1002 | - | let priceAssetBalanceDelta = $ | |
1003 | - | let $ | |
1004 | - | let refreshKLpActions = $ | |
1005 | - | let updatedKLp = $ | |
1006 | - | let isUpdatedKLpValid = validateUpdatedKLp(updatedKLp) | |
1025 | + | let amountAssetBalanceDelta = $t03920239449._1 | |
1026 | + | let priceAssetBalanceDelta = $t03920239449._2 | |
1027 | + | let $t03945239560 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1028 | + | let refreshKLpActions = $t03945239560._1 | |
1029 | + | let updatedKLp = $t03945239560._2 | |
1030 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1007 | 1031 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1008 | 1032 | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1009 | 1033 | else throw("Strict value is not equal to itself.") | |
1010 | 1034 | } | |
1011 | 1035 | else throw("Strict value is not equal to itself.") | |
1012 | 1036 | } | |
1013 | 1037 | else throw("Strict value is not equal to itself.") | |
1014 | 1038 | } | |
1015 | 1039 | else throw("Strict value is not equal to itself.") | |
1016 | 1040 | } | |
1017 | 1041 | else throw("Strict value is not equal to itself.") | |
1018 | 1042 | } | |
1019 | 1043 | ||
1020 | 1044 | ||
1021 | 1045 | ||
1022 | 1046 | @Callable(i) | |
1023 | 1047 | func get () = { | |
1024 | 1048 | let res = commonGet(i) | |
1025 | 1049 | let outAmtAmt = res._1 | |
1026 | 1050 | let outPrAmt = res._2 | |
1027 | 1051 | let pmtAmt = res._3 | |
1028 | 1052 | let pmtAssetId = res._4 | |
1029 | 1053 | let state = res._5 | |
1054 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt)) | |
1030 | 1055 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1031 | 1056 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1032 | 1057 | then { | |
1033 | - | let $ | |
1034 | - | let refreshKLpActions = $ | |
1035 | - | let updatedKLp = $ | |
1036 | - | let isUpdatedKLpValid = validateUpdatedKLp(updatedKLp) | |
1058 | + | let $t04050840590 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1059 | + | let refreshKLpActions = $t04050840590._1 | |
1060 | + | let updatedKLp = $t04050840590._2 | |
1061 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1037 | 1062 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1038 | 1063 | then (state ++ refreshKLpActions) | |
1039 | 1064 | else throw("Strict value is not equal to itself.") | |
1040 | 1065 | } | |
1041 | 1066 | else throw("Strict value is not equal to itself.") | |
1042 | 1067 | } | |
1043 | 1068 | ||
1044 | 1069 | ||
1045 | 1070 | ||
1046 | 1071 | @Callable(i) | |
1047 | 1072 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
1048 | 1073 | let res = commonGet(i) | |
1049 | 1074 | let outAmAmt = res._1 | |
1050 | 1075 | let outPrAmt = res._2 | |
1051 | 1076 | let pmtAmt = res._3 | |
1052 | 1077 | let pmtAssetId = res._4 | |
1053 | 1078 | let state = res._5 | |
1054 | 1079 | if ((noLessThenAmtAsset > outAmAmt)) | |
1055 | 1080 | then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
1056 | 1081 | else if ((noLessThenPriceAsset > outPrAmt)) | |
1057 | 1082 | then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
1058 | 1083 | else { | |
1084 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt)) | |
1059 | 1085 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1060 | 1086 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1061 | 1087 | then { | |
1062 | - | let $ | |
1063 | - | let refreshKLpActions = $ | |
1064 | - | let updatedKLp = $ | |
1065 | - | let isUpdatedKLpValid = validateUpdatedKLp(updatedKLp) | |
1088 | + | let $t04154141622 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1089 | + | let refreshKLpActions = $t04154141622._1 | |
1090 | + | let updatedKLp = $t04154141622._2 | |
1091 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1066 | 1092 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1067 | 1093 | then (state ++ refreshKLpActions) | |
1068 | 1094 | else throw("Strict value is not equal to itself.") | |
1069 | 1095 | } | |
1070 | 1096 | else throw("Strict value is not equal to itself.") | |
1071 | 1097 | } | |
1072 | 1098 | } | |
1073 | 1099 | ||
1074 | 1100 | ||
1075 | 1101 | ||
1076 | 1102 | @Callable(i) | |
1077 | 1103 | func unstakeAndGet (amount) = { | |
1078 | 1104 | let checkPayments = if ((size(i.payments) != 0)) | |
1079 | 1105 | then throw("No payments are expected") | |
1080 | 1106 | else true | |
1081 | 1107 | if ((checkPayments == checkPayments)) | |
1082 | 1108 | then { | |
1083 | 1109 | let cfg = getPoolConfig() | |
1084 | 1110 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1111 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1085 | 1112 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1086 | 1113 | if ((unstakeInv == unstakeInv)) | |
1087 | 1114 | then { | |
1088 | 1115 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1089 | 1116 | let outAmAmt = res._1 | |
1090 | 1117 | let outPrAmt = res._2 | |
1091 | 1118 | let poolStatus = parseIntValue(res._9) | |
1092 | 1119 | let state = res._10 | |
1093 | 1120 | let checkPoolStatus = if (if (isGlobalShutdown()) | |
1094 | 1121 | then true | |
1095 | 1122 | else (poolStatus == PoolShutdown)) | |
1096 | 1123 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
1097 | 1124 | else true | |
1098 | 1125 | if ((checkPoolStatus == checkPoolStatus)) | |
1099 | 1126 | then { | |
1100 | 1127 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1101 | 1128 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1102 | 1129 | then { | |
1103 | - | let $ | |
1104 | - | let refreshKLpActions = $ | |
1105 | - | let updatedKLp = $ | |
1106 | - | let isUpdatedKLpValid = validateUpdatedKLp(updatedKLp) | |
1130 | + | let $t04274542826 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1131 | + | let refreshKLpActions = $t04274542826._1 | |
1132 | + | let updatedKLp = $t04274542826._2 | |
1133 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1107 | 1134 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1108 | 1135 | then (state ++ refreshKLpActions) | |
1109 | 1136 | else throw("Strict value is not equal to itself.") | |
1110 | 1137 | } | |
1111 | 1138 | else throw("Strict value is not equal to itself.") | |
1112 | 1139 | } | |
1113 | 1140 | else throw("Strict value is not equal to itself.") | |
1114 | 1141 | } | |
1115 | 1142 | else throw("Strict value is not equal to itself.") | |
1116 | 1143 | } | |
1117 | 1144 | else throw("Strict value is not equal to itself.") | |
1118 | 1145 | } | |
1119 | 1146 | ||
1120 | 1147 | ||
1121 | 1148 | ||
1122 | 1149 | @Callable(i) | |
1123 | 1150 | func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = { | |
1124 | 1151 | let isGetDisabled = if (isGlobalShutdown()) | |
1125 | 1152 | then true | |
1126 | 1153 | else (cfgPoolStatus == PoolShutdown) | |
1127 | 1154 | let checks = [if (!(isGetDisabled)) | |
1128 | 1155 | then true | |
1129 | 1156 | else throw("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1130 | 1157 | then true | |
1131 | 1158 | else throw("no payments are expected")] | |
1132 | 1159 | if ((checks == checks)) | |
1133 | 1160 | then { | |
1161 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1134 | 1162 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1135 | 1163 | if ((unstakeInv == unstakeInv)) | |
1136 | 1164 | then { | |
1137 | 1165 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1138 | 1166 | let outAmAmt = res._1 | |
1139 | 1167 | let outPrAmt = res._2 | |
1140 | 1168 | let state = res._10 | |
1141 | 1169 | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1142 | 1170 | then true | |
1143 | 1171 | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1144 | 1172 | then true | |
1145 | 1173 | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1146 | 1174 | if ((checkAmounts == checkAmounts)) | |
1147 | 1175 | then { | |
1148 | 1176 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1149 | 1177 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1150 | 1178 | then { | |
1151 | - | let $ | |
1152 | - | let refreshKLpActions = $ | |
1153 | - | let updatedKLp = $ | |
1154 | - | let isUpdatedKLpValid = validateUpdatedKLp(updatedKLp) | |
1179 | + | let $t04411844199 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1180 | + | let refreshKLpActions = $t04411844199._1 | |
1181 | + | let updatedKLp = $t04411844199._2 | |
1182 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1155 | 1183 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1156 | 1184 | then (state ++ refreshKLpActions) | |
1157 | 1185 | else throw("Strict value is not equal to itself.") | |
1158 | 1186 | } | |
1159 | 1187 | else throw("Strict value is not equal to itself.") | |
1160 | 1188 | } | |
1161 | 1189 | else throw("Strict value is not equal to itself.") | |
1162 | 1190 | } | |
1163 | 1191 | else throw("Strict value is not equal to itself.") | |
1164 | 1192 | } | |
1165 | 1193 | else throw("Strict value is not equal to itself.") | |
1166 | 1194 | } | |
1167 | 1195 | ||
1168 | 1196 | ||
1169 | 1197 | ||
1170 | 1198 | @Callable(i) | |
1171 | 1199 | func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract))) | |
1172 | 1200 | then throw("permissions denied") | |
1173 | 1201 | else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success") | |
1174 | 1202 | ||
1175 | 1203 | ||
1176 | 1204 | ||
1177 | 1205 | @Callable(i) | |
1178 | 1206 | func refreshKLp () = { | |
1179 | 1207 | let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0) | |
1180 | 1208 | let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay)) | |
1181 | 1209 | then unit | |
1182 | 1210 | else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1183 | 1211 | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1184 | 1212 | then { | |
1185 | 1213 | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
1186 | - | let $ | |
1187 | - | let kLpUpdateActions = $ | |
1188 | - | let updatedKLp = $ | |
1214 | + | let $t04538645450 = refreshKLpInternal(0, 0, 0) | |
1215 | + | let kLpUpdateActions = $t04538645450._1 | |
1216 | + | let updatedKLp = $t04538645450._2 | |
1189 | 1217 | let actions = if ((kLp != updatedKLp)) | |
1190 | 1218 | then kLpUpdateActions | |
1191 | 1219 | else throwErr("nothing to refresh") | |
1192 | 1220 | $Tuple2(actions, toString(updatedKLp)) | |
1193 | 1221 | } | |
1194 | 1222 | else throw("Strict value is not equal to itself.") | |
1195 | 1223 | } | |
1196 | 1224 | ||
1197 | 1225 | ||
1198 | 1226 | ||
1199 | 1227 | @Callable(i) | |
1200 | 1228 | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig()) | |
1201 | 1229 | ||
1202 | 1230 | ||
1203 | 1231 | ||
1204 | 1232 | @Callable(i) | |
1205 | 1233 | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
1206 | 1234 | ||
1207 | 1235 | ||
1208 | 1236 | ||
1209 | 1237 | @Callable(i) | |
1210 | 1238 | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
1211 | 1239 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
1212 | 1240 | $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])]) | |
1213 | 1241 | } | |
1214 | 1242 | ||
1215 | 1243 | ||
1216 | 1244 | ||
1217 | 1245 | @Callable(i) | |
1218 | 1246 | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult))) | |
1219 | 1247 | ||
1220 | 1248 | ||
1221 | 1249 | ||
1222 | 1250 | @Callable(i) | |
1223 | 1251 | func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult)) | |
1224 | 1252 | ||
1225 | 1253 | ||
1226 | 1254 | ||
1227 | 1255 | @Callable(i) | |
1228 | 1256 | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
1229 | 1257 | ||
1230 | 1258 | ||
1231 | 1259 | ||
1232 | 1260 | @Callable(i) | |
1233 | 1261 | func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp)) | |
1234 | 1262 | ||
1235 | 1263 | ||
1236 | 1264 | ||
1237 | 1265 | @Callable(i) | |
1238 | 1266 | func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
1239 | 1267 | let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress)) | |
1240 | 1268 | $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10)) | |
1241 | 1269 | } | |
1242 | 1270 | ||
1243 | 1271 | ||
1244 | 1272 | ||
1245 | 1273 | @Callable(i) | |
1246 | 1274 | func statsREADONLY () = { | |
1247 | 1275 | let cfg = getPoolConfig() | |
1248 | 1276 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1249 | 1277 | let amtAssetId = cfg[idxAmtAssetId] | |
1250 | 1278 | let priceAssetId = cfg[idxPriceAssetId] | |
1251 | 1279 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
1252 | 1280 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
1253 | 1281 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1254 | 1282 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1255 | 1283 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1256 | 1284 | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
1257 | 1285 | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
1258 | 1286 | let pricesList = if ((poolLPBalance == 0)) | |
1259 | 1287 | then [zeroBigInt, zeroBigInt, zeroBigInt] | |
1260 | 1288 | else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance) | |
1261 | 1289 | let curPrice = 0 | |
1262 | 1290 | let lpAmtAssetShare = fromX18(pricesList[1], scale8) | |
1263 | 1291 | let lpPriceAssetShare = fromX18(pricesList[2], scale8) | |
1264 | 1292 | let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this)))) | |
1265 | 1293 | $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)) | |
1266 | 1294 | } | |
1267 | 1295 | ||
1268 | 1296 | ||
1269 | 1297 | ||
1270 | 1298 | @Callable(i) | |
1271 | 1299 | func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = { | |
1272 | 1300 | let cfg = getPoolConfig() | |
1273 | 1301 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1274 | 1302 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1275 | 1303 | let amAssetId = fromBase58String(amAssetIdStr) | |
1276 | 1304 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1277 | 1305 | let prAssetId = fromBase58String(prAssetIdStr) | |
1278 | 1306 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1279 | 1307 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1280 | 1308 | let poolStatus = cfg[idxPoolStatus] | |
1281 | 1309 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1282 | 1310 | let accAmtAssetBalance = getAccBalance(amAssetIdStr) | |
1283 | 1311 | let accPriceAssetBalance = getAccBalance(prAssetIdStr) | |
1284 | 1312 | let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm) | |
1285 | 1313 | let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm) | |
1286 | 1314 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1287 | 1315 | then zeroBigInt | |
1288 | 1316 | else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
1289 | 1317 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
1290 | 1318 | let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
1291 | 1319 | let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm) | |
1292 | 1320 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1293 | 1321 | let calcLpAmt = estPut._1 | |
1294 | 1322 | let curPriceCalc = estPut._3 | |
1295 | 1323 | let amBalance = estPut._4 | |
1296 | 1324 | let prBalance = estPut._5 | |
1297 | 1325 | let lpEmission = estPut._6 | |
1298 | 1326 | $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)) | |
1299 | 1327 | } | |
1300 | 1328 | ||
1301 | 1329 | ||
1302 | 1330 | ||
1303 | 1331 | @Callable(i) | |
1304 | 1332 | func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = { | |
1305 | 1333 | let cfg = getPoolConfig() | |
1306 | 1334 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1307 | 1335 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1308 | 1336 | let amAssetId = fromBase58String(amAssetIdStr) | |
1309 | 1337 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1310 | 1338 | let prAssetId = fromBase58String(prAssetIdStr) | |
1311 | 1339 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1312 | 1340 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1313 | 1341 | let poolStatus = cfg[idxPoolStatus] | |
1314 | 1342 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1315 | 1343 | let amBalanceRaw = getAccBalance(amAssetIdStr) | |
1316 | 1344 | let prBalanceRaw = getAccBalance(prAssetIdStr) | |
1317 | 1345 | let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm) | |
1318 | 1346 | let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm) | |
1319 | 1347 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1320 | 1348 | then zeroBigInt | |
1321 | 1349 | else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18) | |
1322 | 1350 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
1323 | 1351 | let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
1324 | 1352 | let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm) | |
1325 | 1353 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1326 | 1354 | let calcLpAmt = estPut._1 | |
1327 | 1355 | let curPriceCalc = estPut._3 | |
1328 | 1356 | let amBalance = estPut._4 | |
1329 | 1357 | let prBalance = estPut._5 | |
1330 | 1358 | let lpEmission = estPut._6 | |
1331 | 1359 | $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)) | |
1332 | 1360 | } | |
1333 | 1361 | ||
1334 | 1362 | ||
1335 | 1363 | ||
1336 | 1364 | @Callable(i) | |
1337 | 1365 | func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = { | |
1338 | 1366 | let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this) | |
1339 | 1367 | let outAmAmt = res._1 | |
1340 | 1368 | let outPrAmt = res._2 | |
1341 | 1369 | let amBalance = res._5 | |
1342 | 1370 | let prBalance = res._6 | |
1343 | 1371 | let lpEmission = res._7 | |
1344 | 1372 | let curPrice = res._8 | |
1345 | 1373 | let poolStatus = parseIntValue(res._9) | |
1346 | 1374 | $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)) | |
1347 | 1375 | } | |
1348 | 1376 | ||
1349 | 1377 | ||
1350 | 1378 | @Verifier(tx) | |
1351 | 1379 | func verify () = { | |
1352 | 1380 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
1353 | 1381 | case pk: ByteVector => | |
1354 | 1382 | pk | |
1355 | 1383 | case _: Unit => | |
1356 | 1384 | tx.senderPublicKey | |
1357 | 1385 | case _ => | |
1358 | 1386 | throw("Match error") | |
1359 | 1387 | } | |
1360 | 1388 | match tx { | |
1361 | 1389 | case order: Order => | |
1362 | 1390 | let matcherPub = getMatcherPubOrFail() | |
1363 | 1391 | let orderValid = validateMatcherOrderAllowed(order) | |
1364 | 1392 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1365 | 1393 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1366 | 1394 | if (if (if (orderValid) | |
1367 | 1395 | then senderValid | |
1368 | 1396 | else false) | |
1369 | 1397 | then matcherValid | |
1370 | 1398 | else false) | |
1371 | 1399 | then true | |
1372 | 1400 | else throwOrderError(orderValid, senderValid, matcherValid) | |
1373 | 1401 | case s: SetScriptTransaction => | |
1374 | 1402 | let newHash = blake2b256(value(s.script)) | |
1375 | 1403 | let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash()))) | |
1376 | 1404 | let currentHash = scriptHash(this) | |
1377 | 1405 | if (if ((allowedHash == newHash)) | |
1378 | 1406 | then (currentHash != newHash) | |
1379 | 1407 | else false) | |
1380 | 1408 | then true | |
1381 | 1409 | else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1382 | 1410 | case _ => | |
1383 | 1411 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1384 | 1412 | } | |
1385 | 1413 | } | |
1386 | 1414 |
github/deemru/w8io/fabc49c 167.46 ms ◑