tx · BL1XTa6RV5C7SJFYJuxxp9YfqZcdZ1xg6ojdtNWZFBkd

3MqczhSTuvkrfmVXHQ7F7FUBKGG4ujRiCVF:  -0.03300000 Waves

2022.12.05 09:30 [2346706] smart account 3MqczhSTuvkrfmVXHQ7F7FUBKGG4ujRiCVF > SELF 0.00000000 Waves

{ "type": 13, "id": "BL1XTa6RV5C7SJFYJuxxp9YfqZcdZ1xg6ojdtNWZFBkd", "fee": 3300000, "feeAssetId": null, "timestamp": 1670221802010, "version": 1, "sender": "3MqczhSTuvkrfmVXHQ7F7FUBKGG4ujRiCVF", "senderPublicKey": "EQAgJZZPyCDpoMAzhZA7KEcgYnQYQw2R5rQGNZAnnywo", "proofs": [ "5UEtb4e8VwUYHfiFLM5JJfou94i8FRuBLqZiCCGwyQ7FMaXKhFLJyTukF2PyE6gq8dqrWUfjuwPbbUZM8whPEd7p" ], "script": "base64:BgLYKwgCEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgQKAggBEgQKAggBEgQKAggBEgUKAwEIARIAEgQKAgEBEgMKAQESBQoDAQEBEgQKAggIEgASABIDCgEIEgUKAwEBARIECgIBARIECgIIARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCBIAEgMKAQESAwoBARIECgIIASIKbFBkZWNpbWFscyIGc2NhbGU4IgxzY2FsZThCaWdJbnQiB3NjYWxlMTgiCnplcm9CaWdJbnQiBGJpZzAiBGJpZzEiBGJpZzIiC3dhdmVzU3RyaW5nIgNTRVAiClBvb2xBY3RpdmUiD1Bvb2xQdXREaXNhYmxlZCITUG9vbE1hdGNoZXJEaXNhYmxlZCIMUG9vbFNodXRkb3duIg5pZHhQb29sQWRkcmVzcyINaWR4UG9vbFN0YXR1cyIQaWR4UG9vbExQQXNzZXRJZCINaWR4QW10QXNzZXRJZCIPaWR4UHJpY2VBc3NldElkIg5pZHhBbXRBc3NldERjbSIQaWR4UHJpY2VBc3NldERjbSIOaWR4SUFtdEFzc2V0SWQiEGlkeElQcmljZUFzc2V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AMwIAgkApAMBBQJjZQkAzAgCCQCkAwEFAmNiCQDMCAIJAKYDAQUCY2gJAMwIAgkApAMBBQJjYQUDbmlsBQFqAQJncAECZ3EABAJncgQCZEUJAQJlRwADCQABAgUCZEUCCkJ5dGVWZWN0b3IEAmVLBQJkRQUCZUsDCQABAgUCZEUCBFVuaXQIBQJncA9zZW5kZXJQdWJsaWNLZXkJAAIBAgtNYXRjaCBlcnJvcgQCZEUFAmdwAwkAAQIFAmRFAgVPcmRlcgQCZGoFAmRFBAJncwkBAmFNAAQCYXoJAQJkaQEFAmRqBAJhQQkA9AMDCAUCZGoJYm9keUJ5dGVzCQCRAwIIBQJkagZwcm9vZnMAAAgFAmRqD3NlbmRlclB1YmxpY0tleQQCYUIJAPQDAwgFAmRqCWJvZHlCeXRlcwkAkQMCCAUCZGoGcHJvb2ZzAAEFAmdzAwMDBQJhegUCYUEHBQJhQgcGCQECYXkDBQJhegUCYUEFAmFCAwkAAQIFAmRFAhRTZXRTY3JpcHRUcmFuc2FjdGlvbgQCZUgFAmRFBAJndAkA9gMBCQEFdmFsdWUBCAUCZUgGc2NyaXB0BAJndQkA2wQBCQEFdmFsdWUBCQCdCAIFAmFKCQECYXcABAJndgkA8QcBBQR0aGlzAwMJAAACBQJndQUCZ3QJAQIhPQIFAmd2BQJndAcGCQD0AwMIBQJncAlib2R5Qnl0ZXMJAJEDAggFAmdwBnByb29mcwAABQJncgkA9AMDCAUCZ3AJYm9keUJ5dGVzCQCRAwIIBQJncAZwcm9vZnMAAAUCZ3JXKual", "chainId": 84, "height": 2346706, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 88vBBCRoVAPxs158hxhWnHnyp3czQLQCgDvivbe9NYTC Next: fKs1ngbPLb2yorNM7Nj57P7U9rCV1QcyC1n8iWK9tDK Diff:
OldNewDifferences
111111
112112 let fee = valueOrElse(getInteger(this, keyFee), feeDefault)
113113
114+let keyKLp = makeString(["%s", "kLp"], SEP)
115+
116+let keyKLpRefreshedHeight = makeString(["%s", "kLpRefreshedHeight"], SEP)
117+
118+let keyKLpRefreshDelay = makeString(["%s", "refreshKLpDelay"], SEP)
119+
120+let kLpRefreshDelayDefault = 30
121+
122+let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault)
123+
114124 func keyFactoryConfig () = "%s__factoryConfig"
115125
116126
149159 func throwErr (msg) = throw(makeString(["lp.ride:", msg], " "))
150160
151161
162+func fmtErr (msg) = makeString(["lp.ride:", msg], " ")
163+
164+
152165 let factoryContract = addressFromStringValue(getStringOrFail(this, fc()))
153166
154167 let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress))
183196
184197 let poolConfigParsed = parsePoolConfig(getPoolConfig())
185198
186-let $t075447710 = poolConfigParsed
199+let $t079158081 = poolConfigParsed
187200
188-let cfgPoolAddress = $t075447710._1
201+let cfgPoolAddress = $t079158081._1
189202
190-let cfgPoolStatus = $t075447710._2
203+let cfgPoolStatus = $t079158081._2
191204
192-let cfgLpAssetId = $t075447710._3
205+let cfgLpAssetId = $t079158081._3
193206
194-let cfgAmountAssetId = $t075447710._4
207+let cfgAmountAssetId = $t079158081._4
195208
196-let cfgPriceAssetId = $t075447710._5
209+let cfgPriceAssetId = $t079158081._5
197210
198-let cfgAmountAssetDecimals = $t075447710._6
211+let cfgAmountAssetDecimals = $t079158081._6
199212
200-let cfgPriceAssetDecimals = $t075447710._7
213+let cfgPriceAssetDecimals = $t079158081._7
201214
202215 func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
203216
360373 }
361374
362375
376+func calcKLp (amountBalance,priceBalance,lpEmission) = {
377+ let updatedKLp = fraction(pow((amountBalance * priceBalance), 0, toBigInt(5), 1, 0, DOWN), scale18, lpEmission)
378+ updatedKLp
379+ }
380+
381+
382+func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = {
383+ let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta)
384+ let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta)
385+ let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta)
386+ let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission))
387+ let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))]
388+ $Tuple2(actions, updatedKLp)
389+ }
390+
391+
363392 func validateMatcherOrderAllowed (order) = {
364- let cfg = getPoolConfig()
365- let amtAssetId = cfg[idxAmtAssetId]
366- let priceAssetId = cfg[idxPriceAssetId]
367- let poolStatus = parseIntValue(cfg[idxPoolStatus])
368- let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
369- let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
370- let accAmtAssetBalance = getAccBalance(amtAssetId)
371- let accPriceAssetBalance = getAccBalance(priceAssetId)
372- let curPriceX18 = if ((order.orderType == Buy))
373- then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance)
374- else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance)
375- let curPrice = fromX18(curPriceX18, scale8)
393+ let amountAssetAmount = order.amount
394+ let priceAssetAmount = fraction(order.amount, order.price, scale8)
395+ let $t01955919771 = if ((order.orderType == Buy))
396+ then $Tuple2(amountAssetAmount, -(priceAssetAmount))
397+ else $Tuple2(-(amountAssetAmount), priceAssetAmount)
398+ let amountAssetBalanceDelta = $t01955919771._1
399+ let priceAssetBalanceDelta = $t01955919771._2
376400 if (if (if (isGlobalShutdown())
377401 then true
378- else (poolStatus == PoolMatcherDisabled))
402+ else (cfgPoolStatus == PoolMatcherDisabled))
379403 then true
380- else (poolStatus == PoolShutdown))
404+ else (cfgPoolStatus == PoolShutdown))
381405 then throw("Exchange operations disabled")
382- else {
383- let orderAmtAsset = order.assetPair.amountAsset
384- let orderAmtAssetStr = if ((orderAmtAsset == unit))
385- then "WAVES"
386- else toBase58String(value(orderAmtAsset))
387- let orderPriceAsset = order.assetPair.priceAsset
388- let orderPriceAssetStr = if ((orderPriceAsset == unit))
389- then "WAVES"
390- else toBase58String(value(orderPriceAsset))
391- if (if ((orderAmtAssetStr != amtAssetId))
392- then true
393- else (orderPriceAssetStr != priceAssetId))
394- then throw("Wrong order assets.")
395- else {
396- let orderPrice = order.price
397- let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm)
398- let castedOrderPrice = toScale(orderPrice, scale8, priceDcm)
399- let isOrderPriceValid = if ((order.orderType == Buy))
400- then (curPrice >= castedOrderPrice)
401- else (castedOrderPrice >= curPrice)
402- true
403- }
404- }
406+ else if (if ((order.assetPair.amountAsset != cfgAmountAssetId))
407+ then true
408+ else (order.assetPair.priceAsset != cfgPriceAssetId))
409+ then throw("Wrong order assets.")
410+ else {
411+ let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp"))
412+ let $t02024220342 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
413+ let unusedActions = $t02024220342._1
414+ let kLpNew = $t02024220342._2
415+ let isOrderValid = (kLpNew > kLp)
416+ isOrderValid
417+ }
405418 }
406419
407420
474487 else if ((paymentAssetId == cfgPriceAssetId))
475488 then false
476489 else throwErr("invalid asset")
477- let $t02257122864 = if (isEval)
490+ let $t02302623319 = if (isEval)
478491 then $Tuple2(amountBalanceRaw, priceBalanceRaw)
479492 else if (paymentInAmountAsset)
480493 then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw)
481494 else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw))
482- let amountBalanceOld = $t02257122864._1
483- let priceBalanceOld = $t02257122864._2
484- let $t02286823017 = if (paymentInAmountAsset)
495+ let amountBalanceOld = $t02302623319._1
496+ let priceBalanceOld = $t02302623319._2
497+ let $t02332323472 = if (paymentInAmountAsset)
485498 then $Tuple2(paymentAmountRaw, 0)
486499 else $Tuple2(0, paymentAmountRaw)
487- let amountAssetAmountRaw = $t02286823017._1
488- let priceAssetAmountRaw = $t02286823017._2
500+ let amountAssetAmountRaw = $t02332323472._1
501+ let priceAssetAmountRaw = $t02332323472._2
489502 let amountAssetAmount = takeFee(amountAssetAmountRaw)._1
490503 let priceAssetAmount = takeFee(priceAssetAmountRaw)._1
491- let $t02313923198 = takeFee(paymentAmountRaw)
492- let paymentAmount = $t02313923198._1
493- let feeAmount = $t02313923198._2
504+ let $t02359423653 = takeFee(paymentAmountRaw)
505+ let paymentAmount = $t02359423653._1
506+ let feeAmount = $t02359423653._2
494507 let amountBalanceNew = (amountBalanceOld + amountAssetAmount)
495508 let priceBalanceNew = (priceBalanceOld + priceAssetAmount)
496509 let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals))
513526 let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals))
514527 let priceOld = fromX18(priceOldX18, scale8)
515528 let loss = {
516- let $t02467524842 = if (paymentInAmountAsset)
529+ let $t02513025297 = if (paymentInAmountAsset)
517530 then $Tuple2(amountAssetAmountRaw, amountBalanceOld)
518531 else $Tuple2(priceAssetAmountRaw, priceBalanceOld)
519- let amount = $t02467524842._1
520- let balance = $t02467524842._2
532+ let amount = $t02513025297._1
533+ let balance = $t02513025297._2
521534 let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance)))
522535 fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth)
523536 }
524- $Tuple4(issueAmount, commonState, feeAmount, loss)
537+ $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset)
525538 }
526539 else throw("Strict value is not equal to itself.")
527540 }
551564 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
552565 let redeemedBigInt = toBigInt(paymentAmount)
553566 let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))])
554- let $t02642226472 = takeFee(amountRaw)
555- let totalAmount = $t02642226472._1
556- let feeAmount = $t02642226472._2
557- let $t02647626702 = if (outInAmountAsset)
567+ let $t02689926949 = takeFee(amountRaw)
568+ let totalAmount = $t02689926949._1
569+ let feeAmount = $t02689926949._2
570+ let $t02695327179 = if (outInAmountAsset)
558571 then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
559572 else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw))
560- let outAmAmount = $t02647626702._1
561- let outPrAmount = $t02647626702._2
562- let amBalanceNew = $t02647626702._3
563- let prBalanceNew = $t02647626702._4
573+ let outAmAmount = $t02695327179._1
574+ let outPrAmount = $t02695327179._2
575+ let amBalanceNew = $t02695327179._3
576+ let prBalanceNew = $t02695327179._4
564577 let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
565578 let priceNew = fromX18(priceNewX18, scale8)
566579 let commonState = if (isEval)
572585 let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2)
573586 fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset)
574587 }
575- $Tuple4(totalAmount, commonState, feeAmount, loss)
588+ $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset)
576589 }
577590 else throw("Strict value is not equal to itself.")
578591 }
701714 else throw("Strict value is not equal to itself.")
702715 }
703716 else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
704- (state ++ lpTransfer)
717+ let $t03113031195 = refreshKLpInternal(0, 0, 0)
718+ let refreshKLpActions = $t03113031195._1
719+ let updatedKLp = $t03113031195._2
720+ ((state ++ lpTransfer) ++ refreshKLpActions)
705721 }
706722 else throw("Strict value is not equal to itself.")
707723 }
719735 then throw("Invalid value passed")
720736 else {
721737 let estPut = commonPut(i, maxSlippage, false)
722- estPut._9
738+ let state = estPut._9
739+ let $t03148131546 = refreshKLpInternal(0, 0, 0)
740+ let refreshKLpActions = $t03148131546._1
741+ let updatedKLp = $t03148131546._2
742+ (state ++ refreshKLpActions)
723743 }
724744
725745
753773 let paymentAmountRaw = payment.amount
754774 let userAddress = i.caller
755775 let txId = i.transactionId
756- let $t03160931736 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
757- let emitAmountEstimated = $t03160931736._1
758- let commonState = $t03160931736._2
759- let feeAmount = $t03160931736._3
760- let bonus = $t03160931736._4
761- let emitAmount = if (if ((minOutAmount > 0))
762- then (minOutAmount > emitAmountEstimated)
763- else false)
764- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
765- else emitAmountEstimated
766- let emitInv = emit(emitAmount)
767- if ((emitInv == emitInv))
776+ let $t03232232474 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
777+ if (($t03232232474 == $t03232232474))
768778 then {
769- let lpTransfer = if (autoStake)
779+ let paymentInAmountAsset = $t03232232474._5
780+ let bonus = $t03232232474._4
781+ let feeAmount = $t03232232474._3
782+ let commonState = $t03232232474._2
783+ let emitAmountEstimated = $t03232232474._1
784+ let emitAmount = if (if ((minOutAmount > 0))
785+ then (minOutAmount > emitAmountEstimated)
786+ else false)
787+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
788+ else emitAmountEstimated
789+ let emitInv = emit(emitAmount)
790+ if ((emitInv == emitInv))
770791 then {
771- let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
772- if ((stakeInv == stakeInv))
773- then nil
774- else throw("Strict value is not equal to itself.")
792+ let lpTransfer = if (autoStake)
793+ then {
794+ let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
795+ if ((stakeInv == stakeInv))
796+ then nil
797+ else throw("Strict value is not equal to itself.")
798+ }
799+ else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
800+ let sendFee = if ((feeAmount > 0))
801+ then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
802+ else nil
803+ let $t03306033257 = if ((this == feeCollectorAddress))
804+ then $Tuple2(0, 0)
805+ else if (paymentInAmountAsset)
806+ then $Tuple2(-(feeAmount), 0)
807+ else $Tuple2(0, -(feeAmount))
808+ let amountAssetBalanceDelta = $t03306033257._1
809+ let priceAssetBalanceDelta = $t03306033257._2
810+ let $t03326033368 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
811+ let refreshKLpActions = $t03326033368._1
812+ let updatedKLp = $t03326033368._2
813+ $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
775814 }
776- else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
777- let sendFee = if ((feeAmount > 0))
778- then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
779- else nil
780- $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount)
815+ else throw("Strict value is not equal to itself.")
781816 }
782817 else throw("Strict value is not equal to itself.")
783818 }
788823
789824 @Callable(i)
790825 func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = {
791- let $t03246532600 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
792- let emitAmountEstimated = $t03246532600._1
793- let commonState = $t03246532600._2
794- let feeAmount = $t03246532600._3
795- let bonus = $t03246532600._4
826+ let $t03356133718 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
827+ let emitAmountEstimated = $t03356133718._1
828+ let commonState = $t03356133718._2
829+ let feeAmount = $t03356133718._3
830+ let bonus = $t03356133718._4
831+ let paymentInAmountAsset = $t03356133718._5
796832 $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
797833 }
798834
826862 let paymentAmount = payment.amount
827863 let userAddress = i.caller
828864 let txId = i.transactionId
829- let $t03340533537 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
830- let amountEstimated = $t03340533537._1
831- let commonState = $t03340533537._2
832- let feeAmount = $t03340533537._3
833- let bonus = $t03340533537._4
834- let amount = if (if ((minOutAmount > 0))
835- then (minOutAmount > amountEstimated)
836- else false)
837- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
838- else amountEstimated
839- let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
840- if ((burnInv == burnInv))
865+ let $t03452334676 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
866+ if (($t03452334676 == $t03452334676))
841867 then {
842- let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
843- let sendFee = if ((feeAmount > 0))
844- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
845- else nil
846- $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
868+ let outInAmountAsset = $t03452334676._5
869+ let bonus = $t03452334676._4
870+ let feeAmount = $t03452334676._3
871+ let commonState = $t03452334676._2
872+ let amountEstimated = $t03452334676._1
873+ let amount = if (if ((minOutAmount > 0))
874+ then (minOutAmount > amountEstimated)
875+ else false)
876+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
877+ else amountEstimated
878+ let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
879+ if ((burnInv == burnInv))
880+ then {
881+ let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
882+ let sendFee = if ((feeAmount > 0))
883+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
884+ else nil
885+ let $t03517635423 = {
886+ let feeAmountForCalc = if ((this == feeCollectorAddress))
887+ then 0
888+ else feeAmount
889+ if (outInAmountAsset)
890+ then $Tuple2(-((amount + feeAmountForCalc)), 0)
891+ else $Tuple2(0, -((amount + feeAmountForCalc)))
892+ }
893+ let amountAssetBalanceDelta = $t03517635423._1
894+ let priceAssetBalanceDelta = $t03517635423._2
895+ let $t03542635534 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
896+ let refreshKLpActions = $t03542635534._1
897+ let updatedKLp = $t03542635534._2
898+ $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
899+ }
900+ else throw("Strict value is not equal to itself.")
847901 }
848902 else throw("Strict value is not equal to itself.")
849903 }
854908
855909 @Callable(i)
856910 func getOneTknREADONLY (outAssetId,paymentAmount) = {
857- let $t03417234310 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
858- let amountEstimated = $t03417234310._1
859- let commonState = $t03417234310._2
860- let feeAmount = $t03417234310._3
861- let bonus = $t03417234310._4
911+ let $t03571835874 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
912+ let amountEstimated = $t03571835874._1
913+ let commonState = $t03571835874._2
914+ let feeAmount = $t03571835874._3
915+ let bonus = $t03571835874._4
916+ let outInAmountAsset = $t03571835874._5
862917 $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
863918 }
864919
892947 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
893948 if ((unstakeInv == unstakeInv))
894949 then {
895- let $t03513535265 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
896- let amountEstimated = $t03513535265._1
897- let commonState = $t03513535265._2
898- let feeAmount = $t03513535265._3
899- let bonus = $t03513535265._4
900- let amount = if (if ((minOutAmount > 0))
901- then (minOutAmount > amountEstimated)
902- else false)
903- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
904- else amountEstimated
905- let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
906- if ((burnInv == burnInv))
950+ let $t03669936850 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
951+ if (($t03669936850 == $t03669936850))
907952 then {
908- let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
909- let sendFee = if ((feeAmount > 0))
910- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
911- else nil
912- $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
953+ let outInAmountAsset = $t03669936850._5
954+ let bonus = $t03669936850._4
955+ let feeAmount = $t03669936850._3
956+ let commonState = $t03669936850._2
957+ let amountEstimated = $t03669936850._1
958+ let amount = if (if ((minOutAmount > 0))
959+ then (minOutAmount > amountEstimated)
960+ else false)
961+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
962+ else amountEstimated
963+ let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
964+ if ((burnInv == burnInv))
965+ then {
966+ let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
967+ let sendFee = if ((feeAmount > 0))
968+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
969+ else nil
970+ let $t03734537592 = {
971+ let feeAmountForCalc = if ((this == feeCollectorAddress))
972+ then 0
973+ else feeAmount
974+ if (outInAmountAsset)
975+ then $Tuple2(-((amount + feeAmountForCalc)), 0)
976+ else $Tuple2(0, -((amount + feeAmountForCalc)))
977+ }
978+ let amountAssetBalanceDelta = $t03734537592._1
979+ let priceAssetBalanceDelta = $t03734537592._2
980+ let $t03759537703 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
981+ let refreshKLpActions = $t03759537703._1
982+ let updatedKLp = $t03759537703._2
983+ $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
984+ }
985+ else throw("Strict value is not equal to itself.")
913986 }
914987 else throw("Strict value is not equal to itself.")
915988 }
9301003 let state = res._5
9311004 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
9321005 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
933- then state
1006+ then {
1007+ let $t03849538577 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1008+ let refreshKLpActions = $t03849538577._1
1009+ let updatedKLp = $t03849538577._2
1010+ (state ++ refreshKLpActions)
1011+ }
9341012 else throw("Strict value is not equal to itself.")
9351013 }
9361014
9511029 else {
9521030 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
9531031 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
954- then state
1032+ then {
1033+ let $t03937339454 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1034+ let refreshKLpActions = $t03937339454._1
1035+ let updatedKLp = $t03937339454._2
1036+ (state ++ refreshKLpActions)
1037+ }
9551038 else throw("Strict value is not equal to itself.")
9561039 }
9571040 }
9711054 if ((unstakeInv == unstakeInv))
9721055 then {
9731056 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1057+ let outAmAmt = res._1
1058+ let outPrAmt = res._2
9741059 let poolStatus = parseIntValue(res._9)
9751060 let state = res._10
9761061 let checkPoolStatus = if (if (isGlobalShutdown())
9821067 then {
9831068 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
9841069 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
985- then state
1070+ then {
1071+ let $t04042740508 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1072+ let refreshKLpActions = $t04042740508._1
1073+ let updatedKLp = $t04042740508._2
1074+ (state ++ refreshKLpActions)
1075+ }
9861076 else throw("Strict value is not equal to itself.")
9871077 }
9881078 else throw("Strict value is not equal to itself.")
10221112 then {
10231113 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
10241114 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1025- then state
1115+ then {
1116+ let $t04164841729 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1117+ let refreshKLpActions = $t04164841729._1
1118+ let updatedKLp = $t04164841729._2
1119+ (state ++ refreshKLpActions)
1120+ }
10261121 else throw("Strict value is not equal to itself.")
10271122 }
10281123 else throw("Strict value is not equal to itself.")
10381133 func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
10391134 then throw("permissions denied")
10401135 else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success")
1136+
1137+
1138+
1139+@Callable(i)
1140+func refreshKLp () = {
1141+ let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0)
1142+ let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay))
1143+ then unit
1144+ else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1145+ if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1146+ then {
1147+ let $t04271742772 = refreshKLpInternal(0, 0, 0)
1148+ let actions = $t04271742772._1
1149+ let updatedKLp = $t04271742772._2
1150+ $Tuple2(actions, toString(updatedKLp))
1151+ }
1152+ else throw("Strict value is not equal to itself.")
1153+ }
10411154
10421155
10431156
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
114+let keyKLp = makeString(["%s", "kLp"], SEP)
115+
116+let keyKLpRefreshedHeight = makeString(["%s", "kLpRefreshedHeight"], SEP)
117+
118+let keyKLpRefreshDelay = makeString(["%s", "refreshKLpDelay"], SEP)
119+
120+let kLpRefreshDelayDefault = 30
121+
122+let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault)
123+
114124 func keyFactoryConfig () = "%s__factoryConfig"
115125
116126
117127 func keyMatcherPub () = "%s%s__matcher__publicKey"
118128
119129
120130 func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset")
121131
122132
123133 func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config")
124134
125135
126136 func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr)
127137
128138
129139 func keyAllPoolsShutdown () = "%s__shutdown"
130140
131141
132142 func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress)
133143
134144
135145 func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash"
136146
137147
138148 let keyFeeCollectorAddress = "%s__feeCollectorAddress"
139149
140150 func throwOrderError (orderValid,senderValid,matcherValid) = throw(((((("order validation failed: orderValid=" + toString(orderValid)) + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid)))
141151
142152
143153 func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
144154
145155
146156 func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
147157
148158
149159 func throwErr (msg) = throw(makeString(["lp.ride:", msg], " "))
150160
151161
162+func fmtErr (msg) = makeString(["lp.ride:", msg], " ")
163+
164+
152165 let factoryContract = addressFromStringValue(getStringOrFail(this, fc()))
153166
154167 let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress))
155168
156169 func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false)
157170
158171
159172 func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub()))
160173
161174
162175 func getPoolConfig () = {
163176 let amtAsset = getStringOrFail(this, aa())
164177 let priceAsset = getStringOrFail(this, pa())
165178 let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset))
166179 let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset))
167180 split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP)
168181 }
169182
170183
171184 func parseAssetId (input) = if ((input == wavesString))
172185 then unit
173186 else fromBase58String(input)
174187
175188
176189 func assetIdToString (input) = if ((input == unit))
177190 then wavesString
178191 else toBase58String(value(input))
179192
180193
181194 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]))
182195
183196
184197 let poolConfigParsed = parsePoolConfig(getPoolConfig())
185198
186-let $t075447710 = poolConfigParsed
199+let $t079158081 = poolConfigParsed
187200
188-let cfgPoolAddress = $t075447710._1
201+let cfgPoolAddress = $t079158081._1
189202
190-let cfgPoolStatus = $t075447710._2
203+let cfgPoolStatus = $t079158081._2
191204
192-let cfgLpAssetId = $t075447710._3
205+let cfgLpAssetId = $t079158081._3
193206
194-let cfgAmountAssetId = $t075447710._4
207+let cfgAmountAssetId = $t079158081._4
195208
196-let cfgPriceAssetId = $t075447710._5
209+let cfgPriceAssetId = $t079158081._5
197210
198-let cfgAmountAssetDecimals = $t075447710._6
211+let cfgAmountAssetDecimals = $t079158081._6
199212
200-let cfgPriceAssetDecimals = $t075447710._7
213+let cfgPriceAssetDecimals = $t079158081._7
201214
202215 func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
203216
204217
205218 let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address")
206219
207220 let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address")
208221
209222 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)
210223
211224
212225 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)
213226
214227
215228 func getAccBalance (assetId) = if ((assetId == "WAVES"))
216229 then wavesBalance(this).available
217230 else assetBalance(this, fromBase58String(assetId))
218231
219232
220233 func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
221234
222235
223236 func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
224237 let amtAssetAmtX18 = toX18(amAmt, amAssetDcm)
225238 let priceAssetAmtX18 = toX18(prAmt, prAssetDcm)
226239 calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18)
227240 }
228241
229242
230243 func calcPrices (amAmt,prAmt,lpAmt) = {
231244 let cfg = getPoolConfig()
232245 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
233246 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
234247 let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt)
235248 let amAmtX18 = toX18(amAmt, amtAssetDcm)
236249 let prAmtX18 = toX18(prAmt, priceAssetDcm)
237250 let lpAmtX18 = toX18(lpAmt, scale8)
238251 let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18)
239252 let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18)
240253 [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18]
241254 }
242255
243256
244257 func calculatePrices (amAmt,prAmt,lpAmt) = {
245258 let prices = calcPrices(amAmt, prAmt, lpAmt)
246259 [fromX18(prices[0], scale8), fromX18(prices[1], scale8), fromX18(prices[2], scale8)]
247260 }
248261
249262
250263 func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
251264 let cfg = getPoolConfig()
252265 let lpAssetId = cfg[idxPoolLPAssetId]
253266 let amAssetId = cfg[idxAmtAssetId]
254267 let prAssetId = cfg[idxPriceAssetId]
255268 let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
256269 let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
257270 let poolStatus = cfg[idxPoolStatus]
258271 let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity
259272 if ((lpAssetId != pmtAssetId))
260273 then throw("Invalid asset passed.")
261274 else {
262275 let amBalance = getAccBalance(amAssetId)
263276 let amBalanceX18 = toX18(amBalance, amAssetDcm)
264277 let prBalance = getAccBalance(prAssetId)
265278 let prBalanceX18 = toX18(prBalance, prAssetDcm)
266279 let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18)
267280 let curPrice = fromX18(curPriceX18, scale8)
268281 let pmtLpAmtX18 = toX18(pmtLpAmt, scale8)
269282 let lpEmissionX18 = toX18(lpEmission, scale8)
270283 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18)
271284 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18)
272285 let outAmAmt = fromX18(outAmAmtX18, amAssetDcm)
273286 let outPrAmt = fromX18(outPrAmtX18, prAssetDcm)
274287 let state = if ((txId58 == ""))
275288 then nil
276289 else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES"))
277290 then unit
278291 else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES"))
279292 then unit
280293 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)]
281294 $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state)
282295 }
283296 }
284297
285298
286299 func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = {
287300 let cfg = getPoolConfig()
288301 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
289302 let amAssetIdStr = cfg[idxAmtAssetId]
290303 let prAssetIdStr = cfg[idxPriceAssetId]
291304 let iAmtAssetId = cfg[idxIAmtAssetId]
292305 let iPriceAssetId = cfg[idxIPriceAssetId]
293306 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
294307 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
295308 let poolStatus = cfg[idxPoolStatus]
296309 let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
297310 let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES")))
298311 let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES")))
299312 if (if ((amAssetIdStr != inAmAssetIdStr))
300313 then true
301314 else (prAssetIdStr != inPrAssetIdStr))
302315 then throw("Invalid amt or price asset passed.")
303316 else {
304317 let amBalance = if (isEvaluate)
305318 then getAccBalance(amAssetIdStr)
306319 else (getAccBalance(amAssetIdStr) - inAmAssetAmt)
307320 let prBalance = if (isEvaluate)
308321 then getAccBalance(prAssetIdStr)
309322 else (getAccBalance(prAssetIdStr) - inPrAssetAmt)
310323 let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm)
311324 let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm)
312325 let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18)
313326 let amBalanceX18 = toX18(amBalance, amtAssetDcm)
314327 let prBalanceX18 = toX18(prBalance, priceAssetDcm)
315328 let res = if ((lpEmission == 0))
316329 then {
317330 let curPriceX18 = zeroBigInt
318331 let slippageX18 = zeroBigInt
319332 let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN)
320333 $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
321334 }
322335 else {
323336 let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18)
324337 let slippageX18 = fraction(absBigInt((curPriceX18 - userPriceX18)), scale18, curPriceX18)
325338 let slippageToleranceX18 = toX18(slippageTolerance, scale8)
326339 if (if ((curPriceX18 != zeroBigInt))
327340 then (slippageX18 > slippageToleranceX18)
328341 else false)
329342 then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18)))
330343 else {
331344 let lpEmissionX18 = toX18(lpEmission, scale8)
332345 let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
333346 let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
334347 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
335348 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
336349 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
337350 let expAmtAssetAmtX18 = expectedAmts._1
338351 let expPriceAssetAmtX18 = expectedAmts._2
339352 let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
340353 $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18)
341354 }
342355 }
343356 let calcLpAmt = res._1
344357 let calcAmAssetPmt = res._2
345358 let calcPrAssetPmt = res._3
346359 let curPrice = fromX18(res._4, scale8)
347360 let slippageCalc = fromX18(res._5, scale8)
348361 if ((0 >= calcLpAmt))
349362 then throw("Invalid calculations. LP calculated is less than zero.")
350363 else {
351364 let emitLpAmt = if (!(emitLp))
352365 then 0
353366 else calcLpAmt
354367 let amDiff = (inAmAssetAmt - calcAmAssetPmt)
355368 let prDiff = (inPrAssetAmt - calcPrAssetPmt)
356369 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))]
357370 $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId)
358371 }
359372 }
360373 }
361374
362375
376+func calcKLp (amountBalance,priceBalance,lpEmission) = {
377+ let updatedKLp = fraction(pow((amountBalance * priceBalance), 0, toBigInt(5), 1, 0, DOWN), scale18, lpEmission)
378+ updatedKLp
379+ }
380+
381+
382+func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = {
383+ let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta)
384+ let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta)
385+ let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta)
386+ let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission))
387+ let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))]
388+ $Tuple2(actions, updatedKLp)
389+ }
390+
391+
363392 func validateMatcherOrderAllowed (order) = {
364- let cfg = getPoolConfig()
365- let amtAssetId = cfg[idxAmtAssetId]
366- let priceAssetId = cfg[idxPriceAssetId]
367- let poolStatus = parseIntValue(cfg[idxPoolStatus])
368- let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
369- let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
370- let accAmtAssetBalance = getAccBalance(amtAssetId)
371- let accPriceAssetBalance = getAccBalance(priceAssetId)
372- let curPriceX18 = if ((order.orderType == Buy))
373- then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance)
374- else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance)
375- let curPrice = fromX18(curPriceX18, scale8)
393+ let amountAssetAmount = order.amount
394+ let priceAssetAmount = fraction(order.amount, order.price, scale8)
395+ let $t01955919771 = if ((order.orderType == Buy))
396+ then $Tuple2(amountAssetAmount, -(priceAssetAmount))
397+ else $Tuple2(-(amountAssetAmount), priceAssetAmount)
398+ let amountAssetBalanceDelta = $t01955919771._1
399+ let priceAssetBalanceDelta = $t01955919771._2
376400 if (if (if (isGlobalShutdown())
377401 then true
378- else (poolStatus == PoolMatcherDisabled))
402+ else (cfgPoolStatus == PoolMatcherDisabled))
379403 then true
380- else (poolStatus == PoolShutdown))
404+ else (cfgPoolStatus == PoolShutdown))
381405 then throw("Exchange operations disabled")
382- else {
383- let orderAmtAsset = order.assetPair.amountAsset
384- let orderAmtAssetStr = if ((orderAmtAsset == unit))
385- then "WAVES"
386- else toBase58String(value(orderAmtAsset))
387- let orderPriceAsset = order.assetPair.priceAsset
388- let orderPriceAssetStr = if ((orderPriceAsset == unit))
389- then "WAVES"
390- else toBase58String(value(orderPriceAsset))
391- if (if ((orderAmtAssetStr != amtAssetId))
392- then true
393- else (orderPriceAssetStr != priceAssetId))
394- then throw("Wrong order assets.")
395- else {
396- let orderPrice = order.price
397- let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm)
398- let castedOrderPrice = toScale(orderPrice, scale8, priceDcm)
399- let isOrderPriceValid = if ((order.orderType == Buy))
400- then (curPrice >= castedOrderPrice)
401- else (castedOrderPrice >= curPrice)
402- true
403- }
404- }
406+ else if (if ((order.assetPair.amountAsset != cfgAmountAssetId))
407+ then true
408+ else (order.assetPair.priceAsset != cfgPriceAssetId))
409+ then throw("Wrong order assets.")
410+ else {
411+ let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp"))
412+ let $t02024220342 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
413+ let unusedActions = $t02024220342._1
414+ let kLpNew = $t02024220342._2
415+ let isOrderValid = (kLpNew > kLp)
416+ isOrderValid
417+ }
405418 }
406419
407420
408421 func commonGet (i) = if ((size(i.payments) != 1))
409422 then throw("exactly 1 payment is expected")
410423 else {
411424 let pmt = value(i.payments[0])
412425 let pmtAssetId = value(pmt.assetId)
413426 let pmtAmt = pmt.amount
414427 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller)
415428 let outAmAmt = res._1
416429 let outPrAmt = res._2
417430 let poolStatus = parseIntValue(res._9)
418431 let state = res._10
419432 if (if (isGlobalShutdown())
420433 then true
421434 else (poolStatus == PoolShutdown))
422435 then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
423436 else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state)
424437 }
425438
426439
427440 func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2))
428441 then throw("exactly 2 payments are expected")
429442 else {
430443 let amAssetPmt = value(i.payments[0])
431444 let prAssetPmt = value(i.payments[1])
432445 let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp)
433446 let poolStatus = parseIntValue(estPut._8)
434447 if (if (if (isGlobalShutdown())
435448 then true
436449 else (poolStatus == PoolPutDisabled))
437450 then true
438451 else (poolStatus == PoolShutdown))
439452 then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus)))
440453 else estPut
441454 }
442455
443456
444457 func emit (amount) = {
445458 let emitInv = invoke(factoryContract, "emit", [amount], nil)
446459 if ((emitInv == emitInv))
447460 then {
448461 let emitInvLegacy = match emitInv {
449462 case legacyFactoryContract: Address =>
450463 invoke(legacyFactoryContract, "emit", [amount], nil)
451464 case _ =>
452465 unit
453466 }
454467 if ((emitInvLegacy == emitInvLegacy))
455468 then amount
456469 else throw("Strict value is not equal to itself.")
457470 }
458471 else throw("Strict value is not equal to itself.")
459472 }
460473
461474
462475 func takeFee (amount) = {
463476 let feeAmount = fraction(amount, fee, scale8)
464477 $Tuple2((amount - feeAmount), feeAmount)
465478 }
466479
467480
468481 func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = {
469482 let isEval = (txId == unit)
470483 let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId))
471484 let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId))
472485 let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId))
473486 then true
474487 else if ((paymentAssetId == cfgPriceAssetId))
475488 then false
476489 else throwErr("invalid asset")
477- let $t02257122864 = if (isEval)
490+ let $t02302623319 = if (isEval)
478491 then $Tuple2(amountBalanceRaw, priceBalanceRaw)
479492 else if (paymentInAmountAsset)
480493 then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw)
481494 else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw))
482- let amountBalanceOld = $t02257122864._1
483- let priceBalanceOld = $t02257122864._2
484- let $t02286823017 = if (paymentInAmountAsset)
495+ let amountBalanceOld = $t02302623319._1
496+ let priceBalanceOld = $t02302623319._2
497+ let $t02332323472 = if (paymentInAmountAsset)
485498 then $Tuple2(paymentAmountRaw, 0)
486499 else $Tuple2(0, paymentAmountRaw)
487- let amountAssetAmountRaw = $t02286823017._1
488- let priceAssetAmountRaw = $t02286823017._2
500+ let amountAssetAmountRaw = $t02332323472._1
501+ let priceAssetAmountRaw = $t02332323472._2
489502 let amountAssetAmount = takeFee(amountAssetAmountRaw)._1
490503 let priceAssetAmount = takeFee(priceAssetAmountRaw)._1
491- let $t02313923198 = takeFee(paymentAmountRaw)
492- let paymentAmount = $t02313923198._1
493- let feeAmount = $t02313923198._2
504+ let $t02359423653 = takeFee(paymentAmountRaw)
505+ let paymentAmount = $t02359423653._1
506+ let feeAmount = $t02359423653._2
494507 let amountBalanceNew = (amountBalanceOld + amountAssetAmount)
495508 let priceBalanceNew = (priceBalanceOld + priceAssetAmount)
496509 let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals))
497510 let priceNew = fromX18(priceNewX18, scale8)
498511 let paymentBalance = if (paymentInAmountAsset)
499512 then amountBalanceOld
500513 else priceBalanceOld
501514 let paymentBalanceBigInt = toBigInt(paymentBalance)
502515 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
503516 let chechSupply = if ((supplyBigInt > big0))
504517 then true
505518 else throwErr("initial deposit requires all coins")
506519 if ((chechSupply == chechSupply))
507520 then {
508521 let depositBigInt = toBigInt(paymentAmount)
509522 let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))])
510523 let commonState = if (isEval)
511524 then nil
512525 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))]
513526 let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals))
514527 let priceOld = fromX18(priceOldX18, scale8)
515528 let loss = {
516- let $t02467524842 = if (paymentInAmountAsset)
529+ let $t02513025297 = if (paymentInAmountAsset)
517530 then $Tuple2(amountAssetAmountRaw, amountBalanceOld)
518531 else $Tuple2(priceAssetAmountRaw, priceBalanceOld)
519- let amount = $t02467524842._1
520- let balance = $t02467524842._2
532+ let amount = $t02513025297._1
533+ let balance = $t02513025297._2
521534 let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance)))
522535 fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth)
523536 }
524- $Tuple4(issueAmount, commonState, feeAmount, loss)
537+ $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset)
525538 }
526539 else throw("Strict value is not equal to itself.")
527540 }
528541
529542
530543 func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = {
531544 let isEval = (txId == unit)
532545 let checks = [if ((paymentAssetId == cfgLpAssetId))
533546 then true
534547 else throwErr("invalid lp asset")]
535548 if ((checks == checks))
536549 then {
537550 let outInAmountAsset = if ((outAssetId == cfgAmountAssetId))
538551 then true
539552 else if ((outAssetId == cfgPriceAssetId))
540553 then false
541554 else throwErr("invalid asset")
542555 let balanceBigInt = if (outInAmountAsset)
543556 then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId)))
544557 else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId)))
545558 let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId))
546559 let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId))
547560 let outBalance = if (outInAmountAsset)
548561 then amBalanceOld
549562 else prBalanceOld
550563 let outBalanceBigInt = toBigInt(outBalance)
551564 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
552565 let redeemedBigInt = toBigInt(paymentAmount)
553566 let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))])
554- let $t02642226472 = takeFee(amountRaw)
555- let totalAmount = $t02642226472._1
556- let feeAmount = $t02642226472._2
557- let $t02647626702 = if (outInAmountAsset)
567+ let $t02689926949 = takeFee(amountRaw)
568+ let totalAmount = $t02689926949._1
569+ let feeAmount = $t02689926949._2
570+ let $t02695327179 = if (outInAmountAsset)
558571 then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
559572 else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw))
560- let outAmAmount = $t02647626702._1
561- let outPrAmount = $t02647626702._2
562- let amBalanceNew = $t02647626702._3
563- let prBalanceNew = $t02647626702._4
573+ let outAmAmount = $t02695327179._1
574+ let outPrAmount = $t02695327179._2
575+ let amBalanceNew = $t02695327179._3
576+ let prBalanceNew = $t02695327179._4
564577 let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
565578 let priceNew = fromX18(priceNewX18, scale8)
566579 let commonState = if (isEval)
567580 then nil
568581 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)]
569582 let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals))
570583 let priceOld = fromX18(priceOldX18, scale8)
571584 let loss = {
572585 let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2)
573586 fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset)
574587 }
575- $Tuple4(totalAmount, commonState, feeAmount, loss)
588+ $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset)
576589 }
577590 else throw("Strict value is not equal to itself.")
578591 }
579592
580593
581594 func managerPublicKeyOrUnit () = match getString(mpk()) {
582595 case s: String =>
583596 fromBase58String(s)
584597 case _: Unit =>
585598 unit
586599 case _ =>
587600 throw("Match error")
588601 }
589602
590603
591604 func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) {
592605 case s: String =>
593606 fromBase58String(s)
594607 case _: Unit =>
595608 unit
596609 case _ =>
597610 throw("Match error")
598611 }
599612
600613
601614 func isManager (i) = match managerPublicKeyOrUnit() {
602615 case pk: ByteVector =>
603616 (i.callerPublicKey == pk)
604617 case _: Unit =>
605618 (i.caller == this)
606619 case _ =>
607620 throw("Match error")
608621 }
609622
610623
611624 func mustManager (i) = {
612625 let pd = throw("Permission denied")
613626 match managerPublicKeyOrUnit() {
614627 case pk: ByteVector =>
615628 if ((i.callerPublicKey == pk))
616629 then true
617630 else pd
618631 case _: Unit =>
619632 if ((i.caller == this))
620633 then true
621634 else pd
622635 case _ =>
623636 throw("Match error")
624637 }
625638 }
626639
627640
628641 @Callable(i)
629642 func setManager (pendingManagerPublicKey) = {
630643 let checkCaller = mustManager(i)
631644 if ((checkCaller == checkCaller))
632645 then {
633646 let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
634647 if ((checkManagerPublicKey == checkManagerPublicKey))
635648 then [StringEntry(pmpk(), pendingManagerPublicKey)]
636649 else throw("Strict value is not equal to itself.")
637650 }
638651 else throw("Strict value is not equal to itself.")
639652 }
640653
641654
642655
643656 @Callable(i)
644657 func confirmManager () = {
645658 let pm = pendingManagerPublicKeyOrUnit()
646659 let hasPM = if (isDefined(pm))
647660 then true
648661 else throw("No pending manager")
649662 if ((hasPM == hasPM))
650663 then {
651664 let checkPM = if ((i.callerPublicKey == value(pm)))
652665 then true
653666 else throw("You are not pending manager")
654667 if ((checkPM == checkPM))
655668 then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())]
656669 else throw("Strict value is not equal to itself.")
657670 }
658671 else throw("Strict value is not equal to itself.")
659672 }
660673
661674
662675
663676 @Callable(i)
664677 func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance))
665678 then throw("Invalid slippageTolerance passed")
666679 else {
667680 let estPut = commonPut(i, slippageTolerance, true)
668681 let emitLpAmt = estPut._2
669682 let lpAssetId = estPut._7
670683 let state = estPut._9
671684 let amDiff = estPut._10
672685 let prDiff = estPut._11
673686 let amId = estPut._12
674687 let prId = estPut._13
675688 let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
676689 if ((emitInv == emitInv))
677690 then {
678691 let emitInvLegacy = match emitInv {
679692 case legacyFactoryContract: Address =>
680693 invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
681694 case _ =>
682695 unit
683696 }
684697 if ((emitInvLegacy == emitInvLegacy))
685698 then {
686699 let slippageAInv = if ((amDiff > 0))
687700 then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
688701 else nil
689702 if ((slippageAInv == slippageAInv))
690703 then {
691704 let slippagePInv = if ((prDiff > 0))
692705 then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
693706 else nil
694707 if ((slippagePInv == slippagePInv))
695708 then {
696709 let lpTransfer = if (shouldAutoStake)
697710 then {
698711 let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
699712 if ((slpStakeInv == slpStakeInv))
700713 then nil
701714 else throw("Strict value is not equal to itself.")
702715 }
703716 else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
704- (state ++ lpTransfer)
717+ let $t03113031195 = refreshKLpInternal(0, 0, 0)
718+ let refreshKLpActions = $t03113031195._1
719+ let updatedKLp = $t03113031195._2
720+ ((state ++ lpTransfer) ++ refreshKLpActions)
705721 }
706722 else throw("Strict value is not equal to itself.")
707723 }
708724 else throw("Strict value is not equal to itself.")
709725 }
710726 else throw("Strict value is not equal to itself.")
711727 }
712728 else throw("Strict value is not equal to itself.")
713729 }
714730
715731
716732
717733 @Callable(i)
718734 func putForFree (maxSlippage) = if ((0 > maxSlippage))
719735 then throw("Invalid value passed")
720736 else {
721737 let estPut = commonPut(i, maxSlippage, false)
722- estPut._9
738+ let state = estPut._9
739+ let $t03148131546 = refreshKLpInternal(0, 0, 0)
740+ let refreshKLpActions = $t03148131546._1
741+ let updatedKLp = $t03148131546._2
742+ (state ++ refreshKLpActions)
723743 }
724744
725745
726746
727747 @Callable(i)
728748 func putOneTkn (minOutAmount,autoStake) = {
729749 let isPoolOneTokenOperationsDisabled = {
730750 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
731751 if ($isInstanceOf(@, "Boolean"))
732752 then @
733753 else throw(($getType(@) + " couldn't be cast to Boolean"))
734754 }
735755 let isPutDisabled = if (if (if (isGlobalShutdown())
736756 then true
737757 else (cfgPoolStatus == PoolPutDisabled))
738758 then true
739759 else (cfgPoolStatus == PoolShutdown))
740760 then true
741761 else isPoolOneTokenOperationsDisabled
742762 let checks = [if (if (!(isPutDisabled))
743763 then true
744764 else isManager(i))
745765 then true
746766 else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1))
747767 then true
748768 else throwErr("exactly 1 payment are expected")]
749769 if ((checks == checks))
750770 then {
751771 let payment = i.payments[0]
752772 let paymentAssetId = payment.assetId
753773 let paymentAmountRaw = payment.amount
754774 let userAddress = i.caller
755775 let txId = i.transactionId
756- let $t03160931736 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
757- let emitAmountEstimated = $t03160931736._1
758- let commonState = $t03160931736._2
759- let feeAmount = $t03160931736._3
760- let bonus = $t03160931736._4
761- let emitAmount = if (if ((minOutAmount > 0))
762- then (minOutAmount > emitAmountEstimated)
763- else false)
764- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
765- else emitAmountEstimated
766- let emitInv = emit(emitAmount)
767- if ((emitInv == emitInv))
776+ let $t03232232474 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
777+ if (($t03232232474 == $t03232232474))
768778 then {
769- let lpTransfer = if (autoStake)
779+ let paymentInAmountAsset = $t03232232474._5
780+ let bonus = $t03232232474._4
781+ let feeAmount = $t03232232474._3
782+ let commonState = $t03232232474._2
783+ let emitAmountEstimated = $t03232232474._1
784+ let emitAmount = if (if ((minOutAmount > 0))
785+ then (minOutAmount > emitAmountEstimated)
786+ else false)
787+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
788+ else emitAmountEstimated
789+ let emitInv = emit(emitAmount)
790+ if ((emitInv == emitInv))
770791 then {
771- let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
772- if ((stakeInv == stakeInv))
773- then nil
774- else throw("Strict value is not equal to itself.")
792+ let lpTransfer = if (autoStake)
793+ then {
794+ let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
795+ if ((stakeInv == stakeInv))
796+ then nil
797+ else throw("Strict value is not equal to itself.")
798+ }
799+ else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
800+ let sendFee = if ((feeAmount > 0))
801+ then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
802+ else nil
803+ let $t03306033257 = if ((this == feeCollectorAddress))
804+ then $Tuple2(0, 0)
805+ else if (paymentInAmountAsset)
806+ then $Tuple2(-(feeAmount), 0)
807+ else $Tuple2(0, -(feeAmount))
808+ let amountAssetBalanceDelta = $t03306033257._1
809+ let priceAssetBalanceDelta = $t03306033257._2
810+ let $t03326033368 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
811+ let refreshKLpActions = $t03326033368._1
812+ let updatedKLp = $t03326033368._2
813+ $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
775814 }
776- else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
777- let sendFee = if ((feeAmount > 0))
778- then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
779- else nil
780- $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount)
815+ else throw("Strict value is not equal to itself.")
781816 }
782817 else throw("Strict value is not equal to itself.")
783818 }
784819 else throw("Strict value is not equal to itself.")
785820 }
786821
787822
788823
789824 @Callable(i)
790825 func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = {
791- let $t03246532600 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
792- let emitAmountEstimated = $t03246532600._1
793- let commonState = $t03246532600._2
794- let feeAmount = $t03246532600._3
795- let bonus = $t03246532600._4
826+ let $t03356133718 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
827+ let emitAmountEstimated = $t03356133718._1
828+ let commonState = $t03356133718._2
829+ let feeAmount = $t03356133718._3
830+ let bonus = $t03356133718._4
831+ let paymentInAmountAsset = $t03356133718._5
796832 $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
797833 }
798834
799835
800836
801837 @Callable(i)
802838 func getOneTkn (outAssetIdStr,minOutAmount) = {
803839 let isPoolOneTokenOperationsDisabled = {
804840 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
805841 if ($isInstanceOf(@, "Boolean"))
806842 then @
807843 else throw(($getType(@) + " couldn't be cast to Boolean"))
808844 }
809845 let isGetDisabled = if (if (isGlobalShutdown())
810846 then true
811847 else (cfgPoolStatus == PoolShutdown))
812848 then true
813849 else isPoolOneTokenOperationsDisabled
814850 let checks = [if (if (!(isGetDisabled))
815851 then true
816852 else isManager(i))
817853 then true
818854 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1))
819855 then true
820856 else throwErr("exactly 1 payment are expected")]
821857 if ((checks == checks))
822858 then {
823859 let outAssetId = parseAssetId(outAssetIdStr)
824860 let payment = i.payments[0]
825861 let paymentAssetId = payment.assetId
826862 let paymentAmount = payment.amount
827863 let userAddress = i.caller
828864 let txId = i.transactionId
829- let $t03340533537 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
830- let amountEstimated = $t03340533537._1
831- let commonState = $t03340533537._2
832- let feeAmount = $t03340533537._3
833- let bonus = $t03340533537._4
834- let amount = if (if ((minOutAmount > 0))
835- then (minOutAmount > amountEstimated)
836- else false)
837- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
838- else amountEstimated
839- let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
840- if ((burnInv == burnInv))
865+ let $t03452334676 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
866+ if (($t03452334676 == $t03452334676))
841867 then {
842- let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
843- let sendFee = if ((feeAmount > 0))
844- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
845- else nil
846- $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
868+ let outInAmountAsset = $t03452334676._5
869+ let bonus = $t03452334676._4
870+ let feeAmount = $t03452334676._3
871+ let commonState = $t03452334676._2
872+ let amountEstimated = $t03452334676._1
873+ let amount = if (if ((minOutAmount > 0))
874+ then (minOutAmount > amountEstimated)
875+ else false)
876+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
877+ else amountEstimated
878+ let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
879+ if ((burnInv == burnInv))
880+ then {
881+ let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
882+ let sendFee = if ((feeAmount > 0))
883+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
884+ else nil
885+ let $t03517635423 = {
886+ let feeAmountForCalc = if ((this == feeCollectorAddress))
887+ then 0
888+ else feeAmount
889+ if (outInAmountAsset)
890+ then $Tuple2(-((amount + feeAmountForCalc)), 0)
891+ else $Tuple2(0, -((amount + feeAmountForCalc)))
892+ }
893+ let amountAssetBalanceDelta = $t03517635423._1
894+ let priceAssetBalanceDelta = $t03517635423._2
895+ let $t03542635534 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
896+ let refreshKLpActions = $t03542635534._1
897+ let updatedKLp = $t03542635534._2
898+ $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
899+ }
900+ else throw("Strict value is not equal to itself.")
847901 }
848902 else throw("Strict value is not equal to itself.")
849903 }
850904 else throw("Strict value is not equal to itself.")
851905 }
852906
853907
854908
855909 @Callable(i)
856910 func getOneTknREADONLY (outAssetId,paymentAmount) = {
857- let $t03417234310 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
858- let amountEstimated = $t03417234310._1
859- let commonState = $t03417234310._2
860- let feeAmount = $t03417234310._3
861- let bonus = $t03417234310._4
911+ let $t03571835874 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
912+ let amountEstimated = $t03571835874._1
913+ let commonState = $t03571835874._2
914+ let feeAmount = $t03571835874._3
915+ let bonus = $t03571835874._4
916+ let outInAmountAsset = $t03571835874._5
862917 $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
863918 }
864919
865920
866921
867922 @Callable(i)
868923 func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = {
869924 let isPoolOneTokenOperationsDisabled = {
870925 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
871926 if ($isInstanceOf(@, "Boolean"))
872927 then @
873928 else throw(($getType(@) + " couldn't be cast to Boolean"))
874929 }
875930 let isGetDisabled = if (if (isGlobalShutdown())
876931 then true
877932 else (cfgPoolStatus == PoolShutdown))
878933 then true
879934 else isPoolOneTokenOperationsDisabled
880935 let checks = [if (if (!(isGetDisabled))
881936 then true
882937 else isManager(i))
883938 then true
884939 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0))
885940 then true
886941 else throwErr("no payments are expected")]
887942 if ((checks == checks))
888943 then {
889944 let outAssetId = parseAssetId(outAssetIdStr)
890945 let userAddress = i.caller
891946 let txId = i.transactionId
892947 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
893948 if ((unstakeInv == unstakeInv))
894949 then {
895- let $t03513535265 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
896- let amountEstimated = $t03513535265._1
897- let commonState = $t03513535265._2
898- let feeAmount = $t03513535265._3
899- let bonus = $t03513535265._4
900- let amount = if (if ((minOutAmount > 0))
901- then (minOutAmount > amountEstimated)
902- else false)
903- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
904- else amountEstimated
905- let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
906- if ((burnInv == burnInv))
950+ let $t03669936850 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
951+ if (($t03669936850 == $t03669936850))
907952 then {
908- let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
909- let sendFee = if ((feeAmount > 0))
910- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
911- else nil
912- $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
953+ let outInAmountAsset = $t03669936850._5
954+ let bonus = $t03669936850._4
955+ let feeAmount = $t03669936850._3
956+ let commonState = $t03669936850._2
957+ let amountEstimated = $t03669936850._1
958+ let amount = if (if ((minOutAmount > 0))
959+ then (minOutAmount > amountEstimated)
960+ else false)
961+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
962+ else amountEstimated
963+ let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
964+ if ((burnInv == burnInv))
965+ then {
966+ let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
967+ let sendFee = if ((feeAmount > 0))
968+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
969+ else nil
970+ let $t03734537592 = {
971+ let feeAmountForCalc = if ((this == feeCollectorAddress))
972+ then 0
973+ else feeAmount
974+ if (outInAmountAsset)
975+ then $Tuple2(-((amount + feeAmountForCalc)), 0)
976+ else $Tuple2(0, -((amount + feeAmountForCalc)))
977+ }
978+ let amountAssetBalanceDelta = $t03734537592._1
979+ let priceAssetBalanceDelta = $t03734537592._2
980+ let $t03759537703 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
981+ let refreshKLpActions = $t03759537703._1
982+ let updatedKLp = $t03759537703._2
983+ $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
984+ }
985+ else throw("Strict value is not equal to itself.")
913986 }
914987 else throw("Strict value is not equal to itself.")
915988 }
916989 else throw("Strict value is not equal to itself.")
917990 }
918991 else throw("Strict value is not equal to itself.")
919992 }
920993
921994
922995
923996 @Callable(i)
924997 func get () = {
925998 let res = commonGet(i)
926999 let outAmtAmt = res._1
9271000 let outPrAmt = res._2
9281001 let pmtAmt = res._3
9291002 let pmtAssetId = res._4
9301003 let state = res._5
9311004 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
9321005 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
933- then state
1006+ then {
1007+ let $t03849538577 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1008+ let refreshKLpActions = $t03849538577._1
1009+ let updatedKLp = $t03849538577._2
1010+ (state ++ refreshKLpActions)
1011+ }
9341012 else throw("Strict value is not equal to itself.")
9351013 }
9361014
9371015
9381016
9391017 @Callable(i)
9401018 func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = {
9411019 let res = commonGet(i)
9421020 let outAmAmt = res._1
9431021 let outPrAmt = res._2
9441022 let pmtAmt = res._3
9451023 let pmtAssetId = res._4
9461024 let state = res._5
9471025 if ((noLessThenAmtAsset > outAmAmt))
9481026 then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset)))
9491027 else if ((noLessThenPriceAsset > outPrAmt))
9501028 then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
9511029 else {
9521030 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
9531031 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
954- then state
1032+ then {
1033+ let $t03937339454 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1034+ let refreshKLpActions = $t03937339454._1
1035+ let updatedKLp = $t03937339454._2
1036+ (state ++ refreshKLpActions)
1037+ }
9551038 else throw("Strict value is not equal to itself.")
9561039 }
9571040 }
9581041
9591042
9601043
9611044 @Callable(i)
9621045 func unstakeAndGet (amount) = {
9631046 let checkPayments = if ((size(i.payments) != 0))
9641047 then throw("No payments are expected")
9651048 else true
9661049 if ((checkPayments == checkPayments))
9671050 then {
9681051 let cfg = getPoolConfig()
9691052 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
9701053 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
9711054 if ((unstakeInv == unstakeInv))
9721055 then {
9731056 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1057+ let outAmAmt = res._1
1058+ let outPrAmt = res._2
9741059 let poolStatus = parseIntValue(res._9)
9751060 let state = res._10
9761061 let checkPoolStatus = if (if (isGlobalShutdown())
9771062 then true
9781063 else (poolStatus == PoolShutdown))
9791064 then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
9801065 else true
9811066 if ((checkPoolStatus == checkPoolStatus))
9821067 then {
9831068 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
9841069 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
985- then state
1070+ then {
1071+ let $t04042740508 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1072+ let refreshKLpActions = $t04042740508._1
1073+ let updatedKLp = $t04042740508._2
1074+ (state ++ refreshKLpActions)
1075+ }
9861076 else throw("Strict value is not equal to itself.")
9871077 }
9881078 else throw("Strict value is not equal to itself.")
9891079 }
9901080 else throw("Strict value is not equal to itself.")
9911081 }
9921082 else throw("Strict value is not equal to itself.")
9931083 }
9941084
9951085
9961086
9971087 @Callable(i)
9981088 func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = {
9991089 let isGetDisabled = if (isGlobalShutdown())
10001090 then true
10011091 else (cfgPoolStatus == PoolShutdown)
10021092 let checks = [if (!(isGetDisabled))
10031093 then true
10041094 else throw("get operation is blocked by admin"), if ((size(i.payments) == 0))
10051095 then true
10061096 else throw("no payments are expected")]
10071097 if ((checks == checks))
10081098 then {
10091099 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
10101100 if ((unstakeInv == unstakeInv))
10111101 then {
10121102 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
10131103 let outAmAmt = res._1
10141104 let outPrAmt = res._2
10151105 let state = res._10
10161106 let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
10171107 then true
10181108 else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
10191109 then true
10201110 else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
10211111 if ((checkAmounts == checkAmounts))
10221112 then {
10231113 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
10241114 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1025- then state
1115+ then {
1116+ let $t04164841729 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1117+ let refreshKLpActions = $t04164841729._1
1118+ let updatedKLp = $t04164841729._2
1119+ (state ++ refreshKLpActions)
1120+ }
10261121 else throw("Strict value is not equal to itself.")
10271122 }
10281123 else throw("Strict value is not equal to itself.")
10291124 }
10301125 else throw("Strict value is not equal to itself.")
10311126 }
10321127 else throw("Strict value is not equal to itself.")
10331128 }
10341129
10351130
10361131
10371132 @Callable(i)
10381133 func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
10391134 then throw("permissions denied")
10401135 else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success")
1136+
1137+
1138+
1139+@Callable(i)
1140+func refreshKLp () = {
1141+ let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0)
1142+ let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay))
1143+ then unit
1144+ else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1145+ if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1146+ then {
1147+ let $t04271742772 = refreshKLpInternal(0, 0, 0)
1148+ let actions = $t04271742772._1
1149+ let updatedKLp = $t04271742772._2
1150+ $Tuple2(actions, toString(updatedKLp))
1151+ }
1152+ else throw("Strict value is not equal to itself.")
1153+ }
10411154
10421155
10431156
10441157 @Callable(i)
10451158 func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig())
10461159
10471160
10481161
10491162 @Callable(i)
10501163 func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId))
10511164
10521165
10531166
10541167 @Callable(i)
10551168 func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = {
10561169 let prices = calcPrices(amAmt, prAmt, lpAmt)
10571170 $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])])
10581171 }
10591172
10601173
10611174
10621175 @Callable(i)
10631176 func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult)))
10641177
10651178
10661179
10671180 @Callable(i)
10681181 func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult))
10691182
10701183
10711184
10721185 @Callable(i)
10731186 func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18))))
10741187
10751188
10761189
10771190 @Callable(i)
10781191 func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp))
10791192
10801193
10811194
10821195 @Callable(i)
10831196 func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
10841197 let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress))
10851198 $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10))
10861199 }
10871200
10881201
10891202
10901203 @Callable(i)
10911204 func statsREADONLY () = {
10921205 let cfg = getPoolConfig()
10931206 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
10941207 let amtAssetId = cfg[idxAmtAssetId]
10951208 let priceAssetId = cfg[idxPriceAssetId]
10961209 let iAmtAssetId = cfg[idxIAmtAssetId]
10971210 let iPriceAssetId = cfg[idxIPriceAssetId]
10981211 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
10991212 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
11001213 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
11011214 let accAmtAssetBalance = getAccBalance(amtAssetId)
11021215 let accPriceAssetBalance = getAccBalance(priceAssetId)
11031216 let pricesList = if ((poolLPBalance == 0))
11041217 then [zeroBigInt, zeroBigInt, zeroBigInt]
11051218 else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance)
11061219 let curPrice = 0
11071220 let lpAmtAssetShare = fromX18(pricesList[1], scale8)
11081221 let lpPriceAssetShare = fromX18(pricesList[2], scale8)
11091222 let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this))))
11101223 $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))
11111224 }
11121225
11131226
11141227
11151228 @Callable(i)
11161229 func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = {
11171230 let cfg = getPoolConfig()
11181231 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
11191232 let amAssetIdStr = cfg[idxAmtAssetId]
11201233 let amAssetId = fromBase58String(amAssetIdStr)
11211234 let prAssetIdStr = cfg[idxPriceAssetId]
11221235 let prAssetId = fromBase58String(prAssetIdStr)
11231236 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
11241237 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
11251238 let poolStatus = cfg[idxPoolStatus]
11261239 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
11271240 let accAmtAssetBalance = getAccBalance(amAssetIdStr)
11281241 let accPriceAssetBalance = getAccBalance(prAssetIdStr)
11291242 let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm)
11301243 let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm)
11311244 let curPriceX18 = if ((poolLPBalance == 0))
11321245 then zeroBigInt
11331246 else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18)
11341247 let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm)
11351248 let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
11361249 let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm)
11371250 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
11381251 let calcLpAmt = estPut._1
11391252 let curPriceCalc = estPut._3
11401253 let amBalance = estPut._4
11411254 let prBalance = estPut._5
11421255 let lpEmission = estPut._6
11431256 $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))
11441257 }
11451258
11461259
11471260
11481261 @Callable(i)
11491262 func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = {
11501263 let cfg = getPoolConfig()
11511264 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
11521265 let amAssetIdStr = cfg[idxAmtAssetId]
11531266 let amAssetId = fromBase58String(amAssetIdStr)
11541267 let prAssetIdStr = cfg[idxPriceAssetId]
11551268 let prAssetId = fromBase58String(prAssetIdStr)
11561269 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
11571270 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
11581271 let poolStatus = cfg[idxPoolStatus]
11591272 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
11601273 let amBalanceRaw = getAccBalance(amAssetIdStr)
11611274 let prBalanceRaw = getAccBalance(prAssetIdStr)
11621275 let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm)
11631276 let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm)
11641277 let curPriceX18 = if ((poolLPBalance == 0))
11651278 then zeroBigInt
11661279 else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18)
11671280 let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm)
11681281 let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
11691282 let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm)
11701283 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
11711284 let calcLpAmt = estPut._1
11721285 let curPriceCalc = estPut._3
11731286 let amBalance = estPut._4
11741287 let prBalance = estPut._5
11751288 let lpEmission = estPut._6
11761289 $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))
11771290 }
11781291
11791292
11801293
11811294 @Callable(i)
11821295 func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = {
11831296 let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this)
11841297 let outAmAmt = res._1
11851298 let outPrAmt = res._2
11861299 let amBalance = res._5
11871300 let prBalance = res._6
11881301 let lpEmission = res._7
11891302 let curPrice = res._8
11901303 let poolStatus = parseIntValue(res._9)
11911304 $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))
11921305 }
11931306
11941307
11951308 @Verifier(tx)
11961309 func verify () = {
11971310 let targetPublicKey = match managerPublicKeyOrUnit() {
11981311 case pk: ByteVector =>
11991312 pk
12001313 case _: Unit =>
12011314 tx.senderPublicKey
12021315 case _ =>
12031316 throw("Match error")
12041317 }
12051318 match tx {
12061319 case order: Order =>
12071320 let matcherPub = getMatcherPubOrFail()
12081321 let orderValid = validateMatcherOrderAllowed(order)
12091322 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
12101323 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
12111324 if (if (if (orderValid)
12121325 then senderValid
12131326 else false)
12141327 then matcherValid
12151328 else false)
12161329 then true
12171330 else throwOrderError(orderValid, senderValid, matcherValid)
12181331 case s: SetScriptTransaction =>
12191332 let newHash = blake2b256(value(s.script))
12201333 let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash())))
12211334 let currentHash = scriptHash(this)
12221335 if (if ((allowedHash == newHash))
12231336 then (currentHash != newHash)
12241337 else false)
12251338 then true
12261339 else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
12271340 case _ =>
12281341 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
12291342 }
12301343 }
12311344

github/deemru/w8io/169f3d6 
157.53 ms