tx · KTjVuMSQdGqMHAk18DvgBhLaL82zYSipHpvY6BpVta4

3MrULQRLc52GWrJF1tMcAm4M78fPe57o9Kt:  -0.03400000 Waves

2022.12.06 17:09 [2348588] smart account 3MrULQRLc52GWrJF1tMcAm4M78fPe57o9Kt > SELF 0.00000000 Waves

{ "type": 13, "id": "KTjVuMSQdGqMHAk18DvgBhLaL82zYSipHpvY6BpVta4", "fee": 3400000, "feeAssetId": null, "timestamp": 1670335795151, "version": 1, "sender": "3MrULQRLc52GWrJF1tMcAm4M78fPe57o9Kt", "senderPublicKey": "Aig94J3pRT3J41eXw33rJrs67gTCECiMVRZrbtuoARit", "proofs": [ "4iqUHP33KEqJiyic4xNEoeKjup3thcvQA98MmfQxS48XN867aNAxVRKrsuoqooa1K86ajZYcq24xk3ZSFui9rsPu" ], "script": "base64:BgLYLAgCEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgQKAggBEgQKAggBEgQKAggBEgUKAwEIARIAEgQKAgEBEgMKAQESBQoDAQEBEgQKAggIEgASABIDCgEIEgUKAwEBARIECgIBARIECgIIARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCBIAEgMKAQESAwoBARIECgIIASIKbFBkZWNpbWFscyIGc2NhbGU4IgxzY2FsZThCaWdJbnQiB3NjYWxlMTgiCnplcm9CaWdJbnQiBGJpZzAiBGJpZzEiBGJpZzIiC3dhdmVzU3RyaW5nIgNTRVAiClBvb2xBY3RpdmUiD1Bvb2xQdXREaXNhYmxlZCITUG9vbE1hdGNoZXJEaXNhYmxlZCIMUG9vbFNodXRkb3duIg5pZHhQb29sQWRkcmVzcyINaWR4UG9vbFN0YXR1cyIQaWR4UG9vbExQQXNzZXRJZCINaWR4QW10QXNzZXRJZCIPaWR4UHJpY2VBc3NldElkIg5pZHhBbXRBc3NldERjbSIQaWR4UHJpY2VBc3NldERjbSIOaWR4SUFtdEFzc2V0SWQiEGlkeElQcmljZUFzc2V0SWQiDWlkeExQQXNzZXREY20iEmlkeFBvb2xBb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oAsH45", "chainId": 84, "height": 2348588, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: C8SrPUzU7oXZLy2EDbAEAnrz4VkDuHgBBWSNsqHvqiTv Next: 9eVBejn7edpgiQcY3f9QxaAqJSvzqtxeAs93vV8cjbu6 Diff:
OldNewDifferences
379379 }
380380
381381
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+
382391 func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = {
383392 let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta)
384393 let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta)
389398 }
390399
391400
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")
401404
402405
403406 func validateMatcherOrderAllowed (order) = {
404407 let amountAssetAmount = order.amount
405408 let priceAssetAmount = fraction(order.amount, order.price, scale8)
406- let $t02002520237 = if ((order.orderType == Buy))
409+ let $t02021820430 = if ((order.orderType == Buy))
407410 then $Tuple2(amountAssetAmount, -(priceAssetAmount))
408411 else $Tuple2(-(amountAssetAmount), priceAssetAmount)
409- let amountAssetBalanceDelta = $t02002520237._1
410- let priceAssetBalanceDelta = $t02002520237._2
412+ let amountAssetBalanceDelta = $t02021820430._1
413+ let priceAssetBalanceDelta = $t02021820430._2
411414 if (if (if (isGlobalShutdown())
412415 then true
413416 else (cfgPoolStatus == PoolMatcherDisabled))
420423 then throw("Wrong order assets.")
421424 else {
422425 let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp"))
423- let $t02070820808 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
424- let unusedActions = $t02070820808._1
425- let kLpNew = $t02070820808._2
426+ let $t02090121001 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
427+ let unusedActions = $t02090121001._1
428+ let kLpNew = $t02090121001._2
426429 let isOrderValid = (kLpNew > kLp)
427430 isOrderValid
428431 }
498501 else if ((paymentAssetId == cfgPriceAssetId))
499502 then false
500503 else throwErr("invalid asset")
501- let $t02349223785 = if (isEval)
504+ let $t02368523978 = if (isEval)
502505 then $Tuple2(amountBalanceRaw, priceBalanceRaw)
503506 else if (paymentInAmountAsset)
504507 then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw)
505508 else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw))
506- let amountBalanceOld = $t02349223785._1
507- let priceBalanceOld = $t02349223785._2
508- let $t02378923938 = if (paymentInAmountAsset)
509+ let amountBalanceOld = $t02368523978._1
510+ let priceBalanceOld = $t02368523978._2
511+ let $t02398224131 = if (paymentInAmountAsset)
509512 then $Tuple2(paymentAmountRaw, 0)
510513 else $Tuple2(0, paymentAmountRaw)
511- let amountAssetAmountRaw = $t02378923938._1
512- let priceAssetAmountRaw = $t02378923938._2
514+ let amountAssetAmountRaw = $t02398224131._1
515+ let priceAssetAmountRaw = $t02398224131._2
513516 let amountAssetAmount = takeFee(amountAssetAmountRaw)._1
514517 let priceAssetAmount = takeFee(priceAssetAmountRaw)._1
515- let $t02406024119 = takeFee(paymentAmountRaw)
516- let paymentAmount = $t02406024119._1
517- let feeAmount = $t02406024119._2
518+ let $t02425324312 = takeFee(paymentAmountRaw)
519+ let paymentAmount = $t02425324312._1
520+ let feeAmount = $t02425324312._2
518521 let amountBalanceNew = (amountBalanceOld + amountAssetAmount)
519522 let priceBalanceNew = (priceBalanceOld + priceAssetAmount)
520523 let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals))
537540 let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals))
538541 let priceOld = fromX18(priceOldX18, scale8)
539542 let loss = {
540- let $t02559625763 = if (paymentInAmountAsset)
543+ let $t02578925956 = if (paymentInAmountAsset)
541544 then $Tuple2(amountAssetAmountRaw, amountBalanceOld)
542545 else $Tuple2(priceAssetAmountRaw, priceBalanceOld)
543- let amount = $t02559625763._1
544- let balance = $t02559625763._2
546+ let amount = $t02578925956._1
547+ let balance = $t02578925956._2
545548 let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance)))
546549 fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth)
547550 }
575578 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
576579 let redeemedBigInt = toBigInt(paymentAmount)
577580 let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))])
578- let $t02736527415 = takeFee(amountRaw)
579- let totalAmount = $t02736527415._1
580- let feeAmount = $t02736527415._2
581- let $t02741927645 = if (outInAmountAsset)
581+ let $t02755827608 = takeFee(amountRaw)
582+ let totalAmount = $t02755827608._1
583+ let feeAmount = $t02755827608._2
584+ let $t02761227838 = if (outInAmountAsset)
582585 then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
583586 else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw))
584- let outAmAmount = $t02741927645._1
585- let outPrAmount = $t02741927645._2
586- let amBalanceNew = $t02741927645._3
587- let prBalanceNew = $t02741927645._4
587+ let outAmAmount = $t02761227838._1
588+ let outPrAmount = $t02761227838._2
589+ let amBalanceNew = $t02761227838._3
590+ let prBalanceNew = $t02761227838._4
588591 let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
589592 let priceNew = fromX18(priceNewX18, scale8)
590593 let commonState = if (isEval)
696699 let prDiff = estPut._11
697700 let amId = estPut._12
698701 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))
701706 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))
709709 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))
714717 then {
715- let slippagePInv = if ((prDiff > 0))
716- then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
718+ let slippageAInv = if ((amDiff > 0))
719+ then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
717720 else nil
718- if ((slippagePInv == slippagePInv))
721+ if ((slippageAInv == slippageAInv))
719722 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))
721727 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)
725742 else throw("Strict value is not equal to itself.")
726743 }
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)
734744 else throw("Strict value is not equal to itself.")
735745 }
736746 else throw("Strict value is not equal to itself.")
750760 else {
751761 let estPut = commonPut(i, maxSlippage, false)
752762 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+ }
759776 else throw("Strict value is not equal to itself.")
760777 }
761778
788805 let payment = i.payments[0]
789806 let paymentAssetId = payment.assetId
790807 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")
791813 let userAddress = i.caller
792814 let txId = i.transactionId
793- let $t03291333065 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
794- if (($t03291333065 == $t03291333065))
815+ let $t03386734019 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
816+ if (($t03386734019 == $t03386734019))
795817 then {
796- let paymentInAmountAsset = $t03291333065._5
797- let bonus = $t03291333065._4
798- let feeAmount = $t03291333065._3
799- let commonState = $t03291333065._2
800- let emitAmountEstimated = $t03291333065._1
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
801823 let emitAmount = if (if ((minOutAmount > 0))
802824 then (minOutAmount > emitAmountEstimated)
803825 else false)
817839 let sendFee = if ((feeAmount > 0))
818840 then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
819841 else nil
820- let $t03365133848 = if ((this == feeCollectorAddress))
842+ let $t03460534802 = if ((this == feeCollectorAddress))
821843 then $Tuple2(0, 0)
822844 else if (paymentInAmountAsset)
823845 then $Tuple2(-(feeAmount), 0)
824846 else $Tuple2(0, -(feeAmount))
825- let amountAssetBalanceDelta = $t03365133848._1
826- let priceAssetBalanceDelta = $t03365133848._2
827- let $t03385133959 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
828- let refreshKLpActions = $t03385133959._1
829- let updatedKLp = $t03385133959._2
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)
831853 if ((isUpdatedKLpValid == isUpdatedKLpValid))
832854 then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
833855 else throw("Strict value is not equal to itself.")
843865
844866 @Callable(i)
845867 func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = {
846- let $t03421334370 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
847- let emitAmountEstimated = $t03421334370._1
848- let commonState = $t03421334370._2
849- let feeAmount = $t03421334370._3
850- let bonus = $t03421334370._4
851- let paymentInAmountAsset = $t03421334370._5
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
852874 $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
853875 }
854876
880902 let payment = i.payments[0]
881903 let paymentAssetId = payment.assetId
882904 let paymentAmount = payment.amount
905+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(paymentAmount))
883906 let userAddress = i.caller
884907 let txId = i.transactionId
885- let $t03517535328 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
886- if (($t03517535328 == $t03517535328))
908+ let $t03623036383 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
909+ if (($t03623036383 == $t03623036383))
887910 then {
888- let outInAmountAsset = $t03517535328._5
889- let bonus = $t03517535328._4
890- let feeAmount = $t03517535328._3
891- let commonState = $t03517535328._2
892- let amountEstimated = $t03517535328._1
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
893916 let amount = if (if ((minOutAmount > 0))
894917 then (minOutAmount > amountEstimated)
895918 else false)
902925 let sendFee = if ((feeAmount > 0))
903926 then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
904927 else nil
905- let $t03582836075 = {
928+ let $t03688337130 = {
906929 let feeAmountForCalc = if ((this == feeCollectorAddress))
907930 then 0
908931 else feeAmount
910933 then $Tuple2(-((amount + feeAmountForCalc)), 0)
911934 else $Tuple2(0, -((amount + feeAmountForCalc)))
912935 }
913- let amountAssetBalanceDelta = $t03582836075._1
914- let priceAssetBalanceDelta = $t03582836075._2
915- let $t03607836186 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
916- let refreshKLpActions = $t03607836186._1
917- let updatedKLp = $t03607836186._2
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)
919942 if ((isUpdatedKLpValid == isUpdatedKLpValid))
920943 then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
921944 else throw("Strict value is not equal to itself.")
931954
932955 @Callable(i)
933956 func getOneTknREADONLY (outAssetId,paymentAmount) = {
934- let $t03643136587 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
935- let amountEstimated = $t03643136587._1
936- let commonState = $t03643136587._2
937- let feeAmount = $t03643136587._3
938- let bonus = $t03643136587._4
939- let outInAmountAsset = $t03643136587._5
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
940963 $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
941964 }
942965
967990 let outAssetId = parseAssetId(outAssetIdStr)
968991 let userAddress = i.caller
969992 let txId = i.transactionId
993+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
970994 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
971995 if ((unstakeInv == unstakeInv))
972996 then {
973- let $t03741237563 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
974- if (($t03741237563 == $t03741237563))
997+ let $t03855638707 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
998+ if (($t03855638707 == $t03855638707))
975999 then {
976- let outInAmountAsset = $t03741237563._5
977- let bonus = $t03741237563._4
978- let feeAmount = $t03741237563._3
979- let commonState = $t03741237563._2
980- let amountEstimated = $t03741237563._1
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
9811005 let amount = if (if ((minOutAmount > 0))
9821006 then (minOutAmount > amountEstimated)
9831007 else false)
9901014 let sendFee = if ((feeAmount > 0))
9911015 then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
9921016 else nil
993- let $t03805838305 = {
1017+ let $t03920239449 = {
9941018 let feeAmountForCalc = if ((this == feeCollectorAddress))
9951019 then 0
9961020 else feeAmount
9981022 then $Tuple2(-((amount + feeAmountForCalc)), 0)
9991023 else $Tuple2(0, -((amount + feeAmountForCalc)))
10001024 }
1001- let amountAssetBalanceDelta = $t03805838305._1
1002- let priceAssetBalanceDelta = $t03805838305._2
1003- let $t03830838416 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1004- let refreshKLpActions = $t03830838416._1
1005- let updatedKLp = $t03830838416._2
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)
10071031 if ((isUpdatedKLpValid == isUpdatedKLpValid))
10081032 then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
10091033 else throw("Strict value is not equal to itself.")
10271051 let pmtAmt = res._3
10281052 let pmtAssetId = res._4
10291053 let state = res._5
1054+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt))
10301055 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
10311056 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
10321057 then {
1033- let $t03926939351 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1034- let refreshKLpActions = $t03926939351._1
1035- let updatedKLp = $t03926939351._2
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)
10371062 if ((isUpdatedKLpValid == isUpdatedKLpValid))
10381063 then (state ++ refreshKLpActions)
10391064 else throw("Strict value is not equal to itself.")
10561081 else if ((noLessThenPriceAsset > outPrAmt))
10571082 then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
10581083 else {
1084+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt))
10591085 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
10601086 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
10611087 then {
1062- let $t04020840289 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1063- let refreshKLpActions = $t04020840289._1
1064- let updatedKLp = $t04020840289._2
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)
10661092 if ((isUpdatedKLpValid == isUpdatedKLpValid))
10671093 then (state ++ refreshKLpActions)
10681094 else throw("Strict value is not equal to itself.")
10821108 then {
10831109 let cfg = getPoolConfig()
10841110 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
1111+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
10851112 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
10861113 if ((unstakeInv == unstakeInv))
10871114 then {
11001127 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
11011128 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
11021129 then {
1103- let $t04132341404 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1104- let refreshKLpActions = $t04132341404._1
1105- let updatedKLp = $t04132341404._2
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)
11071134 if ((isUpdatedKLpValid == isUpdatedKLpValid))
11081135 then (state ++ refreshKLpActions)
11091136 else throw("Strict value is not equal to itself.")
11311158 else throw("no payments are expected")]
11321159 if ((checks == checks))
11331160 then {
1161+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
11341162 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
11351163 if ((unstakeInv == unstakeInv))
11361164 then {
11481176 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
11491177 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
11501178 then {
1151- let $t04260742688 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1152- let refreshKLpActions = $t04260742688._1
1153- let updatedKLp = $t04260742688._2
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)
11551183 if ((isUpdatedKLpValid == isUpdatedKLpValid))
11561184 then (state ++ refreshKLpActions)
11571185 else throw("Strict value is not equal to itself.")
11831211 if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
11841212 then {
11851213 let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp"))
1186- let $t04386343927 = refreshKLpInternal(0, 0, 0)
1187- let kLpUpdateActions = $t04386343927._1
1188- let updatedKLp = $t04386343927._2
1214+ let $t04538645450 = refreshKLpInternal(0, 0, 0)
1215+ let kLpUpdateActions = $t04538645450._1
1216+ let updatedKLp = $t04538645450._2
11891217 let actions = if ((kLp != updatedKLp))
11901218 then kLpUpdateActions
11911219 else throwErr("nothing to refresh")
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let lPdecimals = 8
55
66 let scale8 = 100000000
77
88 let scale8BigInt = toBigInt(100000000)
99
1010 let scale18 = toBigInt(1000000000000000000)
1111
1212 let zeroBigInt = toBigInt(0)
1313
1414 let big0 = toBigInt(0)
1515
1616 let big1 = toBigInt(1)
1717
1818 let big2 = toBigInt(2)
1919
2020 let wavesString = "WAVES"
2121
2222 let SEP = "__"
2323
2424 let PoolActive = 1
2525
2626 let PoolPutDisabled = 2
2727
2828 let PoolMatcherDisabled = 3
2929
3030 let PoolShutdown = 4
3131
3232 let idxPoolAddress = 1
3333
3434 let idxPoolStatus = 2
3535
3636 let idxPoolLPAssetId = 3
3737
3838 let idxAmtAssetId = 4
3939
4040 let idxPriceAssetId = 5
4141
4242 let idxAmtAssetDcm = 6
4343
4444 let idxPriceAssetDcm = 7
4545
4646 let idxIAmtAssetId = 8
4747
4848 let idxIPriceAssetId = 9
4949
5050 let idxLPAssetDcm = 10
5151
5252 let idxPoolAmtAssetAmt = 1
5353
5454 let idxPoolPriceAssetAmt = 2
5555
5656 let idxPoolLPAssetAmt = 3
5757
5858 let idxFactoryStakingContract = 1
5959
6060 let idxFactorySlippageContract = 7
6161
6262 func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult))
6363
6464
6565 func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18))
6666
6767
6868 func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale)
6969
7070
7171 func abs (val) = if ((0 > val))
7272 then -(val)
7373 else val
7474
7575
7676 func absBigInt (val) = if ((zeroBigInt > val))
7777 then -(val)
7878 else val
7979
8080
8181 func fc () = "%s__factoryContract"
8282
8383
8484 func mpk () = "%s__managerPublicKey"
8585
8686
8787 func pmpk () = "%s__pendingManagerPublicKey"
8888
8989
9090 func pl () = "%s%s__price__last"
9191
9292
9393 func ph (h,timestamp) = makeString(["%s%s%d%d__price__history", toString(h), toString(timestamp)], SEP)
9494
9595
9696 func pau (userAddress,txId) = ((("%s%s%s__P__" + userAddress) + "__") + txId)
9797
9898
9999 func gau (userAddress,txId) = ((("%s%s%s__G__" + userAddress) + "__") + txId)
100100
101101
102102 func aa () = "%s__amountAsset"
103103
104104
105105 func pa () = "%s__priceAsset"
106106
107107
108108 let keyFee = "%s__fee"
109109
110110 let feeDefault = fraction(10, scale8, 10000)
111111
112112 let fee = valueOrElse(getInteger(this, keyFee), feeDefault)
113113
114114 let keyKLp = makeString(["%s", "kLp"], SEP)
115115
116116 let keyKLpRefreshedHeight = makeString(["%s", "kLpRefreshedHeight"], SEP)
117117
118118 let keyKLpRefreshDelay = makeString(["%s", "refreshKLpDelay"], SEP)
119119
120120 let kLpRefreshDelayDefault = 30
121121
122122 let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault)
123123
124124 func keyFactoryConfig () = "%s__factoryConfig"
125125
126126
127127 func keyMatcherPub () = "%s%s__matcher__publicKey"
128128
129129
130130 func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset")
131131
132132
133133 func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config")
134134
135135
136136 func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr)
137137
138138
139139 func keyAllPoolsShutdown () = "%s__shutdown"
140140
141141
142142 func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress)
143143
144144
145145 func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash"
146146
147147
148148 let keyFeeCollectorAddress = "%s__feeCollectorAddress"
149149
150150 func throwOrderError (orderValid,senderValid,matcherValid) = throw(((((("order validation failed: orderValid=" + toString(orderValid)) + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid)))
151151
152152
153153 func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
154154
155155
156156 func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
157157
158158
159159 func throwErr (msg) = throw(makeString(["lp.ride:", msg], " "))
160160
161161
162162 func fmtErr (msg) = makeString(["lp.ride:", msg], " ")
163163
164164
165165 let factoryContract = addressFromStringValue(getStringOrFail(this, fc()))
166166
167167 let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress))
168168
169169 func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false)
170170
171171
172172 func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub()))
173173
174174
175175 func getPoolConfig () = {
176176 let amtAsset = getStringOrFail(this, aa())
177177 let priceAsset = getStringOrFail(this, pa())
178178 let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset))
179179 let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset))
180180 split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP)
181181 }
182182
183183
184184 func parseAssetId (input) = if ((input == wavesString))
185185 then unit
186186 else fromBase58String(input)
187187
188188
189189 func assetIdToString (input) = if ((input == unit))
190190 then wavesString
191191 else toBase58String(value(input))
192192
193193
194194 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]))
195195
196196
197197 let poolConfigParsed = parsePoolConfig(getPoolConfig())
198198
199199 let $t079158081 = poolConfigParsed
200200
201201 let cfgPoolAddress = $t079158081._1
202202
203203 let cfgPoolStatus = $t079158081._2
204204
205205 let cfgLpAssetId = $t079158081._3
206206
207207 let cfgAmountAssetId = $t079158081._4
208208
209209 let cfgPriceAssetId = $t079158081._5
210210
211211 let cfgAmountAssetDecimals = $t079158081._6
212212
213213 let cfgPriceAssetDecimals = $t079158081._7
214214
215215 func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
216216
217217
218218 let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address")
219219
220220 let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address")
221221
222222 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)
223223
224224
225225 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)
226226
227227
228228 func getAccBalance (assetId) = if ((assetId == "WAVES"))
229229 then wavesBalance(this).available
230230 else assetBalance(this, fromBase58String(assetId))
231231
232232
233233 func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
234234
235235
236236 func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
237237 let amtAssetAmtX18 = toX18(amAmt, amAssetDcm)
238238 let priceAssetAmtX18 = toX18(prAmt, prAssetDcm)
239239 calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18)
240240 }
241241
242242
243243 func calcPrices (amAmt,prAmt,lpAmt) = {
244244 let cfg = getPoolConfig()
245245 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
246246 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
247247 let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt)
248248 let amAmtX18 = toX18(amAmt, amtAssetDcm)
249249 let prAmtX18 = toX18(prAmt, priceAssetDcm)
250250 let lpAmtX18 = toX18(lpAmt, scale8)
251251 let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18)
252252 let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18)
253253 [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18]
254254 }
255255
256256
257257 func calculatePrices (amAmt,prAmt,lpAmt) = {
258258 let prices = calcPrices(amAmt, prAmt, lpAmt)
259259 [fromX18(prices[0], scale8), fromX18(prices[1], scale8), fromX18(prices[2], scale8)]
260260 }
261261
262262
263263 func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
264264 let cfg = getPoolConfig()
265265 let lpAssetId = cfg[idxPoolLPAssetId]
266266 let amAssetId = cfg[idxAmtAssetId]
267267 let prAssetId = cfg[idxPriceAssetId]
268268 let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
269269 let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
270270 let poolStatus = cfg[idxPoolStatus]
271271 let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity
272272 if ((lpAssetId != pmtAssetId))
273273 then throw("Invalid asset passed.")
274274 else {
275275 let amBalance = getAccBalance(amAssetId)
276276 let amBalanceX18 = toX18(amBalance, amAssetDcm)
277277 let prBalance = getAccBalance(prAssetId)
278278 let prBalanceX18 = toX18(prBalance, prAssetDcm)
279279 let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18)
280280 let curPrice = fromX18(curPriceX18, scale8)
281281 let pmtLpAmtX18 = toX18(pmtLpAmt, scale8)
282282 let lpEmissionX18 = toX18(lpEmission, scale8)
283283 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18)
284284 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18)
285285 let outAmAmt = fromX18(outAmAmtX18, amAssetDcm)
286286 let outPrAmt = fromX18(outPrAmtX18, prAssetDcm)
287287 let state = if ((txId58 == ""))
288288 then nil
289289 else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES"))
290290 then unit
291291 else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES"))
292292 then unit
293293 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)]
294294 $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state)
295295 }
296296 }
297297
298298
299299 func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = {
300300 let cfg = getPoolConfig()
301301 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
302302 let amAssetIdStr = cfg[idxAmtAssetId]
303303 let prAssetIdStr = cfg[idxPriceAssetId]
304304 let iAmtAssetId = cfg[idxIAmtAssetId]
305305 let iPriceAssetId = cfg[idxIPriceAssetId]
306306 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
307307 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
308308 let poolStatus = cfg[idxPoolStatus]
309309 let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
310310 let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES")))
311311 let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES")))
312312 if (if ((amAssetIdStr != inAmAssetIdStr))
313313 then true
314314 else (prAssetIdStr != inPrAssetIdStr))
315315 then throw("Invalid amt or price asset passed.")
316316 else {
317317 let amBalance = if (isEvaluate)
318318 then getAccBalance(amAssetIdStr)
319319 else (getAccBalance(amAssetIdStr) - inAmAssetAmt)
320320 let prBalance = if (isEvaluate)
321321 then getAccBalance(prAssetIdStr)
322322 else (getAccBalance(prAssetIdStr) - inPrAssetAmt)
323323 let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm)
324324 let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm)
325325 let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18)
326326 let amBalanceX18 = toX18(amBalance, amtAssetDcm)
327327 let prBalanceX18 = toX18(prBalance, priceAssetDcm)
328328 let res = if ((lpEmission == 0))
329329 then {
330330 let curPriceX18 = zeroBigInt
331331 let slippageX18 = zeroBigInt
332332 let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN)
333333 $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
334334 }
335335 else {
336336 let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18)
337337 let slippageX18 = fraction(absBigInt((curPriceX18 - userPriceX18)), scale18, curPriceX18)
338338 let slippageToleranceX18 = toX18(slippageTolerance, scale8)
339339 if (if ((curPriceX18 != zeroBigInt))
340340 then (slippageX18 > slippageToleranceX18)
341341 else false)
342342 then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18)))
343343 else {
344344 let lpEmissionX18 = toX18(lpEmission, scale8)
345345 let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
346346 let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
347347 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
348348 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
349349 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
350350 let expAmtAssetAmtX18 = expectedAmts._1
351351 let expPriceAssetAmtX18 = expectedAmts._2
352352 let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
353353 $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18)
354354 }
355355 }
356356 let calcLpAmt = res._1
357357 let calcAmAssetPmt = res._2
358358 let calcPrAssetPmt = res._3
359359 let curPrice = fromX18(res._4, scale8)
360360 let slippageCalc = fromX18(res._5, scale8)
361361 if ((0 >= calcLpAmt))
362362 then throw("Invalid calculations. LP calculated is less than zero.")
363363 else {
364364 let emitLpAmt = if (!(emitLp))
365365 then 0
366366 else calcLpAmt
367367 let amDiff = (inAmAssetAmt - calcAmAssetPmt)
368368 let prDiff = (inPrAssetAmt - calcPrAssetPmt)
369369 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))]
370370 $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId)
371371 }
372372 }
373373 }
374374
375375
376376 func calcKLp (amountBalance,priceBalance,lpEmission) = {
377377 let updatedKLp = fraction(pow((amountBalance * priceBalance), 0, toBigInt(5), 1, 0, DOWN), scale18, lpEmission)
378378 updatedKLp
379379 }
380380
381381
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+
382391 func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = {
383392 let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta)
384393 let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta)
385394 let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta)
386395 let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission))
387396 let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))]
388397 $Tuple2(actions, updatedKLp)
389398 }
390399
391400
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")
401404
402405
403406 func validateMatcherOrderAllowed (order) = {
404407 let amountAssetAmount = order.amount
405408 let priceAssetAmount = fraction(order.amount, order.price, scale8)
406- let $t02002520237 = if ((order.orderType == Buy))
409+ let $t02021820430 = if ((order.orderType == Buy))
407410 then $Tuple2(amountAssetAmount, -(priceAssetAmount))
408411 else $Tuple2(-(amountAssetAmount), priceAssetAmount)
409- let amountAssetBalanceDelta = $t02002520237._1
410- let priceAssetBalanceDelta = $t02002520237._2
412+ let amountAssetBalanceDelta = $t02021820430._1
413+ let priceAssetBalanceDelta = $t02021820430._2
411414 if (if (if (isGlobalShutdown())
412415 then true
413416 else (cfgPoolStatus == PoolMatcherDisabled))
414417 then true
415418 else (cfgPoolStatus == PoolShutdown))
416419 then throw("Exchange operations disabled")
417420 else if (if ((order.assetPair.amountAsset != cfgAmountAssetId))
418421 then true
419422 else (order.assetPair.priceAsset != cfgPriceAssetId))
420423 then throw("Wrong order assets.")
421424 else {
422425 let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp"))
423- let $t02070820808 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
424- let unusedActions = $t02070820808._1
425- let kLpNew = $t02070820808._2
426+ let $t02090121001 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
427+ let unusedActions = $t02090121001._1
428+ let kLpNew = $t02090121001._2
426429 let isOrderValid = (kLpNew > kLp)
427430 isOrderValid
428431 }
429432 }
430433
431434
432435 func commonGet (i) = if ((size(i.payments) != 1))
433436 then throw("exactly 1 payment is expected")
434437 else {
435438 let pmt = value(i.payments[0])
436439 let pmtAssetId = value(pmt.assetId)
437440 let pmtAmt = pmt.amount
438441 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller)
439442 let outAmAmt = res._1
440443 let outPrAmt = res._2
441444 let poolStatus = parseIntValue(res._9)
442445 let state = res._10
443446 if (if (isGlobalShutdown())
444447 then true
445448 else (poolStatus == PoolShutdown))
446449 then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
447450 else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state)
448451 }
449452
450453
451454 func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2))
452455 then throw("exactly 2 payments are expected")
453456 else {
454457 let amAssetPmt = value(i.payments[0])
455458 let prAssetPmt = value(i.payments[1])
456459 let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp)
457460 let poolStatus = parseIntValue(estPut._8)
458461 if (if (if (isGlobalShutdown())
459462 then true
460463 else (poolStatus == PoolPutDisabled))
461464 then true
462465 else (poolStatus == PoolShutdown))
463466 then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus)))
464467 else estPut
465468 }
466469
467470
468471 func emit (amount) = {
469472 let emitInv = invoke(factoryContract, "emit", [amount], nil)
470473 if ((emitInv == emitInv))
471474 then {
472475 let emitInvLegacy = match emitInv {
473476 case legacyFactoryContract: Address =>
474477 invoke(legacyFactoryContract, "emit", [amount], nil)
475478 case _ =>
476479 unit
477480 }
478481 if ((emitInvLegacy == emitInvLegacy))
479482 then amount
480483 else throw("Strict value is not equal to itself.")
481484 }
482485 else throw("Strict value is not equal to itself.")
483486 }
484487
485488
486489 func takeFee (amount) = {
487490 let feeAmount = fraction(amount, fee, scale8)
488491 $Tuple2((amount - feeAmount), feeAmount)
489492 }
490493
491494
492495 func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = {
493496 let isEval = (txId == unit)
494497 let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId))
495498 let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId))
496499 let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId))
497500 then true
498501 else if ((paymentAssetId == cfgPriceAssetId))
499502 then false
500503 else throwErr("invalid asset")
501- let $t02349223785 = if (isEval)
504+ let $t02368523978 = if (isEval)
502505 then $Tuple2(amountBalanceRaw, priceBalanceRaw)
503506 else if (paymentInAmountAsset)
504507 then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw)
505508 else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw))
506- let amountBalanceOld = $t02349223785._1
507- let priceBalanceOld = $t02349223785._2
508- let $t02378923938 = if (paymentInAmountAsset)
509+ let amountBalanceOld = $t02368523978._1
510+ let priceBalanceOld = $t02368523978._2
511+ let $t02398224131 = if (paymentInAmountAsset)
509512 then $Tuple2(paymentAmountRaw, 0)
510513 else $Tuple2(0, paymentAmountRaw)
511- let amountAssetAmountRaw = $t02378923938._1
512- let priceAssetAmountRaw = $t02378923938._2
514+ let amountAssetAmountRaw = $t02398224131._1
515+ let priceAssetAmountRaw = $t02398224131._2
513516 let amountAssetAmount = takeFee(amountAssetAmountRaw)._1
514517 let priceAssetAmount = takeFee(priceAssetAmountRaw)._1
515- let $t02406024119 = takeFee(paymentAmountRaw)
516- let paymentAmount = $t02406024119._1
517- let feeAmount = $t02406024119._2
518+ let $t02425324312 = takeFee(paymentAmountRaw)
519+ let paymentAmount = $t02425324312._1
520+ let feeAmount = $t02425324312._2
518521 let amountBalanceNew = (amountBalanceOld + amountAssetAmount)
519522 let priceBalanceNew = (priceBalanceOld + priceAssetAmount)
520523 let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals))
521524 let priceNew = fromX18(priceNewX18, scale8)
522525 let paymentBalance = if (paymentInAmountAsset)
523526 then amountBalanceOld
524527 else priceBalanceOld
525528 let paymentBalanceBigInt = toBigInt(paymentBalance)
526529 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
527530 let chechSupply = if ((supplyBigInt > big0))
528531 then true
529532 else throwErr("initial deposit requires all coins")
530533 if ((chechSupply == chechSupply))
531534 then {
532535 let depositBigInt = toBigInt(paymentAmount)
533536 let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))])
534537 let commonState = if (isEval)
535538 then nil
536539 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))]
537540 let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals))
538541 let priceOld = fromX18(priceOldX18, scale8)
539542 let loss = {
540- let $t02559625763 = if (paymentInAmountAsset)
543+ let $t02578925956 = if (paymentInAmountAsset)
541544 then $Tuple2(amountAssetAmountRaw, amountBalanceOld)
542545 else $Tuple2(priceAssetAmountRaw, priceBalanceOld)
543- let amount = $t02559625763._1
544- let balance = $t02559625763._2
546+ let amount = $t02578925956._1
547+ let balance = $t02578925956._2
545548 let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance)))
546549 fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth)
547550 }
548551 $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset)
549552 }
550553 else throw("Strict value is not equal to itself.")
551554 }
552555
553556
554557 func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = {
555558 let isEval = (txId == unit)
556559 let checks = [if ((paymentAssetId == cfgLpAssetId))
557560 then true
558561 else throwErr("invalid lp asset")]
559562 if ((checks == checks))
560563 then {
561564 let outInAmountAsset = if ((outAssetId == cfgAmountAssetId))
562565 then true
563566 else if ((outAssetId == cfgPriceAssetId))
564567 then false
565568 else throwErr("invalid asset")
566569 let balanceBigInt = if (outInAmountAsset)
567570 then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId)))
568571 else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId)))
569572 let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId))
570573 let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId))
571574 let outBalance = if (outInAmountAsset)
572575 then amBalanceOld
573576 else prBalanceOld
574577 let outBalanceBigInt = toBigInt(outBalance)
575578 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
576579 let redeemedBigInt = toBigInt(paymentAmount)
577580 let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))])
578- let $t02736527415 = takeFee(amountRaw)
579- let totalAmount = $t02736527415._1
580- let feeAmount = $t02736527415._2
581- let $t02741927645 = if (outInAmountAsset)
581+ let $t02755827608 = takeFee(amountRaw)
582+ let totalAmount = $t02755827608._1
583+ let feeAmount = $t02755827608._2
584+ let $t02761227838 = if (outInAmountAsset)
582585 then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
583586 else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw))
584- let outAmAmount = $t02741927645._1
585- let outPrAmount = $t02741927645._2
586- let amBalanceNew = $t02741927645._3
587- let prBalanceNew = $t02741927645._4
587+ let outAmAmount = $t02761227838._1
588+ let outPrAmount = $t02761227838._2
589+ let amBalanceNew = $t02761227838._3
590+ let prBalanceNew = $t02761227838._4
588591 let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
589592 let priceNew = fromX18(priceNewX18, scale8)
590593 let commonState = if (isEval)
591594 then nil
592595 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)]
593596 let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals))
594597 let priceOld = fromX18(priceOldX18, scale8)
595598 let loss = {
596599 let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2)
597600 fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset)
598601 }
599602 $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset)
600603 }
601604 else throw("Strict value is not equal to itself.")
602605 }
603606
604607
605608 func managerPublicKeyOrUnit () = match getString(mpk()) {
606609 case s: String =>
607610 fromBase58String(s)
608611 case _: Unit =>
609612 unit
610613 case _ =>
611614 throw("Match error")
612615 }
613616
614617
615618 func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) {
616619 case s: String =>
617620 fromBase58String(s)
618621 case _: Unit =>
619622 unit
620623 case _ =>
621624 throw("Match error")
622625 }
623626
624627
625628 func isManager (i) = match managerPublicKeyOrUnit() {
626629 case pk: ByteVector =>
627630 (i.callerPublicKey == pk)
628631 case _: Unit =>
629632 (i.caller == this)
630633 case _ =>
631634 throw("Match error")
632635 }
633636
634637
635638 func mustManager (i) = {
636639 let pd = throw("Permission denied")
637640 match managerPublicKeyOrUnit() {
638641 case pk: ByteVector =>
639642 if ((i.callerPublicKey == pk))
640643 then true
641644 else pd
642645 case _: Unit =>
643646 if ((i.caller == this))
644647 then true
645648 else pd
646649 case _ =>
647650 throw("Match error")
648651 }
649652 }
650653
651654
652655 @Callable(i)
653656 func setManager (pendingManagerPublicKey) = {
654657 let checkCaller = mustManager(i)
655658 if ((checkCaller == checkCaller))
656659 then {
657660 let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
658661 if ((checkManagerPublicKey == checkManagerPublicKey))
659662 then [StringEntry(pmpk(), pendingManagerPublicKey)]
660663 else throw("Strict value is not equal to itself.")
661664 }
662665 else throw("Strict value is not equal to itself.")
663666 }
664667
665668
666669
667670 @Callable(i)
668671 func confirmManager () = {
669672 let pm = pendingManagerPublicKeyOrUnit()
670673 let hasPM = if (isDefined(pm))
671674 then true
672675 else throw("No pending manager")
673676 if ((hasPM == hasPM))
674677 then {
675678 let checkPM = if ((i.callerPublicKey == value(pm)))
676679 then true
677680 else throw("You are not pending manager")
678681 if ((checkPM == checkPM))
679682 then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())]
680683 else throw("Strict value is not equal to itself.")
681684 }
682685 else throw("Strict value is not equal to itself.")
683686 }
684687
685688
686689
687690 @Callable(i)
688691 func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance))
689692 then throw("Invalid slippageTolerance passed")
690693 else {
691694 let estPut = commonPut(i, slippageTolerance, true)
692695 let emitLpAmt = estPut._2
693696 let lpAssetId = estPut._7
694697 let state = estPut._9
695698 let amDiff = estPut._10
696699 let prDiff = estPut._11
697700 let amId = estPut._12
698701 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))
701706 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))
709709 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))
714717 then {
715- let slippagePInv = if ((prDiff > 0))
716- then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
718+ let slippageAInv = if ((amDiff > 0))
719+ then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
717720 else nil
718- if ((slippagePInv == slippagePInv))
721+ if ((slippageAInv == slippageAInv))
719722 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))
721727 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)
725742 else throw("Strict value is not equal to itself.")
726743 }
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)
734744 else throw("Strict value is not equal to itself.")
735745 }
736746 else throw("Strict value is not equal to itself.")
737747 }
738748 else throw("Strict value is not equal to itself.")
739749 }
740750 else throw("Strict value is not equal to itself.")
741751 }
742752 else throw("Strict value is not equal to itself.")
743753 }
744754
745755
746756
747757 @Callable(i)
748758 func putForFree (maxSlippage) = if ((0 > maxSlippage))
749759 then throw("Invalid value passed")
750760 else {
751761 let estPut = commonPut(i, maxSlippage, false)
752762 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+ }
759776 else throw("Strict value is not equal to itself.")
760777 }
761778
762779
763780
764781 @Callable(i)
765782 func putOneTkn (minOutAmount,autoStake) = {
766783 let isPoolOneTokenOperationsDisabled = {
767784 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
768785 if ($isInstanceOf(@, "Boolean"))
769786 then @
770787 else throw(($getType(@) + " couldn't be cast to Boolean"))
771788 }
772789 let isPutDisabled = if (if (if (isGlobalShutdown())
773790 then true
774791 else (cfgPoolStatus == PoolPutDisabled))
775792 then true
776793 else (cfgPoolStatus == PoolShutdown))
777794 then true
778795 else isPoolOneTokenOperationsDisabled
779796 let checks = [if (if (!(isPutDisabled))
780797 then true
781798 else isManager(i))
782799 then true
783800 else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1))
784801 then true
785802 else throwErr("exactly 1 payment are expected")]
786803 if ((checks == checks))
787804 then {
788805 let payment = i.payments[0]
789806 let paymentAssetId = payment.assetId
790807 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")
791813 let userAddress = i.caller
792814 let txId = i.transactionId
793- let $t03291333065 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
794- if (($t03291333065 == $t03291333065))
815+ let $t03386734019 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
816+ if (($t03386734019 == $t03386734019))
795817 then {
796- let paymentInAmountAsset = $t03291333065._5
797- let bonus = $t03291333065._4
798- let feeAmount = $t03291333065._3
799- let commonState = $t03291333065._2
800- let emitAmountEstimated = $t03291333065._1
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
801823 let emitAmount = if (if ((minOutAmount > 0))
802824 then (minOutAmount > emitAmountEstimated)
803825 else false)
804826 then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
805827 else emitAmountEstimated
806828 let emitInv = emit(emitAmount)
807829 if ((emitInv == emitInv))
808830 then {
809831 let lpTransfer = if (autoStake)
810832 then {
811833 let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
812834 if ((stakeInv == stakeInv))
813835 then nil
814836 else throw("Strict value is not equal to itself.")
815837 }
816838 else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
817839 let sendFee = if ((feeAmount > 0))
818840 then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
819841 else nil
820- let $t03365133848 = if ((this == feeCollectorAddress))
842+ let $t03460534802 = if ((this == feeCollectorAddress))
821843 then $Tuple2(0, 0)
822844 else if (paymentInAmountAsset)
823845 then $Tuple2(-(feeAmount), 0)
824846 else $Tuple2(0, -(feeAmount))
825- let amountAssetBalanceDelta = $t03365133848._1
826- let priceAssetBalanceDelta = $t03365133848._2
827- let $t03385133959 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
828- let refreshKLpActions = $t03385133959._1
829- let updatedKLp = $t03385133959._2
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)
831853 if ((isUpdatedKLpValid == isUpdatedKLpValid))
832854 then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
833855 else throw("Strict value is not equal to itself.")
834856 }
835857 else throw("Strict value is not equal to itself.")
836858 }
837859 else throw("Strict value is not equal to itself.")
838860 }
839861 else throw("Strict value is not equal to itself.")
840862 }
841863
842864
843865
844866 @Callable(i)
845867 func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = {
846- let $t03421334370 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
847- let emitAmountEstimated = $t03421334370._1
848- let commonState = $t03421334370._2
849- let feeAmount = $t03421334370._3
850- let bonus = $t03421334370._4
851- let paymentInAmountAsset = $t03421334370._5
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
852874 $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
853875 }
854876
855877
856878
857879 @Callable(i)
858880 func getOneTkn (outAssetIdStr,minOutAmount) = {
859881 let isPoolOneTokenOperationsDisabled = {
860882 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
861883 if ($isInstanceOf(@, "Boolean"))
862884 then @
863885 else throw(($getType(@) + " couldn't be cast to Boolean"))
864886 }
865887 let isGetDisabled = if (if (isGlobalShutdown())
866888 then true
867889 else (cfgPoolStatus == PoolShutdown))
868890 then true
869891 else isPoolOneTokenOperationsDisabled
870892 let checks = [if (if (!(isGetDisabled))
871893 then true
872894 else isManager(i))
873895 then true
874896 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1))
875897 then true
876898 else throwErr("exactly 1 payment are expected")]
877899 if ((checks == checks))
878900 then {
879901 let outAssetId = parseAssetId(outAssetIdStr)
880902 let payment = i.payments[0]
881903 let paymentAssetId = payment.assetId
882904 let paymentAmount = payment.amount
905+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(paymentAmount))
883906 let userAddress = i.caller
884907 let txId = i.transactionId
885- let $t03517535328 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
886- if (($t03517535328 == $t03517535328))
908+ let $t03623036383 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
909+ if (($t03623036383 == $t03623036383))
887910 then {
888- let outInAmountAsset = $t03517535328._5
889- let bonus = $t03517535328._4
890- let feeAmount = $t03517535328._3
891- let commonState = $t03517535328._2
892- let amountEstimated = $t03517535328._1
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
893916 let amount = if (if ((minOutAmount > 0))
894917 then (minOutAmount > amountEstimated)
895918 else false)
896919 then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
897920 else amountEstimated
898921 let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
899922 if ((burnInv == burnInv))
900923 then {
901924 let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
902925 let sendFee = if ((feeAmount > 0))
903926 then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
904927 else nil
905- let $t03582836075 = {
928+ let $t03688337130 = {
906929 let feeAmountForCalc = if ((this == feeCollectorAddress))
907930 then 0
908931 else feeAmount
909932 if (outInAmountAsset)
910933 then $Tuple2(-((amount + feeAmountForCalc)), 0)
911934 else $Tuple2(0, -((amount + feeAmountForCalc)))
912935 }
913- let amountAssetBalanceDelta = $t03582836075._1
914- let priceAssetBalanceDelta = $t03582836075._2
915- let $t03607836186 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
916- let refreshKLpActions = $t03607836186._1
917- let updatedKLp = $t03607836186._2
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)
919942 if ((isUpdatedKLpValid == isUpdatedKLpValid))
920943 then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
921944 else throw("Strict value is not equal to itself.")
922945 }
923946 else throw("Strict value is not equal to itself.")
924947 }
925948 else throw("Strict value is not equal to itself.")
926949 }
927950 else throw("Strict value is not equal to itself.")
928951 }
929952
930953
931954
932955 @Callable(i)
933956 func getOneTknREADONLY (outAssetId,paymentAmount) = {
934- let $t03643136587 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
935- let amountEstimated = $t03643136587._1
936- let commonState = $t03643136587._2
937- let feeAmount = $t03643136587._3
938- let bonus = $t03643136587._4
939- let outInAmountAsset = $t03643136587._5
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
940963 $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
941964 }
942965
943966
944967
945968 @Callable(i)
946969 func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = {
947970 let isPoolOneTokenOperationsDisabled = {
948971 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
949972 if ($isInstanceOf(@, "Boolean"))
950973 then @
951974 else throw(($getType(@) + " couldn't be cast to Boolean"))
952975 }
953976 let isGetDisabled = if (if (isGlobalShutdown())
954977 then true
955978 else (cfgPoolStatus == PoolShutdown))
956979 then true
957980 else isPoolOneTokenOperationsDisabled
958981 let checks = [if (if (!(isGetDisabled))
959982 then true
960983 else isManager(i))
961984 then true
962985 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0))
963986 then true
964987 else throwErr("no payments are expected")]
965988 if ((checks == checks))
966989 then {
967990 let outAssetId = parseAssetId(outAssetIdStr)
968991 let userAddress = i.caller
969992 let txId = i.transactionId
993+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
970994 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
971995 if ((unstakeInv == unstakeInv))
972996 then {
973- let $t03741237563 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
974- if (($t03741237563 == $t03741237563))
997+ let $t03855638707 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
998+ if (($t03855638707 == $t03855638707))
975999 then {
976- let outInAmountAsset = $t03741237563._5
977- let bonus = $t03741237563._4
978- let feeAmount = $t03741237563._3
979- let commonState = $t03741237563._2
980- let amountEstimated = $t03741237563._1
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
9811005 let amount = if (if ((minOutAmount > 0))
9821006 then (minOutAmount > amountEstimated)
9831007 else false)
9841008 then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
9851009 else amountEstimated
9861010 let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
9871011 if ((burnInv == burnInv))
9881012 then {
9891013 let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
9901014 let sendFee = if ((feeAmount > 0))
9911015 then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
9921016 else nil
993- let $t03805838305 = {
1017+ let $t03920239449 = {
9941018 let feeAmountForCalc = if ((this == feeCollectorAddress))
9951019 then 0
9961020 else feeAmount
9971021 if (outInAmountAsset)
9981022 then $Tuple2(-((amount + feeAmountForCalc)), 0)
9991023 else $Tuple2(0, -((amount + feeAmountForCalc)))
10001024 }
1001- let amountAssetBalanceDelta = $t03805838305._1
1002- let priceAssetBalanceDelta = $t03805838305._2
1003- let $t03830838416 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1004- let refreshKLpActions = $t03830838416._1
1005- let updatedKLp = $t03830838416._2
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)
10071031 if ((isUpdatedKLpValid == isUpdatedKLpValid))
10081032 then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
10091033 else throw("Strict value is not equal to itself.")
10101034 }
10111035 else throw("Strict value is not equal to itself.")
10121036 }
10131037 else throw("Strict value is not equal to itself.")
10141038 }
10151039 else throw("Strict value is not equal to itself.")
10161040 }
10171041 else throw("Strict value is not equal to itself.")
10181042 }
10191043
10201044
10211045
10221046 @Callable(i)
10231047 func get () = {
10241048 let res = commonGet(i)
10251049 let outAmtAmt = res._1
10261050 let outPrAmt = res._2
10271051 let pmtAmt = res._3
10281052 let pmtAssetId = res._4
10291053 let state = res._5
1054+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt))
10301055 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
10311056 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
10321057 then {
1033- let $t03926939351 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1034- let refreshKLpActions = $t03926939351._1
1035- let updatedKLp = $t03926939351._2
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)
10371062 if ((isUpdatedKLpValid == isUpdatedKLpValid))
10381063 then (state ++ refreshKLpActions)
10391064 else throw("Strict value is not equal to itself.")
10401065 }
10411066 else throw("Strict value is not equal to itself.")
10421067 }
10431068
10441069
10451070
10461071 @Callable(i)
10471072 func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = {
10481073 let res = commonGet(i)
10491074 let outAmAmt = res._1
10501075 let outPrAmt = res._2
10511076 let pmtAmt = res._3
10521077 let pmtAssetId = res._4
10531078 let state = res._5
10541079 if ((noLessThenAmtAsset > outAmAmt))
10551080 then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset)))
10561081 else if ((noLessThenPriceAsset > outPrAmt))
10571082 then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
10581083 else {
1084+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt))
10591085 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
10601086 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
10611087 then {
1062- let $t04020840289 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1063- let refreshKLpActions = $t04020840289._1
1064- let updatedKLp = $t04020840289._2
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)
10661092 if ((isUpdatedKLpValid == isUpdatedKLpValid))
10671093 then (state ++ refreshKLpActions)
10681094 else throw("Strict value is not equal to itself.")
10691095 }
10701096 else throw("Strict value is not equal to itself.")
10711097 }
10721098 }
10731099
10741100
10751101
10761102 @Callable(i)
10771103 func unstakeAndGet (amount) = {
10781104 let checkPayments = if ((size(i.payments) != 0))
10791105 then throw("No payments are expected")
10801106 else true
10811107 if ((checkPayments == checkPayments))
10821108 then {
10831109 let cfg = getPoolConfig()
10841110 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
1111+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
10851112 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
10861113 if ((unstakeInv == unstakeInv))
10871114 then {
10881115 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
10891116 let outAmAmt = res._1
10901117 let outPrAmt = res._2
10911118 let poolStatus = parseIntValue(res._9)
10921119 let state = res._10
10931120 let checkPoolStatus = if (if (isGlobalShutdown())
10941121 then true
10951122 else (poolStatus == PoolShutdown))
10961123 then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
10971124 else true
10981125 if ((checkPoolStatus == checkPoolStatus))
10991126 then {
11001127 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
11011128 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
11021129 then {
1103- let $t04132341404 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1104- let refreshKLpActions = $t04132341404._1
1105- let updatedKLp = $t04132341404._2
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)
11071134 if ((isUpdatedKLpValid == isUpdatedKLpValid))
11081135 then (state ++ refreshKLpActions)
11091136 else throw("Strict value is not equal to itself.")
11101137 }
11111138 else throw("Strict value is not equal to itself.")
11121139 }
11131140 else throw("Strict value is not equal to itself.")
11141141 }
11151142 else throw("Strict value is not equal to itself.")
11161143 }
11171144 else throw("Strict value is not equal to itself.")
11181145 }
11191146
11201147
11211148
11221149 @Callable(i)
11231150 func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = {
11241151 let isGetDisabled = if (isGlobalShutdown())
11251152 then true
11261153 else (cfgPoolStatus == PoolShutdown)
11271154 let checks = [if (!(isGetDisabled))
11281155 then true
11291156 else throw("get operation is blocked by admin"), if ((size(i.payments) == 0))
11301157 then true
11311158 else throw("no payments are expected")]
11321159 if ((checks == checks))
11331160 then {
1161+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
11341162 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
11351163 if ((unstakeInv == unstakeInv))
11361164 then {
11371165 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
11381166 let outAmAmt = res._1
11391167 let outPrAmt = res._2
11401168 let state = res._10
11411169 let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
11421170 then true
11431171 else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
11441172 then true
11451173 else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
11461174 if ((checkAmounts == checkAmounts))
11471175 then {
11481176 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
11491177 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
11501178 then {
1151- let $t04260742688 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1152- let refreshKLpActions = $t04260742688._1
1153- let updatedKLp = $t04260742688._2
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)
11551183 if ((isUpdatedKLpValid == isUpdatedKLpValid))
11561184 then (state ++ refreshKLpActions)
11571185 else throw("Strict value is not equal to itself.")
11581186 }
11591187 else throw("Strict value is not equal to itself.")
11601188 }
11611189 else throw("Strict value is not equal to itself.")
11621190 }
11631191 else throw("Strict value is not equal to itself.")
11641192 }
11651193 else throw("Strict value is not equal to itself.")
11661194 }
11671195
11681196
11691197
11701198 @Callable(i)
11711199 func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
11721200 then throw("permissions denied")
11731201 else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success")
11741202
11751203
11761204
11771205 @Callable(i)
11781206 func refreshKLp () = {
11791207 let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0)
11801208 let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay))
11811209 then unit
11821210 else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], ""))
11831211 if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
11841212 then {
11851213 let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp"))
1186- let $t04386343927 = refreshKLpInternal(0, 0, 0)
1187- let kLpUpdateActions = $t04386343927._1
1188- let updatedKLp = $t04386343927._2
1214+ let $t04538645450 = refreshKLpInternal(0, 0, 0)
1215+ let kLpUpdateActions = $t04538645450._1
1216+ let updatedKLp = $t04538645450._2
11891217 let actions = if ((kLp != updatedKLp))
11901218 then kLpUpdateActions
11911219 else throwErr("nothing to refresh")
11921220 $Tuple2(actions, toString(updatedKLp))
11931221 }
11941222 else throw("Strict value is not equal to itself.")
11951223 }
11961224
11971225
11981226
11991227 @Callable(i)
12001228 func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig())
12011229
12021230
12031231
12041232 @Callable(i)
12051233 func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId))
12061234
12071235
12081236
12091237 @Callable(i)
12101238 func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = {
12111239 let prices = calcPrices(amAmt, prAmt, lpAmt)
12121240 $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])])
12131241 }
12141242
12151243
12161244
12171245 @Callable(i)
12181246 func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult)))
12191247
12201248
12211249
12221250 @Callable(i)
12231251 func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult))
12241252
12251253
12261254
12271255 @Callable(i)
12281256 func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18))))
12291257
12301258
12311259
12321260 @Callable(i)
12331261 func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp))
12341262
12351263
12361264
12371265 @Callable(i)
12381266 func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
12391267 let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress))
12401268 $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10))
12411269 }
12421270
12431271
12441272
12451273 @Callable(i)
12461274 func statsREADONLY () = {
12471275 let cfg = getPoolConfig()
12481276 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
12491277 let amtAssetId = cfg[idxAmtAssetId]
12501278 let priceAssetId = cfg[idxPriceAssetId]
12511279 let iAmtAssetId = cfg[idxIAmtAssetId]
12521280 let iPriceAssetId = cfg[idxIPriceAssetId]
12531281 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
12541282 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
12551283 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
12561284 let accAmtAssetBalance = getAccBalance(amtAssetId)
12571285 let accPriceAssetBalance = getAccBalance(priceAssetId)
12581286 let pricesList = if ((poolLPBalance == 0))
12591287 then [zeroBigInt, zeroBigInt, zeroBigInt]
12601288 else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance)
12611289 let curPrice = 0
12621290 let lpAmtAssetShare = fromX18(pricesList[1], scale8)
12631291 let lpPriceAssetShare = fromX18(pricesList[2], scale8)
12641292 let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this))))
12651293 $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))
12661294 }
12671295
12681296
12691297
12701298 @Callable(i)
12711299 func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = {
12721300 let cfg = getPoolConfig()
12731301 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
12741302 let amAssetIdStr = cfg[idxAmtAssetId]
12751303 let amAssetId = fromBase58String(amAssetIdStr)
12761304 let prAssetIdStr = cfg[idxPriceAssetId]
12771305 let prAssetId = fromBase58String(prAssetIdStr)
12781306 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
12791307 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
12801308 let poolStatus = cfg[idxPoolStatus]
12811309 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
12821310 let accAmtAssetBalance = getAccBalance(amAssetIdStr)
12831311 let accPriceAssetBalance = getAccBalance(prAssetIdStr)
12841312 let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm)
12851313 let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm)
12861314 let curPriceX18 = if ((poolLPBalance == 0))
12871315 then zeroBigInt
12881316 else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18)
12891317 let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm)
12901318 let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
12911319 let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm)
12921320 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
12931321 let calcLpAmt = estPut._1
12941322 let curPriceCalc = estPut._3
12951323 let amBalance = estPut._4
12961324 let prBalance = estPut._5
12971325 let lpEmission = estPut._6
12981326 $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))
12991327 }
13001328
13011329
13021330
13031331 @Callable(i)
13041332 func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = {
13051333 let cfg = getPoolConfig()
13061334 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
13071335 let amAssetIdStr = cfg[idxAmtAssetId]
13081336 let amAssetId = fromBase58String(amAssetIdStr)
13091337 let prAssetIdStr = cfg[idxPriceAssetId]
13101338 let prAssetId = fromBase58String(prAssetIdStr)
13111339 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
13121340 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
13131341 let poolStatus = cfg[idxPoolStatus]
13141342 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
13151343 let amBalanceRaw = getAccBalance(amAssetIdStr)
13161344 let prBalanceRaw = getAccBalance(prAssetIdStr)
13171345 let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm)
13181346 let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm)
13191347 let curPriceX18 = if ((poolLPBalance == 0))
13201348 then zeroBigInt
13211349 else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18)
13221350 let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm)
13231351 let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
13241352 let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm)
13251353 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
13261354 let calcLpAmt = estPut._1
13271355 let curPriceCalc = estPut._3
13281356 let amBalance = estPut._4
13291357 let prBalance = estPut._5
13301358 let lpEmission = estPut._6
13311359 $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))
13321360 }
13331361
13341362
13351363
13361364 @Callable(i)
13371365 func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = {
13381366 let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this)
13391367 let outAmAmt = res._1
13401368 let outPrAmt = res._2
13411369 let amBalance = res._5
13421370 let prBalance = res._6
13431371 let lpEmission = res._7
13441372 let curPrice = res._8
13451373 let poolStatus = parseIntValue(res._9)
13461374 $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))
13471375 }
13481376
13491377
13501378 @Verifier(tx)
13511379 func verify () = {
13521380 let targetPublicKey = match managerPublicKeyOrUnit() {
13531381 case pk: ByteVector =>
13541382 pk
13551383 case _: Unit =>
13561384 tx.senderPublicKey
13571385 case _ =>
13581386 throw("Match error")
13591387 }
13601388 match tx {
13611389 case order: Order =>
13621390 let matcherPub = getMatcherPubOrFail()
13631391 let orderValid = validateMatcherOrderAllowed(order)
13641392 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
13651393 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
13661394 if (if (if (orderValid)
13671395 then senderValid
13681396 else false)
13691397 then matcherValid
13701398 else false)
13711399 then true
13721400 else throwOrderError(orderValid, senderValid, matcherValid)
13731401 case s: SetScriptTransaction =>
13741402 let newHash = blake2b256(value(s.script))
13751403 let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash())))
13761404 let currentHash = scriptHash(this)
13771405 if (if ((allowedHash == newHash))
13781406 then (currentHash != newHash)
13791407 else false)
13801408 then true
13811409 else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
13821410 case _ =>
13831411 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
13841412 }
13851413 }
13861414

github/deemru/w8io/026f985 
231.31 ms