tx · 8nZ1GBkYUkmsXo4Akj2ovQDfpohbBmVhqEx79ktfwYGV

3NAYgaLaVNNh5qw3Zx5PydFoE7mSoqYvP2H:  -0.04200000 Waves

2023.04.06 10:21 [2522379] smart account 3NAYgaLaVNNh5qw3Zx5PydFoE7mSoqYvP2H > SELF 0.00000000 Waves

{ "type": 13, "id": "8nZ1GBkYUkmsXo4Akj2ovQDfpohbBmVhqEx79ktfwYGV", "fee": 4200000, "feeAssetId": null, "timestamp": 1680765733647, "version": 2, "chainId": 84, "sender": "3NAYgaLaVNNh5qw3Zx5PydFoE7mSoqYvP2H", "senderPublicKey": "BNZJaZQpQutteRwUttAsDbWkozgmUAAjBrkxaaYMuV8", "proofs": [ "3WLPbWG8QR5g82yAWwTgbeNxKXCKtgqbupVx3LbWDnBPdxBkUb8t9NzQJqsDcdhvKxcC6TbYS5SFo7Lbzsgjihqg" ], "script": "base64:BgKQNwgCEgASBQoDAQQBEgcKBQEEAQgBEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgQKAggBEgQKAggBEgQKAggBEgUKAwEIARIAEgQKAgEBEgMKAQESBQoDAQEBEgQKAggIEgASABIDCgEIEgUKAwEBARIECgIBARIECgIIARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCBIAEgMKAQESAwoBARIECgIIASIKbFBkZWNpbWFscyIGc2NhbGU4IgxzY2FsZThCaWdJbnQiB3NjYWxlMTgiCnplcm9CaWdJbnQiBGJpZzAiBGJpZzEiBGJpZzIiC3dhdmVzU3RyaW5nIgNTRVAiClBvb2xBY3RpdmUiD1Bvb2xQdXREaXNhYmxlZCITUG9vbE1hdGNoZXJEaXNhYmxlZCIMUG9vbFNodXRkb3duIg5pZHhQb29sQWRkcmVzcyINaWR4UG9vbFN0YXR1cyIQaWR4UG9vbExQQXNzZXRJZCINaWR4QW10QXNzZXRJZCIPaWR4UHJpY2VBc3NldElkIg5pZHhBbXRBc3NldERjbSIQaWR4UHJpY2VBc3NldERjbSIOaWR4SUFtdEFz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YlQCFFNldFNjcmlwdFRyYW5zYWN0aW9uBAJnZgUCYlQDCQD0AwMIBQJpaAlib2R5Qnl0ZXMJAJEDAggFAmloBnByb29mcwAABQJpagYEAmltCQD2AwEJAQV2YWx1ZQEIBQJnZgZzY3JpcHQEAmluCQDbBAEJAQV2YWx1ZQEJAJ0IAgUCYVQJAQJhRgAEAmlvCQDxBwEFBHRoaXMDCQAAAgUCaW4FAmltCQECIT0CBQJpbwUCaW0HCQD0AwMIBQJpaAlib2R5Qnl0ZXMJAJEDAggFAmloBnByb29mcwAABQJpauamT2I=", "height": 2522379, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3V2RveLtsogji62AcF3RuvcXbBnB6EB9Qkp2U1wA4jSz Next: FBju3LPE5ESkrSGqPa5cGGR2JZ2n5LdyaqoKJkSTWLow 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
219231
220232 let poolConfigParsed = parsePoolConfig(getPoolConfig())
221233
222-let $t084698635 = poolConfigParsed
234+let $t089629128 = poolConfigParsed
223235
224-let cfgPoolAddress = $t084698635._1
236+let cfgPoolAddress = $t089629128._1
225237
226-let cfgPoolStatus = $t084698635._2
238+let cfgPoolStatus = $t089629128._2
227239
228-let cfgLpAssetId = $t084698635._3
240+let cfgLpAssetId = $t089629128._3
229241
230-let cfgAmountAssetId = $t084698635._4
242+let cfgAmountAssetId = $t089629128._4
231243
232-let cfgPriceAssetId = $t084698635._5
244+let cfgPriceAssetId = $t089629128._5
233245
234-let cfgAmountAssetDecimals = $t084698635._6
246+let cfgAmountAssetDecimals = $t089629128._6
235247
236-let cfgPriceAssetDecimals = $t084698635._7
248+let cfgPriceAssetDecimals = $t089629128._7
237249
238250 func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
239251
248260 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)
249261
250262
251-func getAccBalance (assetId) = if ((assetId == "WAVES"))
252- then wavesBalance(this).available
253- else assetBalance(this, fromBase58String(assetId))
263+func getAccBalance (assetId) = {
264+ let balanceOnPool = if ((assetId == "WAVES"))
265+ then wavesBalance(this).available
266+ else assetBalance(this, fromBase58String(assetId))
267+ let totalBalance = ((balanceOnPool + getAdditionalBalanceOrZero(assetId)) - getStakingAssetBalanceOrZero(assetId))
268+ max([0, totalBalance])
269+ }
254270
255271
256272 func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
257273
258274
259275 func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
276+
277+
278+func getRate (proxy) = {
279+ let inv = invoke(proxy, "getRate", nil, nil)
280+ if ((inv == inv))
281+ then match inv {
282+ case r: Int =>
283+ r
284+ case _ =>
285+ throwErr("proxy.getRate() unexpected value")
286+ }
287+ else throw("Strict value is not equal to itself.")
288+ }
289+
290+
291+func deposit (assetId,amount,stakingAssetId,proxy) = {
292+ let currentAdditionalBalance = getAdditionalBalanceOrZero(assetId)
293+ if ((currentAdditionalBalance == currentAdditionalBalance))
294+ then {
295+ let currentStakingAssetBalance = getStakingAssetBalanceOrZero(stakingAssetId)
296+ if ((currentStakingAssetBalance == currentStakingAssetBalance))
297+ then {
298+ let asset = parseAssetId(assetId)
299+ if ((amount > 0))
300+ then {
301+ let depositInvoke = invoke(proxy, "deposit", nil, [AttachedPayment(asset, amount)])
302+ if ((depositInvoke == depositInvoke))
303+ then match depositInvoke {
304+ case receivedStakingAsset: Int =>
305+ let newAdditionalBalance = (currentAdditionalBalance + amount)
306+ let newStakingAssetBalance = (currentStakingAssetBalance + receivedStakingAsset)
307+[IntegerEntry(keyAdditionalBalance(assetId), newAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance)]
308+ case _ =>
309+ nil
310+ }
311+ else throw("Strict value is not equal to itself.")
312+ }
313+ else nil
314+ }
315+ else throw("Strict value is not equal to itself.")
316+ }
317+ else throw("Strict value is not equal to itself.")
318+ }
319+
320+
321+func withdraw (assetId,amount,stakingAssetId,proxy,proxyRateMul,profitAddress) = {
322+ let currentAdditionalBalance = getAdditionalBalanceOrZero(assetId)
323+ if ((currentAdditionalBalance == currentAdditionalBalance))
324+ then {
325+ let currentStakingAssetBalance = getStakingAssetBalanceOrZero(stakingAssetId)
326+ if ((currentStakingAssetBalance == currentStakingAssetBalance))
327+ then {
328+ let currentProxyRate = getRate(proxy)
329+ if ((currentProxyRate == currentProxyRate))
330+ then {
331+ let oldRate = fraction(proxyRateMul, currentAdditionalBalance, currentStakingAssetBalance)
332+ let stakingAsset = parseAssetId(stakingAssetId)
333+ let oldSendStakingAmount = fraction(proxyRateMul, amount, oldRate)
334+ let sendStakingAssetAmount = fraction(proxyRateMul, amount, currentProxyRate)
335+ let profitAmount = max([0, (oldSendStakingAmount - sendStakingAssetAmount)])
336+ if ((sendStakingAssetAmount > 0))
337+ then {
338+ let withdrawInvoke = invoke(proxy, "withdraw", nil, [AttachedPayment(stakingAsset, sendStakingAssetAmount)])
339+ if ((withdrawInvoke == withdrawInvoke))
340+ then match withdrawInvoke {
341+ case receivedAssets: Int =>
342+ let newAdditionalBalance = (currentAdditionalBalance - receivedAssets)
343+ let newStakingAssetBalance = ((currentStakingAssetBalance - sendStakingAssetAmount) - profitAmount)
344+[IntegerEntry(keyAdditionalBalance(assetId), newAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance), ScriptTransfer(profitAddress, profitAmount, parseAssetId(stakingAssetId))]
345+ case _ =>
346+ nil
347+ }
348+ else throw("Strict value is not equal to itself.")
349+ }
350+ else nil
351+ }
352+ else throw("Strict value is not equal to itself.")
353+ }
354+ else throw("Strict value is not equal to itself.")
355+ }
356+ else throw("Strict value is not equal to itself.")
357+ }
358+
359+
360+func getLeaseProxyConfig (assetId) = match invoke(factoryContract, "getPoolLeaseConfigREADONLY", [toString(this), assetId], nil) {
361+ case a: (Boolean, Int, Int, String, String, Int, String) =>
362+ a
363+ case _ =>
364+ throwErr((("[" + assetId) + "] getLeaseProxyConfig() error"))
365+}
366+
367+
368+func rebalanceInternal (targetRatio,assetId,stakingAssetId,minBalance,proxy,proxyRateMul,profitAddress) = {
369+ let currentAdditionalBalance = getAdditionalBalanceOrZero(assetId)
370+ if ((currentAdditionalBalance == currentAdditionalBalance))
371+ then {
372+ let currentStakingAssetBalance = getStakingAssetBalanceOrZero(stakingAssetId)
373+ if ((currentStakingAssetBalance == currentStakingAssetBalance))
374+ then {
375+ let availableBalance = match parseAssetId(assetId) {
376+ case b: ByteVector =>
377+ assetBalance(this, b)
378+ case u: Unit =>
379+ wavesBalance(this).available
380+ case _ =>
381+ throw("Match error")
382+ }
383+ if ((availableBalance == availableBalance))
384+ then {
385+ let wholeBalance = max([0, ((availableBalance + currentAdditionalBalance) - minBalance)])
386+ let targetAdditionalBalance = fraction(targetRatio, wholeBalance, 100)
387+ let diff = (currentAdditionalBalance - targetAdditionalBalance)
388+ if ((diff == 0))
389+ then nil
390+ else if ((0 > diff))
391+ then {
392+ let sendAssetAmount = -(diff)
393+ deposit(assetId, sendAssetAmount, stakingAssetId, proxy)
394+ }
395+ else {
396+ let getAssetAmount = diff
397+ withdraw(assetId, getAssetAmount, stakingAssetId, proxy, proxyRateMul, profitAddress)
398+ }
399+ }
400+ else throw("Strict value is not equal to itself.")
401+ }
402+ else throw("Strict value is not equal to itself.")
403+ }
404+ else throw("Strict value is not equal to itself.")
405+ }
406+
407+
408+func rebalanceAsset (assetId) = {
409+ let $t01552715663 = getLeaseProxyConfig(assetId)
410+ let isLeasable = $t01552715663._1
411+ let leasedRatio = $t01552715663._2
412+ let minBalance = $t01552715663._3
413+ let proxyAddress = $t01552715663._4
414+ let proxyAssetId = $t01552715663._5
415+ let proxyRateMul = $t01552715663._6
416+ let stakingProfitAddress = $t01552715663._7
417+ if (isLeasable)
418+ then rebalanceInternal(leasedRatio, assetId, proxyAssetId, minBalance, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress))
419+ else nil
420+ }
421+
422+
423+func withdrawAndRebalanceAsset (assetId,getAmount) = {
424+ let $t01605216188 = getLeaseProxyConfig(assetId)
425+ let isLeasable = $t01605216188._1
426+ let leasedRatio = $t01605216188._2
427+ let minBalance = $t01605216188._3
428+ let proxyAddress = $t01605216188._4
429+ let proxyAssetId = $t01605216188._5
430+ let proxyRateMul = $t01605216188._6
431+ let stakingProfitAddress = $t01605216188._7
432+ if (isLeasable)
433+ then {
434+ let newTotalCalcBalance = max([0, ((getAccBalance(assetId) - getAmount) - minBalance)])
435+ if ((newTotalCalcBalance == newTotalCalcBalance))
436+ then {
437+ let newAdditionalBalance = fraction(leasedRatio, newTotalCalcBalance, 100)
438+ if ((newAdditionalBalance == newAdditionalBalance))
439+ then {
440+ let withdrawAmount = max([0, (getAdditionalBalanceOrZero(assetId) - newAdditionalBalance)])
441+ if ((withdrawAmount == withdrawAmount))
442+ then withdraw(assetId, withdrawAmount, proxyAssetId, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress))
443+ else throw("Strict value is not equal to itself.")
444+ }
445+ else throw("Strict value is not equal to itself.")
446+ }
447+ else throw("Strict value is not equal to itself.")
448+ }
449+ else nil
450+ }
260451
261452
262453 func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
310501 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18)
311502 let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR)
312503 let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR)
313- let state = if ((txId58 == ""))
314- then nil
315- else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES"))
316- then unit
317- else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES"))
318- then unit
319- 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)]
320- $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state)
504+ let AmAmtWithdrawState = withdrawAndRebalanceAsset(amAssetId, outAmAmt)
505+ if ((AmAmtWithdrawState == AmAmtWithdrawState))
506+ then {
507+ let PrAmtWithdrawState = withdrawAndRebalanceAsset(prAssetId, outPrAmt)
508+ if ((PrAmtWithdrawState == PrAmtWithdrawState))
509+ then {
510+ let state = if ((txId58 == ""))
511+ then nil
512+ else ((AmAmtWithdrawState ++ PrAmtWithdrawState) ++ [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES"))
513+ then unit
514+ else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES"))
515+ then unit
516+ 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)])
517+ $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state)
518+ }
519+ else throw("Strict value is not equal to itself.")
520+ }
521+ else throw("Strict value is not equal to itself.")
321522 }
322523 }
323524
438639 let priceAssetBalance = getAccBalance(assetIdToString(cfgPriceAssetId))
439640 let amountAssetAmount = order.amount
440641 let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR)
441- let $t02154121753 = if ((order.orderType == Buy))
642+ let $t02815328365 = if ((order.orderType == Buy))
442643 then $Tuple2(amountAssetAmount, -(priceAssetAmount))
443644 else $Tuple2(-(amountAssetAmount), priceAssetAmount)
444- let amountAssetBalanceDelta = $t02154121753._1
445- let priceAssetBalanceDelta = $t02154121753._2
645+ let amountAssetBalanceDelta = $t02815328365._1
646+ let priceAssetBalanceDelta = $t02815328365._2
446647 if (if (if (isGlobalShutdown())
447648 then true
448649 else (cfgPoolStatus == PoolMatcherDisabled))
455656 then throw("Wrong order assets.")
456657 else {
457658 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
659+ let $t02880528905 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
660+ let unusedActions = $t02880528905._1
661+ let kLpNew = $t02880528905._2
461662 let isOrderValid = (kLpNew >= kLp)
462663 let info = makeString(["kLp=", toString(kLp), " kLpNew=", toString(kLpNew), " amountAssetBalance=", toString(amountAssetBalance), " priceAssetBalance=", toString(priceAssetBalance), " amountAssetBalanceDelta=", toString(amountAssetBalanceDelta), " priceAssetBalanceDelta=", toString(priceAssetBalanceDelta), " height=", toString(height)], "")
463664 $Tuple2(isOrderValid, info)
536737 else if ((paymentAssetId == cfgPriceAssetId))
537738 then false
538739 else throwErr("invalid asset")
539- let $t02540625699 = if (isEval)
740+ let $t03201832311 = if (isEval)
540741 then $Tuple2(amountBalanceRaw, priceBalanceRaw)
541742 else if (paymentInAmountAsset)
542743 then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw)
543744 else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw))
544- let amountBalanceOld = $t02540625699._1
545- let priceBalanceOld = $t02540625699._2
546- let $t02570325852 = if (paymentInAmountAsset)
745+ let amountBalanceOld = $t03201832311._1
746+ let priceBalanceOld = $t03201832311._2
747+ let $t03231532464 = if (paymentInAmountAsset)
547748 then $Tuple2(paymentAmountRaw, 0)
548749 else $Tuple2(0, paymentAmountRaw)
549- let amountAssetAmountRaw = $t02570325852._1
550- let priceAssetAmountRaw = $t02570325852._2
750+ let amountAssetAmountRaw = $t03231532464._1
751+ let priceAssetAmountRaw = $t03231532464._2
551752 let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1
552753 let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1
553- let $t02598426048 = takeFee(paymentAmountRaw, inFee)
554- let paymentAmount = $t02598426048._1
555- let feeAmount = $t02598426048._2
754+ let $t03259632660 = takeFee(paymentAmountRaw, inFee)
755+ let paymentAmount = $t03259632660._1
756+ let feeAmount = $t03259632660._2
556757 let amountBalanceNew = (amountBalanceOld + amountAssetAmount)
557758 let priceBalanceNew = (priceBalanceOld + priceAssetAmount)
558759 let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals))
575776 let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals))
576777 let priceOld = fromX18(priceOldX18, scale8)
577778 let loss = {
578- let $t02772927896 = if (paymentInAmountAsset)
779+ let $t03434134508 = if (paymentInAmountAsset)
579780 then $Tuple2(amountAssetAmountRaw, amountBalanceOld)
580781 else $Tuple2(priceAssetAmountRaw, priceBalanceOld)
581- let amount = $t02772927896._1
582- let balance = $t02772927896._2
782+ let amount = $t03434134508._1
783+ let balance = $t03434134508._2
583784 let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance)))
584785 fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth)
585786 }
619820 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
620821 let redeemedBigInt = toBigInt(paymentAmount)
621822 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)
823+ let $t03658636642 = takeFee(amountRaw, outFee)
824+ let totalAmount = $t03658636642._1
825+ let feeAmount = $t03658636642._2
826+ let $t03664636872 = if (outInAmountAsset)
626827 then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
627828 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
829+ let outAmAmount = $t03664636872._1
830+ let outPrAmount = $t03664636872._2
831+ let amBalanceNew = $t03664636872._3
832+ let prBalanceNew = $t03664636872._4
632833 let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
633834 let priceNew = fromX18(priceNewX18, scale8)
634835 let commonState = if (isEval)
694895
695896
696897 @Callable(i)
898+func rebalance () = (rebalanceAsset(getStringOrFail(this, aa())) ++ rebalanceAsset(getStringOrFail(this, pa())))
899+
900+
901+
902+@Callable(i)
697903 func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse,feePoolAmount) = {
698- let $t03197732282 = if ((isReverse == false))
904+ let $t03875839063 = if ((isReverse == false))
699905 then {
700906 let assetOut = getStringOrFail(this, pa())
701907 let assetIn = getStringOrFail(this, aa())
706912 let assetIn = getStringOrFail(this, pa())
707913 $Tuple2(assetOut, assetIn)
708914 }
709- let assetOut = $t03197732282._1
710- let assetIn = $t03197732282._2
915+ let assetOut = $t03875839063._1
916+ let assetIn = $t03875839063._2
711917 let poolAssetInBalance = getAccBalance(assetIn)
712918 let poolAssetOutBalance = getAccBalance(assetOut)
713919 let amountOut = fraction(poolAssetOutBalance, cleanAmountIn, (poolAssetInBalance + cleanAmountIn))
757963 then true
758964 else throw("Exchange result is fewer coins than expected")
759965 if ((checkMin == checkMin))
760- then $Tuple2([ScriptTransfer(addressFromStringValue(addressTo), amountOut, parseAssetId(assetOut))], amountOut)
966+ then {
967+ let rebalanceState = rebalanceAsset(assetIn)
968+ if ((rebalanceState == rebalanceState))
969+ then {
970+ let withdrawState = withdrawAndRebalanceAsset(assetOut, amountOut)
971+ if ((withdrawState == withdrawState))
972+ then $Tuple2(((withdrawState ++ rebalanceState) ++ [ScriptTransfer(addressFromStringValue(addressTo), amountOut, parseAssetId(assetOut))]), amountOut)
973+ else throw("Strict value is not equal to itself.")
974+ }
975+ else throw("Strict value is not equal to itself.")
976+ }
761977 else throw("Strict value is not equal to itself.")
762978 }
763979 else throw("Strict value is not equal to itself.")
8481064 else throw("Strict value is not equal to itself.")
8491065 }
8501066 else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
851- let $t03716637628 = refreshKLpInternal(0, 0, 0)
852- if (($t03716637628 == $t03716637628))
1067+ let $t04410944571 = refreshKLpInternal(0, 0, 0)
1068+ if (($t04410944571 == $t04410944571))
8531069 then {
854- let updatedKLp = $t03716637628._2
855- let refreshKLpActions = $t03716637628._1
1070+ let updatedKLp = $t04410944571._2
1071+ let refreshKLpActions = $t04410944571._1
8561072 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
8571073 if ((isUpdatedKLpValid == isUpdatedKLpValid))
858- then ((state ++ lpTransfer) ++ refreshKLpActions)
1074+ then {
1075+ let reb = invoke(this, "rebalance", nil, nil)
1076+ if ((reb == reb))
1077+ then ((state ++ lpTransfer) ++ refreshKLpActions)
1078+ else throw("Strict value is not equal to itself.")
1079+ }
8591080 else throw("Strict value is not equal to itself.")
8601081 }
8611082 else throw("Strict value is not equal to itself.")
8841105 let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
8851106 if ((currentKLp == currentKLp))
8861107 then {
887- let $t03819038255 = refreshKLpInternal(0, 0, 0)
888- let refreshKLpActions = $t03819038255._1
889- let updatedKLp = $t03819038255._2
1108+ let $t04518345248 = refreshKLpInternal(0, 0, 0)
1109+ let refreshKLpActions = $t04518345248._1
1110+ let updatedKLp = $t04518345248._2
8901111 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
8911112 if ((isUpdatedKLpValid == isUpdatedKLpValid))
8921113 then (state ++ refreshKLpActions)
9331154 then {
9341155 let userAddress = i.caller
9351156 let txId = i.transactionId
936- let $t03944339595 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
937- if (($t03944339595 == $t03944339595))
1157+ let $t04643646588 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
1158+ if (($t04643646588 == $t04643646588))
9381159 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
1160+ let paymentInAmountAsset = $t04643646588._5
1161+ let bonus = $t04643646588._4
1162+ let feeAmount = $t04643646588._3
1163+ let commonState = $t04643646588._2
1164+ let emitAmountEstimated = $t04643646588._1
9441165 let emitAmount = if (if ((minOutAmount > 0))
9451166 then (minOutAmount > emitAmountEstimated)
9461167 else false)
9601181 let sendFee = if ((feeAmount > 0))
9611182 then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
9621183 else nil
963- let $t04018140378 = if ((this == feeCollectorAddress))
1184+ let $t04717447371 = if ((this == feeCollectorAddress))
9641185 then $Tuple2(0, 0)
9651186 else if (paymentInAmountAsset)
9661187 then $Tuple2(-(feeAmount), 0)
9671188 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
1189+ let amountAssetBalanceDelta = $t04717447371._1
1190+ let priceAssetBalanceDelta = $t04717447371._2
1191+ let $t04737447482 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1192+ let refreshKLpActions = $t04737447482._1
1193+ let updatedKLp = $t04737447482._2
9731194 let kLp = value(getString(keyKLp))
9741195 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
9751196 if ((isUpdatedKLpValid == isUpdatedKLpValid))
976- then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
1197+ then {
1198+ let reb = invoke(this, "rebalance", nil, nil)
1199+ if ((reb == reb))
1200+ then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
1201+ else throw("Strict value is not equal to itself.")
1202+ }
9771203 else throw("Strict value is not equal to itself.")
9781204 }
9791205 else throw("Strict value is not equal to itself.")
9891215
9901216 @Callable(i)
9911217 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
1218+ let $t04783747994 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
1219+ let emitAmountEstimated = $t04783747994._1
1220+ let commonState = $t04783747994._2
1221+ let feeAmount = $t04783747994._3
1222+ let bonus = $t04783747994._4
1223+ let paymentInAmountAsset = $t04783747994._5
9981224 $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
9991225 }
10001226
10311257 then {
10321258 let userAddress = i.caller
10331259 let txId = i.transactionId
1034- let $t04183741990 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
1035- if (($t04183741990 == $t04183741990))
1260+ let $t04887949032 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
1261+ if (($t04887949032 == $t04887949032))
10361262 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
1263+ let outInAmountAsset = $t04887949032._5
1264+ let bonus = $t04887949032._4
1265+ let feeAmount = $t04887949032._3
1266+ let commonState = $t04887949032._2
1267+ let amountEstimated = $t04887949032._1
10421268 let amount = if (if ((minOutAmount > 0))
10431269 then (minOutAmount > amountEstimated)
10441270 else false)
10471273 let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
10481274 if ((burnInv == burnInv))
10491275 then {
1050- let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
1051- let sendFee = if ((feeAmount > 0))
1052- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
1053- else nil
1054- let $t04249042737 = {
1055- let feeAmountForCalc = if ((this == feeCollectorAddress))
1056- then 0
1057- else feeAmount
1058- if (outInAmountAsset)
1059- then $Tuple2(-((amount + feeAmountForCalc)), 0)
1060- else $Tuple2(0, -((amount + feeAmountForCalc)))
1061- }
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
1067- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1068- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1069- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1276+ let withdrawState = withdrawAndRebalanceAsset(outAssetIdStr, amount)
1277+ if ((withdrawState == withdrawState))
1278+ then {
1279+ let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
1280+ let sendFee = if ((feeAmount > 0))
1281+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
1282+ else nil
1283+ let $t04960649853 = {
1284+ let feeAmountForCalc = if ((this == feeCollectorAddress))
1285+ then 0
1286+ else feeAmount
1287+ if (outInAmountAsset)
1288+ then $Tuple2(-((amount + feeAmountForCalc)), 0)
1289+ else $Tuple2(0, -((amount + feeAmountForCalc)))
1290+ }
1291+ let amountAssetBalanceDelta = $t04960649853._1
1292+ let priceAssetBalanceDelta = $t04960649853._2
1293+ let $t04985649964 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1294+ let refreshKLpActions = $t04985649964._1
1295+ let updatedKLp = $t04985649964._2
1296+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1297+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1298+ then $Tuple2(((((commonState ++ withdrawState) ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1299+ else throw("Strict value is not equal to itself.")
1300+ }
10701301 else throw("Strict value is not equal to itself.")
10711302 }
10721303 else throw("Strict value is not equal to itself.")
10821313
10831314 @Callable(i)
10841315 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
1316+ let $t05024250398 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
1317+ let amountEstimated = $t05024250398._1
1318+ let commonState = $t05024250398._2
1319+ let feeAmount = $t05024250398._3
1320+ let bonus = $t05024250398._4
1321+ let outInAmountAsset = $t05024250398._5
10911322 $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
10921323 }
10931324
11241355 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
11251356 if ((unstakeInv == unstakeInv))
11261357 then {
1127- let $t04416644317 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
1128- if (($t04416644317 == $t04416644317))
1358+ let $t05130351454 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
1359+ if (($t05130351454 == $t05130351454))
11291360 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
1361+ let outInAmountAsset = $t05130351454._5
1362+ let bonus = $t05130351454._4
1363+ let feeAmount = $t05130351454._3
1364+ let commonState = $t05130351454._2
1365+ let amountEstimated = $t05130351454._1
11351366 let amount = if (if ((minOutAmount > 0))
11361367 then (minOutAmount > amountEstimated)
11371368 else false)
11401371 let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
11411372 if ((burnInv == burnInv))
11421373 then {
1143- let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
1144- let sendFee = if ((feeAmount > 0))
1145- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
1146- else nil
1147- let $t04481245059 = {
1148- let feeAmountForCalc = if ((this == feeCollectorAddress))
1149- then 0
1150- else feeAmount
1151- if (outInAmountAsset)
1152- then $Tuple2(-((amount + feeAmountForCalc)), 0)
1153- else $Tuple2(0, -((amount + feeAmountForCalc)))
1154- }
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
1160- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1161- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1162- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1374+ let withdrawState = withdrawAndRebalanceAsset(outAssetIdStr, amount)
1375+ if ((withdrawState == withdrawState))
1376+ then {
1377+ let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
1378+ let sendFee = if ((feeAmount > 0))
1379+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
1380+ else nil
1381+ let $t05202352270 = {
1382+ let feeAmountForCalc = if ((this == feeCollectorAddress))
1383+ then 0
1384+ else feeAmount
1385+ if (outInAmountAsset)
1386+ then $Tuple2(-((amount + feeAmountForCalc)), 0)
1387+ else $Tuple2(0, -((amount + feeAmountForCalc)))
1388+ }
1389+ let amountAssetBalanceDelta = $t05202352270._1
1390+ let priceAssetBalanceDelta = $t05202352270._2
1391+ let $t05227352381 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1392+ let refreshKLpActions = $t05227352381._1
1393+ let updatedKLp = $t05227352381._2
1394+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1395+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1396+ then $Tuple2(((((commonState ++ withdrawState) ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1397+ else throw("Strict value is not equal to itself.")
1398+ }
11631399 else throw("Strict value is not equal to itself.")
11641400 }
11651401 else throw("Strict value is not equal to itself.")
11891425 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
11901426 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
11911427 then {
1192- let $t04611646198 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1193- let refreshKLpActions = $t04611646198._1
1194- let updatedKLp = $t04611646198._2
1428+ let $t05334853430 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1429+ let refreshKLpActions = $t05334853430._1
1430+ let updatedKLp = $t05334853430._2
11951431 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
11961432 if ((isUpdatedKLpValid == isUpdatedKLpValid))
11971433 then (state ++ refreshKLpActions)
12231459 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
12241460 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
12251461 then {
1226- let $t04714747228 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1227- let refreshKLpActions = $t04714747228._1
1228- let updatedKLp = $t04714747228._2
1462+ let $t05437954460 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1463+ let refreshKLpActions = $t05437954460._1
1464+ let updatedKLp = $t05437954460._2
12291465 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
12301466 if ((isUpdatedKLpValid == isUpdatedKLpValid))
12311467 then (state ++ refreshKLpActions)
12691505 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
12701506 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
12711507 then {
1272- let $t04835448435 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1273- let refreshKLpActions = $t04835448435._1
1274- let updatedKLp = $t04835448435._2
1508+ let $t05558655667 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1509+ let refreshKLpActions = $t05558655667._1
1510+ let updatedKLp = $t05558655667._2
12751511 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
12761512 if ((isUpdatedKLpValid == isUpdatedKLpValid))
12771513 then (state ++ refreshKLpActions)
13221558 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
13231559 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
13241560 then {
1325- let $t04973049811 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1326- let refreshKLpActions = $t04973049811._1
1327- let updatedKLp = $t04973049811._2
1561+ let $t05696257043 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1562+ let refreshKLpActions = $t05696257043._1
1563+ let updatedKLp = $t05696257043._2
13281564 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
13291565 if ((isUpdatedKLpValid == isUpdatedKLpValid))
13301566 then (state ++ refreshKLpActions)
13591595 if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
13601596 then {
13611597 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
1598+ let $t05823058294 = refreshKLpInternal(0, 0, 0)
1599+ let kLpUpdateActions = $t05823058294._1
1600+ let updatedKLp = $t05823058294._2
13651601 let actions = if ((kLp != updatedKLp))
13661602 then kLpUpdateActions
13671603 else throwErr("nothing to refresh")
15361772 match tx {
15371773 case order: Order =>
15381774 let matcherPub = getMatcherPubOrFail()
1539- let $t05972459793 = validateMatcherOrderAllowed(order)
1540- let orderValid = $t05972459793._1
1541- let orderValidInfo = $t05972459793._2
1775+ let $t06695667025 = validateMatcherOrderAllowed(order)
1776+ let orderValid = $t06695667025._1
1777+ let orderValidInfo = $t06695667025._2
15421778 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
15431779 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
15441780 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"
158170
159171 func throwOrderError (orderValid,orderValidInfo,senderValid,matcherValid) = throw((((((((("order validation failed: orderValid=" + toString(orderValid)) + " (") + orderValidInfo) + ")") + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid)))
160172
161173
162174 func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
163175
164176
165177 func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
166178
167179
168180 func throwErr (msg) = throw(makeString(["lp.ride:", msg], " "))
169181
170182
171183 func fmtErr (msg) = makeString(["lp.ride:", msg], " ")
172184
173185
174186 let factoryContract = addressFromStringValue(getStringOrFail(this, fc()))
175187
176188 let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress))
177189
178190 let inFee = {
179191 let @ = invoke(factoryContract, "getInFeeREADONLY", [toString(this)], nil)
180192 if ($isInstanceOf(@, "Int"))
181193 then @
182194 else throw(($getType(@) + " couldn't be cast to Int"))
183195 }
184196
185197 let outFee = {
186198 let @ = invoke(factoryContract, "getOutFeeREADONLY", [toString(this)], nil)
187199 if ($isInstanceOf(@, "Int"))
188200 then @
189201 else throw(($getType(@) + " couldn't be cast to Int"))
190202 }
191203
192204 func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false)
193205
194206
195207 func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub()))
196208
197209
198210 func getPoolConfig () = {
199211 let amtAsset = getStringOrFail(this, aa())
200212 let priceAsset = getStringOrFail(this, pa())
201213 let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset))
202214 let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset))
203215 split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP)
204216 }
205217
206218
207219 func parseAssetId (input) = if ((input == wavesString))
208220 then unit
209221 else fromBase58String(input)
210222
211223
212224 func assetIdToString (input) = if ((input == unit))
213225 then wavesString
214226 else toBase58String(value(input))
215227
216228
217229 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]))
218230
219231
220232 let poolConfigParsed = parsePoolConfig(getPoolConfig())
221233
222-let $t084698635 = poolConfigParsed
234+let $t089629128 = poolConfigParsed
223235
224-let cfgPoolAddress = $t084698635._1
236+let cfgPoolAddress = $t089629128._1
225237
226-let cfgPoolStatus = $t084698635._2
238+let cfgPoolStatus = $t089629128._2
227239
228-let cfgLpAssetId = $t084698635._3
240+let cfgLpAssetId = $t089629128._3
229241
230-let cfgAmountAssetId = $t084698635._4
242+let cfgAmountAssetId = $t089629128._4
231243
232-let cfgPriceAssetId = $t084698635._5
244+let cfgPriceAssetId = $t089629128._5
233245
234-let cfgAmountAssetDecimals = $t084698635._6
246+let cfgAmountAssetDecimals = $t089629128._6
235247
236-let cfgPriceAssetDecimals = $t084698635._7
248+let cfgPriceAssetDecimals = $t089629128._7
237249
238250 func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
239251
240252
241253 let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address")
242254
243255 let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address")
244256
245257 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)
246258
247259
248260 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)
249261
250262
251-func getAccBalance (assetId) = if ((assetId == "WAVES"))
252- then wavesBalance(this).available
253- else assetBalance(this, fromBase58String(assetId))
263+func getAccBalance (assetId) = {
264+ let balanceOnPool = if ((assetId == "WAVES"))
265+ then wavesBalance(this).available
266+ else assetBalance(this, fromBase58String(assetId))
267+ let totalBalance = ((balanceOnPool + getAdditionalBalanceOrZero(assetId)) - getStakingAssetBalanceOrZero(assetId))
268+ max([0, totalBalance])
269+ }
254270
255271
256272 func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
257273
258274
259275 func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
276+
277+
278+func getRate (proxy) = {
279+ let inv = invoke(proxy, "getRate", nil, nil)
280+ if ((inv == inv))
281+ then match inv {
282+ case r: Int =>
283+ r
284+ case _ =>
285+ throwErr("proxy.getRate() unexpected value")
286+ }
287+ else throw("Strict value is not equal to itself.")
288+ }
289+
290+
291+func deposit (assetId,amount,stakingAssetId,proxy) = {
292+ let currentAdditionalBalance = getAdditionalBalanceOrZero(assetId)
293+ if ((currentAdditionalBalance == currentAdditionalBalance))
294+ then {
295+ let currentStakingAssetBalance = getStakingAssetBalanceOrZero(stakingAssetId)
296+ if ((currentStakingAssetBalance == currentStakingAssetBalance))
297+ then {
298+ let asset = parseAssetId(assetId)
299+ if ((amount > 0))
300+ then {
301+ let depositInvoke = invoke(proxy, "deposit", nil, [AttachedPayment(asset, amount)])
302+ if ((depositInvoke == depositInvoke))
303+ then match depositInvoke {
304+ case receivedStakingAsset: Int =>
305+ let newAdditionalBalance = (currentAdditionalBalance + amount)
306+ let newStakingAssetBalance = (currentStakingAssetBalance + receivedStakingAsset)
307+[IntegerEntry(keyAdditionalBalance(assetId), newAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance)]
308+ case _ =>
309+ nil
310+ }
311+ else throw("Strict value is not equal to itself.")
312+ }
313+ else nil
314+ }
315+ else throw("Strict value is not equal to itself.")
316+ }
317+ else throw("Strict value is not equal to itself.")
318+ }
319+
320+
321+func withdraw (assetId,amount,stakingAssetId,proxy,proxyRateMul,profitAddress) = {
322+ let currentAdditionalBalance = getAdditionalBalanceOrZero(assetId)
323+ if ((currentAdditionalBalance == currentAdditionalBalance))
324+ then {
325+ let currentStakingAssetBalance = getStakingAssetBalanceOrZero(stakingAssetId)
326+ if ((currentStakingAssetBalance == currentStakingAssetBalance))
327+ then {
328+ let currentProxyRate = getRate(proxy)
329+ if ((currentProxyRate == currentProxyRate))
330+ then {
331+ let oldRate = fraction(proxyRateMul, currentAdditionalBalance, currentStakingAssetBalance)
332+ let stakingAsset = parseAssetId(stakingAssetId)
333+ let oldSendStakingAmount = fraction(proxyRateMul, amount, oldRate)
334+ let sendStakingAssetAmount = fraction(proxyRateMul, amount, currentProxyRate)
335+ let profitAmount = max([0, (oldSendStakingAmount - sendStakingAssetAmount)])
336+ if ((sendStakingAssetAmount > 0))
337+ then {
338+ let withdrawInvoke = invoke(proxy, "withdraw", nil, [AttachedPayment(stakingAsset, sendStakingAssetAmount)])
339+ if ((withdrawInvoke == withdrawInvoke))
340+ then match withdrawInvoke {
341+ case receivedAssets: Int =>
342+ let newAdditionalBalance = (currentAdditionalBalance - receivedAssets)
343+ let newStakingAssetBalance = ((currentStakingAssetBalance - sendStakingAssetAmount) - profitAmount)
344+[IntegerEntry(keyAdditionalBalance(assetId), newAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance), ScriptTransfer(profitAddress, profitAmount, parseAssetId(stakingAssetId))]
345+ case _ =>
346+ nil
347+ }
348+ else throw("Strict value is not equal to itself.")
349+ }
350+ else nil
351+ }
352+ else throw("Strict value is not equal to itself.")
353+ }
354+ else throw("Strict value is not equal to itself.")
355+ }
356+ else throw("Strict value is not equal to itself.")
357+ }
358+
359+
360+func getLeaseProxyConfig (assetId) = match invoke(factoryContract, "getPoolLeaseConfigREADONLY", [toString(this), assetId], nil) {
361+ case a: (Boolean, Int, Int, String, String, Int, String) =>
362+ a
363+ case _ =>
364+ throwErr((("[" + assetId) + "] getLeaseProxyConfig() error"))
365+}
366+
367+
368+func rebalanceInternal (targetRatio,assetId,stakingAssetId,minBalance,proxy,proxyRateMul,profitAddress) = {
369+ let currentAdditionalBalance = getAdditionalBalanceOrZero(assetId)
370+ if ((currentAdditionalBalance == currentAdditionalBalance))
371+ then {
372+ let currentStakingAssetBalance = getStakingAssetBalanceOrZero(stakingAssetId)
373+ if ((currentStakingAssetBalance == currentStakingAssetBalance))
374+ then {
375+ let availableBalance = match parseAssetId(assetId) {
376+ case b: ByteVector =>
377+ assetBalance(this, b)
378+ case u: Unit =>
379+ wavesBalance(this).available
380+ case _ =>
381+ throw("Match error")
382+ }
383+ if ((availableBalance == availableBalance))
384+ then {
385+ let wholeBalance = max([0, ((availableBalance + currentAdditionalBalance) - minBalance)])
386+ let targetAdditionalBalance = fraction(targetRatio, wholeBalance, 100)
387+ let diff = (currentAdditionalBalance - targetAdditionalBalance)
388+ if ((diff == 0))
389+ then nil
390+ else if ((0 > diff))
391+ then {
392+ let sendAssetAmount = -(diff)
393+ deposit(assetId, sendAssetAmount, stakingAssetId, proxy)
394+ }
395+ else {
396+ let getAssetAmount = diff
397+ withdraw(assetId, getAssetAmount, stakingAssetId, proxy, proxyRateMul, profitAddress)
398+ }
399+ }
400+ else throw("Strict value is not equal to itself.")
401+ }
402+ else throw("Strict value is not equal to itself.")
403+ }
404+ else throw("Strict value is not equal to itself.")
405+ }
406+
407+
408+func rebalanceAsset (assetId) = {
409+ let $t01552715663 = getLeaseProxyConfig(assetId)
410+ let isLeasable = $t01552715663._1
411+ let leasedRatio = $t01552715663._2
412+ let minBalance = $t01552715663._3
413+ let proxyAddress = $t01552715663._4
414+ let proxyAssetId = $t01552715663._5
415+ let proxyRateMul = $t01552715663._6
416+ let stakingProfitAddress = $t01552715663._7
417+ if (isLeasable)
418+ then rebalanceInternal(leasedRatio, assetId, proxyAssetId, minBalance, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress))
419+ else nil
420+ }
421+
422+
423+func withdrawAndRebalanceAsset (assetId,getAmount) = {
424+ let $t01605216188 = getLeaseProxyConfig(assetId)
425+ let isLeasable = $t01605216188._1
426+ let leasedRatio = $t01605216188._2
427+ let minBalance = $t01605216188._3
428+ let proxyAddress = $t01605216188._4
429+ let proxyAssetId = $t01605216188._5
430+ let proxyRateMul = $t01605216188._6
431+ let stakingProfitAddress = $t01605216188._7
432+ if (isLeasable)
433+ then {
434+ let newTotalCalcBalance = max([0, ((getAccBalance(assetId) - getAmount) - minBalance)])
435+ if ((newTotalCalcBalance == newTotalCalcBalance))
436+ then {
437+ let newAdditionalBalance = fraction(leasedRatio, newTotalCalcBalance, 100)
438+ if ((newAdditionalBalance == newAdditionalBalance))
439+ then {
440+ let withdrawAmount = max([0, (getAdditionalBalanceOrZero(assetId) - newAdditionalBalance)])
441+ if ((withdrawAmount == withdrawAmount))
442+ then withdraw(assetId, withdrawAmount, proxyAssetId, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress))
443+ else throw("Strict value is not equal to itself.")
444+ }
445+ else throw("Strict value is not equal to itself.")
446+ }
447+ else throw("Strict value is not equal to itself.")
448+ }
449+ else nil
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)
313- let state = if ((txId58 == ""))
314- then nil
315- else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES"))
316- then unit
317- else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES"))
318- then unit
319- 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)]
320- $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state)
504+ let AmAmtWithdrawState = withdrawAndRebalanceAsset(amAssetId, outAmAmt)
505+ if ((AmAmtWithdrawState == AmAmtWithdrawState))
506+ then {
507+ let PrAmtWithdrawState = withdrawAndRebalanceAsset(prAssetId, outPrAmt)
508+ if ((PrAmtWithdrawState == PrAmtWithdrawState))
509+ then {
510+ let state = if ((txId58 == ""))
511+ then nil
512+ else ((AmAmtWithdrawState ++ PrAmtWithdrawState) ++ [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES"))
513+ then unit
514+ else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES"))
515+ then unit
516+ 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)])
517+ $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state)
518+ }
519+ else throw("Strict value is not equal to itself.")
520+ }
521+ else throw("Strict value is not equal to itself.")
321522 }
322523 }
323524
324525
325526 func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = {
326527 let cfg = getPoolConfig()
327528 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
328529 let amAssetIdStr = cfg[idxAmtAssetId]
329530 let prAssetIdStr = cfg[idxPriceAssetId]
330531 let iAmtAssetId = cfg[idxIAmtAssetId]
331532 let iPriceAssetId = cfg[idxIPriceAssetId]
332533 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
333534 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
334535 let poolStatus = cfg[idxPoolStatus]
335536 let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
336537 let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES")))
337538 let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES")))
338539 if (if ((amAssetIdStr != inAmAssetIdStr))
339540 then true
340541 else (prAssetIdStr != inPrAssetIdStr))
341542 then throw("Invalid amt or price asset passed.")
342543 else {
343544 let amBalance = if (isEvaluate)
344545 then getAccBalance(amAssetIdStr)
345546 else (getAccBalance(amAssetIdStr) - inAmAssetAmt)
346547 let prBalance = if (isEvaluate)
347548 then getAccBalance(prAssetIdStr)
348549 else (getAccBalance(prAssetIdStr) - inPrAssetAmt)
349550 let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm)
350551 let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm)
351552 let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18)
352553 let amBalanceX18 = toX18(amBalance, amtAssetDcm)
353554 let prBalanceX18 = toX18(prBalance, priceAssetDcm)
354555 let res = if ((lpEmission == 0))
355556 then {
356557 let curPriceX18 = zeroBigInt
357558 let slippageX18 = zeroBigInt
358559 let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN)
359560 $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
360561 }
361562 else {
362563 let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18)
363564 let slippageX18 = fraction(absBigInt((curPriceX18 - userPriceX18)), scale18, curPriceX18)
364565 let slippageToleranceX18 = toX18(slippageTolerance, scale8)
365566 if (if ((curPriceX18 != zeroBigInt))
366567 then (slippageX18 > slippageToleranceX18)
367568 else false)
368569 then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18)))
369570 else {
370571 let lpEmissionX18 = toX18(lpEmission, scale8)
371572 let prViaAmX18 = fraction(inAmAssetAmtX18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING)
372573 let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, FLOOR), CEILING)
373574 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
374575 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
375576 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
376577 let expAmtAssetAmtX18 = expectedAmts._1
377578 let expPriceAssetAmtX18 = expectedAmts._2
378579 let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR)
379580 $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtAssetDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceAssetDcm, CEILING), curPriceX18, slippageX18)
380581 }
381582 }
382583 let calcLpAmt = res._1
383584 let calcAmAssetPmt = res._2
384585 let calcPrAssetPmt = res._3
385586 let curPrice = fromX18(res._4, scale8)
386587 let slippageCalc = fromX18(res._5, scale8)
387588 if ((0 >= calcLpAmt))
388589 then throw("Invalid calculations. LP calculated is less than zero.")
389590 else {
390591 let emitLpAmt = if (!(emitLp))
391592 then 0
392593 else calcLpAmt
393594 let amDiff = (inAmAssetAmt - calcAmAssetPmt)
394595 let prDiff = (inPrAssetAmt - calcPrAssetPmt)
395596 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))]
396597 $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId)
397598 }
398599 }
399600 }
400601
401602
402603 func calcKLp (amountBalance,priceBalance,lpEmission) = {
403604 let amountBalanceX18 = toX18BigInt(amountBalance, toBigInt(cfgAmountAssetDecimals))
404605 let priceBalanceX18 = toX18BigInt(priceBalance, toBigInt(cfgPriceAssetDecimals))
405606 let updatedKLp = fraction(pow((amountBalanceX18 * priceBalanceX18), 0, toBigInt(5), 1, 18, DOWN), big1, lpEmission)
406607 if ((lpEmission == big0))
407608 then big0
408609 else updatedKLp
409610 }
410611
411612
412613 func calcCurrentKLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = {
413614 let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta)
414615 let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta)
415616 let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta)
416617 let currentKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpAssetEmission)
417618 currentKLp
418619 }
419620
420621
421622 func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = {
422623 let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta)
423624 let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta)
424625 let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta)
425626 let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission))
426627 let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))]
427628 $Tuple2(actions, updatedKLp)
428629 }
429630
430631
431632 func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp))
432633 then true
433634 else throwErr(makeString(["updated KLp lower than current KLp", toString(oldKLp), toString(updatedKLp)], " "))
434635
435636
436637 func validateMatcherOrderAllowed (order) = {
437638 let amountAssetBalance = getAccBalance(assetIdToString(cfgAmountAssetId))
438639 let priceAssetBalance = getAccBalance(assetIdToString(cfgPriceAssetId))
439640 let amountAssetAmount = order.amount
440641 let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR)
441- let $t02154121753 = if ((order.orderType == Buy))
642+ let $t02815328365 = if ((order.orderType == Buy))
442643 then $Tuple2(amountAssetAmount, -(priceAssetAmount))
443644 else $Tuple2(-(amountAssetAmount), priceAssetAmount)
444- let amountAssetBalanceDelta = $t02154121753._1
445- let priceAssetBalanceDelta = $t02154121753._2
645+ let amountAssetBalanceDelta = $t02815328365._1
646+ let priceAssetBalanceDelta = $t02815328365._2
446647 if (if (if (isGlobalShutdown())
447648 then true
448649 else (cfgPoolStatus == PoolMatcherDisabled))
449650 then true
450651 else (cfgPoolStatus == PoolShutdown))
451652 then throw("Exchange operations disabled")
452653 else if (if ((order.assetPair.amountAsset != cfgAmountAssetId))
453654 then true
454655 else (order.assetPair.priceAsset != cfgPriceAssetId))
455656 then throw("Wrong order assets.")
456657 else {
457658 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
659+ let $t02880528905 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
660+ let unusedActions = $t02880528905._1
661+ let kLpNew = $t02880528905._2
461662 let isOrderValid = (kLpNew >= kLp)
462663 let info = makeString(["kLp=", toString(kLp), " kLpNew=", toString(kLpNew), " amountAssetBalance=", toString(amountAssetBalance), " priceAssetBalance=", toString(priceAssetBalance), " amountAssetBalanceDelta=", toString(amountAssetBalanceDelta), " priceAssetBalanceDelta=", toString(priceAssetBalanceDelta), " height=", toString(height)], "")
463664 $Tuple2(isOrderValid, info)
464665 }
465666 }
466667
467668
468669 func commonGet (i) = if ((size(i.payments) != 1))
469670 then throw("exactly 1 payment is expected")
470671 else {
471672 let pmt = value(i.payments[0])
472673 let pmtAssetId = value(pmt.assetId)
473674 let pmtAmt = pmt.amount
474675 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller)
475676 let outAmAmt = res._1
476677 let outPrAmt = res._2
477678 let poolStatus = parseIntValue(res._9)
478679 let state = res._10
479680 if (if (isGlobalShutdown())
480681 then true
481682 else (poolStatus == PoolShutdown))
482683 then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
483684 else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state)
484685 }
485686
486687
487688 func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2))
488689 then throw("exactly 2 payments are expected")
489690 else {
490691 let amAssetPmt = value(i.payments[0])
491692 let prAssetPmt = value(i.payments[1])
492693 let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp)
493694 let poolStatus = parseIntValue(estPut._8)
494695 if (if (if (isGlobalShutdown())
495696 then true
496697 else (poolStatus == PoolPutDisabled))
497698 then true
498699 else (poolStatus == PoolShutdown))
499700 then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus)))
500701 else estPut
501702 }
502703
503704
504705 func emit (amount) = {
505706 let emitInv = invoke(factoryContract, "emit", [amount], nil)
506707 if ((emitInv == emitInv))
507708 then {
508709 let emitInvLegacy = match emitInv {
509710 case legacyFactoryContract: Address =>
510711 invoke(legacyFactoryContract, "emit", [amount], nil)
511712 case _ =>
512713 unit
513714 }
514715 if ((emitInvLegacy == emitInvLegacy))
515716 then amount
516717 else throw("Strict value is not equal to itself.")
517718 }
518719 else throw("Strict value is not equal to itself.")
519720 }
520721
521722
522723 func takeFee (amount,fee) = {
523724 let feeAmount = if ((fee == 0))
524725 then 0
525726 else fraction(amount, fee, scale8)
526727 $Tuple2((amount - feeAmount), feeAmount)
527728 }
528729
529730
530731 func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = {
531732 let isEval = (txId == unit)
532733 let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId))
533734 let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId))
534735 let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId))
535736 then true
536737 else if ((paymentAssetId == cfgPriceAssetId))
537738 then false
538739 else throwErr("invalid asset")
539- let $t02540625699 = if (isEval)
740+ let $t03201832311 = if (isEval)
540741 then $Tuple2(amountBalanceRaw, priceBalanceRaw)
541742 else if (paymentInAmountAsset)
542743 then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw)
543744 else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw))
544- let amountBalanceOld = $t02540625699._1
545- let priceBalanceOld = $t02540625699._2
546- let $t02570325852 = if (paymentInAmountAsset)
745+ let amountBalanceOld = $t03201832311._1
746+ let priceBalanceOld = $t03201832311._2
747+ let $t03231532464 = if (paymentInAmountAsset)
547748 then $Tuple2(paymentAmountRaw, 0)
548749 else $Tuple2(0, paymentAmountRaw)
549- let amountAssetAmountRaw = $t02570325852._1
550- let priceAssetAmountRaw = $t02570325852._2
750+ let amountAssetAmountRaw = $t03231532464._1
751+ let priceAssetAmountRaw = $t03231532464._2
551752 let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1
552753 let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1
553- let $t02598426048 = takeFee(paymentAmountRaw, inFee)
554- let paymentAmount = $t02598426048._1
555- let feeAmount = $t02598426048._2
754+ let $t03259632660 = takeFee(paymentAmountRaw, inFee)
755+ let paymentAmount = $t03259632660._1
756+ let feeAmount = $t03259632660._2
556757 let amountBalanceNew = (amountBalanceOld + amountAssetAmount)
557758 let priceBalanceNew = (priceBalanceOld + priceAssetAmount)
558759 let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals))
559760 let priceNew = fromX18(priceNewX18, scale8)
560761 let paymentBalance = if (paymentInAmountAsset)
561762 then amountBalanceOld
562763 else priceBalanceOld
563764 let paymentBalanceBigInt = toBigInt(paymentBalance)
564765 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
565766 let chechSupply = if ((supplyBigInt > big0))
566767 then true
567768 else throwErr("initial deposit requires all coins")
568769 if ((chechSupply == chechSupply))
569770 then {
570771 let depositBigInt = toBigInt(paymentAmount)
571772 let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))])
572773 let commonState = if (isEval)
573774 then nil
574775 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))]
575776 let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals))
576777 let priceOld = fromX18(priceOldX18, scale8)
577778 let loss = {
578- let $t02772927896 = if (paymentInAmountAsset)
779+ let $t03434134508 = if (paymentInAmountAsset)
579780 then $Tuple2(amountAssetAmountRaw, amountBalanceOld)
580781 else $Tuple2(priceAssetAmountRaw, priceBalanceOld)
581- let amount = $t02772927896._1
582- let balance = $t02772927896._2
782+ let amount = $t03434134508._1
783+ let balance = $t03434134508._2
583784 let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance)))
584785 fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth)
585786 }
586787 $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset)
587788 }
588789 else throw("Strict value is not equal to itself.")
589790 }
590791
591792
592793 func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = {
593794 let isEval = (txId == unit)
594795 let cfg = getPoolConfig()
595796 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
596797 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
597798 let checks = [if ((paymentAssetId == cfgLpAssetId))
598799 then true
599800 else throwErr("invalid lp asset")]
600801 if ((checks == checks))
601802 then {
602803 let outInAmountAsset = if ((outAssetId == cfgAmountAssetId))
603804 then true
604805 else if ((outAssetId == cfgPriceAssetId))
605806 then false
606807 else throwErr("invalid asset")
607808 let balanceBigInt = if (outInAmountAsset)
608809 then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId)))
609810 else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId)))
610811 let outInAmountAssetDecimals = if (outInAmountAsset)
611812 then amtAssetDcm
612813 else priceAssetDcm
613814 let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId))
614815 let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId))
615816 let outBalance = if (outInAmountAsset)
616817 then amBalanceOld
617818 else prBalanceOld
618819 let outBalanceBigInt = toBigInt(outBalance)
619820 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
620821 let redeemedBigInt = toBigInt(paymentAmount)
621822 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)
823+ let $t03658636642 = takeFee(amountRaw, outFee)
824+ let totalAmount = $t03658636642._1
825+ let feeAmount = $t03658636642._2
826+ let $t03664636872 = if (outInAmountAsset)
626827 then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
627828 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
829+ let outAmAmount = $t03664636872._1
830+ let outPrAmount = $t03664636872._2
831+ let amBalanceNew = $t03664636872._3
832+ let prBalanceNew = $t03664636872._4
632833 let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
633834 let priceNew = fromX18(priceNewX18, scale8)
634835 let commonState = if (isEval)
635836 then nil
636837 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)]
637838 let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals))
638839 let priceOld = fromX18(priceOldX18, scale8)
639840 let loss = {
640841 let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2)
641842 fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset)
642843 }
643844 $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset)
644845 }
645846 else throw("Strict value is not equal to itself.")
646847 }
647848
648849
649850 func managerPublicKeyOrUnit () = match getString(mpk()) {
650851 case s: String =>
651852 fromBase58String(s)
652853 case _: Unit =>
653854 unit
654855 case _ =>
655856 throw("Match error")
656857 }
657858
658859
659860 func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) {
660861 case s: String =>
661862 fromBase58String(s)
662863 case _: Unit =>
663864 unit
664865 case _ =>
665866 throw("Match error")
666867 }
667868
668869
669870 func isManager (i) = match managerPublicKeyOrUnit() {
670871 case pk: ByteVector =>
671872 (i.callerPublicKey == pk)
672873 case _: Unit =>
673874 (i.caller == this)
674875 case _ =>
675876 throw("Match error")
676877 }
677878
678879
679880 func mustManager (i) = {
680881 let pd = throw("Permission denied")
681882 match managerPublicKeyOrUnit() {
682883 case pk: ByteVector =>
683884 if ((i.callerPublicKey == pk))
684885 then true
685886 else pd
686887 case _: Unit =>
687888 if ((i.caller == this))
688889 then true
689890 else pd
690891 case _ =>
691892 throw("Match error")
692893 }
693894 }
694895
695896
696897 @Callable(i)
898+func rebalance () = (rebalanceAsset(getStringOrFail(this, aa())) ++ rebalanceAsset(getStringOrFail(this, pa())))
899+
900+
901+
902+@Callable(i)
697903 func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse,feePoolAmount) = {
698- let $t03197732282 = if ((isReverse == false))
904+ let $t03875839063 = if ((isReverse == false))
699905 then {
700906 let assetOut = getStringOrFail(this, pa())
701907 let assetIn = getStringOrFail(this, aa())
702908 $Tuple2(assetOut, assetIn)
703909 }
704910 else {
705911 let assetOut = getStringOrFail(this, aa())
706912 let assetIn = getStringOrFail(this, pa())
707913 $Tuple2(assetOut, assetIn)
708914 }
709- let assetOut = $t03197732282._1
710- let assetIn = $t03197732282._2
915+ let assetOut = $t03875839063._1
916+ let assetIn = $t03875839063._2
711917 let poolAssetInBalance = getAccBalance(assetIn)
712918 let poolAssetOutBalance = getAccBalance(assetOut)
713919 let amountOut = fraction(poolAssetOutBalance, cleanAmountIn, (poolAssetInBalance + cleanAmountIn))
714920 let oldK = (toBigInt(poolAssetInBalance) * toBigInt(poolAssetOutBalance))
715921 let newK = (((toBigInt(getAccBalance(assetIn)) + toBigInt(cleanAmountIn)) + toBigInt(feePoolAmount)) * (toBigInt(getAccBalance(assetOut)) - toBigInt(amountOut)))
716922 let checkK = if ((newK >= oldK))
717923 then true
718924 else throw("new K is fewer error")
719925 if ((checkK == checkK))
720926 then $Tuple2(nil, amountOut)
721927 else throw("Strict value is not equal to itself.")
722928 }
723929
724930
725931
726932 @Callable(i)
727933 func calculateAmountOutForSwapAndSendTokens (cleanAmountIn,isReverse,amountOutMin,addressTo,feePoolAmount) = {
728934 let swapContact = {
729935 let @ = invoke(factoryContract, "getSwapContractREADONLY", nil, nil)
730936 if ($isInstanceOf(@, "String"))
731937 then @
732938 else throw(($getType(@) + " couldn't be cast to String"))
733939 }
734940 let checks = [if ((value(i.payments[0]).amount >= cleanAmountIn))
735941 then true
736942 else throwErr("Wrong amount"), if ((i.caller == addressFromStringValue(swapContact)))
737943 then true
738944 else throwErr("Permission denied")]
739945 if ((checks == checks))
740946 then {
741947 let pmt = value(i.payments[0])
742948 let assetIn = assetIdToString(pmt.assetId)
743949 let assetOut = if ((isReverse == false))
744950 then getStringOrFail(this, pa())
745951 else getStringOrFail(this, aa())
746952 let poolAssetInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount)
747953 let poolAssetOutBalance = getAccBalance(assetOut)
748954 let amountOut = fraction(poolAssetOutBalance, cleanAmountIn, (poolAssetInBalance + cleanAmountIn))
749955 let oldK = (toBigInt(poolAssetInBalance) * toBigInt(poolAssetOutBalance))
750956 let newK = ((toBigInt(getAccBalance(assetIn)) + toBigInt(feePoolAmount)) * (toBigInt(getAccBalance(assetOut)) - toBigInt(amountOut)))
751957 let checkK = if ((newK >= oldK))
752958 then true
753959 else throw("new K is fewer error")
754960 if ((checkK == checkK))
755961 then {
756962 let checkMin = if ((amountOut >= amountOutMin))
757963 then true
758964 else throw("Exchange result is fewer coins than expected")
759965 if ((checkMin == checkMin))
760- then $Tuple2([ScriptTransfer(addressFromStringValue(addressTo), amountOut, parseAssetId(assetOut))], amountOut)
966+ then {
967+ let rebalanceState = rebalanceAsset(assetIn)
968+ if ((rebalanceState == rebalanceState))
969+ then {
970+ let withdrawState = withdrawAndRebalanceAsset(assetOut, amountOut)
971+ if ((withdrawState == withdrawState))
972+ then $Tuple2(((withdrawState ++ rebalanceState) ++ [ScriptTransfer(addressFromStringValue(addressTo), amountOut, parseAssetId(assetOut))]), amountOut)
973+ else throw("Strict value is not equal to itself.")
974+ }
975+ else throw("Strict value is not equal to itself.")
976+ }
761977 else throw("Strict value is not equal to itself.")
762978 }
763979 else throw("Strict value is not equal to itself.")
764980 }
765981 else throw("Strict value is not equal to itself.")
766982 }
767983
768984
769985
770986 @Callable(i)
771987 func setManager (pendingManagerPublicKey) = {
772988 let checkCaller = mustManager(i)
773989 if ((checkCaller == checkCaller))
774990 then {
775991 let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
776992 if ((checkManagerPublicKey == checkManagerPublicKey))
777993 then [StringEntry(pmpk(), pendingManagerPublicKey)]
778994 else throw("Strict value is not equal to itself.")
779995 }
780996 else throw("Strict value is not equal to itself.")
781997 }
782998
783999
7841000
7851001 @Callable(i)
7861002 func confirmManager () = {
7871003 let pm = pendingManagerPublicKeyOrUnit()
7881004 let hasPM = if (isDefined(pm))
7891005 then true
7901006 else throw("No pending manager")
7911007 if ((hasPM == hasPM))
7921008 then {
7931009 let checkPM = if ((i.callerPublicKey == value(pm)))
7941010 then true
7951011 else throw("You are not pending manager")
7961012 if ((checkPM == checkPM))
7971013 then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())]
7981014 else throw("Strict value is not equal to itself.")
7991015 }
8001016 else throw("Strict value is not equal to itself.")
8011017 }
8021018
8031019
8041020
8051021 @Callable(i)
8061022 func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance))
8071023 then throw("Invalid slippageTolerance passed")
8081024 else {
8091025 let estPut = commonPut(i, slippageTolerance, true)
8101026 let emitLpAmt = estPut._2
8111027 let lpAssetId = estPut._7
8121028 let state = estPut._9
8131029 let amDiff = estPut._10
8141030 let prDiff = estPut._11
8151031 let amId = estPut._12
8161032 let prId = estPut._13
8171033 let amAssetPmt = toBigInt(value(i.payments[0]).amount)
8181034 let prAssetPmt = toBigInt(value(i.payments[1]).amount)
8191035 let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
8201036 if ((currentKLp == currentKLp))
8211037 then {
8221038 let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
8231039 if ((emitInv == emitInv))
8241040 then {
8251041 let emitInvLegacy = match emitInv {
8261042 case legacyFactoryContract: Address =>
8271043 invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
8281044 case _ =>
8291045 unit
8301046 }
8311047 if ((emitInvLegacy == emitInvLegacy))
8321048 then {
8331049 let slippageAInv = if ((amDiff > 0))
8341050 then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
8351051 else nil
8361052 if ((slippageAInv == slippageAInv))
8371053 then {
8381054 let slippagePInv = if ((prDiff > 0))
8391055 then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
8401056 else nil
8411057 if ((slippagePInv == slippagePInv))
8421058 then {
8431059 let lpTransfer = if (shouldAutoStake)
8441060 then {
8451061 let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
8461062 if ((slpStakeInv == slpStakeInv))
8471063 then nil
8481064 else throw("Strict value is not equal to itself.")
8491065 }
8501066 else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
851- let $t03716637628 = refreshKLpInternal(0, 0, 0)
852- if (($t03716637628 == $t03716637628))
1067+ let $t04410944571 = refreshKLpInternal(0, 0, 0)
1068+ if (($t04410944571 == $t04410944571))
8531069 then {
854- let updatedKLp = $t03716637628._2
855- let refreshKLpActions = $t03716637628._1
1070+ let updatedKLp = $t04410944571._2
1071+ let refreshKLpActions = $t04410944571._1
8561072 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
8571073 if ((isUpdatedKLpValid == isUpdatedKLpValid))
858- then ((state ++ lpTransfer) ++ refreshKLpActions)
1074+ then {
1075+ let reb = invoke(this, "rebalance", nil, nil)
1076+ if ((reb == reb))
1077+ then ((state ++ lpTransfer) ++ refreshKLpActions)
1078+ else throw("Strict value is not equal to itself.")
1079+ }
8591080 else throw("Strict value is not equal to itself.")
8601081 }
8611082 else throw("Strict value is not equal to itself.")
8621083 }
8631084 else throw("Strict value is not equal to itself.")
8641085 }
8651086 else throw("Strict value is not equal to itself.")
8661087 }
8671088 else throw("Strict value is not equal to itself.")
8681089 }
8691090 else throw("Strict value is not equal to itself.")
8701091 }
8711092 else throw("Strict value is not equal to itself.")
8721093 }
8731094
8741095
8751096
8761097 @Callable(i)
8771098 func putForFree (maxSlippage) = if ((0 > maxSlippage))
8781099 then throw("Invalid value passed")
8791100 else {
8801101 let estPut = commonPut(i, maxSlippage, false)
8811102 let state = estPut._9
8821103 let amAssetPmt = toBigInt(value(i.payments[0]).amount)
8831104 let prAssetPmt = toBigInt(value(i.payments[1]).amount)
8841105 let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
8851106 if ((currentKLp == currentKLp))
8861107 then {
887- let $t03819038255 = refreshKLpInternal(0, 0, 0)
888- let refreshKLpActions = $t03819038255._1
889- let updatedKLp = $t03819038255._2
1108+ let $t04518345248 = refreshKLpInternal(0, 0, 0)
1109+ let refreshKLpActions = $t04518345248._1
1110+ let updatedKLp = $t04518345248._2
8901111 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
8911112 if ((isUpdatedKLpValid == isUpdatedKLpValid))
8921113 then (state ++ refreshKLpActions)
8931114 else throw("Strict value is not equal to itself.")
8941115 }
8951116 else throw("Strict value is not equal to itself.")
8961117 }
8971118
8981119
8991120
9001121 @Callable(i)
9011122 func putOneTkn (minOutAmount,autoStake) = {
9021123 let isPoolOneTokenOperationsDisabled = {
9031124 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
9041125 if ($isInstanceOf(@, "Boolean"))
9051126 then @
9061127 else throw(($getType(@) + " couldn't be cast to Boolean"))
9071128 }
9081129 let isPutDisabled = if (if (if (isGlobalShutdown())
9091130 then true
9101131 else (cfgPoolStatus == PoolPutDisabled))
9111132 then true
9121133 else (cfgPoolStatus == PoolShutdown))
9131134 then true
9141135 else isPoolOneTokenOperationsDisabled
9151136 let checks = [if (if (!(isPutDisabled))
9161137 then true
9171138 else isManager(i))
9181139 then true
9191140 else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1))
9201141 then true
9211142 else throwErr("exactly 1 payment are expected")]
9221143 if ((checks == checks))
9231144 then {
9241145 let payment = i.payments[0]
9251146 let paymentAssetId = payment.assetId
9261147 let paymentAmountRaw = payment.amount
9271148 let currentKLp = if ((paymentAssetId == cfgAmountAssetId))
9281149 then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0))
9291150 else if ((paymentAssetId == cfgPriceAssetId))
9301151 then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0))
9311152 else throwErr("payment asset is not supported")
9321153 if ((currentKLp == currentKLp))
9331154 then {
9341155 let userAddress = i.caller
9351156 let txId = i.transactionId
936- let $t03944339595 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
937- if (($t03944339595 == $t03944339595))
1157+ let $t04643646588 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
1158+ if (($t04643646588 == $t04643646588))
9381159 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
1160+ let paymentInAmountAsset = $t04643646588._5
1161+ let bonus = $t04643646588._4
1162+ let feeAmount = $t04643646588._3
1163+ let commonState = $t04643646588._2
1164+ let emitAmountEstimated = $t04643646588._1
9441165 let emitAmount = if (if ((minOutAmount > 0))
9451166 then (minOutAmount > emitAmountEstimated)
9461167 else false)
9471168 then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
9481169 else emitAmountEstimated
9491170 let emitInv = emit(emitAmount)
9501171 if ((emitInv == emitInv))
9511172 then {
9521173 let lpTransfer = if (autoStake)
9531174 then {
9541175 let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
9551176 if ((stakeInv == stakeInv))
9561177 then nil
9571178 else throw("Strict value is not equal to itself.")
9581179 }
9591180 else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
9601181 let sendFee = if ((feeAmount > 0))
9611182 then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
9621183 else nil
963- let $t04018140378 = if ((this == feeCollectorAddress))
1184+ let $t04717447371 = if ((this == feeCollectorAddress))
9641185 then $Tuple2(0, 0)
9651186 else if (paymentInAmountAsset)
9661187 then $Tuple2(-(feeAmount), 0)
9671188 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
1189+ let amountAssetBalanceDelta = $t04717447371._1
1190+ let priceAssetBalanceDelta = $t04717447371._2
1191+ let $t04737447482 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1192+ let refreshKLpActions = $t04737447482._1
1193+ let updatedKLp = $t04737447482._2
9731194 let kLp = value(getString(keyKLp))
9741195 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
9751196 if ((isUpdatedKLpValid == isUpdatedKLpValid))
976- then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
1197+ then {
1198+ let reb = invoke(this, "rebalance", nil, nil)
1199+ if ((reb == reb))
1200+ then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
1201+ else throw("Strict value is not equal to itself.")
1202+ }
9771203 else throw("Strict value is not equal to itself.")
9781204 }
9791205 else throw("Strict value is not equal to itself.")
9801206 }
9811207 else throw("Strict value is not equal to itself.")
9821208 }
9831209 else throw("Strict value is not equal to itself.")
9841210 }
9851211 else throw("Strict value is not equal to itself.")
9861212 }
9871213
9881214
9891215
9901216 @Callable(i)
9911217 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
1218+ let $t04783747994 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
1219+ let emitAmountEstimated = $t04783747994._1
1220+ let commonState = $t04783747994._2
1221+ let feeAmount = $t04783747994._3
1222+ let bonus = $t04783747994._4
1223+ let paymentInAmountAsset = $t04783747994._5
9981224 $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
9991225 }
10001226
10011227
10021228
10031229 @Callable(i)
10041230 func getOneTkn (outAssetIdStr,minOutAmount) = {
10051231 let isPoolOneTokenOperationsDisabled = {
10061232 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
10071233 if ($isInstanceOf(@, "Boolean"))
10081234 then @
10091235 else throw(($getType(@) + " couldn't be cast to Boolean"))
10101236 }
10111237 let isGetDisabled = if (if (isGlobalShutdown())
10121238 then true
10131239 else (cfgPoolStatus == PoolShutdown))
10141240 then true
10151241 else isPoolOneTokenOperationsDisabled
10161242 let checks = [if (if (!(isGetDisabled))
10171243 then true
10181244 else isManager(i))
10191245 then true
10201246 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1))
10211247 then true
10221248 else throwErr("exactly 1 payment are expected")]
10231249 if ((checks == checks))
10241250 then {
10251251 let outAssetId = parseAssetId(outAssetIdStr)
10261252 let payment = i.payments[0]
10271253 let paymentAssetId = payment.assetId
10281254 let paymentAmount = payment.amount
10291255 let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
10301256 if ((currentKLp == currentKLp))
10311257 then {
10321258 let userAddress = i.caller
10331259 let txId = i.transactionId
1034- let $t04183741990 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
1035- if (($t04183741990 == $t04183741990))
1260+ let $t04887949032 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
1261+ if (($t04887949032 == $t04887949032))
10361262 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
1263+ let outInAmountAsset = $t04887949032._5
1264+ let bonus = $t04887949032._4
1265+ let feeAmount = $t04887949032._3
1266+ let commonState = $t04887949032._2
1267+ let amountEstimated = $t04887949032._1
10421268 let amount = if (if ((minOutAmount > 0))
10431269 then (minOutAmount > amountEstimated)
10441270 else false)
10451271 then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
10461272 else amountEstimated
10471273 let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
10481274 if ((burnInv == burnInv))
10491275 then {
1050- let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
1051- let sendFee = if ((feeAmount > 0))
1052- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
1053- else nil
1054- let $t04249042737 = {
1055- let feeAmountForCalc = if ((this == feeCollectorAddress))
1056- then 0
1057- else feeAmount
1058- if (outInAmountAsset)
1059- then $Tuple2(-((amount + feeAmountForCalc)), 0)
1060- else $Tuple2(0, -((amount + feeAmountForCalc)))
1061- }
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
1067- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1068- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1069- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1276+ let withdrawState = withdrawAndRebalanceAsset(outAssetIdStr, amount)
1277+ if ((withdrawState == withdrawState))
1278+ then {
1279+ let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
1280+ let sendFee = if ((feeAmount > 0))
1281+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
1282+ else nil
1283+ let $t04960649853 = {
1284+ let feeAmountForCalc = if ((this == feeCollectorAddress))
1285+ then 0
1286+ else feeAmount
1287+ if (outInAmountAsset)
1288+ then $Tuple2(-((amount + feeAmountForCalc)), 0)
1289+ else $Tuple2(0, -((amount + feeAmountForCalc)))
1290+ }
1291+ let amountAssetBalanceDelta = $t04960649853._1
1292+ let priceAssetBalanceDelta = $t04960649853._2
1293+ let $t04985649964 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1294+ let refreshKLpActions = $t04985649964._1
1295+ let updatedKLp = $t04985649964._2
1296+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1297+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1298+ then $Tuple2(((((commonState ++ withdrawState) ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1299+ else throw("Strict value is not equal to itself.")
1300+ }
10701301 else throw("Strict value is not equal to itself.")
10711302 }
10721303 else throw("Strict value is not equal to itself.")
10731304 }
10741305 else throw("Strict value is not equal to itself.")
10751306 }
10761307 else throw("Strict value is not equal to itself.")
10771308 }
10781309 else throw("Strict value is not equal to itself.")
10791310 }
10801311
10811312
10821313
10831314 @Callable(i)
10841315 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
1316+ let $t05024250398 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
1317+ let amountEstimated = $t05024250398._1
1318+ let commonState = $t05024250398._2
1319+ let feeAmount = $t05024250398._3
1320+ let bonus = $t05024250398._4
1321+ let outInAmountAsset = $t05024250398._5
10911322 $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
10921323 }
10931324
10941325
10951326
10961327 @Callable(i)
10971328 func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = {
10981329 let isPoolOneTokenOperationsDisabled = {
10991330 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
11001331 if ($isInstanceOf(@, "Boolean"))
11011332 then @
11021333 else throw(($getType(@) + " couldn't be cast to Boolean"))
11031334 }
11041335 let isGetDisabled = if (if (isGlobalShutdown())
11051336 then true
11061337 else (cfgPoolStatus == PoolShutdown))
11071338 then true
11081339 else isPoolOneTokenOperationsDisabled
11091340 let checks = [if (if (!(isGetDisabled))
11101341 then true
11111342 else isManager(i))
11121343 then true
11131344 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0))
11141345 then true
11151346 else throwErr("no payments are expected")]
11161347 if ((checks == checks))
11171348 then {
11181349 let outAssetId = parseAssetId(outAssetIdStr)
11191350 let userAddress = i.caller
11201351 let txId = i.transactionId
11211352 let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
11221353 if ((currentKLp == currentKLp))
11231354 then {
11241355 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
11251356 if ((unstakeInv == unstakeInv))
11261357 then {
1127- let $t04416644317 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
1128- if (($t04416644317 == $t04416644317))
1358+ let $t05130351454 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
1359+ if (($t05130351454 == $t05130351454))
11291360 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
1361+ let outInAmountAsset = $t05130351454._5
1362+ let bonus = $t05130351454._4
1363+ let feeAmount = $t05130351454._3
1364+ let commonState = $t05130351454._2
1365+ let amountEstimated = $t05130351454._1
11351366 let amount = if (if ((minOutAmount > 0))
11361367 then (minOutAmount > amountEstimated)
11371368 else false)
11381369 then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
11391370 else amountEstimated
11401371 let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
11411372 if ((burnInv == burnInv))
11421373 then {
1143- let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
1144- let sendFee = if ((feeAmount > 0))
1145- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
1146- else nil
1147- let $t04481245059 = {
1148- let feeAmountForCalc = if ((this == feeCollectorAddress))
1149- then 0
1150- else feeAmount
1151- if (outInAmountAsset)
1152- then $Tuple2(-((amount + feeAmountForCalc)), 0)
1153- else $Tuple2(0, -((amount + feeAmountForCalc)))
1154- }
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
1160- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1161- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1162- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1374+ let withdrawState = withdrawAndRebalanceAsset(outAssetIdStr, amount)
1375+ if ((withdrawState == withdrawState))
1376+ then {
1377+ let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
1378+ let sendFee = if ((feeAmount > 0))
1379+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
1380+ else nil
1381+ let $t05202352270 = {
1382+ let feeAmountForCalc = if ((this == feeCollectorAddress))
1383+ then 0
1384+ else feeAmount
1385+ if (outInAmountAsset)
1386+ then $Tuple2(-((amount + feeAmountForCalc)), 0)
1387+ else $Tuple2(0, -((amount + feeAmountForCalc)))
1388+ }
1389+ let amountAssetBalanceDelta = $t05202352270._1
1390+ let priceAssetBalanceDelta = $t05202352270._2
1391+ let $t05227352381 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1392+ let refreshKLpActions = $t05227352381._1
1393+ let updatedKLp = $t05227352381._2
1394+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1395+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1396+ then $Tuple2(((((commonState ++ withdrawState) ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1397+ else throw("Strict value is not equal to itself.")
1398+ }
11631399 else throw("Strict value is not equal to itself.")
11641400 }
11651401 else throw("Strict value is not equal to itself.")
11661402 }
11671403 else throw("Strict value is not equal to itself.")
11681404 }
11691405 else throw("Strict value is not equal to itself.")
11701406 }
11711407 else throw("Strict value is not equal to itself.")
11721408 }
11731409 else throw("Strict value is not equal to itself.")
11741410 }
11751411
11761412
11771413
11781414 @Callable(i)
11791415 func get () = {
11801416 let res = commonGet(i)
11811417 let outAmtAmt = res._1
11821418 let outPrAmt = res._2
11831419 let pmtAmt = res._3
11841420 let pmtAssetId = res._4
11851421 let state = res._5
11861422 let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
11871423 if ((currentKLp == currentKLp))
11881424 then {
11891425 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
11901426 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
11911427 then {
1192- let $t04611646198 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1193- let refreshKLpActions = $t04611646198._1
1194- let updatedKLp = $t04611646198._2
1428+ let $t05334853430 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1429+ let refreshKLpActions = $t05334853430._1
1430+ let updatedKLp = $t05334853430._2
11951431 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
11961432 if ((isUpdatedKLpValid == isUpdatedKLpValid))
11971433 then (state ++ refreshKLpActions)
11981434 else throw("Strict value is not equal to itself.")
11991435 }
12001436 else throw("Strict value is not equal to itself.")
12011437 }
12021438 else throw("Strict value is not equal to itself.")
12031439 }
12041440
12051441
12061442
12071443 @Callable(i)
12081444 func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = {
12091445 let res = commonGet(i)
12101446 let outAmAmt = res._1
12111447 let outPrAmt = res._2
12121448 let pmtAmt = res._3
12131449 let pmtAssetId = res._4
12141450 let state = res._5
12151451 if ((noLessThenAmtAsset > outAmAmt))
12161452 then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset)))
12171453 else if ((noLessThenPriceAsset > outPrAmt))
12181454 then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
12191455 else {
12201456 let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
12211457 if ((currentKLp == currentKLp))
12221458 then {
12231459 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
12241460 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
12251461 then {
1226- let $t04714747228 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1227- let refreshKLpActions = $t04714747228._1
1228- let updatedKLp = $t04714747228._2
1462+ let $t05437954460 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1463+ let refreshKLpActions = $t05437954460._1
1464+ let updatedKLp = $t05437954460._2
12291465 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
12301466 if ((isUpdatedKLpValid == isUpdatedKLpValid))
12311467 then (state ++ refreshKLpActions)
12321468 else throw("Strict value is not equal to itself.")
12331469 }
12341470 else throw("Strict value is not equal to itself.")
12351471 }
12361472 else throw("Strict value is not equal to itself.")
12371473 }
12381474 }
12391475
12401476
12411477
12421478 @Callable(i)
12431479 func unstakeAndGet (amount) = {
12441480 let checkPayments = if ((size(i.payments) != 0))
12451481 then throw("No payments are expected")
12461482 else true
12471483 if ((checkPayments == checkPayments))
12481484 then {
12491485 let cfg = getPoolConfig()
12501486 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
12511487 let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
12521488 if ((currentKLp == currentKLp))
12531489 then {
12541490 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
12551491 if ((unstakeInv == unstakeInv))
12561492 then {
12571493 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
12581494 let outAmAmt = res._1
12591495 let outPrAmt = res._2
12601496 let poolStatus = parseIntValue(res._9)
12611497 let state = res._10
12621498 let checkPoolStatus = if (if (isGlobalShutdown())
12631499 then true
12641500 else (poolStatus == PoolShutdown))
12651501 then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
12661502 else true
12671503 if ((checkPoolStatus == checkPoolStatus))
12681504 then {
12691505 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
12701506 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
12711507 then {
1272- let $t04835448435 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1273- let refreshKLpActions = $t04835448435._1
1274- let updatedKLp = $t04835448435._2
1508+ let $t05558655667 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1509+ let refreshKLpActions = $t05558655667._1
1510+ let updatedKLp = $t05558655667._2
12751511 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
12761512 if ((isUpdatedKLpValid == isUpdatedKLpValid))
12771513 then (state ++ refreshKLpActions)
12781514 else throw("Strict value is not equal to itself.")
12791515 }
12801516 else throw("Strict value is not equal to itself.")
12811517 }
12821518 else throw("Strict value is not equal to itself.")
12831519 }
12841520 else throw("Strict value is not equal to itself.")
12851521 }
12861522 else throw("Strict value is not equal to itself.")
12871523 }
12881524 else throw("Strict value is not equal to itself.")
12891525 }
12901526
12911527
12921528
12931529 @Callable(i)
12941530 func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = {
12951531 let isGetDisabled = if (isGlobalShutdown())
12961532 then true
12971533 else (cfgPoolStatus == PoolShutdown)
12981534 let checks = [if (!(isGetDisabled))
12991535 then true
13001536 else throw("get operation is blocked by admin"), if ((size(i.payments) == 0))
13011537 then true
13021538 else throw("no payments are expected")]
13031539 if ((checks == checks))
13041540 then {
13051541 let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
13061542 if ((currentKLp == currentKLp))
13071543 then {
13081544 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
13091545 if ((unstakeInv == unstakeInv))
13101546 then {
13111547 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
13121548 let outAmAmt = res._1
13131549 let outPrAmt = res._2
13141550 let state = res._10
13151551 let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
13161552 then true
13171553 else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
13181554 then true
13191555 else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
13201556 if ((checkAmounts == checkAmounts))
13211557 then {
13221558 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
13231559 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
13241560 then {
1325- let $t04973049811 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1326- let refreshKLpActions = $t04973049811._1
1327- let updatedKLp = $t04973049811._2
1561+ let $t05696257043 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1562+ let refreshKLpActions = $t05696257043._1
1563+ let updatedKLp = $t05696257043._2
13281564 let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
13291565 if ((isUpdatedKLpValid == isUpdatedKLpValid))
13301566 then (state ++ refreshKLpActions)
13311567 else throw("Strict value is not equal to itself.")
13321568 }
13331569 else throw("Strict value is not equal to itself.")
13341570 }
13351571 else throw("Strict value is not equal to itself.")
13361572 }
13371573 else throw("Strict value is not equal to itself.")
13381574 }
13391575 else throw("Strict value is not equal to itself.")
13401576 }
13411577 else throw("Strict value is not equal to itself.")
13421578 }
13431579
13441580
13451581
13461582 @Callable(i)
13471583 func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
13481584 then throw("permissions denied")
13491585 else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success")
13501586
13511587
13521588
13531589 @Callable(i)
13541590 func refreshKLp () = {
13551591 let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0)
13561592 let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay))
13571593 then unit
13581594 else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], ""))
13591595 if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
13601596 then {
13611597 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
1598+ let $t05823058294 = refreshKLpInternal(0, 0, 0)
1599+ let kLpUpdateActions = $t05823058294._1
1600+ let updatedKLp = $t05823058294._2
13651601 let actions = if ((kLp != updatedKLp))
13661602 then kLpUpdateActions
13671603 else throwErr("nothing to refresh")
13681604 $Tuple2(actions, toString(updatedKLp))
13691605 }
13701606 else throw("Strict value is not equal to itself.")
13711607 }
13721608
13731609
13741610
13751611 @Callable(i)
13761612 func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig())
13771613
13781614
13791615
13801616 @Callable(i)
13811617 func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId))
13821618
13831619
13841620
13851621 @Callable(i)
13861622 func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = {
13871623 let prices = calcPrices(amAmt, prAmt, lpAmt)
13881624 $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])])
13891625 }
13901626
13911627
13921628
13931629 @Callable(i)
13941630 func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult)))
13951631
13961632
13971633
13981634 @Callable(i)
13991635 func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult))
14001636
14011637
14021638
14031639 @Callable(i)
14041640 func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18))))
14051641
14061642
14071643
14081644 @Callable(i)
14091645 func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp))
14101646
14111647
14121648
14131649 @Callable(i)
14141650 func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
14151651 let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress))
14161652 $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10))
14171653 }
14181654
14191655
14201656
14211657 @Callable(i)
14221658 func statsREADONLY () = {
14231659 let cfg = getPoolConfig()
14241660 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
14251661 let amtAssetId = cfg[idxAmtAssetId]
14261662 let priceAssetId = cfg[idxPriceAssetId]
14271663 let iAmtAssetId = cfg[idxIAmtAssetId]
14281664 let iPriceAssetId = cfg[idxIPriceAssetId]
14291665 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
14301666 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
14311667 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
14321668 let accAmtAssetBalance = getAccBalance(amtAssetId)
14331669 let accPriceAssetBalance = getAccBalance(priceAssetId)
14341670 let pricesList = if ((poolLPBalance == 0))
14351671 then [zeroBigInt, zeroBigInt, zeroBigInt]
14361672 else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance)
14371673 let curPrice = 0
14381674 let lpAmtAssetShare = fromX18(pricesList[1], scale8)
14391675 let lpPriceAssetShare = fromX18(pricesList[2], scale8)
14401676 let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this))))
14411677 $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))
14421678 }
14431679
14441680
14451681
14461682 @Callable(i)
14471683 func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = {
14481684 let cfg = getPoolConfig()
14491685 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
14501686 let amAssetIdStr = cfg[idxAmtAssetId]
14511687 let amAssetId = fromBase58String(amAssetIdStr)
14521688 let prAssetIdStr = cfg[idxPriceAssetId]
14531689 let prAssetId = fromBase58String(prAssetIdStr)
14541690 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
14551691 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
14561692 let poolStatus = cfg[idxPoolStatus]
14571693 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
14581694 let accAmtAssetBalance = getAccBalance(amAssetIdStr)
14591695 let accPriceAssetBalance = getAccBalance(prAssetIdStr)
14601696 let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm)
14611697 let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm)
14621698 let curPriceX18 = if ((poolLPBalance == 0))
14631699 then zeroBigInt
14641700 else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18)
14651701 let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm)
14661702 let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
14671703 let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm)
14681704 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
14691705 let calcLpAmt = estPut._1
14701706 let curPriceCalc = estPut._3
14711707 let amBalance = estPut._4
14721708 let prBalance = estPut._5
14731709 let lpEmission = estPut._6
14741710 $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))
14751711 }
14761712
14771713
14781714
14791715 @Callable(i)
14801716 func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = {
14811717 let cfg = getPoolConfig()
14821718 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
14831719 let amAssetIdStr = cfg[idxAmtAssetId]
14841720 let amAssetId = fromBase58String(amAssetIdStr)
14851721 let prAssetIdStr = cfg[idxPriceAssetId]
14861722 let prAssetId = fromBase58String(prAssetIdStr)
14871723 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
14881724 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
14891725 let poolStatus = cfg[idxPoolStatus]
14901726 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
14911727 let amBalanceRaw = getAccBalance(amAssetIdStr)
14921728 let prBalanceRaw = getAccBalance(prAssetIdStr)
14931729 let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm)
14941730 let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm)
14951731 let curPriceX18 = if ((poolLPBalance == 0))
14961732 then zeroBigInt
14971733 else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18)
14981734 let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm)
14991735 let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
15001736 let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm)
15011737 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
15021738 let calcLpAmt = estPut._1
15031739 let curPriceCalc = estPut._3
15041740 let amBalance = estPut._4
15051741 let prBalance = estPut._5
15061742 let lpEmission = estPut._6
15071743 $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))
15081744 }
15091745
15101746
15111747
15121748 @Callable(i)
15131749 func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = {
15141750 let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this)
15151751 let outAmAmt = res._1
15161752 let outPrAmt = res._2
15171753 let amBalance = res._5
15181754 let prBalance = res._6
15191755 let lpEmission = res._7
15201756 let curPrice = res._8
15211757 let poolStatus = parseIntValue(res._9)
15221758 $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))
15231759 }
15241760
15251761
15261762 @Verifier(tx)
15271763 func verify () = {
15281764 let targetPublicKey = match managerPublicKeyOrUnit() {
15291765 case pk: ByteVector =>
15301766 pk
15311767 case _: Unit =>
15321768 tx.senderPublicKey
15331769 case _ =>
15341770 throw("Match error")
15351771 }
15361772 match tx {
15371773 case order: Order =>
15381774 let matcherPub = getMatcherPubOrFail()
1539- let $t05972459793 = validateMatcherOrderAllowed(order)
1540- let orderValid = $t05972459793._1
1541- let orderValidInfo = $t05972459793._2
1775+ let $t06695667025 = validateMatcherOrderAllowed(order)
1776+ let orderValid = $t06695667025._1
1777+ let orderValidInfo = $t06695667025._2
15421778 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
15431779 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
15441780 if (if (if (orderValid)
15451781 then senderValid
15461782 else false)
15471783 then matcherValid
15481784 else false)
15491785 then true
15501786 else throwOrderError(orderValid, orderValidInfo, senderValid, matcherValid)
15511787 case s: SetScriptTransaction =>
15521788 if (sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey))
15531789 then true
15541790 else {
15551791 let newHash = blake2b256(value(s.script))
15561792 let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash())))
15571793 let currentHash = scriptHash(this)
15581794 if ((allowedHash == newHash))
15591795 then (currentHash != newHash)
15601796 else false
15611797 }
15621798 case _ =>
15631799 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
15641800 }
15651801 }
15661802

github/deemru/w8io/169f3d6 
274.72 ms