tx · DESKE8FVKp7c4R9wu794HnyRMp3MTWyya3mEkY8NU4ck

3N9gvX5N9mqdzHZjthYPtLjCvs5Z5y7WcKm:  -0.04300000 Waves

2023.05.04 11:14 [2562762] smart account 3N9gvX5N9mqdzHZjthYPtLjCvs5Z5y7WcKm > SELF 0.00000000 Waves

{ "type": 13, "id": "DESKE8FVKp7c4R9wu794HnyRMp3MTWyya3mEkY8NU4ck", "fee": 4300000, "feeAssetId": null, "timestamp": 1683188079847, "version": 2, "chainId": 84, "sender": "3N9gvX5N9mqdzHZjthYPtLjCvs5Z5y7WcKm", "senderPublicKey": "BPXEMrsvB4LzzNPWvb1syBrFgvWKNnPsegeMeaW3MY9C", "proofs": [ "4LYXAwWV93GU2aC7mcMdWd9tZF46WSztYn8h3NvmH8unAy5Wy1YfziHMS567XYevDagS6Hpwt4JSqCurdCi2u8eX" ], "script": "base64:BgL3NwgCEgASBQoDAQQBEgcKBQEEAQgBEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgQKAggBEgQKAggBEgQKAggBEgUKAwEIARIAEgQKAgEBEgMKAQESBQoDAQEBEgQKAggIEgASABIDCgEIEgUKAwEBARIECgIBARIECgIIARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCBIAEgMKAQESAwoBARIECgIIASIKbFBkZWNpbWFscyIGc2NhbGU4IgxzY2FsZThCaWdJbnQiB3NjYWxlMTgiCnplcm9CaWdJbnQiBGJpZzAiBGJpZzEiBGJpZzIiC3dhdmVzU3RyaW5nIgNTRVAiClBvb2xBY3RpdmUiD1Bvb2xQdXREaXNhYmxlZCITUG9vbE1hdGNoZXJEaXNhYmxlZCIMUG9vbFNodXRkb3duIg5pZHhQb29sQWRkcmVzcyINaWR4UG9vbFN0YXR1cyIQaWR4UG9vbExQQXNzZXRJZCINaWR4QW10QXNzZXRJZCIPaWR4UHJpY2VBc3NldElkIg5pZHhBbXRBc3NldERjbSIQaWR4UHJpY2VBc3NldERjbSIOaWR4SUFtdEFzc2V0SWQiEG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FAmltAwMDBQJhSwUCYU0HBQJhTgcGCQECYUoEBQJhSwUCYUwFAmFNBQJhTgMJAAECBQJiVgIUU2V0U2NyaXB0VHJhbnNhY3Rpb24EAmdpBQJiVgMJAPQDAwgFAmlqCWJvZHlCeXRlcwkAkQMCCAUCaWoGcHJvb2ZzAAAFAmlsBgQCaW8JAPYDAQkBBXZhbHVlAQgFAmdpBnNjcmlwdAQCaXAJANsEAQkBBXZhbHVlAQkAnQgCBQJhVgkBAmFGAAQCaXEJAPEHAQUEdGhpcwMJAAACBQJpcAUCaW8JAQIhPQIFAmlxBQJpbwcJAPQDAwgFAmlqCWJvZHlCeXRlcwkAkQMCCAUCaWoGcHJvb2ZzAAAFAmlsLmY3kQ==", "height": 2562762, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: jcNRJcbbHqLFSUAeLyY4xNSJ5YPNCysECGq4zzKgQkH Next: HeDk2P9YfWftxbnUDUBbbTyVyp5xwxHZ6nfeWhZmSfhp Diff:
OldNewDifferences
130130
131131 let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault)
132132
133+func keyAdditionalBalance (assetId) = makeString(["%s%s", "stakedBalance", assetId], SEP)
134+
135+
136+func keyStakingAssetBalance (assetId) = makeString(["%s%s", "shareAssetBalance", assetId], SEP)
137+
138+
139+func getAdditionalBalanceOrZero (assetId) = valueOrElse(getInteger(this, keyAdditionalBalance(assetId)), 0)
140+
141+
142+func getStakingAssetBalanceOrZero (assetId) = valueOrElse(getInteger(this, keyStakingAssetBalance(assetId)), 0)
143+
144+
133145 func keyFactoryConfig () = "%s__factoryConfig"
134146
135147
155167
156168
157169 let keyFeeCollectorAddress = "%s__feeCollectorAddress"
170+
171+func keySkipOrderValidation (poolAddress) = ("%s%s__skipOrderValidation__" + poolAddress)
172+
158173
159174 func throwOrderError (orderValid,orderValidInfo,senderValid,matcherValid) = throw((((((((("order validation failed: orderValid=" + toString(orderValid)) + " (") + orderValidInfo) + ")") + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid)))
160175
219234
220235 let poolConfigParsed = parsePoolConfig(getPoolConfig())
221236
222-let $t084698635 = poolConfigParsed
237+let $t090589224 = poolConfigParsed
223238
224-let cfgPoolAddress = $t084698635._1
239+let cfgPoolAddress = $t090589224._1
225240
226-let cfgPoolStatus = $t084698635._2
241+let cfgPoolStatus = $t090589224._2
227242
228-let cfgLpAssetId = $t084698635._3
243+let cfgLpAssetId = $t090589224._3
229244
230-let cfgAmountAssetId = $t084698635._4
245+let cfgAmountAssetId = $t090589224._4
231246
232-let cfgPriceAssetId = $t084698635._5
247+let cfgPriceAssetId = $t090589224._5
233248
234-let cfgAmountAssetDecimals = $t084698635._6
249+let cfgAmountAssetDecimals = $t090589224._6
235250
236-let cfgPriceAssetDecimals = $t084698635._7
251+let cfgPriceAssetDecimals = $t090589224._7
237252
238253 func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
239254
248263 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)
249264
250265
251-func getAccBalance (assetId) = if ((assetId == "WAVES"))
252- then wavesBalance(this).available
253- else assetBalance(this, fromBase58String(assetId))
266+func getAccBalance (assetId) = {
267+ let balanceOnPool = if ((assetId == "WAVES"))
268+ then wavesBalance(this).available
269+ else assetBalance(this, fromBase58String(assetId))
270+ let totalBalance = ((balanceOnPool + getAdditionalBalanceOrZero(assetId)) - getStakingAssetBalanceOrZero(assetId))
271+ max([0, totalBalance])
272+ }
254273
255274
256275 func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
257276
258277
259278 func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
279+
280+
281+func getRate (proxy) = {
282+ let inv = invoke(proxy, "getRate", nil, nil)
283+ if ((inv == inv))
284+ then match inv {
285+ case r: Int =>
286+ r
287+ case _ =>
288+ throwErr("proxy.getRate() unexpected value")
289+ }
290+ else throw("Strict value is not equal to itself.")
291+ }
292+
293+
294+func deposit (assetId,amount,stakingAssetId,proxy) = {
295+ let currentAdditionalBalance = getAdditionalBalanceOrZero(assetId)
296+ if ((currentAdditionalBalance == currentAdditionalBalance))
297+ then {
298+ let currentStakingAssetBalance = getStakingAssetBalanceOrZero(stakingAssetId)
299+ if ((currentStakingAssetBalance == currentStakingAssetBalance))
300+ then {
301+ let asset = parseAssetId(assetId)
302+ if ((amount > 0))
303+ then {
304+ let depositInvoke = invoke(proxy, "deposit", nil, [AttachedPayment(asset, amount)])
305+ if ((depositInvoke == depositInvoke))
306+ then match depositInvoke {
307+ case receivedStakingAsset: Int =>
308+ let newAdditionalBalance = (currentAdditionalBalance + amount)
309+ let newStakingAssetBalance = (currentStakingAssetBalance + receivedStakingAsset)
310+[IntegerEntry(keyAdditionalBalance(assetId), newAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance)]
311+ case _ =>
312+ nil
313+ }
314+ else throw("Strict value is not equal to itself.")
315+ }
316+ else nil
317+ }
318+ else throw("Strict value is not equal to itself.")
319+ }
320+ else throw("Strict value is not equal to itself.")
321+ }
322+
323+
324+func withdraw (assetId,amount,stakingAssetId,proxy,proxyRateMul,profitAddress) = {
325+ let currentAdditionalBalance = getAdditionalBalanceOrZero(assetId)
326+ if ((currentAdditionalBalance == currentAdditionalBalance))
327+ then {
328+ let currentStakingAssetBalance = getStakingAssetBalanceOrZero(stakingAssetId)
329+ if ((currentStakingAssetBalance == currentStakingAssetBalance))
330+ then {
331+ let currentProxyRate = getRate(proxy)
332+ if ((currentProxyRate == currentProxyRate))
333+ then {
334+ let oldRate = fraction(proxyRateMul, currentAdditionalBalance, currentStakingAssetBalance)
335+ let stakingAsset = parseAssetId(stakingAssetId)
336+ let oldSendStakingAmount = fraction(proxyRateMul, amount, oldRate)
337+ let sendStakingAssetAmount = fraction(proxyRateMul, amount, currentProxyRate)
338+ let profitAmount = max([0, (oldSendStakingAmount - sendStakingAssetAmount)])
339+ if ((sendStakingAssetAmount > 0))
340+ then {
341+ let withdrawInvoke = invoke(proxy, "withdraw", nil, [AttachedPayment(stakingAsset, sendStakingAssetAmount)])
342+ if ((withdrawInvoke == withdrawInvoke))
343+ then match withdrawInvoke {
344+ case receivedAssets: Int =>
345+ let newAdditionalBalance = (currentAdditionalBalance - receivedAssets)
346+ let newStakingAssetBalance = ((currentStakingAssetBalance - sendStakingAssetAmount) - profitAmount)
347+[IntegerEntry(keyAdditionalBalance(assetId), newAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance), ScriptTransfer(profitAddress, profitAmount, parseAssetId(stakingAssetId))]
348+ case _ =>
349+ nil
350+ }
351+ else throw("Strict value is not equal to itself.")
352+ }
353+ else nil
354+ }
355+ else throw("Strict value is not equal to itself.")
356+ }
357+ else throw("Strict value is not equal to itself.")
358+ }
359+ else throw("Strict value is not equal to itself.")
360+ }
361+
362+
363+func getLeaseProxyConfig (assetId) = match invoke(factoryContract, "getPoolLeaseConfigREADONLY", [toString(this), assetId], nil) {
364+ case a: (Boolean, Int, Int, String, String, Int, String) =>
365+ a
366+ case _ =>
367+ throwErr((("[" + assetId) + "] getLeaseProxyConfig() error"))
368+}
369+
370+
371+func rebalanceInternal (targetRatio,assetId,stakingAssetId,minBalance,proxy,proxyRateMul,profitAddress) = {
372+ let currentAdditionalBalance = getAdditionalBalanceOrZero(assetId)
373+ if ((currentAdditionalBalance == currentAdditionalBalance))
374+ then {
375+ let currentStakingAssetBalance = getStakingAssetBalanceOrZero(stakingAssetId)
376+ if ((currentStakingAssetBalance == currentStakingAssetBalance))
377+ then {
378+ let leasableTotalBalance = max([0, (getAccBalance(assetId) - minBalance)])
379+ let targetAdditionalBalance = fraction(targetRatio, leasableTotalBalance, 100)
380+ let diff = (currentAdditionalBalance - targetAdditionalBalance)
381+ if ((diff == 0))
382+ then nil
383+ else if ((0 > diff))
384+ then {
385+ let sendAssetAmount = -(diff)
386+ deposit(assetId, sendAssetAmount, stakingAssetId, proxy)
387+ }
388+ else {
389+ let getAssetAmount = diff
390+ withdraw(assetId, getAssetAmount, stakingAssetId, proxy, proxyRateMul, profitAddress)
391+ }
392+ }
393+ else throw("Strict value is not equal to itself.")
394+ }
395+ else throw("Strict value is not equal to itself.")
396+ }
397+
398+
399+func rebalanceAsset (assetId) = {
400+ let $t01546015596 = getLeaseProxyConfig(assetId)
401+ let isLeasable = $t01546015596._1
402+ let leasedRatio = $t01546015596._2
403+ let minBalance = $t01546015596._3
404+ let proxyAddress = $t01546015596._4
405+ let proxyAssetId = $t01546015596._5
406+ let proxyRateMul = $t01546015596._6
407+ let stakingProfitAddress = $t01546015596._7
408+ if (isLeasable)
409+ then rebalanceInternal(leasedRatio, assetId, proxyAssetId, minBalance, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress))
410+ else nil
411+ }
412+
413+
414+func withdrawAndRebalanceAsset (assetId,getAmount) = {
415+ let $t01599516131 = getLeaseProxyConfig(assetId)
416+ let isLeasable = $t01599516131._1
417+ let leasedRatio = $t01599516131._2
418+ let minBalance = $t01599516131._3
419+ let proxyAddress = $t01599516131._4
420+ let proxyAssetId = $t01599516131._5
421+ let proxyRateMul = $t01599516131._6
422+ let stakingProfitAddress = $t01599516131._7
423+ if (isLeasable)
424+ then {
425+ let newTotalLeasableBalance = max([0, ((getAccBalance(assetId) - getAmount) - minBalance)])
426+ if ((newTotalLeasableBalance == newTotalLeasableBalance))
427+ then {
428+ let newAdditionalBalance = fraction(leasedRatio, newTotalLeasableBalance, 100)
429+ if ((newAdditionalBalance == newAdditionalBalance))
430+ then {
431+ let withdrawAmount = (getAdditionalBalanceOrZero(assetId) - newAdditionalBalance)
432+ if ((withdrawAmount == withdrawAmount))
433+ then if ((0 > withdrawAmount))
434+ then deposit(assetId, -(withdrawAmount), proxyAssetId, addressFromStringValue(proxyAddress))
435+ else withdraw(assetId, withdrawAmount, proxyAssetId, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress))
436+ else throw("Strict value is not equal to itself.")
437+ }
438+ else throw("Strict value is not equal to itself.")
439+ }
440+ else throw("Strict value is not equal to itself.")
441+ }
442+ else nil
443+ }
444+
445+
446+func withdrawAndRebalanceAll (amountAssetOutAmount,priceAssetOutAmount) = {
447+ let AmAmtWithdrawState = withdrawAndRebalanceAsset(getStringOrFail(this, aa()), amountAssetOutAmount)
448+ let PrAmtWithdrawState = withdrawAndRebalanceAsset(getStringOrFail(this, pa()), priceAssetOutAmount)
449+ (AmAmtWithdrawState ++ PrAmtWithdrawState)
450+ }
260451
261452
262453 func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
428619 }
429620
430621
622+func skipOrderValidation () = valueOrElse(getBoolean(factoryContract, keySkipOrderValidation(toString(this))), false)
623+
624+
431625 func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp))
432626 then true
433627 else throwErr(makeString(["updated KLp lower than current KLp", toString(oldKLp), toString(updatedKLp)], " "))
438632 let priceAssetBalance = getAccBalance(assetIdToString(cfgPriceAssetId))
439633 let amountAssetAmount = order.amount
440634 let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR)
441- let $t02154121753 = if ((order.orderType == Buy))
635+ let $t02852028732 = if ((order.orderType == Buy))
442636 then $Tuple2(amountAssetAmount, -(priceAssetAmount))
443637 else $Tuple2(-(amountAssetAmount), priceAssetAmount)
444- let amountAssetBalanceDelta = $t02154121753._1
445- let priceAssetBalanceDelta = $t02154121753._2
638+ let amountAssetBalanceDelta = $t02852028732._1
639+ let priceAssetBalanceDelta = $t02852028732._2
446640 if (if (if (isGlobalShutdown())
447641 then true
448642 else (cfgPoolStatus == PoolMatcherDisabled))
455649 then throw("Wrong order assets.")
456650 else {
457651 let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp"))
458- let $t02219322293 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
459- let unusedActions = $t02219322293._1
460- let kLpNew = $t02219322293._2
652+ let $t02917229272 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
653+ let unusedActions = $t02917229272._1
654+ let kLpNew = $t02917229272._2
461655 let isOrderValid = (kLpNew >= kLp)
462656 let info = makeString(["kLp=", toString(kLp), " kLpNew=", toString(kLpNew), " amountAssetBalance=", toString(amountAssetBalance), " priceAssetBalance=", toString(priceAssetBalance), " amountAssetBalanceDelta=", toString(amountAssetBalanceDelta), " priceAssetBalanceDelta=", toString(priceAssetBalanceDelta), " height=", toString(height)], "")
463657 $Tuple2(isOrderValid, info)
536730 else if ((paymentAssetId == cfgPriceAssetId))
537731 then false
538732 else throwErr("invalid asset")
539- let $t02540625699 = if (isEval)
733+ let $t03238532678 = if (isEval)
540734 then $Tuple2(amountBalanceRaw, priceBalanceRaw)
541735 else if (paymentInAmountAsset)
542736 then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw)
543737 else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw))
544- let amountBalanceOld = $t02540625699._1
545- let priceBalanceOld = $t02540625699._2
546- let $t02570325852 = if (paymentInAmountAsset)
738+ let amountBalanceOld = $t03238532678._1
739+ let priceBalanceOld = $t03238532678._2
740+ let $t03268232831 = if (paymentInAmountAsset)
547741 then $Tuple2(paymentAmountRaw, 0)
548742 else $Tuple2(0, paymentAmountRaw)
549- let amountAssetAmountRaw = $t02570325852._1
550- let priceAssetAmountRaw = $t02570325852._2
743+ let amountAssetAmountRaw = $t03268232831._1
744+ let priceAssetAmountRaw = $t03268232831._2
551745 let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1
552746 let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1
553- let $t02598426048 = takeFee(paymentAmountRaw, inFee)
554- let paymentAmount = $t02598426048._1
555- let feeAmount = $t02598426048._2
747+ let $t03296333027 = takeFee(paymentAmountRaw, inFee)
748+ let paymentAmount = $t03296333027._1
749+ let feeAmount = $t03296333027._2
556750 let amountBalanceNew = (amountBalanceOld + amountAssetAmount)
557751 let priceBalanceNew = (priceBalanceOld + priceAssetAmount)
558752 let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals))
575769 let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals))
576770 let priceOld = fromX18(priceOldX18, scale8)
577771 let loss = {
578- let $t02772927896 = if (paymentInAmountAsset)
772+ let $t03470834875 = if (paymentInAmountAsset)
579773 then $Tuple2(amountAssetAmountRaw, amountBalanceOld)
580774 else $Tuple2(priceAssetAmountRaw, priceBalanceOld)
581- let amount = $t02772927896._1
582- let balance = $t02772927896._2
775+ let amount = $t03470834875._1
776+ let balance = $t03470834875._2
583777 let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance)))
584778 fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth)
585779 }
619813 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
620814 let redeemedBigInt = toBigInt(paymentAmount)
621815 let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))])
622- let $t02997430030 = takeFee(amountRaw, outFee)
623- let totalAmount = $t02997430030._1
624- let feeAmount = $t02997430030._2
625- let $t03003430260 = if (outInAmountAsset)
816+ let $t03695337009 = takeFee(amountRaw, outFee)
817+ let totalAmount = $t03695337009._1
818+ let feeAmount = $t03695337009._2
819+ let $t03701337239 = if (outInAmountAsset)
626820 then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
627821 else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw))
628- let outAmAmount = $t03003430260._1
629- let outPrAmount = $t03003430260._2
630- let amBalanceNew = $t03003430260._3
631- let prBalanceNew = $t03003430260._4
822+ let outAmAmount = $t03701337239._1
823+ let outPrAmount = $t03701337239._2
824+ let amBalanceNew = $t03701337239._3
825+ let prBalanceNew = $t03701337239._4
632826 let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
633827 let priceNew = fromX18(priceNewX18, scale8)
634828 let commonState = if (isEval)
694888
695889
696890 @Callable(i)
891+func rebalance () = (rebalanceAsset(getStringOrFail(this, aa())) ++ rebalanceAsset(getStringOrFail(this, pa())))
892+
893+
894+
895+@Callable(i)
697896 func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse,feePoolAmount) = {
698- let $t03197732282 = if ((isReverse == false))
897+ let $t03912539430 = if ((isReverse == false))
699898 then {
700899 let assetOut = getStringOrFail(this, pa())
701900 let assetIn = getStringOrFail(this, aa())
706905 let assetIn = getStringOrFail(this, pa())
707906 $Tuple2(assetOut, assetIn)
708907 }
709- let assetOut = $t03197732282._1
710- let assetIn = $t03197732282._2
908+ let assetOut = $t03912539430._1
909+ let assetIn = $t03912539430._2
711910 let poolAssetInBalance = getAccBalance(assetIn)
712911 let poolAssetOutBalance = getAccBalance(assetOut)
713912 let amountOut = fraction(poolAssetOutBalance, cleanAmountIn, (poolAssetInBalance + cleanAmountIn))
757956 then true
758957 else throw("Exchange result is fewer coins than expected")
759958 if ((checkMin == checkMin))
760- then $Tuple2([ScriptTransfer(addressFromStringValue(addressTo), amountOut, parseAssetId(assetOut))], amountOut)
959+ then {
960+ let rebalanceState = rebalanceAsset(assetIn)
961+ if ((rebalanceState == rebalanceState))
962+ then {
963+ let withdrawState = withdrawAndRebalanceAsset(assetOut, amountOut)
964+ if ((withdrawState == withdrawState))
965+ then $Tuple2(((withdrawState ++ rebalanceState) ++ [ScriptTransfer(addressFromStringValue(addressTo), amountOut, parseAssetId(assetOut))]), amountOut)
966+ else throw("Strict value is not equal to itself.")
967+ }
968+ else throw("Strict value is not equal to itself.")
969+ }
761970 else throw("Strict value is not equal to itself.")
762971 }
763972 else throw("Strict value is not equal to itself.")
8481057 else throw("Strict value is not equal to itself.")
8491058 }
8501059 else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
851- let $t03716637628 = refreshKLpInternal(0, 0, 0)
852- if (($t03716637628 == $t03716637628))
1060+ let $t04447644938 = refreshKLpInternal(0, 0, 0)
1061+ if (($t04447644938 == $t04447644938))
8531062 then {
854- let updatedKLp = $t03716637628._2
855- let refreshKLpActions = $t03716637628._1
1063+ let updatedKLp = $t04447644938._2
1064+ let refreshKLpActions = $t04447644938._1
8561065 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
8571066 if ((isUpdatedKLpValid == isUpdatedKLpValid))
858- then ((state ++ lpTransfer) ++ refreshKLpActions)
1067+ then {
1068+ let reb = invoke(this, "rebalance", nil, nil)
1069+ if ((reb == reb))
1070+ then ((state ++ lpTransfer) ++ refreshKLpActions)
1071+ else throw("Strict value is not equal to itself.")
1072+ }
8591073 else throw("Strict value is not equal to itself.")
8601074 }
8611075 else throw("Strict value is not equal to itself.")
8841098 let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
8851099 if ((currentKLp == currentKLp))
8861100 then {
887- let $t03819038255 = refreshKLpInternal(0, 0, 0)
888- let refreshKLpActions = $t03819038255._1
889- let updatedKLp = $t03819038255._2
1101+ let $t04555045615 = refreshKLpInternal(0, 0, 0)
1102+ let refreshKLpActions = $t04555045615._1
1103+ let updatedKLp = $t04555045615._2
8901104 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
8911105 if ((isUpdatedKLpValid == isUpdatedKLpValid))
8921106 then (state ++ refreshKLpActions)
9331147 then {
9341148 let userAddress = i.caller
9351149 let txId = i.transactionId
936- let $t03944339595 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
937- if (($t03944339595 == $t03944339595))
1150+ let $t04680346955 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
1151+ if (($t04680346955 == $t04680346955))
9381152 then {
939- let paymentInAmountAsset = $t03944339595._5
940- let bonus = $t03944339595._4
941- let feeAmount = $t03944339595._3
942- let commonState = $t03944339595._2
943- let emitAmountEstimated = $t03944339595._1
1153+ let paymentInAmountAsset = $t04680346955._5
1154+ let bonus = $t04680346955._4
1155+ let feeAmount = $t04680346955._3
1156+ let commonState = $t04680346955._2
1157+ let emitAmountEstimated = $t04680346955._1
9441158 let emitAmount = if (if ((minOutAmount > 0))
9451159 then (minOutAmount > emitAmountEstimated)
9461160 else false)
9601174 let sendFee = if ((feeAmount > 0))
9611175 then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
9621176 else nil
963- let $t04018140378 = if ((this == feeCollectorAddress))
1177+ let $t04754147738 = if ((this == feeCollectorAddress))
9641178 then $Tuple2(0, 0)
9651179 else if (paymentInAmountAsset)
9661180 then $Tuple2(-(feeAmount), 0)
9671181 else $Tuple2(0, -(feeAmount))
968- let amountAssetBalanceDelta = $t04018140378._1
969- let priceAssetBalanceDelta = $t04018140378._2
970- let $t04038140489 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
971- let refreshKLpActions = $t04038140489._1
972- let updatedKLp = $t04038140489._2
1182+ let amountAssetBalanceDelta = $t04754147738._1
1183+ let priceAssetBalanceDelta = $t04754147738._2
1184+ let $t04774147849 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1185+ let refreshKLpActions = $t04774147849._1
1186+ let updatedKLp = $t04774147849._2
9731187 let kLp = value(getString(keyKLp))
9741188 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
9751189 if ((isUpdatedKLpValid == isUpdatedKLpValid))
976- then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
1190+ then {
1191+ let reb = invoke(this, "rebalance", nil, nil)
1192+ if ((reb == reb))
1193+ then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
1194+ else throw("Strict value is not equal to itself.")
1195+ }
9771196 else throw("Strict value is not equal to itself.")
9781197 }
9791198 else throw("Strict value is not equal to itself.")
9891208
9901209 @Callable(i)
9911210 func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = {
992- let $t04079540952 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
993- let emitAmountEstimated = $t04079540952._1
994- let commonState = $t04079540952._2
995- let feeAmount = $t04079540952._3
996- let bonus = $t04079540952._4
997- let paymentInAmountAsset = $t04079540952._5
1211+ let $t04820448361 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
1212+ let emitAmountEstimated = $t04820448361._1
1213+ let commonState = $t04820448361._2
1214+ let feeAmount = $t04820448361._3
1215+ let bonus = $t04820448361._4
1216+ let paymentInAmountAsset = $t04820448361._5
9981217 $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
9991218 }
10001219
10311250 then {
10321251 let userAddress = i.caller
10331252 let txId = i.transactionId
1034- let $t04183741990 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
1035- if (($t04183741990 == $t04183741990))
1253+ let $t04924649399 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
1254+ if (($t04924649399 == $t04924649399))
10361255 then {
1037- let outInAmountAsset = $t04183741990._5
1038- let bonus = $t04183741990._4
1039- let feeAmount = $t04183741990._3
1040- let commonState = $t04183741990._2
1041- let amountEstimated = $t04183741990._1
1256+ let outInAmountAsset = $t04924649399._5
1257+ let bonus = $t04924649399._4
1258+ let feeAmount = $t04924649399._3
1259+ let commonState = $t04924649399._2
1260+ let amountEstimated = $t04924649399._1
10421261 let amount = if (if ((minOutAmount > 0))
10431262 then (minOutAmount > amountEstimated)
10441263 else false)
10471266 let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
10481267 if ((burnInv == burnInv))
10491268 then {
1269+ let withdrawState = withdrawAndRebalanceAsset(outAssetIdStr, (amount + max([0, feeAmount])))
10501270 let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
10511271 let sendFee = if ((feeAmount > 0))
10521272 then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
10531273 else nil
1054- let $t04249042737 = {
1274+ let $t05006350310 = {
10551275 let feeAmountForCalc = if ((this == feeCollectorAddress))
10561276 then 0
10571277 else feeAmount
10591279 then $Tuple2(-((amount + feeAmountForCalc)), 0)
10601280 else $Tuple2(0, -((amount + feeAmountForCalc)))
10611281 }
1062- let amountAssetBalanceDelta = $t04249042737._1
1063- let priceAssetBalanceDelta = $t04249042737._2
1064- let $t04274042848 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1065- let refreshKLpActions = $t04274042848._1
1066- let updatedKLp = $t04274042848._2
1282+ let amountAssetBalanceDelta = $t05006350310._1
1283+ let priceAssetBalanceDelta = $t05006350310._2
1284+ let $t05031350421 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1285+ let refreshKLpActions = $t05031350421._1
1286+ let updatedKLp = $t05031350421._2
10671287 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
10681288 if ((isUpdatedKLpValid == isUpdatedKLpValid))
1069- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1289+ then $Tuple2(((((commonState ++ withdrawState) ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
10701290 else throw("Strict value is not equal to itself.")
10711291 }
10721292 else throw("Strict value is not equal to itself.")
10821302
10831303 @Callable(i)
10841304 func getOneTknREADONLY (outAssetId,paymentAmount) = {
1085- let $t04310543261 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
1086- let amountEstimated = $t04310543261._1
1087- let commonState = $t04310543261._2
1088- let feeAmount = $t04310543261._3
1089- let bonus = $t04310543261._4
1090- let outInAmountAsset = $t04310543261._5
1305+ let $t05069950855 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
1306+ let amountEstimated = $t05069950855._1
1307+ let commonState = $t05069950855._2
1308+ let feeAmount = $t05069950855._3
1309+ let bonus = $t05069950855._4
1310+ let outInAmountAsset = $t05069950855._5
10911311 $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
10921312 }
10931313
11241344 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
11251345 if ((unstakeInv == unstakeInv))
11261346 then {
1127- let $t04416644317 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
1128- if (($t04416644317 == $t04416644317))
1347+ let $t05176051911 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
1348+ if (($t05176051911 == $t05176051911))
11291349 then {
1130- let outInAmountAsset = $t04416644317._5
1131- let bonus = $t04416644317._4
1132- let feeAmount = $t04416644317._3
1133- let commonState = $t04416644317._2
1134- let amountEstimated = $t04416644317._1
1350+ let outInAmountAsset = $t05176051911._5
1351+ let bonus = $t05176051911._4
1352+ let feeAmount = $t05176051911._3
1353+ let commonState = $t05176051911._2
1354+ let amountEstimated = $t05176051911._1
11351355 let amount = if (if ((minOutAmount > 0))
11361356 then (minOutAmount > amountEstimated)
11371357 else false)
11401360 let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
11411361 if ((burnInv == burnInv))
11421362 then {
1363+ let withdrawState = withdrawAndRebalanceAsset(outAssetIdStr, (amount + max([0, feeAmount])))
11431364 let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
11441365 let sendFee = if ((feeAmount > 0))
11451366 then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
11461367 else nil
1147- let $t04481245059 = {
1368+ let $t05257052817 = {
11481369 let feeAmountForCalc = if ((this == feeCollectorAddress))
11491370 then 0
11501371 else feeAmount
11521373 then $Tuple2(-((amount + feeAmountForCalc)), 0)
11531374 else $Tuple2(0, -((amount + feeAmountForCalc)))
11541375 }
1155- let amountAssetBalanceDelta = $t04481245059._1
1156- let priceAssetBalanceDelta = $t04481245059._2
1157- let $t04506245170 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1158- let refreshKLpActions = $t04506245170._1
1159- let updatedKLp = $t04506245170._2
1376+ let amountAssetBalanceDelta = $t05257052817._1
1377+ let priceAssetBalanceDelta = $t05257052817._2
1378+ let $t05282052928 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1379+ let refreshKLpActions = $t05282052928._1
1380+ let updatedKLp = $t05282052928._2
11601381 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
11611382 if ((isUpdatedKLpValid == isUpdatedKLpValid))
1162- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1383+ then $Tuple2(((((commonState ++ withdrawState) ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
11631384 else throw("Strict value is not equal to itself.")
11641385 }
11651386 else throw("Strict value is not equal to itself.")
11781399 @Callable(i)
11791400 func get () = {
11801401 let res = commonGet(i)
1181- let outAmtAmt = res._1
1402+ let outAmAmt = res._1
11821403 let outPrAmt = res._2
11831404 let pmtAmt = res._3
11841405 let pmtAssetId = res._4
11851406 let state = res._5
1407+ let withdrawState = withdrawAndRebalanceAll(outAmAmt, outPrAmt)
11861408 let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
11871409 if ((currentKLp == currentKLp))
11881410 then {
11891411 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
11901412 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
11911413 then {
1192- let $t04611646198 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1193- let refreshKLpActions = $t04611646198._1
1194- let updatedKLp = $t04611646198._2
1414+ let $t05402354104 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1415+ let refreshKLpActions = $t05402354104._1
1416+ let updatedKLp = $t05402354104._2
11951417 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
11961418 if ((isUpdatedKLpValid == isUpdatedKLpValid))
1197- then (state ++ refreshKLpActions)
1419+ then ((withdrawState ++ state) ++ refreshKLpActions)
11981420 else throw("Strict value is not equal to itself.")
11991421 }
12001422 else throw("Strict value is not equal to itself.")
12171439 else if ((noLessThenPriceAsset > outPrAmt))
12181440 then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
12191441 else {
1442+ let withdrawState = withdrawAndRebalanceAll(outAmAmt, outPrAmt)
12201443 let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
12211444 if ((currentKLp == currentKLp))
12221445 then {
12231446 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
12241447 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
12251448 then {
1226- let $t04714747228 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1227- let refreshKLpActions = $t04714747228._1
1228- let updatedKLp = $t04714747228._2
1449+ let $t05519955280 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1450+ let refreshKLpActions = $t05519955280._1
1451+ let updatedKLp = $t05519955280._2
12291452 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
12301453 if ((isUpdatedKLpValid == isUpdatedKLpValid))
1231- then (state ++ refreshKLpActions)
1454+ then ((withdrawState ++ state) ++ refreshKLpActions)
12321455 else throw("Strict value is not equal to itself.")
12331456 }
12341457 else throw("Strict value is not equal to itself.")
12591482 let outPrAmt = res._2
12601483 let poolStatus = parseIntValue(res._9)
12611484 let state = res._10
1485+ let withdrawState = withdrawAndRebalanceAll(outAmAmt, outPrAmt)
12621486 let checkPoolStatus = if (if (isGlobalShutdown())
12631487 then true
12641488 else (poolStatus == PoolShutdown))
12691493 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
12701494 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
12711495 then {
1272- let $t04835448435 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1273- let refreshKLpActions = $t04835448435._1
1274- let updatedKLp = $t04835448435._2
1496+ let $t05655256633 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1497+ let refreshKLpActions = $t05655256633._1
1498+ let updatedKLp = $t05655256633._2
12751499 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
12761500 if ((isUpdatedKLpValid == isUpdatedKLpValid))
1277- then (state ++ refreshKLpActions)
1501+ then ((withdrawState ++ state) ++ refreshKLpActions)
12781502 else throw("Strict value is not equal to itself.")
12791503 }
12801504 else throw("Strict value is not equal to itself.")
13121536 let outAmAmt = res._1
13131537 let outPrAmt = res._2
13141538 let state = res._10
1539+ let withdrawState = withdrawAndRebalanceAll(outAmAmt, outPrAmt)
13151540 let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
13161541 then true
13171542 else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
13221547 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
13231548 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
13241549 then {
1325- let $t04973049811 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1326- let refreshKLpActions = $t04973049811._1
1327- let updatedKLp = $t04973049811._2
1550+ let $t05807458155 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1551+ let refreshKLpActions = $t05807458155._1
1552+ let updatedKLp = $t05807458155._2
13281553 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
13291554 if ((isUpdatedKLpValid == isUpdatedKLpValid))
1330- then (state ++ refreshKLpActions)
1555+ then ((withdrawState ++ state) ++ refreshKLpActions)
13311556 else throw("Strict value is not equal to itself.")
13321557 }
13331558 else throw("Strict value is not equal to itself.")
13591584 if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
13601585 then {
13611586 let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp"))
1362- let $t05099851062 = refreshKLpInternal(0, 0, 0)
1363- let kLpUpdateActions = $t05099851062._1
1364- let updatedKLp = $t05099851062._2
1587+ let $t05935959423 = refreshKLpInternal(0, 0, 0)
1588+ let kLpUpdateActions = $t05935959423._1
1589+ let updatedKLp = $t05935959423._2
13651590 let actions = if ((kLp != updatedKLp))
13661591 then kLpUpdateActions
13671592 else throwErr("nothing to refresh")
15361761 match tx {
15371762 case order: Order =>
15381763 let matcherPub = getMatcherPubOrFail()
1539- let $t05972459793 = validateMatcherOrderAllowed(order)
1540- let orderValid = $t05972459793._1
1541- let orderValidInfo = $t05972459793._2
1764+ let $t06808568202 = if (skipOrderValidation())
1765+ then $Tuple2(true, "")
1766+ else validateMatcherOrderAllowed(order)
1767+ let orderValid = $t06808568202._1
1768+ let orderValidInfo = $t06808568202._2
15421769 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
15431770 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
15441771 if (if (if (orderValid)
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 toX18BigInt (origVal,origScaleMult) = fraction(origVal, scale18, origScaleMult)
6666
6767
6868 func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18))
6969
7070
7171 func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round))
7272
7373
7474 func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale)
7575
7676
7777 func abs (val) = if ((0 > val))
7878 then -(val)
7979 else val
8080
8181
8282 func absBigInt (val) = if ((zeroBigInt > val))
8383 then -(val)
8484 else val
8585
8686
8787 func swapContract () = "%s__swapContract"
8888
8989
9090 func fc () = "%s__factoryContract"
9191
9292
9393 func mpk () = "%s__managerPublicKey"
9494
9595
9696 func pmpk () = "%s__pendingManagerPublicKey"
9797
9898
9999 func pl () = "%s%s__price__last"
100100
101101
102102 func ph (h,timestamp) = makeString(["%s%s%d%d__price__history", toString(h), toString(timestamp)], SEP)
103103
104104
105105 func pau (userAddress,txId) = ((("%s%s%s__P__" + userAddress) + "__") + txId)
106106
107107
108108 func gau (userAddress,txId) = ((("%s%s%s__G__" + userAddress) + "__") + txId)
109109
110110
111111 func aa () = "%s__amountAsset"
112112
113113
114114 func pa () = "%s__priceAsset"
115115
116116
117117 let keyFee = "%s__fee"
118118
119119 let feeDefault = fraction(10, scale8, 10000)
120120
121121 let fee = valueOrElse(getInteger(this, keyFee), feeDefault)
122122
123123 let keyKLp = makeString(["%s", "kLp"], SEP)
124124
125125 let keyKLpRefreshedHeight = makeString(["%s", "kLpRefreshedHeight"], SEP)
126126
127127 let keyKLpRefreshDelay = makeString(["%s", "refreshKLpDelay"], SEP)
128128
129129 let kLpRefreshDelayDefault = 30
130130
131131 let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault)
132132
133+func keyAdditionalBalance (assetId) = makeString(["%s%s", "stakedBalance", assetId], SEP)
134+
135+
136+func keyStakingAssetBalance (assetId) = makeString(["%s%s", "shareAssetBalance", assetId], SEP)
137+
138+
139+func getAdditionalBalanceOrZero (assetId) = valueOrElse(getInteger(this, keyAdditionalBalance(assetId)), 0)
140+
141+
142+func getStakingAssetBalanceOrZero (assetId) = valueOrElse(getInteger(this, keyStakingAssetBalance(assetId)), 0)
143+
144+
133145 func keyFactoryConfig () = "%s__factoryConfig"
134146
135147
136148 func keyMatcherPub () = "%s%s__matcher__publicKey"
137149
138150
139151 func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset")
140152
141153
142154 func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config")
143155
144156
145157 func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr)
146158
147159
148160 func keyAllPoolsShutdown () = "%s__shutdown"
149161
150162
151163 func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress)
152164
153165
154166 func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash"
155167
156168
157169 let keyFeeCollectorAddress = "%s__feeCollectorAddress"
170+
171+func keySkipOrderValidation (poolAddress) = ("%s%s__skipOrderValidation__" + poolAddress)
172+
158173
159174 func throwOrderError (orderValid,orderValidInfo,senderValid,matcherValid) = throw((((((((("order validation failed: orderValid=" + toString(orderValid)) + " (") + orderValidInfo) + ")") + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid)))
160175
161176
162177 func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
163178
164179
165180 func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
166181
167182
168183 func throwErr (msg) = throw(makeString(["lp.ride:", msg], " "))
169184
170185
171186 func fmtErr (msg) = makeString(["lp.ride:", msg], " ")
172187
173188
174189 let factoryContract = addressFromStringValue(getStringOrFail(this, fc()))
175190
176191 let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress))
177192
178193 let inFee = {
179194 let @ = invoke(factoryContract, "getInFeeREADONLY", [toString(this)], nil)
180195 if ($isInstanceOf(@, "Int"))
181196 then @
182197 else throw(($getType(@) + " couldn't be cast to Int"))
183198 }
184199
185200 let outFee = {
186201 let @ = invoke(factoryContract, "getOutFeeREADONLY", [toString(this)], nil)
187202 if ($isInstanceOf(@, "Int"))
188203 then @
189204 else throw(($getType(@) + " couldn't be cast to Int"))
190205 }
191206
192207 func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false)
193208
194209
195210 func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub()))
196211
197212
198213 func getPoolConfig () = {
199214 let amtAsset = getStringOrFail(this, aa())
200215 let priceAsset = getStringOrFail(this, pa())
201216 let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset))
202217 let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset))
203218 split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP)
204219 }
205220
206221
207222 func parseAssetId (input) = if ((input == wavesString))
208223 then unit
209224 else fromBase58String(input)
210225
211226
212227 func assetIdToString (input) = if ((input == unit))
213228 then wavesString
214229 else toBase58String(value(input))
215230
216231
217232 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]))
218233
219234
220235 let poolConfigParsed = parsePoolConfig(getPoolConfig())
221236
222-let $t084698635 = poolConfigParsed
237+let $t090589224 = poolConfigParsed
223238
224-let cfgPoolAddress = $t084698635._1
239+let cfgPoolAddress = $t090589224._1
225240
226-let cfgPoolStatus = $t084698635._2
241+let cfgPoolStatus = $t090589224._2
227242
228-let cfgLpAssetId = $t084698635._3
243+let cfgLpAssetId = $t090589224._3
229244
230-let cfgAmountAssetId = $t084698635._4
245+let cfgAmountAssetId = $t090589224._4
231246
232-let cfgPriceAssetId = $t084698635._5
247+let cfgPriceAssetId = $t090589224._5
233248
234-let cfgAmountAssetDecimals = $t084698635._6
249+let cfgAmountAssetDecimals = $t090589224._6
235250
236-let cfgPriceAssetDecimals = $t084698635._7
251+let cfgPriceAssetDecimals = $t090589224._7
237252
238253 func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
239254
240255
241256 let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address")
242257
243258 let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address")
244259
245260 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)
246261
247262
248263 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)
249264
250265
251-func getAccBalance (assetId) = if ((assetId == "WAVES"))
252- then wavesBalance(this).available
253- else assetBalance(this, fromBase58String(assetId))
266+func getAccBalance (assetId) = {
267+ let balanceOnPool = if ((assetId == "WAVES"))
268+ then wavesBalance(this).available
269+ else assetBalance(this, fromBase58String(assetId))
270+ let totalBalance = ((balanceOnPool + getAdditionalBalanceOrZero(assetId)) - getStakingAssetBalanceOrZero(assetId))
271+ max([0, totalBalance])
272+ }
254273
255274
256275 func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
257276
258277
259278 func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
279+
280+
281+func getRate (proxy) = {
282+ let inv = invoke(proxy, "getRate", nil, nil)
283+ if ((inv == inv))
284+ then match inv {
285+ case r: Int =>
286+ r
287+ case _ =>
288+ throwErr("proxy.getRate() unexpected value")
289+ }
290+ else throw("Strict value is not equal to itself.")
291+ }
292+
293+
294+func deposit (assetId,amount,stakingAssetId,proxy) = {
295+ let currentAdditionalBalance = getAdditionalBalanceOrZero(assetId)
296+ if ((currentAdditionalBalance == currentAdditionalBalance))
297+ then {
298+ let currentStakingAssetBalance = getStakingAssetBalanceOrZero(stakingAssetId)
299+ if ((currentStakingAssetBalance == currentStakingAssetBalance))
300+ then {
301+ let asset = parseAssetId(assetId)
302+ if ((amount > 0))
303+ then {
304+ let depositInvoke = invoke(proxy, "deposit", nil, [AttachedPayment(asset, amount)])
305+ if ((depositInvoke == depositInvoke))
306+ then match depositInvoke {
307+ case receivedStakingAsset: Int =>
308+ let newAdditionalBalance = (currentAdditionalBalance + amount)
309+ let newStakingAssetBalance = (currentStakingAssetBalance + receivedStakingAsset)
310+[IntegerEntry(keyAdditionalBalance(assetId), newAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance)]
311+ case _ =>
312+ nil
313+ }
314+ else throw("Strict value is not equal to itself.")
315+ }
316+ else nil
317+ }
318+ else throw("Strict value is not equal to itself.")
319+ }
320+ else throw("Strict value is not equal to itself.")
321+ }
322+
323+
324+func withdraw (assetId,amount,stakingAssetId,proxy,proxyRateMul,profitAddress) = {
325+ let currentAdditionalBalance = getAdditionalBalanceOrZero(assetId)
326+ if ((currentAdditionalBalance == currentAdditionalBalance))
327+ then {
328+ let currentStakingAssetBalance = getStakingAssetBalanceOrZero(stakingAssetId)
329+ if ((currentStakingAssetBalance == currentStakingAssetBalance))
330+ then {
331+ let currentProxyRate = getRate(proxy)
332+ if ((currentProxyRate == currentProxyRate))
333+ then {
334+ let oldRate = fraction(proxyRateMul, currentAdditionalBalance, currentStakingAssetBalance)
335+ let stakingAsset = parseAssetId(stakingAssetId)
336+ let oldSendStakingAmount = fraction(proxyRateMul, amount, oldRate)
337+ let sendStakingAssetAmount = fraction(proxyRateMul, amount, currentProxyRate)
338+ let profitAmount = max([0, (oldSendStakingAmount - sendStakingAssetAmount)])
339+ if ((sendStakingAssetAmount > 0))
340+ then {
341+ let withdrawInvoke = invoke(proxy, "withdraw", nil, [AttachedPayment(stakingAsset, sendStakingAssetAmount)])
342+ if ((withdrawInvoke == withdrawInvoke))
343+ then match withdrawInvoke {
344+ case receivedAssets: Int =>
345+ let newAdditionalBalance = (currentAdditionalBalance - receivedAssets)
346+ let newStakingAssetBalance = ((currentStakingAssetBalance - sendStakingAssetAmount) - profitAmount)
347+[IntegerEntry(keyAdditionalBalance(assetId), newAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance), ScriptTransfer(profitAddress, profitAmount, parseAssetId(stakingAssetId))]
348+ case _ =>
349+ nil
350+ }
351+ else throw("Strict value is not equal to itself.")
352+ }
353+ else nil
354+ }
355+ else throw("Strict value is not equal to itself.")
356+ }
357+ else throw("Strict value is not equal to itself.")
358+ }
359+ else throw("Strict value is not equal to itself.")
360+ }
361+
362+
363+func getLeaseProxyConfig (assetId) = match invoke(factoryContract, "getPoolLeaseConfigREADONLY", [toString(this), assetId], nil) {
364+ case a: (Boolean, Int, Int, String, String, Int, String) =>
365+ a
366+ case _ =>
367+ throwErr((("[" + assetId) + "] getLeaseProxyConfig() error"))
368+}
369+
370+
371+func rebalanceInternal (targetRatio,assetId,stakingAssetId,minBalance,proxy,proxyRateMul,profitAddress) = {
372+ let currentAdditionalBalance = getAdditionalBalanceOrZero(assetId)
373+ if ((currentAdditionalBalance == currentAdditionalBalance))
374+ then {
375+ let currentStakingAssetBalance = getStakingAssetBalanceOrZero(stakingAssetId)
376+ if ((currentStakingAssetBalance == currentStakingAssetBalance))
377+ then {
378+ let leasableTotalBalance = max([0, (getAccBalance(assetId) - minBalance)])
379+ let targetAdditionalBalance = fraction(targetRatio, leasableTotalBalance, 100)
380+ let diff = (currentAdditionalBalance - targetAdditionalBalance)
381+ if ((diff == 0))
382+ then nil
383+ else if ((0 > diff))
384+ then {
385+ let sendAssetAmount = -(diff)
386+ deposit(assetId, sendAssetAmount, stakingAssetId, proxy)
387+ }
388+ else {
389+ let getAssetAmount = diff
390+ withdraw(assetId, getAssetAmount, stakingAssetId, proxy, proxyRateMul, profitAddress)
391+ }
392+ }
393+ else throw("Strict value is not equal to itself.")
394+ }
395+ else throw("Strict value is not equal to itself.")
396+ }
397+
398+
399+func rebalanceAsset (assetId) = {
400+ let $t01546015596 = getLeaseProxyConfig(assetId)
401+ let isLeasable = $t01546015596._1
402+ let leasedRatio = $t01546015596._2
403+ let minBalance = $t01546015596._3
404+ let proxyAddress = $t01546015596._4
405+ let proxyAssetId = $t01546015596._5
406+ let proxyRateMul = $t01546015596._6
407+ let stakingProfitAddress = $t01546015596._7
408+ if (isLeasable)
409+ then rebalanceInternal(leasedRatio, assetId, proxyAssetId, minBalance, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress))
410+ else nil
411+ }
412+
413+
414+func withdrawAndRebalanceAsset (assetId,getAmount) = {
415+ let $t01599516131 = getLeaseProxyConfig(assetId)
416+ let isLeasable = $t01599516131._1
417+ let leasedRatio = $t01599516131._2
418+ let minBalance = $t01599516131._3
419+ let proxyAddress = $t01599516131._4
420+ let proxyAssetId = $t01599516131._5
421+ let proxyRateMul = $t01599516131._6
422+ let stakingProfitAddress = $t01599516131._7
423+ if (isLeasable)
424+ then {
425+ let newTotalLeasableBalance = max([0, ((getAccBalance(assetId) - getAmount) - minBalance)])
426+ if ((newTotalLeasableBalance == newTotalLeasableBalance))
427+ then {
428+ let newAdditionalBalance = fraction(leasedRatio, newTotalLeasableBalance, 100)
429+ if ((newAdditionalBalance == newAdditionalBalance))
430+ then {
431+ let withdrawAmount = (getAdditionalBalanceOrZero(assetId) - newAdditionalBalance)
432+ if ((withdrawAmount == withdrawAmount))
433+ then if ((0 > withdrawAmount))
434+ then deposit(assetId, -(withdrawAmount), proxyAssetId, addressFromStringValue(proxyAddress))
435+ else withdraw(assetId, withdrawAmount, proxyAssetId, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress))
436+ else throw("Strict value is not equal to itself.")
437+ }
438+ else throw("Strict value is not equal to itself.")
439+ }
440+ else throw("Strict value is not equal to itself.")
441+ }
442+ else nil
443+ }
444+
445+
446+func withdrawAndRebalanceAll (amountAssetOutAmount,priceAssetOutAmount) = {
447+ let AmAmtWithdrawState = withdrawAndRebalanceAsset(getStringOrFail(this, aa()), amountAssetOutAmount)
448+ let PrAmtWithdrawState = withdrawAndRebalanceAsset(getStringOrFail(this, pa()), priceAssetOutAmount)
449+ (AmAmtWithdrawState ++ PrAmtWithdrawState)
450+ }
260451
261452
262453 func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
263454 let amtAssetAmtX18 = toX18(amAmt, amAssetDcm)
264455 let priceAssetAmtX18 = toX18(prAmt, prAssetDcm)
265456 calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18)
266457 }
267458
268459
269460 func calcPrices (amAmt,prAmt,lpAmt) = {
270461 let cfg = getPoolConfig()
271462 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
272463 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
273464 let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt)
274465 let amAmtX18 = toX18(amAmt, amtAssetDcm)
275466 let prAmtX18 = toX18(prAmt, priceAssetDcm)
276467 let lpAmtX18 = toX18(lpAmt, scale8)
277468 let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18)
278469 let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18)
279470 [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18]
280471 }
281472
282473
283474 func calculatePrices (amAmt,prAmt,lpAmt) = {
284475 let prices = calcPrices(amAmt, prAmt, lpAmt)
285476 [fromX18(prices[0], scale8), fromX18(prices[1], scale8), fromX18(prices[2], scale8)]
286477 }
287478
288479
289480 func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
290481 let cfg = getPoolConfig()
291482 let lpAssetId = cfg[idxPoolLPAssetId]
292483 let amAssetId = cfg[idxAmtAssetId]
293484 let prAssetId = cfg[idxPriceAssetId]
294485 let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
295486 let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
296487 let poolStatus = cfg[idxPoolStatus]
297488 let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity
298489 if ((lpAssetId != pmtAssetId))
299490 then throw("Invalid asset passed.")
300491 else {
301492 let amBalance = getAccBalance(amAssetId)
302493 let amBalanceX18 = toX18(amBalance, amAssetDcm)
303494 let prBalance = getAccBalance(prAssetId)
304495 let prBalanceX18 = toX18(prBalance, prAssetDcm)
305496 let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18)
306497 let curPrice = fromX18(curPriceX18, scale8)
307498 let pmtLpAmtX18 = toX18(pmtLpAmt, scale8)
308499 let lpEmissionX18 = toX18(lpEmission, scale8)
309500 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18)
310501 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18)
311502 let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR)
312503 let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR)
313504 let state = if ((txId58 == ""))
314505 then nil
315506 else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES"))
316507 then unit
317508 else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES"))
318509 then unit
319510 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)]
320511 $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state)
321512 }
322513 }
323514
324515
325516 func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = {
326517 let cfg = getPoolConfig()
327518 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
328519 let amAssetIdStr = cfg[idxAmtAssetId]
329520 let prAssetIdStr = cfg[idxPriceAssetId]
330521 let iAmtAssetId = cfg[idxIAmtAssetId]
331522 let iPriceAssetId = cfg[idxIPriceAssetId]
332523 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
333524 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
334525 let poolStatus = cfg[idxPoolStatus]
335526 let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
336527 let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES")))
337528 let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES")))
338529 if (if ((amAssetIdStr != inAmAssetIdStr))
339530 then true
340531 else (prAssetIdStr != inPrAssetIdStr))
341532 then throw("Invalid amt or price asset passed.")
342533 else {
343534 let amBalance = if (isEvaluate)
344535 then getAccBalance(amAssetIdStr)
345536 else (getAccBalance(amAssetIdStr) - inAmAssetAmt)
346537 let prBalance = if (isEvaluate)
347538 then getAccBalance(prAssetIdStr)
348539 else (getAccBalance(prAssetIdStr) - inPrAssetAmt)
349540 let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm)
350541 let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm)
351542 let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18)
352543 let amBalanceX18 = toX18(amBalance, amtAssetDcm)
353544 let prBalanceX18 = toX18(prBalance, priceAssetDcm)
354545 let res = if ((lpEmission == 0))
355546 then {
356547 let curPriceX18 = zeroBigInt
357548 let slippageX18 = zeroBigInt
358549 let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN)
359550 $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
360551 }
361552 else {
362553 let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18)
363554 let slippageX18 = fraction(absBigInt((curPriceX18 - userPriceX18)), scale18, curPriceX18)
364555 let slippageToleranceX18 = toX18(slippageTolerance, scale8)
365556 if (if ((curPriceX18 != zeroBigInt))
366557 then (slippageX18 > slippageToleranceX18)
367558 else false)
368559 then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18)))
369560 else {
370561 let lpEmissionX18 = toX18(lpEmission, scale8)
371562 let prViaAmX18 = fraction(inAmAssetAmtX18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING)
372563 let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, FLOOR), CEILING)
373564 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
374565 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
375566 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
376567 let expAmtAssetAmtX18 = expectedAmts._1
377568 let expPriceAssetAmtX18 = expectedAmts._2
378569 let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR)
379570 $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtAssetDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceAssetDcm, CEILING), curPriceX18, slippageX18)
380571 }
381572 }
382573 let calcLpAmt = res._1
383574 let calcAmAssetPmt = res._2
384575 let calcPrAssetPmt = res._3
385576 let curPrice = fromX18(res._4, scale8)
386577 let slippageCalc = fromX18(res._5, scale8)
387578 if ((0 >= calcLpAmt))
388579 then throw("Invalid calculations. LP calculated is less than zero.")
389580 else {
390581 let emitLpAmt = if (!(emitLp))
391582 then 0
392583 else calcLpAmt
393584 let amDiff = (inAmAssetAmt - calcAmAssetPmt)
394585 let prDiff = (inPrAssetAmt - calcPrAssetPmt)
395586 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))]
396587 $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId)
397588 }
398589 }
399590 }
400591
401592
402593 func calcKLp (amountBalance,priceBalance,lpEmission) = {
403594 let amountBalanceX18 = toX18BigInt(amountBalance, toBigInt(cfgAmountAssetDecimals))
404595 let priceBalanceX18 = toX18BigInt(priceBalance, toBigInt(cfgPriceAssetDecimals))
405596 let updatedKLp = fraction(pow((amountBalanceX18 * priceBalanceX18), 0, toBigInt(5), 1, 18, DOWN), big1, lpEmission)
406597 if ((lpEmission == big0))
407598 then big0
408599 else updatedKLp
409600 }
410601
411602
412603 func calcCurrentKLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = {
413604 let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta)
414605 let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta)
415606 let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta)
416607 let currentKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpAssetEmission)
417608 currentKLp
418609 }
419610
420611
421612 func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = {
422613 let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta)
423614 let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta)
424615 let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta)
425616 let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission))
426617 let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))]
427618 $Tuple2(actions, updatedKLp)
428619 }
429620
430621
622+func skipOrderValidation () = valueOrElse(getBoolean(factoryContract, keySkipOrderValidation(toString(this))), false)
623+
624+
431625 func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp))
432626 then true
433627 else throwErr(makeString(["updated KLp lower than current KLp", toString(oldKLp), toString(updatedKLp)], " "))
434628
435629
436630 func validateMatcherOrderAllowed (order) = {
437631 let amountAssetBalance = getAccBalance(assetIdToString(cfgAmountAssetId))
438632 let priceAssetBalance = getAccBalance(assetIdToString(cfgPriceAssetId))
439633 let amountAssetAmount = order.amount
440634 let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR)
441- let $t02154121753 = if ((order.orderType == Buy))
635+ let $t02852028732 = if ((order.orderType == Buy))
442636 then $Tuple2(amountAssetAmount, -(priceAssetAmount))
443637 else $Tuple2(-(amountAssetAmount), priceAssetAmount)
444- let amountAssetBalanceDelta = $t02154121753._1
445- let priceAssetBalanceDelta = $t02154121753._2
638+ let amountAssetBalanceDelta = $t02852028732._1
639+ let priceAssetBalanceDelta = $t02852028732._2
446640 if (if (if (isGlobalShutdown())
447641 then true
448642 else (cfgPoolStatus == PoolMatcherDisabled))
449643 then true
450644 else (cfgPoolStatus == PoolShutdown))
451645 then throw("Exchange operations disabled")
452646 else if (if ((order.assetPair.amountAsset != cfgAmountAssetId))
453647 then true
454648 else (order.assetPair.priceAsset != cfgPriceAssetId))
455649 then throw("Wrong order assets.")
456650 else {
457651 let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp"))
458- let $t02219322293 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
459- let unusedActions = $t02219322293._1
460- let kLpNew = $t02219322293._2
652+ let $t02917229272 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
653+ let unusedActions = $t02917229272._1
654+ let kLpNew = $t02917229272._2
461655 let isOrderValid = (kLpNew >= kLp)
462656 let info = makeString(["kLp=", toString(kLp), " kLpNew=", toString(kLpNew), " amountAssetBalance=", toString(amountAssetBalance), " priceAssetBalance=", toString(priceAssetBalance), " amountAssetBalanceDelta=", toString(amountAssetBalanceDelta), " priceAssetBalanceDelta=", toString(priceAssetBalanceDelta), " height=", toString(height)], "")
463657 $Tuple2(isOrderValid, info)
464658 }
465659 }
466660
467661
468662 func commonGet (i) = if ((size(i.payments) != 1))
469663 then throw("exactly 1 payment is expected")
470664 else {
471665 let pmt = value(i.payments[0])
472666 let pmtAssetId = value(pmt.assetId)
473667 let pmtAmt = pmt.amount
474668 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller)
475669 let outAmAmt = res._1
476670 let outPrAmt = res._2
477671 let poolStatus = parseIntValue(res._9)
478672 let state = res._10
479673 if (if (isGlobalShutdown())
480674 then true
481675 else (poolStatus == PoolShutdown))
482676 then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
483677 else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state)
484678 }
485679
486680
487681 func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2))
488682 then throw("exactly 2 payments are expected")
489683 else {
490684 let amAssetPmt = value(i.payments[0])
491685 let prAssetPmt = value(i.payments[1])
492686 let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp)
493687 let poolStatus = parseIntValue(estPut._8)
494688 if (if (if (isGlobalShutdown())
495689 then true
496690 else (poolStatus == PoolPutDisabled))
497691 then true
498692 else (poolStatus == PoolShutdown))
499693 then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus)))
500694 else estPut
501695 }
502696
503697
504698 func emit (amount) = {
505699 let emitInv = invoke(factoryContract, "emit", [amount], nil)
506700 if ((emitInv == emitInv))
507701 then {
508702 let emitInvLegacy = match emitInv {
509703 case legacyFactoryContract: Address =>
510704 invoke(legacyFactoryContract, "emit", [amount], nil)
511705 case _ =>
512706 unit
513707 }
514708 if ((emitInvLegacy == emitInvLegacy))
515709 then amount
516710 else throw("Strict value is not equal to itself.")
517711 }
518712 else throw("Strict value is not equal to itself.")
519713 }
520714
521715
522716 func takeFee (amount,fee) = {
523717 let feeAmount = if ((fee == 0))
524718 then 0
525719 else fraction(amount, fee, scale8)
526720 $Tuple2((amount - feeAmount), feeAmount)
527721 }
528722
529723
530724 func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = {
531725 let isEval = (txId == unit)
532726 let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId))
533727 let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId))
534728 let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId))
535729 then true
536730 else if ((paymentAssetId == cfgPriceAssetId))
537731 then false
538732 else throwErr("invalid asset")
539- let $t02540625699 = if (isEval)
733+ let $t03238532678 = if (isEval)
540734 then $Tuple2(amountBalanceRaw, priceBalanceRaw)
541735 else if (paymentInAmountAsset)
542736 then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw)
543737 else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw))
544- let amountBalanceOld = $t02540625699._1
545- let priceBalanceOld = $t02540625699._2
546- let $t02570325852 = if (paymentInAmountAsset)
738+ let amountBalanceOld = $t03238532678._1
739+ let priceBalanceOld = $t03238532678._2
740+ let $t03268232831 = if (paymentInAmountAsset)
547741 then $Tuple2(paymentAmountRaw, 0)
548742 else $Tuple2(0, paymentAmountRaw)
549- let amountAssetAmountRaw = $t02570325852._1
550- let priceAssetAmountRaw = $t02570325852._2
743+ let amountAssetAmountRaw = $t03268232831._1
744+ let priceAssetAmountRaw = $t03268232831._2
551745 let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1
552746 let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1
553- let $t02598426048 = takeFee(paymentAmountRaw, inFee)
554- let paymentAmount = $t02598426048._1
555- let feeAmount = $t02598426048._2
747+ let $t03296333027 = takeFee(paymentAmountRaw, inFee)
748+ let paymentAmount = $t03296333027._1
749+ let feeAmount = $t03296333027._2
556750 let amountBalanceNew = (amountBalanceOld + amountAssetAmount)
557751 let priceBalanceNew = (priceBalanceOld + priceAssetAmount)
558752 let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals))
559753 let priceNew = fromX18(priceNewX18, scale8)
560754 let paymentBalance = if (paymentInAmountAsset)
561755 then amountBalanceOld
562756 else priceBalanceOld
563757 let paymentBalanceBigInt = toBigInt(paymentBalance)
564758 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
565759 let chechSupply = if ((supplyBigInt > big0))
566760 then true
567761 else throwErr("initial deposit requires all coins")
568762 if ((chechSupply == chechSupply))
569763 then {
570764 let depositBigInt = toBigInt(paymentAmount)
571765 let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))])
572766 let commonState = if (isEval)
573767 then nil
574768 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))]
575769 let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals))
576770 let priceOld = fromX18(priceOldX18, scale8)
577771 let loss = {
578- let $t02772927896 = if (paymentInAmountAsset)
772+ let $t03470834875 = if (paymentInAmountAsset)
579773 then $Tuple2(amountAssetAmountRaw, amountBalanceOld)
580774 else $Tuple2(priceAssetAmountRaw, priceBalanceOld)
581- let amount = $t02772927896._1
582- let balance = $t02772927896._2
775+ let amount = $t03470834875._1
776+ let balance = $t03470834875._2
583777 let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance)))
584778 fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth)
585779 }
586780 $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset)
587781 }
588782 else throw("Strict value is not equal to itself.")
589783 }
590784
591785
592786 func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = {
593787 let isEval = (txId == unit)
594788 let cfg = getPoolConfig()
595789 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
596790 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
597791 let checks = [if ((paymentAssetId == cfgLpAssetId))
598792 then true
599793 else throwErr("invalid lp asset")]
600794 if ((checks == checks))
601795 then {
602796 let outInAmountAsset = if ((outAssetId == cfgAmountAssetId))
603797 then true
604798 else if ((outAssetId == cfgPriceAssetId))
605799 then false
606800 else throwErr("invalid asset")
607801 let balanceBigInt = if (outInAmountAsset)
608802 then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId)))
609803 else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId)))
610804 let outInAmountAssetDecimals = if (outInAmountAsset)
611805 then amtAssetDcm
612806 else priceAssetDcm
613807 let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId))
614808 let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId))
615809 let outBalance = if (outInAmountAsset)
616810 then amBalanceOld
617811 else prBalanceOld
618812 let outBalanceBigInt = toBigInt(outBalance)
619813 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
620814 let redeemedBigInt = toBigInt(paymentAmount)
621815 let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))])
622- let $t02997430030 = takeFee(amountRaw, outFee)
623- let totalAmount = $t02997430030._1
624- let feeAmount = $t02997430030._2
625- let $t03003430260 = if (outInAmountAsset)
816+ let $t03695337009 = takeFee(amountRaw, outFee)
817+ let totalAmount = $t03695337009._1
818+ let feeAmount = $t03695337009._2
819+ let $t03701337239 = if (outInAmountAsset)
626820 then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
627821 else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw))
628- let outAmAmount = $t03003430260._1
629- let outPrAmount = $t03003430260._2
630- let amBalanceNew = $t03003430260._3
631- let prBalanceNew = $t03003430260._4
822+ let outAmAmount = $t03701337239._1
823+ let outPrAmount = $t03701337239._2
824+ let amBalanceNew = $t03701337239._3
825+ let prBalanceNew = $t03701337239._4
632826 let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
633827 let priceNew = fromX18(priceNewX18, scale8)
634828 let commonState = if (isEval)
635829 then nil
636830 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)]
637831 let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals))
638832 let priceOld = fromX18(priceOldX18, scale8)
639833 let loss = {
640834 let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2)
641835 fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset)
642836 }
643837 $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset)
644838 }
645839 else throw("Strict value is not equal to itself.")
646840 }
647841
648842
649843 func managerPublicKeyOrUnit () = match getString(mpk()) {
650844 case s: String =>
651845 fromBase58String(s)
652846 case _: Unit =>
653847 unit
654848 case _ =>
655849 throw("Match error")
656850 }
657851
658852
659853 func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) {
660854 case s: String =>
661855 fromBase58String(s)
662856 case _: Unit =>
663857 unit
664858 case _ =>
665859 throw("Match error")
666860 }
667861
668862
669863 func isManager (i) = match managerPublicKeyOrUnit() {
670864 case pk: ByteVector =>
671865 (i.callerPublicKey == pk)
672866 case _: Unit =>
673867 (i.caller == this)
674868 case _ =>
675869 throw("Match error")
676870 }
677871
678872
679873 func mustManager (i) = {
680874 let pd = throw("Permission denied")
681875 match managerPublicKeyOrUnit() {
682876 case pk: ByteVector =>
683877 if ((i.callerPublicKey == pk))
684878 then true
685879 else pd
686880 case _: Unit =>
687881 if ((i.caller == this))
688882 then true
689883 else pd
690884 case _ =>
691885 throw("Match error")
692886 }
693887 }
694888
695889
696890 @Callable(i)
891+func rebalance () = (rebalanceAsset(getStringOrFail(this, aa())) ++ rebalanceAsset(getStringOrFail(this, pa())))
892+
893+
894+
895+@Callable(i)
697896 func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse,feePoolAmount) = {
698- let $t03197732282 = if ((isReverse == false))
897+ let $t03912539430 = if ((isReverse == false))
699898 then {
700899 let assetOut = getStringOrFail(this, pa())
701900 let assetIn = getStringOrFail(this, aa())
702901 $Tuple2(assetOut, assetIn)
703902 }
704903 else {
705904 let assetOut = getStringOrFail(this, aa())
706905 let assetIn = getStringOrFail(this, pa())
707906 $Tuple2(assetOut, assetIn)
708907 }
709- let assetOut = $t03197732282._1
710- let assetIn = $t03197732282._2
908+ let assetOut = $t03912539430._1
909+ let assetIn = $t03912539430._2
711910 let poolAssetInBalance = getAccBalance(assetIn)
712911 let poolAssetOutBalance = getAccBalance(assetOut)
713912 let amountOut = fraction(poolAssetOutBalance, cleanAmountIn, (poolAssetInBalance + cleanAmountIn))
714913 let oldK = (toBigInt(poolAssetInBalance) * toBigInt(poolAssetOutBalance))
715914 let newK = (((toBigInt(getAccBalance(assetIn)) + toBigInt(cleanAmountIn)) + toBigInt(feePoolAmount)) * (toBigInt(getAccBalance(assetOut)) - toBigInt(amountOut)))
716915 let checkK = if ((newK >= oldK))
717916 then true
718917 else throw("new K is fewer error")
719918 if ((checkK == checkK))
720919 then $Tuple2(nil, amountOut)
721920 else throw("Strict value is not equal to itself.")
722921 }
723922
724923
725924
726925 @Callable(i)
727926 func calculateAmountOutForSwapAndSendTokens (cleanAmountIn,isReverse,amountOutMin,addressTo,feePoolAmount) = {
728927 let swapContact = {
729928 let @ = invoke(factoryContract, "getSwapContractREADONLY", nil, nil)
730929 if ($isInstanceOf(@, "String"))
731930 then @
732931 else throw(($getType(@) + " couldn't be cast to String"))
733932 }
734933 let checks = [if ((value(i.payments[0]).amount >= cleanAmountIn))
735934 then true
736935 else throwErr("Wrong amount"), if ((i.caller == addressFromStringValue(swapContact)))
737936 then true
738937 else throwErr("Permission denied")]
739938 if ((checks == checks))
740939 then {
741940 let pmt = value(i.payments[0])
742941 let assetIn = assetIdToString(pmt.assetId)
743942 let assetOut = if ((isReverse == false))
744943 then getStringOrFail(this, pa())
745944 else getStringOrFail(this, aa())
746945 let poolAssetInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount)
747946 let poolAssetOutBalance = getAccBalance(assetOut)
748947 let amountOut = fraction(poolAssetOutBalance, cleanAmountIn, (poolAssetInBalance + cleanAmountIn))
749948 let oldK = (toBigInt(poolAssetInBalance) * toBigInt(poolAssetOutBalance))
750949 let newK = ((toBigInt(getAccBalance(assetIn)) + toBigInt(feePoolAmount)) * (toBigInt(getAccBalance(assetOut)) - toBigInt(amountOut)))
751950 let checkK = if ((newK >= oldK))
752951 then true
753952 else throw("new K is fewer error")
754953 if ((checkK == checkK))
755954 then {
756955 let checkMin = if ((amountOut >= amountOutMin))
757956 then true
758957 else throw("Exchange result is fewer coins than expected")
759958 if ((checkMin == checkMin))
760- then $Tuple2([ScriptTransfer(addressFromStringValue(addressTo), amountOut, parseAssetId(assetOut))], amountOut)
959+ then {
960+ let rebalanceState = rebalanceAsset(assetIn)
961+ if ((rebalanceState == rebalanceState))
962+ then {
963+ let withdrawState = withdrawAndRebalanceAsset(assetOut, amountOut)
964+ if ((withdrawState == withdrawState))
965+ then $Tuple2(((withdrawState ++ rebalanceState) ++ [ScriptTransfer(addressFromStringValue(addressTo), amountOut, parseAssetId(assetOut))]), amountOut)
966+ else throw("Strict value is not equal to itself.")
967+ }
968+ else throw("Strict value is not equal to itself.")
969+ }
761970 else throw("Strict value is not equal to itself.")
762971 }
763972 else throw("Strict value is not equal to itself.")
764973 }
765974 else throw("Strict value is not equal to itself.")
766975 }
767976
768977
769978
770979 @Callable(i)
771980 func setManager (pendingManagerPublicKey) = {
772981 let checkCaller = mustManager(i)
773982 if ((checkCaller == checkCaller))
774983 then {
775984 let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
776985 if ((checkManagerPublicKey == checkManagerPublicKey))
777986 then [StringEntry(pmpk(), pendingManagerPublicKey)]
778987 else throw("Strict value is not equal to itself.")
779988 }
780989 else throw("Strict value is not equal to itself.")
781990 }
782991
783992
784993
785994 @Callable(i)
786995 func confirmManager () = {
787996 let pm = pendingManagerPublicKeyOrUnit()
788997 let hasPM = if (isDefined(pm))
789998 then true
790999 else throw("No pending manager")
7911000 if ((hasPM == hasPM))
7921001 then {
7931002 let checkPM = if ((i.callerPublicKey == value(pm)))
7941003 then true
7951004 else throw("You are not pending manager")
7961005 if ((checkPM == checkPM))
7971006 then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())]
7981007 else throw("Strict value is not equal to itself.")
7991008 }
8001009 else throw("Strict value is not equal to itself.")
8011010 }
8021011
8031012
8041013
8051014 @Callable(i)
8061015 func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance))
8071016 then throw("Invalid slippageTolerance passed")
8081017 else {
8091018 let estPut = commonPut(i, slippageTolerance, true)
8101019 let emitLpAmt = estPut._2
8111020 let lpAssetId = estPut._7
8121021 let state = estPut._9
8131022 let amDiff = estPut._10
8141023 let prDiff = estPut._11
8151024 let amId = estPut._12
8161025 let prId = estPut._13
8171026 let amAssetPmt = toBigInt(value(i.payments[0]).amount)
8181027 let prAssetPmt = toBigInt(value(i.payments[1]).amount)
8191028 let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
8201029 if ((currentKLp == currentKLp))
8211030 then {
8221031 let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
8231032 if ((emitInv == emitInv))
8241033 then {
8251034 let emitInvLegacy = match emitInv {
8261035 case legacyFactoryContract: Address =>
8271036 invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
8281037 case _ =>
8291038 unit
8301039 }
8311040 if ((emitInvLegacy == emitInvLegacy))
8321041 then {
8331042 let slippageAInv = if ((amDiff > 0))
8341043 then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
8351044 else nil
8361045 if ((slippageAInv == slippageAInv))
8371046 then {
8381047 let slippagePInv = if ((prDiff > 0))
8391048 then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
8401049 else nil
8411050 if ((slippagePInv == slippagePInv))
8421051 then {
8431052 let lpTransfer = if (shouldAutoStake)
8441053 then {
8451054 let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
8461055 if ((slpStakeInv == slpStakeInv))
8471056 then nil
8481057 else throw("Strict value is not equal to itself.")
8491058 }
8501059 else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
851- let $t03716637628 = refreshKLpInternal(0, 0, 0)
852- if (($t03716637628 == $t03716637628))
1060+ let $t04447644938 = refreshKLpInternal(0, 0, 0)
1061+ if (($t04447644938 == $t04447644938))
8531062 then {
854- let updatedKLp = $t03716637628._2
855- let refreshKLpActions = $t03716637628._1
1063+ let updatedKLp = $t04447644938._2
1064+ let refreshKLpActions = $t04447644938._1
8561065 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
8571066 if ((isUpdatedKLpValid == isUpdatedKLpValid))
858- then ((state ++ lpTransfer) ++ refreshKLpActions)
1067+ then {
1068+ let reb = invoke(this, "rebalance", nil, nil)
1069+ if ((reb == reb))
1070+ then ((state ++ lpTransfer) ++ refreshKLpActions)
1071+ else throw("Strict value is not equal to itself.")
1072+ }
8591073 else throw("Strict value is not equal to itself.")
8601074 }
8611075 else throw("Strict value is not equal to itself.")
8621076 }
8631077 else throw("Strict value is not equal to itself.")
8641078 }
8651079 else throw("Strict value is not equal to itself.")
8661080 }
8671081 else throw("Strict value is not equal to itself.")
8681082 }
8691083 else throw("Strict value is not equal to itself.")
8701084 }
8711085 else throw("Strict value is not equal to itself.")
8721086 }
8731087
8741088
8751089
8761090 @Callable(i)
8771091 func putForFree (maxSlippage) = if ((0 > maxSlippage))
8781092 then throw("Invalid value passed")
8791093 else {
8801094 let estPut = commonPut(i, maxSlippage, false)
8811095 let state = estPut._9
8821096 let amAssetPmt = toBigInt(value(i.payments[0]).amount)
8831097 let prAssetPmt = toBigInt(value(i.payments[1]).amount)
8841098 let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
8851099 if ((currentKLp == currentKLp))
8861100 then {
887- let $t03819038255 = refreshKLpInternal(0, 0, 0)
888- let refreshKLpActions = $t03819038255._1
889- let updatedKLp = $t03819038255._2
1101+ let $t04555045615 = refreshKLpInternal(0, 0, 0)
1102+ let refreshKLpActions = $t04555045615._1
1103+ let updatedKLp = $t04555045615._2
8901104 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
8911105 if ((isUpdatedKLpValid == isUpdatedKLpValid))
8921106 then (state ++ refreshKLpActions)
8931107 else throw("Strict value is not equal to itself.")
8941108 }
8951109 else throw("Strict value is not equal to itself.")
8961110 }
8971111
8981112
8991113
9001114 @Callable(i)
9011115 func putOneTkn (minOutAmount,autoStake) = {
9021116 let isPoolOneTokenOperationsDisabled = {
9031117 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
9041118 if ($isInstanceOf(@, "Boolean"))
9051119 then @
9061120 else throw(($getType(@) + " couldn't be cast to Boolean"))
9071121 }
9081122 let isPutDisabled = if (if (if (isGlobalShutdown())
9091123 then true
9101124 else (cfgPoolStatus == PoolPutDisabled))
9111125 then true
9121126 else (cfgPoolStatus == PoolShutdown))
9131127 then true
9141128 else isPoolOneTokenOperationsDisabled
9151129 let checks = [if (if (!(isPutDisabled))
9161130 then true
9171131 else isManager(i))
9181132 then true
9191133 else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1))
9201134 then true
9211135 else throwErr("exactly 1 payment are expected")]
9221136 if ((checks == checks))
9231137 then {
9241138 let payment = i.payments[0]
9251139 let paymentAssetId = payment.assetId
9261140 let paymentAmountRaw = payment.amount
9271141 let currentKLp = if ((paymentAssetId == cfgAmountAssetId))
9281142 then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0))
9291143 else if ((paymentAssetId == cfgPriceAssetId))
9301144 then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0))
9311145 else throwErr("payment asset is not supported")
9321146 if ((currentKLp == currentKLp))
9331147 then {
9341148 let userAddress = i.caller
9351149 let txId = i.transactionId
936- let $t03944339595 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
937- if (($t03944339595 == $t03944339595))
1150+ let $t04680346955 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
1151+ if (($t04680346955 == $t04680346955))
9381152 then {
939- let paymentInAmountAsset = $t03944339595._5
940- let bonus = $t03944339595._4
941- let feeAmount = $t03944339595._3
942- let commonState = $t03944339595._2
943- let emitAmountEstimated = $t03944339595._1
1153+ let paymentInAmountAsset = $t04680346955._5
1154+ let bonus = $t04680346955._4
1155+ let feeAmount = $t04680346955._3
1156+ let commonState = $t04680346955._2
1157+ let emitAmountEstimated = $t04680346955._1
9441158 let emitAmount = if (if ((minOutAmount > 0))
9451159 then (minOutAmount > emitAmountEstimated)
9461160 else false)
9471161 then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
9481162 else emitAmountEstimated
9491163 let emitInv = emit(emitAmount)
9501164 if ((emitInv == emitInv))
9511165 then {
9521166 let lpTransfer = if (autoStake)
9531167 then {
9541168 let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
9551169 if ((stakeInv == stakeInv))
9561170 then nil
9571171 else throw("Strict value is not equal to itself.")
9581172 }
9591173 else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
9601174 let sendFee = if ((feeAmount > 0))
9611175 then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
9621176 else nil
963- let $t04018140378 = if ((this == feeCollectorAddress))
1177+ let $t04754147738 = if ((this == feeCollectorAddress))
9641178 then $Tuple2(0, 0)
9651179 else if (paymentInAmountAsset)
9661180 then $Tuple2(-(feeAmount), 0)
9671181 else $Tuple2(0, -(feeAmount))
968- let amountAssetBalanceDelta = $t04018140378._1
969- let priceAssetBalanceDelta = $t04018140378._2
970- let $t04038140489 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
971- let refreshKLpActions = $t04038140489._1
972- let updatedKLp = $t04038140489._2
1182+ let amountAssetBalanceDelta = $t04754147738._1
1183+ let priceAssetBalanceDelta = $t04754147738._2
1184+ let $t04774147849 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1185+ let refreshKLpActions = $t04774147849._1
1186+ let updatedKLp = $t04774147849._2
9731187 let kLp = value(getString(keyKLp))
9741188 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
9751189 if ((isUpdatedKLpValid == isUpdatedKLpValid))
976- then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
1190+ then {
1191+ let reb = invoke(this, "rebalance", nil, nil)
1192+ if ((reb == reb))
1193+ then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
1194+ else throw("Strict value is not equal to itself.")
1195+ }
9771196 else throw("Strict value is not equal to itself.")
9781197 }
9791198 else throw("Strict value is not equal to itself.")
9801199 }
9811200 else throw("Strict value is not equal to itself.")
9821201 }
9831202 else throw("Strict value is not equal to itself.")
9841203 }
9851204 else throw("Strict value is not equal to itself.")
9861205 }
9871206
9881207
9891208
9901209 @Callable(i)
9911210 func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = {
992- let $t04079540952 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
993- let emitAmountEstimated = $t04079540952._1
994- let commonState = $t04079540952._2
995- let feeAmount = $t04079540952._3
996- let bonus = $t04079540952._4
997- let paymentInAmountAsset = $t04079540952._5
1211+ let $t04820448361 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
1212+ let emitAmountEstimated = $t04820448361._1
1213+ let commonState = $t04820448361._2
1214+ let feeAmount = $t04820448361._3
1215+ let bonus = $t04820448361._4
1216+ let paymentInAmountAsset = $t04820448361._5
9981217 $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
9991218 }
10001219
10011220
10021221
10031222 @Callable(i)
10041223 func getOneTkn (outAssetIdStr,minOutAmount) = {
10051224 let isPoolOneTokenOperationsDisabled = {
10061225 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
10071226 if ($isInstanceOf(@, "Boolean"))
10081227 then @
10091228 else throw(($getType(@) + " couldn't be cast to Boolean"))
10101229 }
10111230 let isGetDisabled = if (if (isGlobalShutdown())
10121231 then true
10131232 else (cfgPoolStatus == PoolShutdown))
10141233 then true
10151234 else isPoolOneTokenOperationsDisabled
10161235 let checks = [if (if (!(isGetDisabled))
10171236 then true
10181237 else isManager(i))
10191238 then true
10201239 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1))
10211240 then true
10221241 else throwErr("exactly 1 payment are expected")]
10231242 if ((checks == checks))
10241243 then {
10251244 let outAssetId = parseAssetId(outAssetIdStr)
10261245 let payment = i.payments[0]
10271246 let paymentAssetId = payment.assetId
10281247 let paymentAmount = payment.amount
10291248 let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
10301249 if ((currentKLp == currentKLp))
10311250 then {
10321251 let userAddress = i.caller
10331252 let txId = i.transactionId
1034- let $t04183741990 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
1035- if (($t04183741990 == $t04183741990))
1253+ let $t04924649399 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
1254+ if (($t04924649399 == $t04924649399))
10361255 then {
1037- let outInAmountAsset = $t04183741990._5
1038- let bonus = $t04183741990._4
1039- let feeAmount = $t04183741990._3
1040- let commonState = $t04183741990._2
1041- let amountEstimated = $t04183741990._1
1256+ let outInAmountAsset = $t04924649399._5
1257+ let bonus = $t04924649399._4
1258+ let feeAmount = $t04924649399._3
1259+ let commonState = $t04924649399._2
1260+ let amountEstimated = $t04924649399._1
10421261 let amount = if (if ((minOutAmount > 0))
10431262 then (minOutAmount > amountEstimated)
10441263 else false)
10451264 then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
10461265 else amountEstimated
10471266 let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
10481267 if ((burnInv == burnInv))
10491268 then {
1269+ let withdrawState = withdrawAndRebalanceAsset(outAssetIdStr, (amount + max([0, feeAmount])))
10501270 let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
10511271 let sendFee = if ((feeAmount > 0))
10521272 then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
10531273 else nil
1054- let $t04249042737 = {
1274+ let $t05006350310 = {
10551275 let feeAmountForCalc = if ((this == feeCollectorAddress))
10561276 then 0
10571277 else feeAmount
10581278 if (outInAmountAsset)
10591279 then $Tuple2(-((amount + feeAmountForCalc)), 0)
10601280 else $Tuple2(0, -((amount + feeAmountForCalc)))
10611281 }
1062- let amountAssetBalanceDelta = $t04249042737._1
1063- let priceAssetBalanceDelta = $t04249042737._2
1064- let $t04274042848 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1065- let refreshKLpActions = $t04274042848._1
1066- let updatedKLp = $t04274042848._2
1282+ let amountAssetBalanceDelta = $t05006350310._1
1283+ let priceAssetBalanceDelta = $t05006350310._2
1284+ let $t05031350421 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1285+ let refreshKLpActions = $t05031350421._1
1286+ let updatedKLp = $t05031350421._2
10671287 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
10681288 if ((isUpdatedKLpValid == isUpdatedKLpValid))
1069- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1289+ then $Tuple2(((((commonState ++ withdrawState) ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
10701290 else throw("Strict value is not equal to itself.")
10711291 }
10721292 else throw("Strict value is not equal to itself.")
10731293 }
10741294 else throw("Strict value is not equal to itself.")
10751295 }
10761296 else throw("Strict value is not equal to itself.")
10771297 }
10781298 else throw("Strict value is not equal to itself.")
10791299 }
10801300
10811301
10821302
10831303 @Callable(i)
10841304 func getOneTknREADONLY (outAssetId,paymentAmount) = {
1085- let $t04310543261 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
1086- let amountEstimated = $t04310543261._1
1087- let commonState = $t04310543261._2
1088- let feeAmount = $t04310543261._3
1089- let bonus = $t04310543261._4
1090- let outInAmountAsset = $t04310543261._5
1305+ let $t05069950855 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
1306+ let amountEstimated = $t05069950855._1
1307+ let commonState = $t05069950855._2
1308+ let feeAmount = $t05069950855._3
1309+ let bonus = $t05069950855._4
1310+ let outInAmountAsset = $t05069950855._5
10911311 $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
10921312 }
10931313
10941314
10951315
10961316 @Callable(i)
10971317 func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = {
10981318 let isPoolOneTokenOperationsDisabled = {
10991319 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
11001320 if ($isInstanceOf(@, "Boolean"))
11011321 then @
11021322 else throw(($getType(@) + " couldn't be cast to Boolean"))
11031323 }
11041324 let isGetDisabled = if (if (isGlobalShutdown())
11051325 then true
11061326 else (cfgPoolStatus == PoolShutdown))
11071327 then true
11081328 else isPoolOneTokenOperationsDisabled
11091329 let checks = [if (if (!(isGetDisabled))
11101330 then true
11111331 else isManager(i))
11121332 then true
11131333 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0))
11141334 then true
11151335 else throwErr("no payments are expected")]
11161336 if ((checks == checks))
11171337 then {
11181338 let outAssetId = parseAssetId(outAssetIdStr)
11191339 let userAddress = i.caller
11201340 let txId = i.transactionId
11211341 let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
11221342 if ((currentKLp == currentKLp))
11231343 then {
11241344 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
11251345 if ((unstakeInv == unstakeInv))
11261346 then {
1127- let $t04416644317 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
1128- if (($t04416644317 == $t04416644317))
1347+ let $t05176051911 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
1348+ if (($t05176051911 == $t05176051911))
11291349 then {
1130- let outInAmountAsset = $t04416644317._5
1131- let bonus = $t04416644317._4
1132- let feeAmount = $t04416644317._3
1133- let commonState = $t04416644317._2
1134- let amountEstimated = $t04416644317._1
1350+ let outInAmountAsset = $t05176051911._5
1351+ let bonus = $t05176051911._4
1352+ let feeAmount = $t05176051911._3
1353+ let commonState = $t05176051911._2
1354+ let amountEstimated = $t05176051911._1
11351355 let amount = if (if ((minOutAmount > 0))
11361356 then (minOutAmount > amountEstimated)
11371357 else false)
11381358 then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
11391359 else amountEstimated
11401360 let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
11411361 if ((burnInv == burnInv))
11421362 then {
1363+ let withdrawState = withdrawAndRebalanceAsset(outAssetIdStr, (amount + max([0, feeAmount])))
11431364 let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
11441365 let sendFee = if ((feeAmount > 0))
11451366 then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
11461367 else nil
1147- let $t04481245059 = {
1368+ let $t05257052817 = {
11481369 let feeAmountForCalc = if ((this == feeCollectorAddress))
11491370 then 0
11501371 else feeAmount
11511372 if (outInAmountAsset)
11521373 then $Tuple2(-((amount + feeAmountForCalc)), 0)
11531374 else $Tuple2(0, -((amount + feeAmountForCalc)))
11541375 }
1155- let amountAssetBalanceDelta = $t04481245059._1
1156- let priceAssetBalanceDelta = $t04481245059._2
1157- let $t04506245170 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1158- let refreshKLpActions = $t04506245170._1
1159- let updatedKLp = $t04506245170._2
1376+ let amountAssetBalanceDelta = $t05257052817._1
1377+ let priceAssetBalanceDelta = $t05257052817._2
1378+ let $t05282052928 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1379+ let refreshKLpActions = $t05282052928._1
1380+ let updatedKLp = $t05282052928._2
11601381 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
11611382 if ((isUpdatedKLpValid == isUpdatedKLpValid))
1162- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1383+ then $Tuple2(((((commonState ++ withdrawState) ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
11631384 else throw("Strict value is not equal to itself.")
11641385 }
11651386 else throw("Strict value is not equal to itself.")
11661387 }
11671388 else throw("Strict value is not equal to itself.")
11681389 }
11691390 else throw("Strict value is not equal to itself.")
11701391 }
11711392 else throw("Strict value is not equal to itself.")
11721393 }
11731394 else throw("Strict value is not equal to itself.")
11741395 }
11751396
11761397
11771398
11781399 @Callable(i)
11791400 func get () = {
11801401 let res = commonGet(i)
1181- let outAmtAmt = res._1
1402+ let outAmAmt = res._1
11821403 let outPrAmt = res._2
11831404 let pmtAmt = res._3
11841405 let pmtAssetId = res._4
11851406 let state = res._5
1407+ let withdrawState = withdrawAndRebalanceAll(outAmAmt, outPrAmt)
11861408 let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
11871409 if ((currentKLp == currentKLp))
11881410 then {
11891411 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
11901412 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
11911413 then {
1192- let $t04611646198 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1193- let refreshKLpActions = $t04611646198._1
1194- let updatedKLp = $t04611646198._2
1414+ let $t05402354104 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1415+ let refreshKLpActions = $t05402354104._1
1416+ let updatedKLp = $t05402354104._2
11951417 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
11961418 if ((isUpdatedKLpValid == isUpdatedKLpValid))
1197- then (state ++ refreshKLpActions)
1419+ then ((withdrawState ++ state) ++ refreshKLpActions)
11981420 else throw("Strict value is not equal to itself.")
11991421 }
12001422 else throw("Strict value is not equal to itself.")
12011423 }
12021424 else throw("Strict value is not equal to itself.")
12031425 }
12041426
12051427
12061428
12071429 @Callable(i)
12081430 func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = {
12091431 let res = commonGet(i)
12101432 let outAmAmt = res._1
12111433 let outPrAmt = res._2
12121434 let pmtAmt = res._3
12131435 let pmtAssetId = res._4
12141436 let state = res._5
12151437 if ((noLessThenAmtAsset > outAmAmt))
12161438 then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset)))
12171439 else if ((noLessThenPriceAsset > outPrAmt))
12181440 then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
12191441 else {
1442+ let withdrawState = withdrawAndRebalanceAll(outAmAmt, outPrAmt)
12201443 let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
12211444 if ((currentKLp == currentKLp))
12221445 then {
12231446 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
12241447 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
12251448 then {
1226- let $t04714747228 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1227- let refreshKLpActions = $t04714747228._1
1228- let updatedKLp = $t04714747228._2
1449+ let $t05519955280 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1450+ let refreshKLpActions = $t05519955280._1
1451+ let updatedKLp = $t05519955280._2
12291452 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
12301453 if ((isUpdatedKLpValid == isUpdatedKLpValid))
1231- then (state ++ refreshKLpActions)
1454+ then ((withdrawState ++ state) ++ refreshKLpActions)
12321455 else throw("Strict value is not equal to itself.")
12331456 }
12341457 else throw("Strict value is not equal to itself.")
12351458 }
12361459 else throw("Strict value is not equal to itself.")
12371460 }
12381461 }
12391462
12401463
12411464
12421465 @Callable(i)
12431466 func unstakeAndGet (amount) = {
12441467 let checkPayments = if ((size(i.payments) != 0))
12451468 then throw("No payments are expected")
12461469 else true
12471470 if ((checkPayments == checkPayments))
12481471 then {
12491472 let cfg = getPoolConfig()
12501473 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
12511474 let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
12521475 if ((currentKLp == currentKLp))
12531476 then {
12541477 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
12551478 if ((unstakeInv == unstakeInv))
12561479 then {
12571480 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
12581481 let outAmAmt = res._1
12591482 let outPrAmt = res._2
12601483 let poolStatus = parseIntValue(res._9)
12611484 let state = res._10
1485+ let withdrawState = withdrawAndRebalanceAll(outAmAmt, outPrAmt)
12621486 let checkPoolStatus = if (if (isGlobalShutdown())
12631487 then true
12641488 else (poolStatus == PoolShutdown))
12651489 then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
12661490 else true
12671491 if ((checkPoolStatus == checkPoolStatus))
12681492 then {
12691493 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
12701494 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
12711495 then {
1272- let $t04835448435 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1273- let refreshKLpActions = $t04835448435._1
1274- let updatedKLp = $t04835448435._2
1496+ let $t05655256633 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1497+ let refreshKLpActions = $t05655256633._1
1498+ let updatedKLp = $t05655256633._2
12751499 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
12761500 if ((isUpdatedKLpValid == isUpdatedKLpValid))
1277- then (state ++ refreshKLpActions)
1501+ then ((withdrawState ++ state) ++ refreshKLpActions)
12781502 else throw("Strict value is not equal to itself.")
12791503 }
12801504 else throw("Strict value is not equal to itself.")
12811505 }
12821506 else throw("Strict value is not equal to itself.")
12831507 }
12841508 else throw("Strict value is not equal to itself.")
12851509 }
12861510 else throw("Strict value is not equal to itself.")
12871511 }
12881512 else throw("Strict value is not equal to itself.")
12891513 }
12901514
12911515
12921516
12931517 @Callable(i)
12941518 func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = {
12951519 let isGetDisabled = if (isGlobalShutdown())
12961520 then true
12971521 else (cfgPoolStatus == PoolShutdown)
12981522 let checks = [if (!(isGetDisabled))
12991523 then true
13001524 else throw("get operation is blocked by admin"), if ((size(i.payments) == 0))
13011525 then true
13021526 else throw("no payments are expected")]
13031527 if ((checks == checks))
13041528 then {
13051529 let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
13061530 if ((currentKLp == currentKLp))
13071531 then {
13081532 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
13091533 if ((unstakeInv == unstakeInv))
13101534 then {
13111535 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
13121536 let outAmAmt = res._1
13131537 let outPrAmt = res._2
13141538 let state = res._10
1539+ let withdrawState = withdrawAndRebalanceAll(outAmAmt, outPrAmt)
13151540 let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
13161541 then true
13171542 else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
13181543 then true
13191544 else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
13201545 if ((checkAmounts == checkAmounts))
13211546 then {
13221547 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
13231548 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
13241549 then {
1325- let $t04973049811 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1326- let refreshKLpActions = $t04973049811._1
1327- let updatedKLp = $t04973049811._2
1550+ let $t05807458155 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1551+ let refreshKLpActions = $t05807458155._1
1552+ let updatedKLp = $t05807458155._2
13281553 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
13291554 if ((isUpdatedKLpValid == isUpdatedKLpValid))
1330- then (state ++ refreshKLpActions)
1555+ then ((withdrawState ++ state) ++ refreshKLpActions)
13311556 else throw("Strict value is not equal to itself.")
13321557 }
13331558 else throw("Strict value is not equal to itself.")
13341559 }
13351560 else throw("Strict value is not equal to itself.")
13361561 }
13371562 else throw("Strict value is not equal to itself.")
13381563 }
13391564 else throw("Strict value is not equal to itself.")
13401565 }
13411566 else throw("Strict value is not equal to itself.")
13421567 }
13431568
13441569
13451570
13461571 @Callable(i)
13471572 func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
13481573 then throw("permissions denied")
13491574 else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success")
13501575
13511576
13521577
13531578 @Callable(i)
13541579 func refreshKLp () = {
13551580 let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0)
13561581 let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay))
13571582 then unit
13581583 else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], ""))
13591584 if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
13601585 then {
13611586 let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp"))
1362- let $t05099851062 = refreshKLpInternal(0, 0, 0)
1363- let kLpUpdateActions = $t05099851062._1
1364- let updatedKLp = $t05099851062._2
1587+ let $t05935959423 = refreshKLpInternal(0, 0, 0)
1588+ let kLpUpdateActions = $t05935959423._1
1589+ let updatedKLp = $t05935959423._2
13651590 let actions = if ((kLp != updatedKLp))
13661591 then kLpUpdateActions
13671592 else throwErr("nothing to refresh")
13681593 $Tuple2(actions, toString(updatedKLp))
13691594 }
13701595 else throw("Strict value is not equal to itself.")
13711596 }
13721597
13731598
13741599
13751600 @Callable(i)
13761601 func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig())
13771602
13781603
13791604
13801605 @Callable(i)
13811606 func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId))
13821607
13831608
13841609
13851610 @Callable(i)
13861611 func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = {
13871612 let prices = calcPrices(amAmt, prAmt, lpAmt)
13881613 $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])])
13891614 }
13901615
13911616
13921617
13931618 @Callable(i)
13941619 func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult)))
13951620
13961621
13971622
13981623 @Callable(i)
13991624 func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult))
14001625
14011626
14021627
14031628 @Callable(i)
14041629 func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18))))
14051630
14061631
14071632
14081633 @Callable(i)
14091634 func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp))
14101635
14111636
14121637
14131638 @Callable(i)
14141639 func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
14151640 let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress))
14161641 $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10))
14171642 }
14181643
14191644
14201645
14211646 @Callable(i)
14221647 func statsREADONLY () = {
14231648 let cfg = getPoolConfig()
14241649 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
14251650 let amtAssetId = cfg[idxAmtAssetId]
14261651 let priceAssetId = cfg[idxPriceAssetId]
14271652 let iAmtAssetId = cfg[idxIAmtAssetId]
14281653 let iPriceAssetId = cfg[idxIPriceAssetId]
14291654 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
14301655 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
14311656 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
14321657 let accAmtAssetBalance = getAccBalance(amtAssetId)
14331658 let accPriceAssetBalance = getAccBalance(priceAssetId)
14341659 let pricesList = if ((poolLPBalance == 0))
14351660 then [zeroBigInt, zeroBigInt, zeroBigInt]
14361661 else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance)
14371662 let curPrice = 0
14381663 let lpAmtAssetShare = fromX18(pricesList[1], scale8)
14391664 let lpPriceAssetShare = fromX18(pricesList[2], scale8)
14401665 let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this))))
14411666 $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))
14421667 }
14431668
14441669
14451670
14461671 @Callable(i)
14471672 func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = {
14481673 let cfg = getPoolConfig()
14491674 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
14501675 let amAssetIdStr = cfg[idxAmtAssetId]
14511676 let amAssetId = fromBase58String(amAssetIdStr)
14521677 let prAssetIdStr = cfg[idxPriceAssetId]
14531678 let prAssetId = fromBase58String(prAssetIdStr)
14541679 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
14551680 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
14561681 let poolStatus = cfg[idxPoolStatus]
14571682 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
14581683 let accAmtAssetBalance = getAccBalance(amAssetIdStr)
14591684 let accPriceAssetBalance = getAccBalance(prAssetIdStr)
14601685 let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm)
14611686 let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm)
14621687 let curPriceX18 = if ((poolLPBalance == 0))
14631688 then zeroBigInt
14641689 else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18)
14651690 let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm)
14661691 let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
14671692 let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm)
14681693 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
14691694 let calcLpAmt = estPut._1
14701695 let curPriceCalc = estPut._3
14711696 let amBalance = estPut._4
14721697 let prBalance = estPut._5
14731698 let lpEmission = estPut._6
14741699 $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))
14751700 }
14761701
14771702
14781703
14791704 @Callable(i)
14801705 func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = {
14811706 let cfg = getPoolConfig()
14821707 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
14831708 let amAssetIdStr = cfg[idxAmtAssetId]
14841709 let amAssetId = fromBase58String(amAssetIdStr)
14851710 let prAssetIdStr = cfg[idxPriceAssetId]
14861711 let prAssetId = fromBase58String(prAssetIdStr)
14871712 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
14881713 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
14891714 let poolStatus = cfg[idxPoolStatus]
14901715 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
14911716 let amBalanceRaw = getAccBalance(amAssetIdStr)
14921717 let prBalanceRaw = getAccBalance(prAssetIdStr)
14931718 let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm)
14941719 let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm)
14951720 let curPriceX18 = if ((poolLPBalance == 0))
14961721 then zeroBigInt
14971722 else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18)
14981723 let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm)
14991724 let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
15001725 let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm)
15011726 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
15021727 let calcLpAmt = estPut._1
15031728 let curPriceCalc = estPut._3
15041729 let amBalance = estPut._4
15051730 let prBalance = estPut._5
15061731 let lpEmission = estPut._6
15071732 $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))
15081733 }
15091734
15101735
15111736
15121737 @Callable(i)
15131738 func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = {
15141739 let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this)
15151740 let outAmAmt = res._1
15161741 let outPrAmt = res._2
15171742 let amBalance = res._5
15181743 let prBalance = res._6
15191744 let lpEmission = res._7
15201745 let curPrice = res._8
15211746 let poolStatus = parseIntValue(res._9)
15221747 $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))
15231748 }
15241749
15251750
15261751 @Verifier(tx)
15271752 func verify () = {
15281753 let targetPublicKey = match managerPublicKeyOrUnit() {
15291754 case pk: ByteVector =>
15301755 pk
15311756 case _: Unit =>
15321757 tx.senderPublicKey
15331758 case _ =>
15341759 throw("Match error")
15351760 }
15361761 match tx {
15371762 case order: Order =>
15381763 let matcherPub = getMatcherPubOrFail()
1539- let $t05972459793 = validateMatcherOrderAllowed(order)
1540- let orderValid = $t05972459793._1
1541- let orderValidInfo = $t05972459793._2
1764+ let $t06808568202 = if (skipOrderValidation())
1765+ then $Tuple2(true, "")
1766+ else validateMatcherOrderAllowed(order)
1767+ let orderValid = $t06808568202._1
1768+ let orderValidInfo = $t06808568202._2
15421769 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
15431770 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
15441771 if (if (if (orderValid)
15451772 then senderValid
15461773 else false)
15471774 then matcherValid
15481775 else false)
15491776 then true
15501777 else throwOrderError(orderValid, orderValidInfo, senderValid, matcherValid)
15511778 case s: SetScriptTransaction =>
15521779 if (sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey))
15531780 then true
15541781 else {
15551782 let newHash = blake2b256(value(s.script))
15561783 let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash())))
15571784 let currentHash = scriptHash(this)
15581785 if ((allowedHash == newHash))
15591786 then (currentHash != newHash)
15601787 else false
15611788 }
15621789 case _ =>
15631790 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
15641791 }
15651792 }
15661793

github/deemru/w8io/026f985 
270.56 ms