tx · F4EPeFV2iqW37GMzcwFczJXrMFY9iEbS7Y9DMxi2dkVz 3N7b3kPunHUXhZp1vMG9NhPMARNEprCMWxT: -0.04300000 Waves 2023.04.04 13:54 [2519727] smart account 3N7b3kPunHUXhZp1vMG9NhPMARNEprCMWxT > SELF 0.00000000 Waves
{ "type": 13, "id": "F4EPeFV2iqW37GMzcwFczJXrMFY9iEbS7Y9DMxi2dkVz", "fee": 4300000, "feeAssetId": null, "timestamp": 1680605650376, "version": 2, "chainId": 84, "sender": "3N7b3kPunHUXhZp1vMG9NhPMARNEprCMWxT", "senderPublicKey": "AYbpHveq7zviKTDV7SGTB1pZGFbkumgfq3jSwVv6BznT", "proofs": [ "24AGjN8kom4XL7seJjqCTNZX8SxUrUrjRHgBF82vSTkdj8vNs1a8cavHvUFQumoeZhrQSM2GDVc2yhY2UoJu8nHR" ], "script": "base64:BgKdNwgCEgASBQoDAQQBEgcKBQEEAQgBEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgQKAggBEgQKAggBEgQKAggBEgUKAwEIARIAEgQKAgEBEgMKAQESBQoDAQEBEgQKAggIEgASABIDCgEIEgUKAwEBARIECgIBARIECgIIARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCBIAEgMKAQESAwoBARIECgIIASIKbFBkZWNpbWFscyIGc2NhbGU4IgxzY2FsZThCaWdJbnQiB3NjYWxlMTgiCnplcm9CaWdJbnQiBGJpZzAiBGJpZzEiBGJpZzIiC3dhdmVzU3RyaW5nIgNTRVAiClBvb2xBY3RpdmUiD1Bvb2xQdXREaXNhYmxlZCITUG9vbE1hdGNoZXJEaXNhYmxlZCIMUG9vbFNodXRkb3duIg5pZHhQb29sQWRkcmVzcyINaWR4UG9vbFN0YXR1cyIQaWR4UG9vbExQQXNzZXRJZCINaWR4QW10QXNzZXRJZCIPaWR4UHJpY2VBc3NldElkIg5pZHhBbXRBc3NldERjbSIQaWR4UHJpY2VBc3NldERjbSIOaWR4SUFtdEFzc2V0SWQiEGlkeEl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MJAJEDAggFAmlrBnByb29mcwAABQJpbVP5/UQ=", "height": 2519727, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5aEcWjdinQhuARjR4gHtBnFkar5hUHzbAdVCdNcrKtML Next: 41PtbF3TB8d776iYf2p5zuLApfbUgjgWrRi6RNmzqow7 Diff:
Old | New | Differences | |
---|---|---|---|
243 | 243 | ||
244 | 244 | let poolConfigParsed = parsePoolConfig(getPoolConfig()) | |
245 | 245 | ||
246 | - | let $ | |
246 | + | let $t092859451 = poolConfigParsed | |
247 | 247 | ||
248 | - | let cfgPoolAddress = $ | |
248 | + | let cfgPoolAddress = $t092859451._1 | |
249 | 249 | ||
250 | - | let cfgPoolStatus = $ | |
250 | + | let cfgPoolStatus = $t092859451._2 | |
251 | 251 | ||
252 | - | let cfgLpAssetId = $ | |
252 | + | let cfgLpAssetId = $t092859451._3 | |
253 | 253 | ||
254 | - | let cfgAmountAssetId = $ | |
254 | + | let cfgAmountAssetId = $t092859451._4 | |
255 | 255 | ||
256 | - | let cfgPriceAssetId = $ | |
256 | + | let cfgPriceAssetId = $t092859451._5 | |
257 | 257 | ||
258 | - | let cfgAmountAssetDecimals = $ | |
258 | + | let cfgAmountAssetDecimals = $t092859451._6 | |
259 | 259 | ||
260 | - | let cfgPriceAssetDecimals = $ | |
260 | + | let cfgPriceAssetDecimals = $t092859451._7 | |
261 | 261 | ||
262 | 262 | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
263 | 263 | ||
340 | 340 | } | |
341 | 341 | ||
342 | 342 | ||
343 | - | func withdraw (assetId,amount,stakingAssetId,proxy,proxyRateMul) = { | |
343 | + | func withdraw (assetId,amount,stakingAssetId,proxy,proxyRateMul,profitAddress) = { | |
344 | 344 | let currentAdditionalBalance = getAdditionalBalance(assetId) | |
345 | 345 | if ((currentAdditionalBalance == currentAdditionalBalance)) | |
346 | 346 | then { | |
350 | 350 | let currentProxyRate = getRate(proxy) | |
351 | 351 | if ((currentProxyRate == currentProxyRate)) | |
352 | 352 | then { | |
353 | + | let oldRate = fraction(proxyRateMul, currentAdditionalBalance, currentStakingAssetBalance) | |
353 | 354 | let stakingAsset = parseAssetId(stakingAssetId) | |
355 | + | let oldSendStakingAmount = fraction(proxyRateMul, amount, oldRate) | |
354 | 356 | let sendStakingAssetAmount = fraction(proxyRateMul, amount, currentProxyRate) | |
357 | + | let profitAmount = max([0, (oldSendStakingAmount - sendStakingAssetAmount)]) | |
355 | 358 | if ((sendStakingAssetAmount > 0)) | |
356 | 359 | then { | |
357 | 360 | let withdrawInvoke = invoke(proxy, "withdraw", nil, [AttachedPayment(stakingAsset, sendStakingAssetAmount)]) | |
359 | 362 | then match withdrawInvoke { | |
360 | 363 | case receivedAssets: Int => | |
361 | 364 | let newAdditionalBalance = (currentAdditionalBalance - receivedAssets) | |
362 | - | let newStakingAssetBalance = (currentStakingAssetBalance - sendStakingAssetAmount) | |
363 | - | [IntegerEntry(keyAdditionalBalance(assetId), newAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance)] | |
365 | + | let newStakingAssetBalance = ((currentStakingAssetBalance - sendStakingAssetAmount) - profitAmount) | |
366 | + | [IntegerEntry(keyAdditionalBalance(assetId), newAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance), ScriptTransfer(profitAddress, profitAmount, parseAssetId(stakingAssetId))] | |
364 | 367 | case _ => | |
365 | 368 | nil | |
366 | 369 | } | |
379 | 382 | func getLeaseProxyConfig (assetId) = invoke(factoryContract, "getPoolLeaseConfigREADONLY", [toString(this), assetId], nil) | |
380 | 383 | ||
381 | 384 | ||
382 | - | func rebalanceInternal (targetRatio,assetId,stakingAssetId,minBalance,proxy,proxyRateMul) = { | |
385 | + | func rebalanceInternal (targetRatio,assetId,stakingAssetId,minBalance,proxy,proxyRateMul,profitAddress) = { | |
383 | 386 | let currentAdditionalBalance = getAdditionalBalance(assetId) | |
384 | 387 | if ((currentAdditionalBalance == currentAdditionalBalance)) | |
385 | 388 | then { | |
408 | 411 | } | |
409 | 412 | else { | |
410 | 413 | let getAssetAmount = diff | |
411 | - | withdraw(assetId, getAssetAmount, stakingAssetId, proxy, proxyRateMul) | |
414 | + | withdraw(assetId, getAssetAmount, stakingAssetId, proxy, proxyRateMul, profitAddress) | |
412 | 415 | } | |
413 | 416 | } | |
414 | 417 | else throw("Strict value is not equal to itself.") | |
421 | 424 | ||
422 | 425 | func rebalanceAsset (assetId) = match getLeaseProxyConfig(assetId) { | |
423 | 426 | case a: (Boolean, Int, Int, String, String, Int, String) => | |
424 | - | let $ | |
425 | - | let isLeasable = $ | |
426 | - | let leasedRatio = $ | |
427 | - | let minBalance = $ | |
428 | - | let proxyAddress = $ | |
429 | - | let proxyAssetId = $ | |
430 | - | let proxyRateMul = $ | |
431 | - | let stakingProfitAddress = $ | |
427 | + | let $t01605416163 = a | |
428 | + | let isLeasable = $t01605416163._1 | |
429 | + | let leasedRatio = $t01605416163._2 | |
430 | + | let minBalance = $t01605416163._3 | |
431 | + | let proxyAddress = $t01605416163._4 | |
432 | + | let proxyAssetId = $t01605416163._5 | |
433 | + | let proxyRateMul = $t01605416163._6 | |
434 | + | let stakingProfitAddress = $t01605416163._7 | |
432 | 435 | if (isLeasable) | |
433 | - | then rebalanceInternal(leasedRatio, assetId, proxyAssetId, minBalance, addressFromStringValue(proxyAddress), proxyRateMul) | |
436 | + | then rebalanceInternal(leasedRatio, assetId, proxyAssetId, minBalance, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress)) | |
434 | 437 | else nil | |
435 | 438 | case _ => | |
436 | 439 | throwErr((("[" + assetId) + "] Rebalance error")) | |
437 | 440 | } | |
441 | + | ||
442 | + | ||
443 | + | func withdrawAssetWrapper (assetId,amount) = match getLeaseProxyConfig(assetId) { | |
444 | + | case a: (Boolean, Int, Int, String, String, Int, String) => | |
445 | + | let $t01669316802 = a | |
446 | + | let isLeasable = $t01669316802._1 | |
447 | + | let leasedRatio = $t01669316802._2 | |
448 | + | let minBalance = $t01669316802._3 | |
449 | + | let proxyAddress = $t01669316802._4 | |
450 | + | let proxyAssetId = $t01669316802._5 | |
451 | + | let proxyRateMul = $t01669316802._6 | |
452 | + | let stakingProfitAddress = $t01669316802._7 | |
453 | + | if (isLeasable) | |
454 | + | then withdraw(assetId, amount, proxyAssetId, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress)) | |
455 | + | else nil | |
456 | + | case _ => | |
457 | + | throwErr((("[" + assetId) + "] withdrawAssetWrapper() error")) | |
458 | + | } | |
459 | + | ||
460 | + | ||
461 | + | func getWithdrawAssetState (assetId,amount) = { | |
462 | + | let assetOnPool = match parseAssetId(assetId) { | |
463 | + | case b: ByteVector => | |
464 | + | assetBalance(this, b) | |
465 | + | case w: Unit => | |
466 | + | wavesBalance(this).available | |
467 | + | case _ => | |
468 | + | throw("Match error") | |
469 | + | } | |
470 | + | if ((amount > assetOnPool)) | |
471 | + | then { | |
472 | + | let amountDiff = (amount - assetOnPool) | |
473 | + | withdrawAssetWrapper(assetId, amountDiff) | |
474 | + | } | |
475 | + | else nil | |
476 | + | } | |
438 | 477 | ||
439 | 478 | ||
440 | 479 | func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
488 | 527 | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
489 | 528 | let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR) | |
490 | 529 | let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR) | |
491 | - | let state = if ((txId58 == "")) | |
492 | - | then nil | |
493 | - | else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
494 | - | then unit | |
495 | - | else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES")) | |
496 | - | then unit | |
497 | - | 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)] | |
498 | - | $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state) | |
530 | + | let AmAmtWithdrawState = getWithdrawAssetState(amAssetId, outAmAmt) | |
531 | + | if ((AmAmtWithdrawState == AmAmtWithdrawState)) | |
532 | + | then { | |
533 | + | let PrAmtWithdrawState = getWithdrawAssetState(prAssetId, outPrAmt) | |
534 | + | if ((PrAmtWithdrawState == PrAmtWithdrawState)) | |
535 | + | then { | |
536 | + | let reb = invoke(this, "rebalance", nil, nil) | |
537 | + | if ((reb == reb)) | |
538 | + | then { | |
539 | + | let state = if ((txId58 == "")) | |
540 | + | then nil | |
541 | + | else ((AmAmtWithdrawState ++ PrAmtWithdrawState) ++ [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
542 | + | then unit | |
543 | + | else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES")) | |
544 | + | then unit | |
545 | + | 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)]) | |
546 | + | $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state) | |
547 | + | } | |
548 | + | else throw("Strict value is not equal to itself.") | |
549 | + | } | |
550 | + | else throw("Strict value is not equal to itself.") | |
551 | + | } | |
552 | + | else throw("Strict value is not equal to itself.") | |
499 | 553 | } | |
500 | 554 | } | |
501 | 555 | ||
616 | 670 | let priceAssetBalance = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
617 | 671 | let amountAssetAmount = order.amount | |
618 | 672 | let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR) | |
619 | - | let $ | |
673 | + | let $t02904029252 = if ((order.orderType == Buy)) | |
620 | 674 | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
621 | 675 | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
622 | - | let amountAssetBalanceDelta = $ | |
623 | - | let priceAssetBalanceDelta = $ | |
676 | + | let amountAssetBalanceDelta = $t02904029252._1 | |
677 | + | let priceAssetBalanceDelta = $t02904029252._2 | |
624 | 678 | if (if (if (isGlobalShutdown()) | |
625 | 679 | then true | |
626 | 680 | else (cfgPoolStatus == PoolMatcherDisabled)) | |
633 | 687 | then throw("Wrong order assets.") | |
634 | 688 | else { | |
635 | 689 | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
636 | - | let $ | |
637 | - | let unusedActions = $ | |
638 | - | let kLpNew = $ | |
690 | + | let $t02969229792 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
691 | + | let unusedActions = $t02969229792._1 | |
692 | + | let kLpNew = $t02969229792._2 | |
639 | 693 | let isOrderValid = (kLpNew >= kLp) | |
640 | 694 | let info = makeString(["kLp=", toString(kLp), " kLpNew=", toString(kLpNew), " amountAssetBalance=", toString(amountAssetBalance), " priceAssetBalance=", toString(priceAssetBalance), " amountAssetBalanceDelta=", toString(amountAssetBalanceDelta), " priceAssetBalanceDelta=", toString(priceAssetBalanceDelta), " height=", toString(height)], "") | |
641 | 695 | $Tuple2(isOrderValid, info) | |
714 | 768 | else if ((paymentAssetId == cfgPriceAssetId)) | |
715 | 769 | then false | |
716 | 770 | else throwErr("invalid asset") | |
717 | - | let $ | |
771 | + | let $t03290533198 = if (isEval) | |
718 | 772 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
719 | 773 | else if (paymentInAmountAsset) | |
720 | 774 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
721 | 775 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
722 | - | let amountBalanceOld = $ | |
723 | - | let priceBalanceOld = $ | |
724 | - | let $ | |
776 | + | let amountBalanceOld = $t03290533198._1 | |
777 | + | let priceBalanceOld = $t03290533198._2 | |
778 | + | let $t03320233351 = if (paymentInAmountAsset) | |
725 | 779 | then $Tuple2(paymentAmountRaw, 0) | |
726 | 780 | else $Tuple2(0, paymentAmountRaw) | |
727 | - | let amountAssetAmountRaw = $ | |
728 | - | let priceAssetAmountRaw = $ | |
781 | + | let amountAssetAmountRaw = $t03320233351._1 | |
782 | + | let priceAssetAmountRaw = $t03320233351._2 | |
729 | 783 | let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1 | |
730 | 784 | let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1 | |
731 | - | let $ | |
732 | - | let paymentAmount = $ | |
733 | - | let feeAmount = $ | |
785 | + | let $t03348333547 = takeFee(paymentAmountRaw, inFee) | |
786 | + | let paymentAmount = $t03348333547._1 | |
787 | + | let feeAmount = $t03348333547._2 | |
734 | 788 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
735 | 789 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
736 | 790 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
753 | 807 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
754 | 808 | let priceOld = fromX18(priceOldX18, scale8) | |
755 | 809 | let loss = { | |
756 | - | let $ | |
810 | + | let $t03522835395 = if (paymentInAmountAsset) | |
757 | 811 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
758 | 812 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
759 | - | let amount = $ | |
760 | - | let balance = $ | |
813 | + | let amount = $t03522835395._1 | |
814 | + | let balance = $t03522835395._2 | |
761 | 815 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
762 | 816 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
763 | 817 | } | |
797 | 851 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
798 | 852 | let redeemedBigInt = toBigInt(paymentAmount) | |
799 | 853 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
800 | - | let $ | |
801 | - | let totalAmount = $ | |
802 | - | let feeAmount = $ | |
803 | - | let $ | |
854 | + | let $t03747337529 = takeFee(amountRaw, outFee) | |
855 | + | let totalAmount = $t03747337529._1 | |
856 | + | let feeAmount = $t03747337529._2 | |
857 | + | let $t03753337759 = if (outInAmountAsset) | |
804 | 858 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
805 | 859 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
806 | - | let outAmAmount = $ | |
807 | - | let outPrAmount = $ | |
808 | - | let amBalanceNew = $ | |
809 | - | let prBalanceNew = $ | |
860 | + | let outAmAmount = $t03753337759._1 | |
861 | + | let outPrAmount = $t03753337759._2 | |
862 | + | let amBalanceNew = $t03753337759._3 | |
863 | + | let prBalanceNew = $t03753337759._4 | |
810 | 864 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
811 | 865 | let priceNew = fromX18(priceNewX18, scale8) | |
812 | 866 | let commonState = if (isEval) | |
878 | 932 | ||
879 | 933 | @Callable(i) | |
880 | 934 | func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse,feePoolAmount) = { | |
881 | - | let $ | |
935 | + | let $t03964539950 = if ((isReverse == false)) | |
882 | 936 | then { | |
883 | 937 | let assetOut = getStringOrFail(this, pa()) | |
884 | 938 | let assetIn = getStringOrFail(this, aa()) | |
889 | 943 | let assetIn = getStringOrFail(this, pa()) | |
890 | 944 | $Tuple2(assetOut, assetIn) | |
891 | 945 | } | |
892 | - | let assetOut = $ | |
893 | - | let assetIn = $ | |
946 | + | let assetOut = $t03964539950._1 | |
947 | + | let assetIn = $t03964539950._2 | |
894 | 948 | let poolAssetInBalance = getAccBalance(assetIn) | |
895 | 949 | let poolAssetOutBalance = getAccBalance(assetOut) | |
896 | 950 | let amountOut = fraction(poolAssetOutBalance, cleanAmountIn, (poolAssetInBalance + cleanAmountIn)) | |
947 | 1001 | case _ => | |
948 | 1002 | throw("error lease config") | |
949 | 1003 | } | |
950 | - | let $t04006140175 = lsConf | |
951 | - | let isLeasable = $t04006140175._1 | |
952 | - | let leasedRatio = $t04006140175._2 | |
953 | - | let minBalance = $t04006140175._3 | |
954 | - | let proxyAddress = $t04006140175._4 | |
955 | - | let proxyAssetId = $t04006140175._5 | |
956 | - | let proxyRateMul = $t04006140175._6 | |
957 | - | let stakingProfitAddress = $t04006140175._7 | |
958 | - | let assetOnPool = assetBalance(this, fromBase58String(assetOut)) | |
959 | - | let amountOfProfit = if (if ((assetOut == "WAVES")) | |
960 | - | then (amountOut > assetOnPool) | |
961 | - | else false) | |
1004 | + | let withdrawState = getWithdrawAssetState(assetOut, amountOut) | |
1005 | + | if ((withdrawState == withdrawState)) | |
962 | 1006 | then { | |
963 | - | let amountDiff = (amountOut - assetOnPool) | |
964 | - | let oldRatio = (getAdditionalBalance(assetOut) / getStakingAssetBalance(sWavesId())) | |
965 | - | let oldWavesRoughBalane = wavesBalance(this).available | |
966 | - | let wd = invoke(this, "withdraw", [assetOut, amountDiff, sWavesId(), sWavesProxy(), proxyRateMul], nil) | |
967 | - | if ((wd == wd)) | |
968 | - | then { | |
969 | - | let newWavesRoughBalane = wavesBalance(this).available | |
970 | - | let wavesDiff = (newWavesRoughBalane - oldWavesRoughBalane) | |
971 | - | (wavesDiff - amountDiff) | |
972 | - | } | |
1007 | + | let reb = invoke(this, "rebalance", nil, nil) | |
1008 | + | if ((reb == reb)) | |
1009 | + | then $Tuple2((withdrawState ++ [ScriptTransfer(addressFromStringValue(addressTo), amountOut, parseAssetId(assetOut))]), amountOut) | |
973 | 1010 | else throw("Strict value is not equal to itself.") | |
974 | 1011 | } | |
975 | - | else 0 | |
976 | - | let reb = invoke(this, "rebalance", nil, nil) | |
977 | - | if ((reb == reb)) | |
978 | - | then $Tuple2([ScriptTransfer(addressFromStringValue(stakingProfitAddress), amountOfProfit, unit), ScriptTransfer(addressFromStringValue(addressTo), amountOut, parseAssetId(assetOut))], amountOut) | |
979 | 1012 | else throw("Strict value is not equal to itself.") | |
980 | 1013 | } | |
981 | 1014 | else throw("Strict value is not equal to itself.") | |
1068 | 1101 | else throw("Strict value is not equal to itself.") | |
1069 | 1102 | } | |
1070 | 1103 | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
1071 | - | let $ | |
1072 | - | if (($ | |
1104 | + | let $t04515145613 = refreshKLpInternal(0, 0, 0) | |
1105 | + | if (($t04515145613 == $t04515145613)) | |
1073 | 1106 | then { | |
1074 | - | let updatedKLp = $ | |
1075 | - | let refreshKLpActions = $ | |
1107 | + | let updatedKLp = $t04515145613._2 | |
1108 | + | let refreshKLpActions = $t04515145613._1 | |
1076 | 1109 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1077 | 1110 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1078 | 1111 | then ((state ++ lpTransfer) ++ refreshKLpActions) | |
1104 | 1137 | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
1105 | 1138 | if ((currentKLp == currentKLp)) | |
1106 | 1139 | then { | |
1107 | - | let $ | |
1108 | - | let refreshKLpActions = $ | |
1109 | - | let updatedKLp = $ | |
1140 | + | let $t04617546240 = refreshKLpInternal(0, 0, 0) | |
1141 | + | let refreshKLpActions = $t04617546240._1 | |
1142 | + | let updatedKLp = $t04617546240._2 | |
1110 | 1143 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1111 | 1144 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1112 | 1145 | then (state ++ refreshKLpActions) | |
1153 | 1186 | then { | |
1154 | 1187 | let userAddress = i.caller | |
1155 | 1188 | let txId = i.transactionId | |
1156 | - | let $ | |
1157 | - | if (($ | |
1189 | + | let $t04742847580 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
1190 | + | if (($t04742847580 == $t04742847580)) | |
1158 | 1191 | then { | |
1159 | - | let paymentInAmountAsset = $ | |
1160 | - | let bonus = $ | |
1161 | - | let feeAmount = $ | |
1162 | - | let commonState = $ | |
1163 | - | let emitAmountEstimated = $ | |
1192 | + | let paymentInAmountAsset = $t04742847580._5 | |
1193 | + | let bonus = $t04742847580._4 | |
1194 | + | let feeAmount = $t04742847580._3 | |
1195 | + | let commonState = $t04742847580._2 | |
1196 | + | let emitAmountEstimated = $t04742847580._1 | |
1164 | 1197 | let emitAmount = if (if ((minOutAmount > 0)) | |
1165 | 1198 | then (minOutAmount > emitAmountEstimated) | |
1166 | 1199 | else false) | |
1180 | 1213 | let sendFee = if ((feeAmount > 0)) | |
1181 | 1214 | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
1182 | 1215 | else nil | |
1183 | - | let $ | |
1216 | + | let $t04816648363 = if ((this == feeCollectorAddress)) | |
1184 | 1217 | then $Tuple2(0, 0) | |
1185 | 1218 | else if (paymentInAmountAsset) | |
1186 | 1219 | then $Tuple2(-(feeAmount), 0) | |
1187 | 1220 | else $Tuple2(0, -(feeAmount)) | |
1188 | - | let amountAssetBalanceDelta = $ | |
1189 | - | let priceAssetBalanceDelta = $ | |
1190 | - | let $ | |
1191 | - | let refreshKLpActions = $ | |
1192 | - | let updatedKLp = $ | |
1221 | + | let amountAssetBalanceDelta = $t04816648363._1 | |
1222 | + | let priceAssetBalanceDelta = $t04816648363._2 | |
1223 | + | let $t04836648474 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1224 | + | let refreshKLpActions = $t04836648474._1 | |
1225 | + | let updatedKLp = $t04836648474._2 | |
1193 | 1226 | let kLp = value(getString(keyKLp)) | |
1194 | 1227 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1195 | 1228 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1214 | 1247 | ||
1215 | 1248 | @Callable(i) | |
1216 | 1249 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
1217 | - | let $ | |
1218 | - | let emitAmountEstimated = $ | |
1219 | - | let commonState = $ | |
1220 | - | let feeAmount = $ | |
1221 | - | let bonus = $ | |
1222 | - | let paymentInAmountAsset = $ | |
1250 | + | let $t04882948986 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
1251 | + | let emitAmountEstimated = $t04882948986._1 | |
1252 | + | let commonState = $t04882948986._2 | |
1253 | + | let feeAmount = $t04882948986._3 | |
1254 | + | let bonus = $t04882948986._4 | |
1255 | + | let paymentInAmountAsset = $t04882948986._5 | |
1223 | 1256 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
1224 | 1257 | } | |
1225 | 1258 | ||
1256 | 1289 | then { | |
1257 | 1290 | let userAddress = i.caller | |
1258 | 1291 | let txId = i.transactionId | |
1259 | - | let $ | |
1260 | - | if (($ | |
1292 | + | let $t04987150024 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
1293 | + | if (($t04987150024 == $t04987150024)) | |
1261 | 1294 | then { | |
1262 | - | let outInAmountAsset = $ | |
1263 | - | let bonus = $ | |
1264 | - | let feeAmount = $ | |
1265 | - | let commonState = $ | |
1266 | - | let amountEstimated = $ | |
1295 | + | let outInAmountAsset = $t04987150024._5 | |
1296 | + | let bonus = $t04987150024._4 | |
1297 | + | let feeAmount = $t04987150024._3 | |
1298 | + | let commonState = $t04987150024._2 | |
1299 | + | let amountEstimated = $t04987150024._1 | |
1267 | 1300 | let amount = if (if ((minOutAmount > 0)) | |
1268 | 1301 | then (minOutAmount > amountEstimated) | |
1269 | 1302 | else false) | |
1275 | 1308 | case _ => | |
1276 | 1309 | throw("error lease config") | |
1277 | 1310 | } | |
1278 | - | let $t04924349357 = lsConf | |
1279 | - | let isLeasable = $t04924349357._1 | |
1280 | - | let leasedRatio = $t04924349357._2 | |
1281 | - | let minBalance = $t04924349357._3 | |
1282 | - | let proxyAddress = $t04924349357._4 | |
1283 | - | let proxyAssetId = $t04924349357._5 | |
1284 | - | let proxyRateMul = $t04924349357._6 | |
1285 | - | let stakingProfitAddress = $t04924349357._7 | |
1286 | - | let assetOnPool = assetBalance(this, fromBase58String(outAssetIdStr)) | |
1287 | - | let amountOfProfit = if (if ((outAssetIdStr == "WAVES")) | |
1288 | - | then (amount > assetOnPool) | |
1289 | - | else false) | |
1290 | - | then { | |
1291 | - | let amountDiff = (amount - assetOnPool) | |
1292 | - | let oldRatio = (getAdditionalBalance(outAssetIdStr) / getStakingAssetBalance(sWavesId())) | |
1293 | - | let oldWavesRoughBalane = wavesBalance(this).available | |
1294 | - | let wd = invoke(this, "withdraw", [outAssetIdStr, amountDiff, sWavesId(), sWavesProxy(), proxyRateMul], nil) | |
1295 | - | if ((wd == wd)) | |
1296 | - | then { | |
1297 | - | let newWavesRoughBalane = wavesBalance(this).available | |
1298 | - | let wavesDiff = (newWavesRoughBalane - oldWavesRoughBalane) | |
1299 | - | (wavesDiff - amountDiff) | |
1300 | - | } | |
1301 | - | else throw("Strict value is not equal to itself.") | |
1302 | - | } | |
1303 | - | else 0 | |
1304 | - | let profitTransfer = [ScriptTransfer(addressFromStringValue(stakingProfitAddress), amountOfProfit, unit)] | |
1305 | 1311 | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
1306 | 1312 | if ((burnInv == burnInv)) | |
1307 | 1313 | then { | |
1308 | - | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
1309 | - | let sendFee = if ((feeAmount > 0)) | |
1310 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1311 | - | else nil | |
1312 | - | let $t05039650643 = { | |
1313 | - | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1314 | - | then 0 | |
1315 | - | else feeAmount | |
1316 | - | if (outInAmountAsset) | |
1317 | - | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1318 | - | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1319 | - | } | |
1320 | - | let amountAssetBalanceDelta = $t05039650643._1 | |
1321 | - | let priceAssetBalanceDelta = $t05039650643._2 | |
1322 | - | let $t05064650754 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1323 | - | let refreshKLpActions = $t05064650754._1 | |
1324 | - | let updatedKLp = $t05064650754._2 | |
1325 | - | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1326 | - | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1314 | + | let withdrawState = getWithdrawAssetState(outAssetIdStr, amount) | |
1315 | + | if ((withdrawState == withdrawState)) | |
1327 | 1316 | then { | |
1328 | - | let reb = invoke(this, "rebalance", nil, nil) | |
1329 | - | if ((reb == reb)) | |
1330 | - | then $Tuple2(((((commonState ++ assetTransfer) ++ profitTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1317 | + | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
1318 | + | let sendFee = if ((feeAmount > 0)) | |
1319 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1320 | + | else nil | |
1321 | + | let $t05078051027 = { | |
1322 | + | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1323 | + | then 0 | |
1324 | + | else feeAmount | |
1325 | + | if (outInAmountAsset) | |
1326 | + | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1327 | + | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1328 | + | } | |
1329 | + | let amountAssetBalanceDelta = $t05078051027._1 | |
1330 | + | let priceAssetBalanceDelta = $t05078051027._2 | |
1331 | + | let $t05103051138 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1332 | + | let refreshKLpActions = $t05103051138._1 | |
1333 | + | let updatedKLp = $t05103051138._2 | |
1334 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1335 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1336 | + | then { | |
1337 | + | let reb = invoke(this, "rebalance", nil, nil) | |
1338 | + | if ((reb == reb)) | |
1339 | + | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1340 | + | else throw("Strict value is not equal to itself.") | |
1341 | + | } | |
1331 | 1342 | else throw("Strict value is not equal to itself.") | |
1332 | 1343 | } | |
1333 | 1344 | else throw("Strict value is not equal to itself.") | |
1345 | 1356 | ||
1346 | 1357 | @Callable(i) | |
1347 | 1358 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
1348 | - | let $ | |
1349 | - | let amountEstimated = $ | |
1350 | - | let commonState = $ | |
1351 | - | let feeAmount = $ | |
1352 | - | let bonus = $ | |
1353 | - | let outInAmountAsset = $ | |
1359 | + | let $t05144351599 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
1360 | + | let amountEstimated = $t05144351599._1 | |
1361 | + | let commonState = $t05144351599._2 | |
1362 | + | let feeAmount = $t05144351599._3 | |
1363 | + | let bonus = $t05144351599._4 | |
1364 | + | let outInAmountAsset = $t05144351599._5 | |
1354 | 1365 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
1355 | 1366 | } | |
1356 | 1367 | ||
1387 | 1398 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1388 | 1399 | if ((unstakeInv == unstakeInv)) | |
1389 | 1400 | then { | |
1390 | - | let $ | |
1391 | - | if (($ | |
1401 | + | let $t05250452655 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
1402 | + | if (($t05250452655 == $t05250452655)) | |
1392 | 1403 | then { | |
1393 | - | let outInAmountAsset = $ | |
1394 | - | let bonus = $ | |
1395 | - | let feeAmount = $ | |
1396 | - | let commonState = $ | |
1397 | - | let amountEstimated = $ | |
1404 | + | let outInAmountAsset = $t05250452655._5 | |
1405 | + | let bonus = $t05250452655._4 | |
1406 | + | let feeAmount = $t05250452655._3 | |
1407 | + | let commonState = $t05250452655._2 | |
1408 | + | let amountEstimated = $t05250452655._1 | |
1398 | 1409 | let amount = if (if ((minOutAmount > 0)) | |
1399 | 1410 | then (minOutAmount > amountEstimated) | |
1400 | 1411 | else false) | |
1403 | 1414 | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1404 | 1415 | if ((burnInv == burnInv)) | |
1405 | 1416 | then { | |
1406 | - | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
1407 | - | let sendFee = if ((feeAmount > 0)) | |
1408 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1409 | - | else nil | |
1410 | - | let $t05278853035 = { | |
1411 | - | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1412 | - | then 0 | |
1413 | - | else feeAmount | |
1414 | - | if (outInAmountAsset) | |
1415 | - | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1416 | - | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1417 | - | } | |
1418 | - | let amountAssetBalanceDelta = $t05278853035._1 | |
1419 | - | let priceAssetBalanceDelta = $t05278853035._2 | |
1420 | - | let $t05303853146 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1421 | - | let refreshKLpActions = $t05303853146._1 | |
1422 | - | let updatedKLp = $t05303853146._2 | |
1423 | - | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1424 | - | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1425 | - | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1417 | + | let withdrawState = getWithdrawAssetState(outAssetIdStr, amount) | |
1418 | + | if ((withdrawState == withdrawState)) | |
1419 | + | then { | |
1420 | + | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
1421 | + | let sendFee = if ((feeAmount > 0)) | |
1422 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1423 | + | else nil | |
1424 | + | let $t05322053467 = { | |
1425 | + | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1426 | + | then 0 | |
1427 | + | else feeAmount | |
1428 | + | if (outInAmountAsset) | |
1429 | + | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1430 | + | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1431 | + | } | |
1432 | + | let amountAssetBalanceDelta = $t05322053467._1 | |
1433 | + | let priceAssetBalanceDelta = $t05322053467._2 | |
1434 | + | let $t05347053578 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1435 | + | let refreshKLpActions = $t05347053578._1 | |
1436 | + | let updatedKLp = $t05347053578._2 | |
1437 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1438 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1439 | + | then { | |
1440 | + | let reb = invoke(this, "rebalance", nil, nil) | |
1441 | + | if ((reb == reb)) | |
1442 | + | then $Tuple2(((((commonState ++ withdrawState) ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1443 | + | else throw("Strict value is not equal to itself.") | |
1444 | + | } | |
1445 | + | else throw("Strict value is not equal to itself.") | |
1446 | + | } | |
1426 | 1447 | else throw("Strict value is not equal to itself.") | |
1427 | 1448 | } | |
1428 | 1449 | else throw("Strict value is not equal to itself.") | |
1452 | 1473 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1453 | 1474 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1454 | 1475 | then { | |
1455 | - | let $ | |
1456 | - | let refreshKLpActions = $ | |
1457 | - | let updatedKLp = $ | |
1476 | + | let $t05459254674 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1477 | + | let refreshKLpActions = $t05459254674._1 | |
1478 | + | let updatedKLp = $t05459254674._2 | |
1458 | 1479 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1459 | 1480 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1460 | 1481 | then (state ++ refreshKLpActions) | |
1486 | 1507 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1487 | 1508 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1488 | 1509 | then { | |
1489 | - | let $ | |
1490 | - | let refreshKLpActions = $ | |
1491 | - | let updatedKLp = $ | |
1510 | + | let $t05562355704 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1511 | + | let refreshKLpActions = $t05562355704._1 | |
1512 | + | let updatedKLp = $t05562355704._2 | |
1492 | 1513 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1493 | 1514 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1494 | 1515 | then (state ++ refreshKLpActions) | |
1532 | 1553 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1533 | 1554 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1534 | 1555 | then { | |
1535 | - | let $ | |
1536 | - | let refreshKLpActions = $ | |
1537 | - | let updatedKLp = $ | |
1556 | + | let $t05683056911 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1557 | + | let refreshKLpActions = $t05683056911._1 | |
1558 | + | let updatedKLp = $t05683056911._2 | |
1538 | 1559 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1539 | 1560 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1540 | 1561 | then (state ++ refreshKLpActions) | |
1585 | 1606 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1586 | 1607 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1587 | 1608 | then { | |
1588 | - | let $ | |
1589 | - | let refreshKLpActions = $ | |
1590 | - | let updatedKLp = $ | |
1609 | + | let $t05820658287 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1610 | + | let refreshKLpActions = $t05820658287._1 | |
1611 | + | let updatedKLp = $t05820658287._2 | |
1591 | 1612 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1592 | 1613 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1593 | 1614 | then (state ++ refreshKLpActions) | |
1622 | 1643 | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1623 | 1644 | then { | |
1624 | 1645 | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
1625 | - | let $ | |
1626 | - | let kLpUpdateActions = $ | |
1627 | - | let updatedKLp = $ | |
1646 | + | let $t05947459538 = refreshKLpInternal(0, 0, 0) | |
1647 | + | let kLpUpdateActions = $t05947459538._1 | |
1648 | + | let updatedKLp = $t05947459538._2 | |
1628 | 1649 | let actions = if ((kLp != updatedKLp)) | |
1629 | 1650 | then kLpUpdateActions | |
1630 | 1651 | else throwErr("nothing to refresh") | |
1799 | 1820 | match tx { | |
1800 | 1821 | case order: Order => | |
1801 | 1822 | let matcherPub = getMatcherPubOrFail() | |
1802 | - | let $ | |
1803 | - | let orderValid = $ | |
1804 | - | let orderValidInfo = $ | |
1823 | + | let $t06820068269 = validateMatcherOrderAllowed(order) | |
1824 | + | let orderValid = $t06820068269._1 | |
1825 | + | let orderValidInfo = $t06820068269._2 | |
1805 | 1826 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1806 | 1827 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1807 | 1828 | if (if (if (orderValid) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let lPdecimals = 8 | |
5 | 5 | ||
6 | 6 | let scale8 = 100000000 | |
7 | 7 | ||
8 | 8 | let scale8BigInt = toBigInt(100000000) | |
9 | 9 | ||
10 | 10 | let scale18 = toBigInt(1000000000000000000) | |
11 | 11 | ||
12 | 12 | let zeroBigInt = toBigInt(0) | |
13 | 13 | ||
14 | 14 | let big0 = toBigInt(0) | |
15 | 15 | ||
16 | 16 | let big1 = toBigInt(1) | |
17 | 17 | ||
18 | 18 | let big2 = toBigInt(2) | |
19 | 19 | ||
20 | 20 | let wavesString = "WAVES" | |
21 | 21 | ||
22 | 22 | let SEP = "__" | |
23 | 23 | ||
24 | 24 | let PoolActive = 1 | |
25 | 25 | ||
26 | 26 | let PoolPutDisabled = 2 | |
27 | 27 | ||
28 | 28 | let PoolMatcherDisabled = 3 | |
29 | 29 | ||
30 | 30 | let PoolShutdown = 4 | |
31 | 31 | ||
32 | 32 | let idxPoolAddress = 1 | |
33 | 33 | ||
34 | 34 | let idxPoolStatus = 2 | |
35 | 35 | ||
36 | 36 | let idxPoolLPAssetId = 3 | |
37 | 37 | ||
38 | 38 | let idxAmtAssetId = 4 | |
39 | 39 | ||
40 | 40 | let idxPriceAssetId = 5 | |
41 | 41 | ||
42 | 42 | let idxAmtAssetDcm = 6 | |
43 | 43 | ||
44 | 44 | let idxPriceAssetDcm = 7 | |
45 | 45 | ||
46 | 46 | let idxIAmtAssetId = 8 | |
47 | 47 | ||
48 | 48 | let idxIPriceAssetId = 9 | |
49 | 49 | ||
50 | 50 | let idxLPAssetDcm = 10 | |
51 | 51 | ||
52 | 52 | let idxPoolAmtAssetAmt = 1 | |
53 | 53 | ||
54 | 54 | let idxPoolPriceAssetAmt = 2 | |
55 | 55 | ||
56 | 56 | let idxPoolLPAssetAmt = 3 | |
57 | 57 | ||
58 | 58 | let idxFactoryStakingContract = 1 | |
59 | 59 | ||
60 | 60 | let idxFactorySlippageContract = 7 | |
61 | 61 | ||
62 | 62 | func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult)) | |
63 | 63 | ||
64 | 64 | ||
65 | 65 | func toX18BigInt (origVal,origScaleMult) = fraction(origVal, scale18, origScaleMult) | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18)) | |
69 | 69 | ||
70 | 70 | ||
71 | 71 | func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round)) | |
72 | 72 | ||
73 | 73 | ||
74 | 74 | func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
75 | 75 | ||
76 | 76 | ||
77 | 77 | func abs (val) = if ((0 > val)) | |
78 | 78 | then -(val) | |
79 | 79 | else val | |
80 | 80 | ||
81 | 81 | ||
82 | 82 | func absBigInt (val) = if ((zeroBigInt > val)) | |
83 | 83 | then -(val) | |
84 | 84 | else val | |
85 | 85 | ||
86 | 86 | ||
87 | 87 | func swapContract () = "%s__swapContract" | |
88 | 88 | ||
89 | 89 | ||
90 | 90 | func fc () = "%s__factoryContract" | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | func mpk () = "%s__managerPublicKey" | |
94 | 94 | ||
95 | 95 | ||
96 | 96 | func pmpk () = "%s__pendingManagerPublicKey" | |
97 | 97 | ||
98 | 98 | ||
99 | 99 | func pl () = "%s%s__price__last" | |
100 | 100 | ||
101 | 101 | ||
102 | 102 | func ph (h,timestamp) = makeString(["%s%s%d%d__price__history", toString(h), toString(timestamp)], SEP) | |
103 | 103 | ||
104 | 104 | ||
105 | 105 | func pau (userAddress,txId) = ((("%s%s%s__P__" + userAddress) + "__") + txId) | |
106 | 106 | ||
107 | 107 | ||
108 | 108 | func gau (userAddress,txId) = ((("%s%s%s__G__" + userAddress) + "__") + txId) | |
109 | 109 | ||
110 | 110 | ||
111 | 111 | func aa () = "%s__amountAsset" | |
112 | 112 | ||
113 | 113 | ||
114 | 114 | func pa () = "%s__priceAsset" | |
115 | 115 | ||
116 | 116 | ||
117 | 117 | let keyFee = "%s__fee" | |
118 | 118 | ||
119 | 119 | let feeDefault = fraction(10, scale8, 10000) | |
120 | 120 | ||
121 | 121 | let fee = valueOrElse(getInteger(this, keyFee), feeDefault) | |
122 | 122 | ||
123 | 123 | let keyKLp = makeString(["%s", "kLp"], SEP) | |
124 | 124 | ||
125 | 125 | let keyKLpRefreshedHeight = makeString(["%s", "kLpRefreshedHeight"], SEP) | |
126 | 126 | ||
127 | 127 | let keyKLpRefreshDelay = makeString(["%s", "refreshKLpDelay"], SEP) | |
128 | 128 | ||
129 | 129 | let kLpRefreshDelayDefault = 30 | |
130 | 130 | ||
131 | 131 | let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault) | |
132 | 132 | ||
133 | 133 | func keySWavesAssetId () = "%s__sWavesAssetId" | |
134 | 134 | ||
135 | 135 | ||
136 | 136 | func keySWavesProxyAddress () = "%s__sWavesProxyAddress" | |
137 | 137 | ||
138 | 138 | ||
139 | 139 | func keyAdditionalBalance (assetId) = makeString(["%s%s", "additionalBalance", assetId], SEP) | |
140 | 140 | ||
141 | 141 | ||
142 | 142 | func keyStakingAssetBalance (assetId) = makeString(["%s%s", "stakingAssetBalance", assetId], SEP) | |
143 | 143 | ||
144 | 144 | ||
145 | 145 | func getAdditionalBalance (assetId) = valueOrElse(getInteger(this, keyAdditionalBalance(assetId)), 0) | |
146 | 146 | ||
147 | 147 | ||
148 | 148 | func getStakingAssetBalance (assetId) = valueOrElse(getInteger(this, keyStakingAssetBalance(assetId)), 0) | |
149 | 149 | ||
150 | 150 | ||
151 | 151 | func keyFactoryConfig () = "%s__factoryConfig" | |
152 | 152 | ||
153 | 153 | ||
154 | 154 | func keyMatcherPub () = "%s%s__matcher__publicKey" | |
155 | 155 | ||
156 | 156 | ||
157 | 157 | func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset") | |
158 | 158 | ||
159 | 159 | ||
160 | 160 | func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config") | |
161 | 161 | ||
162 | 162 | ||
163 | 163 | func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr) | |
164 | 164 | ||
165 | 165 | ||
166 | 166 | func keyAllPoolsShutdown () = "%s__shutdown" | |
167 | 167 | ||
168 | 168 | ||
169 | 169 | func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress) | |
170 | 170 | ||
171 | 171 | ||
172 | 172 | func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash" | |
173 | 173 | ||
174 | 174 | ||
175 | 175 | let keyFeeCollectorAddress = "%s__feeCollectorAddress" | |
176 | 176 | ||
177 | 177 | func throwOrderError (orderValid,orderValidInfo,senderValid,matcherValid) = throw((((((((("order validation failed: orderValid=" + toString(orderValid)) + " (") + orderValidInfo) + ")") + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid))) | |
178 | 178 | ||
179 | 179 | ||
180 | 180 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
181 | 181 | ||
182 | 182 | ||
183 | 183 | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
184 | 184 | ||
185 | 185 | ||
186 | 186 | func throwErr (msg) = throw(makeString(["lp.ride:", msg], " ")) | |
187 | 187 | ||
188 | 188 | ||
189 | 189 | func fmtErr (msg) = makeString(["lp.ride:", msg], " ") | |
190 | 190 | ||
191 | 191 | ||
192 | 192 | let factoryContract = addressFromStringValue(getStringOrFail(this, fc())) | |
193 | 193 | ||
194 | 194 | let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress)) | |
195 | 195 | ||
196 | 196 | let inFee = { | |
197 | 197 | let @ = invoke(factoryContract, "getInFeeREADONLY", [toString(this)], nil) | |
198 | 198 | if ($isInstanceOf(@, "Int")) | |
199 | 199 | then @ | |
200 | 200 | else throw(($getType(@) + " couldn't be cast to Int")) | |
201 | 201 | } | |
202 | 202 | ||
203 | 203 | let outFee = { | |
204 | 204 | let @ = invoke(factoryContract, "getOutFeeREADONLY", [toString(this)], nil) | |
205 | 205 | if ($isInstanceOf(@, "Int")) | |
206 | 206 | then @ | |
207 | 207 | else throw(($getType(@) + " couldn't be cast to Int")) | |
208 | 208 | } | |
209 | 209 | ||
210 | 210 | func sWavesId () = getStringOrFail(factoryContract, keySWavesAssetId()) | |
211 | 211 | ||
212 | 212 | ||
213 | 213 | func sWavesProxy () = getStringOrFail(factoryContract, keySWavesProxyAddress()) | |
214 | 214 | ||
215 | 215 | ||
216 | 216 | func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false) | |
217 | 217 | ||
218 | 218 | ||
219 | 219 | func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub())) | |
220 | 220 | ||
221 | 221 | ||
222 | 222 | func getPoolConfig () = { | |
223 | 223 | let amtAsset = getStringOrFail(this, aa()) | |
224 | 224 | let priceAsset = getStringOrFail(this, pa()) | |
225 | 225 | let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset)) | |
226 | 226 | let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset)) | |
227 | 227 | split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP) | |
228 | 228 | } | |
229 | 229 | ||
230 | 230 | ||
231 | 231 | func parseAssetId (input) = if ((input == wavesString)) | |
232 | 232 | then unit | |
233 | 233 | else fromBase58String(input) | |
234 | 234 | ||
235 | 235 | ||
236 | 236 | func assetIdToString (input) = if ((input == unit)) | |
237 | 237 | then wavesString | |
238 | 238 | else toBase58String(value(input)) | |
239 | 239 | ||
240 | 240 | ||
241 | 241 | 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])) | |
242 | 242 | ||
243 | 243 | ||
244 | 244 | let poolConfigParsed = parsePoolConfig(getPoolConfig()) | |
245 | 245 | ||
246 | - | let $ | |
246 | + | let $t092859451 = poolConfigParsed | |
247 | 247 | ||
248 | - | let cfgPoolAddress = $ | |
248 | + | let cfgPoolAddress = $t092859451._1 | |
249 | 249 | ||
250 | - | let cfgPoolStatus = $ | |
250 | + | let cfgPoolStatus = $t092859451._2 | |
251 | 251 | ||
252 | - | let cfgLpAssetId = $ | |
252 | + | let cfgLpAssetId = $t092859451._3 | |
253 | 253 | ||
254 | - | let cfgAmountAssetId = $ | |
254 | + | let cfgAmountAssetId = $t092859451._4 | |
255 | 255 | ||
256 | - | let cfgPriceAssetId = $ | |
256 | + | let cfgPriceAssetId = $t092859451._5 | |
257 | 257 | ||
258 | - | let cfgAmountAssetDecimals = $ | |
258 | + | let cfgAmountAssetDecimals = $t092859451._6 | |
259 | 259 | ||
260 | - | let cfgPriceAssetDecimals = $ | |
260 | + | let cfgPriceAssetDecimals = $t092859451._7 | |
261 | 261 | ||
262 | 262 | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
263 | 263 | ||
264 | 264 | ||
265 | 265 | let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address") | |
266 | 266 | ||
267 | 267 | let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address") | |
268 | 268 | ||
269 | 269 | 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) | |
270 | 270 | ||
271 | 271 | ||
272 | 272 | 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) | |
273 | 273 | ||
274 | 274 | ||
275 | 275 | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
276 | 276 | then (wavesBalance(this).available + getAdditionalBalance(assetId)) | |
277 | 277 | else if ((assetId == sWavesId())) | |
278 | 278 | then { | |
279 | 279 | let amtAsset = getStringOrFail(this, aa()) | |
280 | 280 | let priceAsset = getStringOrFail(this, pa()) | |
281 | 281 | if (if (if ((amtAsset == "WAVES")) | |
282 | 282 | then (priceAsset == sWavesId()) | |
283 | 283 | else false) | |
284 | 284 | then true | |
285 | 285 | else if ((priceAsset == "WAVES")) | |
286 | 286 | then (amtAsset == sWavesId()) | |
287 | 287 | else false) | |
288 | 288 | then assetBalance(this, fromBase58String(assetId)) | |
289 | 289 | else (assetBalance(this, fromBase58String(assetId)) + getStakingAssetBalance(assetId)) | |
290 | 290 | } | |
291 | 291 | else assetBalance(this, fromBase58String(assetId)) | |
292 | 292 | ||
293 | 293 | ||
294 | 294 | func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
295 | 295 | ||
296 | 296 | ||
297 | 297 | func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round) | |
298 | 298 | ||
299 | 299 | ||
300 | 300 | func getRate (proxy) = { | |
301 | 301 | let inv = invoke(proxy, "getRate", nil, nil) | |
302 | 302 | if ((inv == inv)) | |
303 | 303 | then match inv { | |
304 | 304 | case r: Int => | |
305 | 305 | r | |
306 | 306 | case _ => | |
307 | 307 | throwErr("proxy.getRate() unexpected value") | |
308 | 308 | } | |
309 | 309 | else throw("Strict value is not equal to itself.") | |
310 | 310 | } | |
311 | 311 | ||
312 | 312 | ||
313 | 313 | func deposit (assetId,amount,stakingAssetId,proxy) = { | |
314 | 314 | let currentAdditionalBalance = getAdditionalBalance(assetId) | |
315 | 315 | if ((currentAdditionalBalance == currentAdditionalBalance)) | |
316 | 316 | then { | |
317 | 317 | let currentStakingAssetBalance = getStakingAssetBalance(stakingAssetId) | |
318 | 318 | if ((currentStakingAssetBalance == currentStakingAssetBalance)) | |
319 | 319 | then { | |
320 | 320 | let asset = parseAssetId(assetId) | |
321 | 321 | if ((amount > 0)) | |
322 | 322 | then { | |
323 | 323 | let depositInvoke = invoke(proxy, "deposit", nil, [AttachedPayment(asset, amount)]) | |
324 | 324 | if ((depositInvoke == depositInvoke)) | |
325 | 325 | then match depositInvoke { | |
326 | 326 | case receivedStakingAsset: Int => | |
327 | 327 | let newAdditionalBalance = (currentAdditionalBalance + amount) | |
328 | 328 | let newStakingAssetBalance = (currentStakingAssetBalance + receivedStakingAsset) | |
329 | 329 | [IntegerEntry(keyAdditionalBalance(assetId), newAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance)] | |
330 | 330 | case _ => | |
331 | 331 | nil | |
332 | 332 | } | |
333 | 333 | else throw("Strict value is not equal to itself.") | |
334 | 334 | } | |
335 | 335 | else nil | |
336 | 336 | } | |
337 | 337 | else throw("Strict value is not equal to itself.") | |
338 | 338 | } | |
339 | 339 | else throw("Strict value is not equal to itself.") | |
340 | 340 | } | |
341 | 341 | ||
342 | 342 | ||
343 | - | func withdraw (assetId,amount,stakingAssetId,proxy,proxyRateMul) = { | |
343 | + | func withdraw (assetId,amount,stakingAssetId,proxy,proxyRateMul,profitAddress) = { | |
344 | 344 | let currentAdditionalBalance = getAdditionalBalance(assetId) | |
345 | 345 | if ((currentAdditionalBalance == currentAdditionalBalance)) | |
346 | 346 | then { | |
347 | 347 | let currentStakingAssetBalance = getStakingAssetBalance(stakingAssetId) | |
348 | 348 | if ((currentStakingAssetBalance == currentStakingAssetBalance)) | |
349 | 349 | then { | |
350 | 350 | let currentProxyRate = getRate(proxy) | |
351 | 351 | if ((currentProxyRate == currentProxyRate)) | |
352 | 352 | then { | |
353 | + | let oldRate = fraction(proxyRateMul, currentAdditionalBalance, currentStakingAssetBalance) | |
353 | 354 | let stakingAsset = parseAssetId(stakingAssetId) | |
355 | + | let oldSendStakingAmount = fraction(proxyRateMul, amount, oldRate) | |
354 | 356 | let sendStakingAssetAmount = fraction(proxyRateMul, amount, currentProxyRate) | |
357 | + | let profitAmount = max([0, (oldSendStakingAmount - sendStakingAssetAmount)]) | |
355 | 358 | if ((sendStakingAssetAmount > 0)) | |
356 | 359 | then { | |
357 | 360 | let withdrawInvoke = invoke(proxy, "withdraw", nil, [AttachedPayment(stakingAsset, sendStakingAssetAmount)]) | |
358 | 361 | if ((withdrawInvoke == withdrawInvoke)) | |
359 | 362 | then match withdrawInvoke { | |
360 | 363 | case receivedAssets: Int => | |
361 | 364 | let newAdditionalBalance = (currentAdditionalBalance - receivedAssets) | |
362 | - | let newStakingAssetBalance = (currentStakingAssetBalance - sendStakingAssetAmount) | |
363 | - | [IntegerEntry(keyAdditionalBalance(assetId), newAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance)] | |
365 | + | let newStakingAssetBalance = ((currentStakingAssetBalance - sendStakingAssetAmount) - profitAmount) | |
366 | + | [IntegerEntry(keyAdditionalBalance(assetId), newAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance), ScriptTransfer(profitAddress, profitAmount, parseAssetId(stakingAssetId))] | |
364 | 367 | case _ => | |
365 | 368 | nil | |
366 | 369 | } | |
367 | 370 | else throw("Strict value is not equal to itself.") | |
368 | 371 | } | |
369 | 372 | else nil | |
370 | 373 | } | |
371 | 374 | else throw("Strict value is not equal to itself.") | |
372 | 375 | } | |
373 | 376 | else throw("Strict value is not equal to itself.") | |
374 | 377 | } | |
375 | 378 | else throw("Strict value is not equal to itself.") | |
376 | 379 | } | |
377 | 380 | ||
378 | 381 | ||
379 | 382 | func getLeaseProxyConfig (assetId) = invoke(factoryContract, "getPoolLeaseConfigREADONLY", [toString(this), assetId], nil) | |
380 | 383 | ||
381 | 384 | ||
382 | - | func rebalanceInternal (targetRatio,assetId,stakingAssetId,minBalance,proxy,proxyRateMul) = { | |
385 | + | func rebalanceInternal (targetRatio,assetId,stakingAssetId,minBalance,proxy,proxyRateMul,profitAddress) = { | |
383 | 386 | let currentAdditionalBalance = getAdditionalBalance(assetId) | |
384 | 387 | if ((currentAdditionalBalance == currentAdditionalBalance)) | |
385 | 388 | then { | |
386 | 389 | let currentStakingAssetBalance = getStakingAssetBalance(stakingAssetId) | |
387 | 390 | if ((currentStakingAssetBalance == currentStakingAssetBalance)) | |
388 | 391 | then { | |
389 | 392 | let availableBalance = match parseAssetId(assetId) { | |
390 | 393 | case b: ByteVector => | |
391 | 394 | assetBalance(this, b) | |
392 | 395 | case u: Unit => | |
393 | 396 | wavesBalance(this).available | |
394 | 397 | case _ => | |
395 | 398 | throw("Match error") | |
396 | 399 | } | |
397 | 400 | if ((availableBalance == availableBalance)) | |
398 | 401 | then { | |
399 | 402 | let wholeBalance = max([0, ((availableBalance + currentAdditionalBalance) - minBalance)]) | |
400 | 403 | let targetAdditionalBalance = fraction(targetRatio, wholeBalance, 100) | |
401 | 404 | let diff = (currentAdditionalBalance - targetAdditionalBalance) | |
402 | 405 | if ((diff == 0)) | |
403 | 406 | then nil | |
404 | 407 | else if ((0 > diff)) | |
405 | 408 | then { | |
406 | 409 | let sendAssetAmount = -(diff) | |
407 | 410 | deposit(assetId, sendAssetAmount, stakingAssetId, proxy) | |
408 | 411 | } | |
409 | 412 | else { | |
410 | 413 | let getAssetAmount = diff | |
411 | - | withdraw(assetId, getAssetAmount, stakingAssetId, proxy, proxyRateMul) | |
414 | + | withdraw(assetId, getAssetAmount, stakingAssetId, proxy, proxyRateMul, profitAddress) | |
412 | 415 | } | |
413 | 416 | } | |
414 | 417 | else throw("Strict value is not equal to itself.") | |
415 | 418 | } | |
416 | 419 | else throw("Strict value is not equal to itself.") | |
417 | 420 | } | |
418 | 421 | else throw("Strict value is not equal to itself.") | |
419 | 422 | } | |
420 | 423 | ||
421 | 424 | ||
422 | 425 | func rebalanceAsset (assetId) = match getLeaseProxyConfig(assetId) { | |
423 | 426 | case a: (Boolean, Int, Int, String, String, Int, String) => | |
424 | - | let $ | |
425 | - | let isLeasable = $ | |
426 | - | let leasedRatio = $ | |
427 | - | let minBalance = $ | |
428 | - | let proxyAddress = $ | |
429 | - | let proxyAssetId = $ | |
430 | - | let proxyRateMul = $ | |
431 | - | let stakingProfitAddress = $ | |
427 | + | let $t01605416163 = a | |
428 | + | let isLeasable = $t01605416163._1 | |
429 | + | let leasedRatio = $t01605416163._2 | |
430 | + | let minBalance = $t01605416163._3 | |
431 | + | let proxyAddress = $t01605416163._4 | |
432 | + | let proxyAssetId = $t01605416163._5 | |
433 | + | let proxyRateMul = $t01605416163._6 | |
434 | + | let stakingProfitAddress = $t01605416163._7 | |
432 | 435 | if (isLeasable) | |
433 | - | then rebalanceInternal(leasedRatio, assetId, proxyAssetId, minBalance, addressFromStringValue(proxyAddress), proxyRateMul) | |
436 | + | then rebalanceInternal(leasedRatio, assetId, proxyAssetId, minBalance, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress)) | |
434 | 437 | else nil | |
435 | 438 | case _ => | |
436 | 439 | throwErr((("[" + assetId) + "] Rebalance error")) | |
437 | 440 | } | |
441 | + | ||
442 | + | ||
443 | + | func withdrawAssetWrapper (assetId,amount) = match getLeaseProxyConfig(assetId) { | |
444 | + | case a: (Boolean, Int, Int, String, String, Int, String) => | |
445 | + | let $t01669316802 = a | |
446 | + | let isLeasable = $t01669316802._1 | |
447 | + | let leasedRatio = $t01669316802._2 | |
448 | + | let minBalance = $t01669316802._3 | |
449 | + | let proxyAddress = $t01669316802._4 | |
450 | + | let proxyAssetId = $t01669316802._5 | |
451 | + | let proxyRateMul = $t01669316802._6 | |
452 | + | let stakingProfitAddress = $t01669316802._7 | |
453 | + | if (isLeasable) | |
454 | + | then withdraw(assetId, amount, proxyAssetId, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress)) | |
455 | + | else nil | |
456 | + | case _ => | |
457 | + | throwErr((("[" + assetId) + "] withdrawAssetWrapper() error")) | |
458 | + | } | |
459 | + | ||
460 | + | ||
461 | + | func getWithdrawAssetState (assetId,amount) = { | |
462 | + | let assetOnPool = match parseAssetId(assetId) { | |
463 | + | case b: ByteVector => | |
464 | + | assetBalance(this, b) | |
465 | + | case w: Unit => | |
466 | + | wavesBalance(this).available | |
467 | + | case _ => | |
468 | + | throw("Match error") | |
469 | + | } | |
470 | + | if ((amount > assetOnPool)) | |
471 | + | then { | |
472 | + | let amountDiff = (amount - assetOnPool) | |
473 | + | withdrawAssetWrapper(assetId, amountDiff) | |
474 | + | } | |
475 | + | else nil | |
476 | + | } | |
438 | 477 | ||
439 | 478 | ||
440 | 479 | func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
441 | 480 | let amtAssetAmtX18 = toX18(amAmt, amAssetDcm) | |
442 | 481 | let priceAssetAmtX18 = toX18(prAmt, prAssetDcm) | |
443 | 482 | calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
444 | 483 | } | |
445 | 484 | ||
446 | 485 | ||
447 | 486 | func calcPrices (amAmt,prAmt,lpAmt) = { | |
448 | 487 | let cfg = getPoolConfig() | |
449 | 488 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
450 | 489 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
451 | 490 | let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt) | |
452 | 491 | let amAmtX18 = toX18(amAmt, amtAssetDcm) | |
453 | 492 | let prAmtX18 = toX18(prAmt, priceAssetDcm) | |
454 | 493 | let lpAmtX18 = toX18(lpAmt, scale8) | |
455 | 494 | let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18) | |
456 | 495 | let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18) | |
457 | 496 | [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18] | |
458 | 497 | } | |
459 | 498 | ||
460 | 499 | ||
461 | 500 | func calculatePrices (amAmt,prAmt,lpAmt) = { | |
462 | 501 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
463 | 502 | [fromX18(prices[0], scale8), fromX18(prices[1], scale8), fromX18(prices[2], scale8)] | |
464 | 503 | } | |
465 | 504 | ||
466 | 505 | ||
467 | 506 | func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
468 | 507 | let cfg = getPoolConfig() | |
469 | 508 | let lpAssetId = cfg[idxPoolLPAssetId] | |
470 | 509 | let amAssetId = cfg[idxAmtAssetId] | |
471 | 510 | let prAssetId = cfg[idxPriceAssetId] | |
472 | 511 | let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
473 | 512 | let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
474 | 513 | let poolStatus = cfg[idxPoolStatus] | |
475 | 514 | let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity | |
476 | 515 | if ((lpAssetId != pmtAssetId)) | |
477 | 516 | then throw("Invalid asset passed.") | |
478 | 517 | else { | |
479 | 518 | let amBalance = getAccBalance(amAssetId) | |
480 | 519 | let amBalanceX18 = toX18(amBalance, amAssetDcm) | |
481 | 520 | let prBalance = getAccBalance(prAssetId) | |
482 | 521 | let prBalanceX18 = toX18(prBalance, prAssetDcm) | |
483 | 522 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
484 | 523 | let curPrice = fromX18(curPriceX18, scale8) | |
485 | 524 | let pmtLpAmtX18 = toX18(pmtLpAmt, scale8) | |
486 | 525 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
487 | 526 | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
488 | 527 | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
489 | 528 | let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR) | |
490 | 529 | let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR) | |
491 | - | let state = if ((txId58 == "")) | |
492 | - | then nil | |
493 | - | else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
494 | - | then unit | |
495 | - | else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES")) | |
496 | - | then unit | |
497 | - | 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)] | |
498 | - | $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state) | |
530 | + | let AmAmtWithdrawState = getWithdrawAssetState(amAssetId, outAmAmt) | |
531 | + | if ((AmAmtWithdrawState == AmAmtWithdrawState)) | |
532 | + | then { | |
533 | + | let PrAmtWithdrawState = getWithdrawAssetState(prAssetId, outPrAmt) | |
534 | + | if ((PrAmtWithdrawState == PrAmtWithdrawState)) | |
535 | + | then { | |
536 | + | let reb = invoke(this, "rebalance", nil, nil) | |
537 | + | if ((reb == reb)) | |
538 | + | then { | |
539 | + | let state = if ((txId58 == "")) | |
540 | + | then nil | |
541 | + | else ((AmAmtWithdrawState ++ PrAmtWithdrawState) ++ [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
542 | + | then unit | |
543 | + | else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES")) | |
544 | + | then unit | |
545 | + | 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)]) | |
546 | + | $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state) | |
547 | + | } | |
548 | + | else throw("Strict value is not equal to itself.") | |
549 | + | } | |
550 | + | else throw("Strict value is not equal to itself.") | |
551 | + | } | |
552 | + | else throw("Strict value is not equal to itself.") | |
499 | 553 | } | |
500 | 554 | } | |
501 | 555 | ||
502 | 556 | ||
503 | 557 | func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = { | |
504 | 558 | let cfg = getPoolConfig() | |
505 | 559 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
506 | 560 | let amAssetIdStr = cfg[idxAmtAssetId] | |
507 | 561 | let prAssetIdStr = cfg[idxPriceAssetId] | |
508 | 562 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
509 | 563 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
510 | 564 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
511 | 565 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
512 | 566 | let poolStatus = cfg[idxPoolStatus] | |
513 | 567 | let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
514 | 568 | let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES"))) | |
515 | 569 | let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES"))) | |
516 | 570 | if (if ((amAssetIdStr != inAmAssetIdStr)) | |
517 | 571 | then true | |
518 | 572 | else (prAssetIdStr != inPrAssetIdStr)) | |
519 | 573 | then throw("Invalid amt or price asset passed.") | |
520 | 574 | else { | |
521 | 575 | let amBalance = if (isEvaluate) | |
522 | 576 | then getAccBalance(amAssetIdStr) | |
523 | 577 | else (getAccBalance(amAssetIdStr) - inAmAssetAmt) | |
524 | 578 | let prBalance = if (isEvaluate) | |
525 | 579 | then getAccBalance(prAssetIdStr) | |
526 | 580 | else (getAccBalance(prAssetIdStr) - inPrAssetAmt) | |
527 | 581 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
528 | 582 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
529 | 583 | let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18) | |
530 | 584 | let amBalanceX18 = toX18(amBalance, amtAssetDcm) | |
531 | 585 | let prBalanceX18 = toX18(prBalance, priceAssetDcm) | |
532 | 586 | let res = if ((lpEmission == 0)) | |
533 | 587 | then { | |
534 | 588 | let curPriceX18 = zeroBigInt | |
535 | 589 | let slippageX18 = zeroBigInt | |
536 | 590 | let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN) | |
537 | 591 | $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
538 | 592 | } | |
539 | 593 | else { | |
540 | 594 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
541 | 595 | let slippageX18 = fraction(absBigInt((curPriceX18 - userPriceX18)), scale18, curPriceX18) | |
542 | 596 | let slippageToleranceX18 = toX18(slippageTolerance, scale8) | |
543 | 597 | if (if ((curPriceX18 != zeroBigInt)) | |
544 | 598 | then (slippageX18 > slippageToleranceX18) | |
545 | 599 | else false) | |
546 | 600 | then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18))) | |
547 | 601 | else { | |
548 | 602 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
549 | 603 | let prViaAmX18 = fraction(inAmAssetAmtX18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING) | |
550 | 604 | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, FLOOR), CEILING) | |
551 | 605 | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
552 | 606 | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
553 | 607 | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
554 | 608 | let expAmtAssetAmtX18 = expectedAmts._1 | |
555 | 609 | let expPriceAssetAmtX18 = expectedAmts._2 | |
556 | 610 | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR) | |
557 | 611 | $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtAssetDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceAssetDcm, CEILING), curPriceX18, slippageX18) | |
558 | 612 | } | |
559 | 613 | } | |
560 | 614 | let calcLpAmt = res._1 | |
561 | 615 | let calcAmAssetPmt = res._2 | |
562 | 616 | let calcPrAssetPmt = res._3 | |
563 | 617 | let curPrice = fromX18(res._4, scale8) | |
564 | 618 | let slippageCalc = fromX18(res._5, scale8) | |
565 | 619 | if ((0 >= calcLpAmt)) | |
566 | 620 | then throw("Invalid calculations. LP calculated is less than zero.") | |
567 | 621 | else { | |
568 | 622 | let emitLpAmt = if (!(emitLp)) | |
569 | 623 | then 0 | |
570 | 624 | else calcLpAmt | |
571 | 625 | let amDiff = (inAmAssetAmt - calcAmAssetPmt) | |
572 | 626 | let prDiff = (inPrAssetAmt - calcPrAssetPmt) | |
573 | 627 | 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))] | |
574 | 628 | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId) | |
575 | 629 | } | |
576 | 630 | } | |
577 | 631 | } | |
578 | 632 | ||
579 | 633 | ||
580 | 634 | func calcKLp (amountBalance,priceBalance,lpEmission) = { | |
581 | 635 | let amountBalanceX18 = toX18BigInt(amountBalance, toBigInt(cfgAmountAssetDecimals)) | |
582 | 636 | let priceBalanceX18 = toX18BigInt(priceBalance, toBigInt(cfgPriceAssetDecimals)) | |
583 | 637 | let updatedKLp = fraction(pow((amountBalanceX18 * priceBalanceX18), 0, toBigInt(5), 1, 18, DOWN), big1, lpEmission) | |
584 | 638 | if ((lpEmission == big0)) | |
585 | 639 | then big0 | |
586 | 640 | else updatedKLp | |
587 | 641 | } | |
588 | 642 | ||
589 | 643 | ||
590 | 644 | func calcCurrentKLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = { | |
591 | 645 | let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta) | |
592 | 646 | let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta) | |
593 | 647 | let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta) | |
594 | 648 | let currentKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpAssetEmission) | |
595 | 649 | currentKLp | |
596 | 650 | } | |
597 | 651 | ||
598 | 652 | ||
599 | 653 | func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
600 | 654 | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
601 | 655 | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
602 | 656 | let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta) | |
603 | 657 | let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
604 | 658 | let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))] | |
605 | 659 | $Tuple2(actions, updatedKLp) | |
606 | 660 | } | |
607 | 661 | ||
608 | 662 | ||
609 | 663 | func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp)) | |
610 | 664 | then true | |
611 | 665 | else throwErr(makeString(["updated KLp lower than current KLp", toString(oldKLp), toString(updatedKLp)], " ")) | |
612 | 666 | ||
613 | 667 | ||
614 | 668 | func validateMatcherOrderAllowed (order) = { | |
615 | 669 | let amountAssetBalance = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
616 | 670 | let priceAssetBalance = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
617 | 671 | let amountAssetAmount = order.amount | |
618 | 672 | let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR) | |
619 | - | let $ | |
673 | + | let $t02904029252 = if ((order.orderType == Buy)) | |
620 | 674 | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
621 | 675 | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
622 | - | let amountAssetBalanceDelta = $ | |
623 | - | let priceAssetBalanceDelta = $ | |
676 | + | let amountAssetBalanceDelta = $t02904029252._1 | |
677 | + | let priceAssetBalanceDelta = $t02904029252._2 | |
624 | 678 | if (if (if (isGlobalShutdown()) | |
625 | 679 | then true | |
626 | 680 | else (cfgPoolStatus == PoolMatcherDisabled)) | |
627 | 681 | then true | |
628 | 682 | else (cfgPoolStatus == PoolShutdown)) | |
629 | 683 | then throw("Exchange operations disabled") | |
630 | 684 | else if (if ((order.assetPair.amountAsset != cfgAmountAssetId)) | |
631 | 685 | then true | |
632 | 686 | else (order.assetPair.priceAsset != cfgPriceAssetId)) | |
633 | 687 | then throw("Wrong order assets.") | |
634 | 688 | else { | |
635 | 689 | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
636 | - | let $ | |
637 | - | let unusedActions = $ | |
638 | - | let kLpNew = $ | |
690 | + | let $t02969229792 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
691 | + | let unusedActions = $t02969229792._1 | |
692 | + | let kLpNew = $t02969229792._2 | |
639 | 693 | let isOrderValid = (kLpNew >= kLp) | |
640 | 694 | let info = makeString(["kLp=", toString(kLp), " kLpNew=", toString(kLpNew), " amountAssetBalance=", toString(amountAssetBalance), " priceAssetBalance=", toString(priceAssetBalance), " amountAssetBalanceDelta=", toString(amountAssetBalanceDelta), " priceAssetBalanceDelta=", toString(priceAssetBalanceDelta), " height=", toString(height)], "") | |
641 | 695 | $Tuple2(isOrderValid, info) | |
642 | 696 | } | |
643 | 697 | } | |
644 | 698 | ||
645 | 699 | ||
646 | 700 | func commonGet (i) = if ((size(i.payments) != 1)) | |
647 | 701 | then throw("exactly 1 payment is expected") | |
648 | 702 | else { | |
649 | 703 | let pmt = value(i.payments[0]) | |
650 | 704 | let pmtAssetId = value(pmt.assetId) | |
651 | 705 | let pmtAmt = pmt.amount | |
652 | 706 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
653 | 707 | let outAmAmt = res._1 | |
654 | 708 | let outPrAmt = res._2 | |
655 | 709 | let poolStatus = parseIntValue(res._9) | |
656 | 710 | let state = res._10 | |
657 | 711 | if (if (isGlobalShutdown()) | |
658 | 712 | then true | |
659 | 713 | else (poolStatus == PoolShutdown)) | |
660 | 714 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
661 | 715 | else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state) | |
662 | 716 | } | |
663 | 717 | ||
664 | 718 | ||
665 | 719 | func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2)) | |
666 | 720 | then throw("exactly 2 payments are expected") | |
667 | 721 | else { | |
668 | 722 | let amAssetPmt = value(i.payments[0]) | |
669 | 723 | let prAssetPmt = value(i.payments[1]) | |
670 | 724 | let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp) | |
671 | 725 | let poolStatus = parseIntValue(estPut._8) | |
672 | 726 | if (if (if (isGlobalShutdown()) | |
673 | 727 | then true | |
674 | 728 | else (poolStatus == PoolPutDisabled)) | |
675 | 729 | then true | |
676 | 730 | else (poolStatus == PoolShutdown)) | |
677 | 731 | then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus))) | |
678 | 732 | else estPut | |
679 | 733 | } | |
680 | 734 | ||
681 | 735 | ||
682 | 736 | func emit (amount) = { | |
683 | 737 | let emitInv = invoke(factoryContract, "emit", [amount], nil) | |
684 | 738 | if ((emitInv == emitInv)) | |
685 | 739 | then { | |
686 | 740 | let emitInvLegacy = match emitInv { | |
687 | 741 | case legacyFactoryContract: Address => | |
688 | 742 | invoke(legacyFactoryContract, "emit", [amount], nil) | |
689 | 743 | case _ => | |
690 | 744 | unit | |
691 | 745 | } | |
692 | 746 | if ((emitInvLegacy == emitInvLegacy)) | |
693 | 747 | then amount | |
694 | 748 | else throw("Strict value is not equal to itself.") | |
695 | 749 | } | |
696 | 750 | else throw("Strict value is not equal to itself.") | |
697 | 751 | } | |
698 | 752 | ||
699 | 753 | ||
700 | 754 | func takeFee (amount,fee) = { | |
701 | 755 | let feeAmount = if ((fee == 0)) | |
702 | 756 | then 0 | |
703 | 757 | else fraction(amount, fee, scale8) | |
704 | 758 | $Tuple2((amount - feeAmount), feeAmount) | |
705 | 759 | } | |
706 | 760 | ||
707 | 761 | ||
708 | 762 | func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = { | |
709 | 763 | let isEval = (txId == unit) | |
710 | 764 | let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
711 | 765 | let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
712 | 766 | let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId)) | |
713 | 767 | then true | |
714 | 768 | else if ((paymentAssetId == cfgPriceAssetId)) | |
715 | 769 | then false | |
716 | 770 | else throwErr("invalid asset") | |
717 | - | let $ | |
771 | + | let $t03290533198 = if (isEval) | |
718 | 772 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
719 | 773 | else if (paymentInAmountAsset) | |
720 | 774 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
721 | 775 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
722 | - | let amountBalanceOld = $ | |
723 | - | let priceBalanceOld = $ | |
724 | - | let $ | |
776 | + | let amountBalanceOld = $t03290533198._1 | |
777 | + | let priceBalanceOld = $t03290533198._2 | |
778 | + | let $t03320233351 = if (paymentInAmountAsset) | |
725 | 779 | then $Tuple2(paymentAmountRaw, 0) | |
726 | 780 | else $Tuple2(0, paymentAmountRaw) | |
727 | - | let amountAssetAmountRaw = $ | |
728 | - | let priceAssetAmountRaw = $ | |
781 | + | let amountAssetAmountRaw = $t03320233351._1 | |
782 | + | let priceAssetAmountRaw = $t03320233351._2 | |
729 | 783 | let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1 | |
730 | 784 | let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1 | |
731 | - | let $ | |
732 | - | let paymentAmount = $ | |
733 | - | let feeAmount = $ | |
785 | + | let $t03348333547 = takeFee(paymentAmountRaw, inFee) | |
786 | + | let paymentAmount = $t03348333547._1 | |
787 | + | let feeAmount = $t03348333547._2 | |
734 | 788 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
735 | 789 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
736 | 790 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
737 | 791 | let priceNew = fromX18(priceNewX18, scale8) | |
738 | 792 | let paymentBalance = if (paymentInAmountAsset) | |
739 | 793 | then amountBalanceOld | |
740 | 794 | else priceBalanceOld | |
741 | 795 | let paymentBalanceBigInt = toBigInt(paymentBalance) | |
742 | 796 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
743 | 797 | let chechSupply = if ((supplyBigInt > big0)) | |
744 | 798 | then true | |
745 | 799 | else throwErr("initial deposit requires all coins") | |
746 | 800 | if ((chechSupply == chechSupply)) | |
747 | 801 | then { | |
748 | 802 | let depositBigInt = toBigInt(paymentAmount) | |
749 | 803 | let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))]) | |
750 | 804 | let commonState = if (isEval) | |
751 | 805 | then nil | |
752 | 806 | 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))] | |
753 | 807 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
754 | 808 | let priceOld = fromX18(priceOldX18, scale8) | |
755 | 809 | let loss = { | |
756 | - | let $ | |
810 | + | let $t03522835395 = if (paymentInAmountAsset) | |
757 | 811 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
758 | 812 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
759 | - | let amount = $ | |
760 | - | let balance = $ | |
813 | + | let amount = $t03522835395._1 | |
814 | + | let balance = $t03522835395._2 | |
761 | 815 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
762 | 816 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
763 | 817 | } | |
764 | 818 | $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset) | |
765 | 819 | } | |
766 | 820 | else throw("Strict value is not equal to itself.") | |
767 | 821 | } | |
768 | 822 | ||
769 | 823 | ||
770 | 824 | func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = { | |
771 | 825 | let isEval = (txId == unit) | |
772 | 826 | let cfg = getPoolConfig() | |
773 | 827 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
774 | 828 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
775 | 829 | let checks = [if ((paymentAssetId == cfgLpAssetId)) | |
776 | 830 | then true | |
777 | 831 | else throwErr("invalid lp asset")] | |
778 | 832 | if ((checks == checks)) | |
779 | 833 | then { | |
780 | 834 | let outInAmountAsset = if ((outAssetId == cfgAmountAssetId)) | |
781 | 835 | then true | |
782 | 836 | else if ((outAssetId == cfgPriceAssetId)) | |
783 | 837 | then false | |
784 | 838 | else throwErr("invalid asset") | |
785 | 839 | let balanceBigInt = if (outInAmountAsset) | |
786 | 840 | then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) | |
787 | 841 | else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) | |
788 | 842 | let outInAmountAssetDecimals = if (outInAmountAsset) | |
789 | 843 | then amtAssetDcm | |
790 | 844 | else priceAssetDcm | |
791 | 845 | let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
792 | 846 | let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
793 | 847 | let outBalance = if (outInAmountAsset) | |
794 | 848 | then amBalanceOld | |
795 | 849 | else prBalanceOld | |
796 | 850 | let outBalanceBigInt = toBigInt(outBalance) | |
797 | 851 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
798 | 852 | let redeemedBigInt = toBigInt(paymentAmount) | |
799 | 853 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
800 | - | let $ | |
801 | - | let totalAmount = $ | |
802 | - | let feeAmount = $ | |
803 | - | let $ | |
854 | + | let $t03747337529 = takeFee(amountRaw, outFee) | |
855 | + | let totalAmount = $t03747337529._1 | |
856 | + | let feeAmount = $t03747337529._2 | |
857 | + | let $t03753337759 = if (outInAmountAsset) | |
804 | 858 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
805 | 859 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
806 | - | let outAmAmount = $ | |
807 | - | let outPrAmount = $ | |
808 | - | let amBalanceNew = $ | |
809 | - | let prBalanceNew = $ | |
860 | + | let outAmAmount = $t03753337759._1 | |
861 | + | let outPrAmount = $t03753337759._2 | |
862 | + | let amBalanceNew = $t03753337759._3 | |
863 | + | let prBalanceNew = $t03753337759._4 | |
810 | 864 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
811 | 865 | let priceNew = fromX18(priceNewX18, scale8) | |
812 | 866 | let commonState = if (isEval) | |
813 | 867 | then nil | |
814 | 868 | 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)] | |
815 | 869 | let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals)) | |
816 | 870 | let priceOld = fromX18(priceOldX18, scale8) | |
817 | 871 | let loss = { | |
818 | 872 | let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2) | |
819 | 873 | fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset) | |
820 | 874 | } | |
821 | 875 | $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset) | |
822 | 876 | } | |
823 | 877 | else throw("Strict value is not equal to itself.") | |
824 | 878 | } | |
825 | 879 | ||
826 | 880 | ||
827 | 881 | func managerPublicKeyOrUnit () = match getString(mpk()) { | |
828 | 882 | case s: String => | |
829 | 883 | fromBase58String(s) | |
830 | 884 | case _: Unit => | |
831 | 885 | unit | |
832 | 886 | case _ => | |
833 | 887 | throw("Match error") | |
834 | 888 | } | |
835 | 889 | ||
836 | 890 | ||
837 | 891 | func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) { | |
838 | 892 | case s: String => | |
839 | 893 | fromBase58String(s) | |
840 | 894 | case _: Unit => | |
841 | 895 | unit | |
842 | 896 | case _ => | |
843 | 897 | throw("Match error") | |
844 | 898 | } | |
845 | 899 | ||
846 | 900 | ||
847 | 901 | func isManager (i) = match managerPublicKeyOrUnit() { | |
848 | 902 | case pk: ByteVector => | |
849 | 903 | (i.callerPublicKey == pk) | |
850 | 904 | case _: Unit => | |
851 | 905 | (i.caller == this) | |
852 | 906 | case _ => | |
853 | 907 | throw("Match error") | |
854 | 908 | } | |
855 | 909 | ||
856 | 910 | ||
857 | 911 | func mustManager (i) = { | |
858 | 912 | let pd = throw("Permission denied") | |
859 | 913 | match managerPublicKeyOrUnit() { | |
860 | 914 | case pk: ByteVector => | |
861 | 915 | if ((i.callerPublicKey == pk)) | |
862 | 916 | then true | |
863 | 917 | else pd | |
864 | 918 | case _: Unit => | |
865 | 919 | if ((i.caller == this)) | |
866 | 920 | then true | |
867 | 921 | else pd | |
868 | 922 | case _ => | |
869 | 923 | throw("Match error") | |
870 | 924 | } | |
871 | 925 | } | |
872 | 926 | ||
873 | 927 | ||
874 | 928 | @Callable(i) | |
875 | 929 | func rebalance () = (rebalanceAsset(getStringOrFail(this, aa())) ++ rebalanceAsset(getStringOrFail(this, pa()))) | |
876 | 930 | ||
877 | 931 | ||
878 | 932 | ||
879 | 933 | @Callable(i) | |
880 | 934 | func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse,feePoolAmount) = { | |
881 | - | let $ | |
935 | + | let $t03964539950 = if ((isReverse == false)) | |
882 | 936 | then { | |
883 | 937 | let assetOut = getStringOrFail(this, pa()) | |
884 | 938 | let assetIn = getStringOrFail(this, aa()) | |
885 | 939 | $Tuple2(assetOut, assetIn) | |
886 | 940 | } | |
887 | 941 | else { | |
888 | 942 | let assetOut = getStringOrFail(this, aa()) | |
889 | 943 | let assetIn = getStringOrFail(this, pa()) | |
890 | 944 | $Tuple2(assetOut, assetIn) | |
891 | 945 | } | |
892 | - | let assetOut = $ | |
893 | - | let assetIn = $ | |
946 | + | let assetOut = $t03964539950._1 | |
947 | + | let assetIn = $t03964539950._2 | |
894 | 948 | let poolAssetInBalance = getAccBalance(assetIn) | |
895 | 949 | let poolAssetOutBalance = getAccBalance(assetOut) | |
896 | 950 | let amountOut = fraction(poolAssetOutBalance, cleanAmountIn, (poolAssetInBalance + cleanAmountIn)) | |
897 | 951 | let oldK = (toBigInt(poolAssetInBalance) * toBigInt(poolAssetOutBalance)) | |
898 | 952 | let newK = (((toBigInt(getAccBalance(assetIn)) + toBigInt(cleanAmountIn)) + toBigInt(feePoolAmount)) * (toBigInt(getAccBalance(assetOut)) - toBigInt(amountOut))) | |
899 | 953 | let checkK = if ((newK >= oldK)) | |
900 | 954 | then true | |
901 | 955 | else throw("new K is fewer error") | |
902 | 956 | if ((checkK == checkK)) | |
903 | 957 | then $Tuple2(nil, amountOut) | |
904 | 958 | else throw("Strict value is not equal to itself.") | |
905 | 959 | } | |
906 | 960 | ||
907 | 961 | ||
908 | 962 | ||
909 | 963 | @Callable(i) | |
910 | 964 | func calculateAmountOutForSwapAndSendTokens (cleanAmountIn,isReverse,amountOutMin,addressTo,feePoolAmount) = { | |
911 | 965 | let swapContact = { | |
912 | 966 | let @ = invoke(factoryContract, "getSwapContractREADONLY", nil, nil) | |
913 | 967 | if ($isInstanceOf(@, "String")) | |
914 | 968 | then @ | |
915 | 969 | else throw(($getType(@) + " couldn't be cast to String")) | |
916 | 970 | } | |
917 | 971 | let checks = [if ((value(i.payments[0]).amount >= cleanAmountIn)) | |
918 | 972 | then true | |
919 | 973 | else throwErr("Wrong amount"), if ((i.caller == addressFromStringValue(swapContact))) | |
920 | 974 | then true | |
921 | 975 | else throwErr("Permission denied")] | |
922 | 976 | if ((checks == checks)) | |
923 | 977 | then { | |
924 | 978 | let pmt = value(i.payments[0]) | |
925 | 979 | let assetIn = assetIdToString(pmt.assetId) | |
926 | 980 | let assetOut = if ((isReverse == false)) | |
927 | 981 | then getStringOrFail(this, pa()) | |
928 | 982 | else getStringOrFail(this, aa()) | |
929 | 983 | let poolAssetInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount) | |
930 | 984 | let poolAssetOutBalance = getAccBalance(assetOut) | |
931 | 985 | let amountOut = fraction(poolAssetOutBalance, cleanAmountIn, (poolAssetInBalance + cleanAmountIn)) | |
932 | 986 | let oldK = (toBigInt(poolAssetInBalance) * toBigInt(poolAssetOutBalance)) | |
933 | 987 | let newK = ((toBigInt(getAccBalance(assetIn)) + toBigInt(feePoolAmount)) * (toBigInt(getAccBalance(assetOut)) - toBigInt(amountOut))) | |
934 | 988 | let checkK = if ((newK >= oldK)) | |
935 | 989 | then true | |
936 | 990 | else throw("new K is fewer error") | |
937 | 991 | if ((checkK == checkK)) | |
938 | 992 | then { | |
939 | 993 | let checkMin = if ((amountOut >= amountOutMin)) | |
940 | 994 | then true | |
941 | 995 | else throw("Exchange result is fewer coins than expected") | |
942 | 996 | if ((checkMin == checkMin)) | |
943 | 997 | then { | |
944 | 998 | let lsConf = match getLeaseProxyConfig(assetOut) { | |
945 | 999 | case a: (Boolean, Int, Int, String, String, Int, String) => | |
946 | 1000 | a | |
947 | 1001 | case _ => | |
948 | 1002 | throw("error lease config") | |
949 | 1003 | } | |
950 | - | let $t04006140175 = lsConf | |
951 | - | let isLeasable = $t04006140175._1 | |
952 | - | let leasedRatio = $t04006140175._2 | |
953 | - | let minBalance = $t04006140175._3 | |
954 | - | let proxyAddress = $t04006140175._4 | |
955 | - | let proxyAssetId = $t04006140175._5 | |
956 | - | let proxyRateMul = $t04006140175._6 | |
957 | - | let stakingProfitAddress = $t04006140175._7 | |
958 | - | let assetOnPool = assetBalance(this, fromBase58String(assetOut)) | |
959 | - | let amountOfProfit = if (if ((assetOut == "WAVES")) | |
960 | - | then (amountOut > assetOnPool) | |
961 | - | else false) | |
1004 | + | let withdrawState = getWithdrawAssetState(assetOut, amountOut) | |
1005 | + | if ((withdrawState == withdrawState)) | |
962 | 1006 | then { | |
963 | - | let amountDiff = (amountOut - assetOnPool) | |
964 | - | let oldRatio = (getAdditionalBalance(assetOut) / getStakingAssetBalance(sWavesId())) | |
965 | - | let oldWavesRoughBalane = wavesBalance(this).available | |
966 | - | let wd = invoke(this, "withdraw", [assetOut, amountDiff, sWavesId(), sWavesProxy(), proxyRateMul], nil) | |
967 | - | if ((wd == wd)) | |
968 | - | then { | |
969 | - | let newWavesRoughBalane = wavesBalance(this).available | |
970 | - | let wavesDiff = (newWavesRoughBalane - oldWavesRoughBalane) | |
971 | - | (wavesDiff - amountDiff) | |
972 | - | } | |
1007 | + | let reb = invoke(this, "rebalance", nil, nil) | |
1008 | + | if ((reb == reb)) | |
1009 | + | then $Tuple2((withdrawState ++ [ScriptTransfer(addressFromStringValue(addressTo), amountOut, parseAssetId(assetOut))]), amountOut) | |
973 | 1010 | else throw("Strict value is not equal to itself.") | |
974 | 1011 | } | |
975 | - | else 0 | |
976 | - | let reb = invoke(this, "rebalance", nil, nil) | |
977 | - | if ((reb == reb)) | |
978 | - | then $Tuple2([ScriptTransfer(addressFromStringValue(stakingProfitAddress), amountOfProfit, unit), ScriptTransfer(addressFromStringValue(addressTo), amountOut, parseAssetId(assetOut))], amountOut) | |
979 | 1012 | else throw("Strict value is not equal to itself.") | |
980 | 1013 | } | |
981 | 1014 | else throw("Strict value is not equal to itself.") | |
982 | 1015 | } | |
983 | 1016 | else throw("Strict value is not equal to itself.") | |
984 | 1017 | } | |
985 | 1018 | else throw("Strict value is not equal to itself.") | |
986 | 1019 | } | |
987 | 1020 | ||
988 | 1021 | ||
989 | 1022 | ||
990 | 1023 | @Callable(i) | |
991 | 1024 | func setManager (pendingManagerPublicKey) = { | |
992 | 1025 | let checkCaller = mustManager(i) | |
993 | 1026 | if ((checkCaller == checkCaller)) | |
994 | 1027 | then { | |
995 | 1028 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
996 | 1029 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
997 | 1030 | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
998 | 1031 | else throw("Strict value is not equal to itself.") | |
999 | 1032 | } | |
1000 | 1033 | else throw("Strict value is not equal to itself.") | |
1001 | 1034 | } | |
1002 | 1035 | ||
1003 | 1036 | ||
1004 | 1037 | ||
1005 | 1038 | @Callable(i) | |
1006 | 1039 | func confirmManager () = { | |
1007 | 1040 | let pm = pendingManagerPublicKeyOrUnit() | |
1008 | 1041 | let hasPM = if (isDefined(pm)) | |
1009 | 1042 | then true | |
1010 | 1043 | else throw("No pending manager") | |
1011 | 1044 | if ((hasPM == hasPM)) | |
1012 | 1045 | then { | |
1013 | 1046 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
1014 | 1047 | then true | |
1015 | 1048 | else throw("You are not pending manager") | |
1016 | 1049 | if ((checkPM == checkPM)) | |
1017 | 1050 | then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())] | |
1018 | 1051 | else throw("Strict value is not equal to itself.") | |
1019 | 1052 | } | |
1020 | 1053 | else throw("Strict value is not equal to itself.") | |
1021 | 1054 | } | |
1022 | 1055 | ||
1023 | 1056 | ||
1024 | 1057 | ||
1025 | 1058 | @Callable(i) | |
1026 | 1059 | func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance)) | |
1027 | 1060 | then throw("Invalid slippageTolerance passed") | |
1028 | 1061 | else { | |
1029 | 1062 | let estPut = commonPut(i, slippageTolerance, true) | |
1030 | 1063 | let emitLpAmt = estPut._2 | |
1031 | 1064 | let lpAssetId = estPut._7 | |
1032 | 1065 | let state = estPut._9 | |
1033 | 1066 | let amDiff = estPut._10 | |
1034 | 1067 | let prDiff = estPut._11 | |
1035 | 1068 | let amId = estPut._12 | |
1036 | 1069 | let prId = estPut._13 | |
1037 | 1070 | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
1038 | 1071 | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
1039 | 1072 | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
1040 | 1073 | if ((currentKLp == currentKLp)) | |
1041 | 1074 | then { | |
1042 | 1075 | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
1043 | 1076 | if ((emitInv == emitInv)) | |
1044 | 1077 | then { | |
1045 | 1078 | let emitInvLegacy = match emitInv { | |
1046 | 1079 | case legacyFactoryContract: Address => | |
1047 | 1080 | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
1048 | 1081 | case _ => | |
1049 | 1082 | unit | |
1050 | 1083 | } | |
1051 | 1084 | if ((emitInvLegacy == emitInvLegacy)) | |
1052 | 1085 | then { | |
1053 | 1086 | let slippageAInv = if ((amDiff > 0)) | |
1054 | 1087 | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
1055 | 1088 | else nil | |
1056 | 1089 | if ((slippageAInv == slippageAInv)) | |
1057 | 1090 | then { | |
1058 | 1091 | let slippagePInv = if ((prDiff > 0)) | |
1059 | 1092 | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
1060 | 1093 | else nil | |
1061 | 1094 | if ((slippagePInv == slippagePInv)) | |
1062 | 1095 | then { | |
1063 | 1096 | let lpTransfer = if (shouldAutoStake) | |
1064 | 1097 | then { | |
1065 | 1098 | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
1066 | 1099 | if ((slpStakeInv == slpStakeInv)) | |
1067 | 1100 | then nil | |
1068 | 1101 | else throw("Strict value is not equal to itself.") | |
1069 | 1102 | } | |
1070 | 1103 | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
1071 | - | let $ | |
1072 | - | if (($ | |
1104 | + | let $t04515145613 = refreshKLpInternal(0, 0, 0) | |
1105 | + | if (($t04515145613 == $t04515145613)) | |
1073 | 1106 | then { | |
1074 | - | let updatedKLp = $ | |
1075 | - | let refreshKLpActions = $ | |
1107 | + | let updatedKLp = $t04515145613._2 | |
1108 | + | let refreshKLpActions = $t04515145613._1 | |
1076 | 1109 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1077 | 1110 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1078 | 1111 | then ((state ++ lpTransfer) ++ refreshKLpActions) | |
1079 | 1112 | else throw("Strict value is not equal to itself.") | |
1080 | 1113 | } | |
1081 | 1114 | else throw("Strict value is not equal to itself.") | |
1082 | 1115 | } | |
1083 | 1116 | else throw("Strict value is not equal to itself.") | |
1084 | 1117 | } | |
1085 | 1118 | else throw("Strict value is not equal to itself.") | |
1086 | 1119 | } | |
1087 | 1120 | else throw("Strict value is not equal to itself.") | |
1088 | 1121 | } | |
1089 | 1122 | else throw("Strict value is not equal to itself.") | |
1090 | 1123 | } | |
1091 | 1124 | else throw("Strict value is not equal to itself.") | |
1092 | 1125 | } | |
1093 | 1126 | ||
1094 | 1127 | ||
1095 | 1128 | ||
1096 | 1129 | @Callable(i) | |
1097 | 1130 | func putForFree (maxSlippage) = if ((0 > maxSlippage)) | |
1098 | 1131 | then throw("Invalid value passed") | |
1099 | 1132 | else { | |
1100 | 1133 | let estPut = commonPut(i, maxSlippage, false) | |
1101 | 1134 | let state = estPut._9 | |
1102 | 1135 | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
1103 | 1136 | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
1104 | 1137 | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
1105 | 1138 | if ((currentKLp == currentKLp)) | |
1106 | 1139 | then { | |
1107 | - | let $ | |
1108 | - | let refreshKLpActions = $ | |
1109 | - | let updatedKLp = $ | |
1140 | + | let $t04617546240 = refreshKLpInternal(0, 0, 0) | |
1141 | + | let refreshKLpActions = $t04617546240._1 | |
1142 | + | let updatedKLp = $t04617546240._2 | |
1110 | 1143 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1111 | 1144 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1112 | 1145 | then (state ++ refreshKLpActions) | |
1113 | 1146 | else throw("Strict value is not equal to itself.") | |
1114 | 1147 | } | |
1115 | 1148 | else throw("Strict value is not equal to itself.") | |
1116 | 1149 | } | |
1117 | 1150 | ||
1118 | 1151 | ||
1119 | 1152 | ||
1120 | 1153 | @Callable(i) | |
1121 | 1154 | func putOneTkn (minOutAmount,autoStake) = { | |
1122 | 1155 | let isPoolOneTokenOperationsDisabled = { | |
1123 | 1156 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
1124 | 1157 | if ($isInstanceOf(@, "Boolean")) | |
1125 | 1158 | then @ | |
1126 | 1159 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
1127 | 1160 | } | |
1128 | 1161 | let isPutDisabled = if (if (if (isGlobalShutdown()) | |
1129 | 1162 | then true | |
1130 | 1163 | else (cfgPoolStatus == PoolPutDisabled)) | |
1131 | 1164 | then true | |
1132 | 1165 | else (cfgPoolStatus == PoolShutdown)) | |
1133 | 1166 | then true | |
1134 | 1167 | else isPoolOneTokenOperationsDisabled | |
1135 | 1168 | let checks = [if (if (!(isPutDisabled)) | |
1136 | 1169 | then true | |
1137 | 1170 | else isManager(i)) | |
1138 | 1171 | then true | |
1139 | 1172 | else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1)) | |
1140 | 1173 | then true | |
1141 | 1174 | else throwErr("exactly 1 payment are expected")] | |
1142 | 1175 | if ((checks == checks)) | |
1143 | 1176 | then { | |
1144 | 1177 | let payment = i.payments[0] | |
1145 | 1178 | let paymentAssetId = payment.assetId | |
1146 | 1179 | let paymentAmountRaw = payment.amount | |
1147 | 1180 | let currentKLp = if ((paymentAssetId == cfgAmountAssetId)) | |
1148 | 1181 | then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0)) | |
1149 | 1182 | else if ((paymentAssetId == cfgPriceAssetId)) | |
1150 | 1183 | then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0)) | |
1151 | 1184 | else throwErr("payment asset is not supported") | |
1152 | 1185 | if ((currentKLp == currentKLp)) | |
1153 | 1186 | then { | |
1154 | 1187 | let userAddress = i.caller | |
1155 | 1188 | let txId = i.transactionId | |
1156 | - | let $ | |
1157 | - | if (($ | |
1189 | + | let $t04742847580 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
1190 | + | if (($t04742847580 == $t04742847580)) | |
1158 | 1191 | then { | |
1159 | - | let paymentInAmountAsset = $ | |
1160 | - | let bonus = $ | |
1161 | - | let feeAmount = $ | |
1162 | - | let commonState = $ | |
1163 | - | let emitAmountEstimated = $ | |
1192 | + | let paymentInAmountAsset = $t04742847580._5 | |
1193 | + | let bonus = $t04742847580._4 | |
1194 | + | let feeAmount = $t04742847580._3 | |
1195 | + | let commonState = $t04742847580._2 | |
1196 | + | let emitAmountEstimated = $t04742847580._1 | |
1164 | 1197 | let emitAmount = if (if ((minOutAmount > 0)) | |
1165 | 1198 | then (minOutAmount > emitAmountEstimated) | |
1166 | 1199 | else false) | |
1167 | 1200 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1168 | 1201 | else emitAmountEstimated | |
1169 | 1202 | let emitInv = emit(emitAmount) | |
1170 | 1203 | if ((emitInv == emitInv)) | |
1171 | 1204 | then { | |
1172 | 1205 | let lpTransfer = if (autoStake) | |
1173 | 1206 | then { | |
1174 | 1207 | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
1175 | 1208 | if ((stakeInv == stakeInv)) | |
1176 | 1209 | then nil | |
1177 | 1210 | else throw("Strict value is not equal to itself.") | |
1178 | 1211 | } | |
1179 | 1212 | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
1180 | 1213 | let sendFee = if ((feeAmount > 0)) | |
1181 | 1214 | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
1182 | 1215 | else nil | |
1183 | - | let $ | |
1216 | + | let $t04816648363 = if ((this == feeCollectorAddress)) | |
1184 | 1217 | then $Tuple2(0, 0) | |
1185 | 1218 | else if (paymentInAmountAsset) | |
1186 | 1219 | then $Tuple2(-(feeAmount), 0) | |
1187 | 1220 | else $Tuple2(0, -(feeAmount)) | |
1188 | - | let amountAssetBalanceDelta = $ | |
1189 | - | let priceAssetBalanceDelta = $ | |
1190 | - | let $ | |
1191 | - | let refreshKLpActions = $ | |
1192 | - | let updatedKLp = $ | |
1221 | + | let amountAssetBalanceDelta = $t04816648363._1 | |
1222 | + | let priceAssetBalanceDelta = $t04816648363._2 | |
1223 | + | let $t04836648474 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1224 | + | let refreshKLpActions = $t04836648474._1 | |
1225 | + | let updatedKLp = $t04836648474._2 | |
1193 | 1226 | let kLp = value(getString(keyKLp)) | |
1194 | 1227 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1195 | 1228 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1196 | 1229 | then { | |
1197 | 1230 | let reb = invoke(this, "rebalance", nil, nil) | |
1198 | 1231 | if ((reb == reb)) | |
1199 | 1232 | then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
1200 | 1233 | else throw("Strict value is not equal to itself.") | |
1201 | 1234 | } | |
1202 | 1235 | else throw("Strict value is not equal to itself.") | |
1203 | 1236 | } | |
1204 | 1237 | else throw("Strict value is not equal to itself.") | |
1205 | 1238 | } | |
1206 | 1239 | else throw("Strict value is not equal to itself.") | |
1207 | 1240 | } | |
1208 | 1241 | else throw("Strict value is not equal to itself.") | |
1209 | 1242 | } | |
1210 | 1243 | else throw("Strict value is not equal to itself.") | |
1211 | 1244 | } | |
1212 | 1245 | ||
1213 | 1246 | ||
1214 | 1247 | ||
1215 | 1248 | @Callable(i) | |
1216 | 1249 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
1217 | - | let $ | |
1218 | - | let emitAmountEstimated = $ | |
1219 | - | let commonState = $ | |
1220 | - | let feeAmount = $ | |
1221 | - | let bonus = $ | |
1222 | - | let paymentInAmountAsset = $ | |
1250 | + | let $t04882948986 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
1251 | + | let emitAmountEstimated = $t04882948986._1 | |
1252 | + | let commonState = $t04882948986._2 | |
1253 | + | let feeAmount = $t04882948986._3 | |
1254 | + | let bonus = $t04882948986._4 | |
1255 | + | let paymentInAmountAsset = $t04882948986._5 | |
1223 | 1256 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
1224 | 1257 | } | |
1225 | 1258 | ||
1226 | 1259 | ||
1227 | 1260 | ||
1228 | 1261 | @Callable(i) | |
1229 | 1262 | func getOneTkn (outAssetIdStr,minOutAmount) = { | |
1230 | 1263 | let isPoolOneTokenOperationsDisabled = { | |
1231 | 1264 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
1232 | 1265 | if ($isInstanceOf(@, "Boolean")) | |
1233 | 1266 | then @ | |
1234 | 1267 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
1235 | 1268 | } | |
1236 | 1269 | let isGetDisabled = if (if (isGlobalShutdown()) | |
1237 | 1270 | then true | |
1238 | 1271 | else (cfgPoolStatus == PoolShutdown)) | |
1239 | 1272 | then true | |
1240 | 1273 | else isPoolOneTokenOperationsDisabled | |
1241 | 1274 | let checks = [if (if (!(isGetDisabled)) | |
1242 | 1275 | then true | |
1243 | 1276 | else isManager(i)) | |
1244 | 1277 | then true | |
1245 | 1278 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1)) | |
1246 | 1279 | then true | |
1247 | 1280 | else throwErr("exactly 1 payment are expected")] | |
1248 | 1281 | if ((checks == checks)) | |
1249 | 1282 | then { | |
1250 | 1283 | let outAssetId = parseAssetId(outAssetIdStr) | |
1251 | 1284 | let payment = i.payments[0] | |
1252 | 1285 | let paymentAssetId = payment.assetId | |
1253 | 1286 | let paymentAmount = payment.amount | |
1254 | 1287 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1255 | 1288 | if ((currentKLp == currentKLp)) | |
1256 | 1289 | then { | |
1257 | 1290 | let userAddress = i.caller | |
1258 | 1291 | let txId = i.transactionId | |
1259 | - | let $ | |
1260 | - | if (($ | |
1292 | + | let $t04987150024 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
1293 | + | if (($t04987150024 == $t04987150024)) | |
1261 | 1294 | then { | |
1262 | - | let outInAmountAsset = $ | |
1263 | - | let bonus = $ | |
1264 | - | let feeAmount = $ | |
1265 | - | let commonState = $ | |
1266 | - | let amountEstimated = $ | |
1295 | + | let outInAmountAsset = $t04987150024._5 | |
1296 | + | let bonus = $t04987150024._4 | |
1297 | + | let feeAmount = $t04987150024._3 | |
1298 | + | let commonState = $t04987150024._2 | |
1299 | + | let amountEstimated = $t04987150024._1 | |
1267 | 1300 | let amount = if (if ((minOutAmount > 0)) | |
1268 | 1301 | then (minOutAmount > amountEstimated) | |
1269 | 1302 | else false) | |
1270 | 1303 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1271 | 1304 | else amountEstimated | |
1272 | 1305 | let lsConf = match getLeaseProxyConfig(outAssetIdStr) { | |
1273 | 1306 | case a: (Boolean, Int, Int, String, String, Int, String) => | |
1274 | 1307 | a | |
1275 | 1308 | case _ => | |
1276 | 1309 | throw("error lease config") | |
1277 | 1310 | } | |
1278 | - | let $t04924349357 = lsConf | |
1279 | - | let isLeasable = $t04924349357._1 | |
1280 | - | let leasedRatio = $t04924349357._2 | |
1281 | - | let minBalance = $t04924349357._3 | |
1282 | - | let proxyAddress = $t04924349357._4 | |
1283 | - | let proxyAssetId = $t04924349357._5 | |
1284 | - | let proxyRateMul = $t04924349357._6 | |
1285 | - | let stakingProfitAddress = $t04924349357._7 | |
1286 | - | let assetOnPool = assetBalance(this, fromBase58String(outAssetIdStr)) | |
1287 | - | let amountOfProfit = if (if ((outAssetIdStr == "WAVES")) | |
1288 | - | then (amount > assetOnPool) | |
1289 | - | else false) | |
1290 | - | then { | |
1291 | - | let amountDiff = (amount - assetOnPool) | |
1292 | - | let oldRatio = (getAdditionalBalance(outAssetIdStr) / getStakingAssetBalance(sWavesId())) | |
1293 | - | let oldWavesRoughBalane = wavesBalance(this).available | |
1294 | - | let wd = invoke(this, "withdraw", [outAssetIdStr, amountDiff, sWavesId(), sWavesProxy(), proxyRateMul], nil) | |
1295 | - | if ((wd == wd)) | |
1296 | - | then { | |
1297 | - | let newWavesRoughBalane = wavesBalance(this).available | |
1298 | - | let wavesDiff = (newWavesRoughBalane - oldWavesRoughBalane) | |
1299 | - | (wavesDiff - amountDiff) | |
1300 | - | } | |
1301 | - | else throw("Strict value is not equal to itself.") | |
1302 | - | } | |
1303 | - | else 0 | |
1304 | - | let profitTransfer = [ScriptTransfer(addressFromStringValue(stakingProfitAddress), amountOfProfit, unit)] | |
1305 | 1311 | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
1306 | 1312 | if ((burnInv == burnInv)) | |
1307 | 1313 | then { | |
1308 | - | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
1309 | - | let sendFee = if ((feeAmount > 0)) | |
1310 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1311 | - | else nil | |
1312 | - | let $t05039650643 = { | |
1313 | - | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1314 | - | then 0 | |
1315 | - | else feeAmount | |
1316 | - | if (outInAmountAsset) | |
1317 | - | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1318 | - | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1319 | - | } | |
1320 | - | let amountAssetBalanceDelta = $t05039650643._1 | |
1321 | - | let priceAssetBalanceDelta = $t05039650643._2 | |
1322 | - | let $t05064650754 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1323 | - | let refreshKLpActions = $t05064650754._1 | |
1324 | - | let updatedKLp = $t05064650754._2 | |
1325 | - | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1326 | - | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1314 | + | let withdrawState = getWithdrawAssetState(outAssetIdStr, amount) | |
1315 | + | if ((withdrawState == withdrawState)) | |
1327 | 1316 | then { | |
1328 | - | let reb = invoke(this, "rebalance", nil, nil) | |
1329 | - | if ((reb == reb)) | |
1330 | - | then $Tuple2(((((commonState ++ assetTransfer) ++ profitTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1317 | + | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
1318 | + | let sendFee = if ((feeAmount > 0)) | |
1319 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1320 | + | else nil | |
1321 | + | let $t05078051027 = { | |
1322 | + | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1323 | + | then 0 | |
1324 | + | else feeAmount | |
1325 | + | if (outInAmountAsset) | |
1326 | + | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1327 | + | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1328 | + | } | |
1329 | + | let amountAssetBalanceDelta = $t05078051027._1 | |
1330 | + | let priceAssetBalanceDelta = $t05078051027._2 | |
1331 | + | let $t05103051138 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1332 | + | let refreshKLpActions = $t05103051138._1 | |
1333 | + | let updatedKLp = $t05103051138._2 | |
1334 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1335 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1336 | + | then { | |
1337 | + | let reb = invoke(this, "rebalance", nil, nil) | |
1338 | + | if ((reb == reb)) | |
1339 | + | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1340 | + | else throw("Strict value is not equal to itself.") | |
1341 | + | } | |
1331 | 1342 | else throw("Strict value is not equal to itself.") | |
1332 | 1343 | } | |
1333 | 1344 | else throw("Strict value is not equal to itself.") | |
1334 | 1345 | } | |
1335 | 1346 | else throw("Strict value is not equal to itself.") | |
1336 | 1347 | } | |
1337 | 1348 | else throw("Strict value is not equal to itself.") | |
1338 | 1349 | } | |
1339 | 1350 | else throw("Strict value is not equal to itself.") | |
1340 | 1351 | } | |
1341 | 1352 | else throw("Strict value is not equal to itself.") | |
1342 | 1353 | } | |
1343 | 1354 | ||
1344 | 1355 | ||
1345 | 1356 | ||
1346 | 1357 | @Callable(i) | |
1347 | 1358 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
1348 | - | let $ | |
1349 | - | let amountEstimated = $ | |
1350 | - | let commonState = $ | |
1351 | - | let feeAmount = $ | |
1352 | - | let bonus = $ | |
1353 | - | let outInAmountAsset = $ | |
1359 | + | let $t05144351599 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
1360 | + | let amountEstimated = $t05144351599._1 | |
1361 | + | let commonState = $t05144351599._2 | |
1362 | + | let feeAmount = $t05144351599._3 | |
1363 | + | let bonus = $t05144351599._4 | |
1364 | + | let outInAmountAsset = $t05144351599._5 | |
1354 | 1365 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
1355 | 1366 | } | |
1356 | 1367 | ||
1357 | 1368 | ||
1358 | 1369 | ||
1359 | 1370 | @Callable(i) | |
1360 | 1371 | func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = { | |
1361 | 1372 | let isPoolOneTokenOperationsDisabled = { | |
1362 | 1373 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
1363 | 1374 | if ($isInstanceOf(@, "Boolean")) | |
1364 | 1375 | then @ | |
1365 | 1376 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
1366 | 1377 | } | |
1367 | 1378 | let isGetDisabled = if (if (isGlobalShutdown()) | |
1368 | 1379 | then true | |
1369 | 1380 | else (cfgPoolStatus == PoolShutdown)) | |
1370 | 1381 | then true | |
1371 | 1382 | else isPoolOneTokenOperationsDisabled | |
1372 | 1383 | let checks = [if (if (!(isGetDisabled)) | |
1373 | 1384 | then true | |
1374 | 1385 | else isManager(i)) | |
1375 | 1386 | then true | |
1376 | 1387 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1377 | 1388 | then true | |
1378 | 1389 | else throwErr("no payments are expected")] | |
1379 | 1390 | if ((checks == checks)) | |
1380 | 1391 | then { | |
1381 | 1392 | let outAssetId = parseAssetId(outAssetIdStr) | |
1382 | 1393 | let userAddress = i.caller | |
1383 | 1394 | let txId = i.transactionId | |
1384 | 1395 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1385 | 1396 | if ((currentKLp == currentKLp)) | |
1386 | 1397 | then { | |
1387 | 1398 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1388 | 1399 | if ((unstakeInv == unstakeInv)) | |
1389 | 1400 | then { | |
1390 | - | let $ | |
1391 | - | if (($ | |
1401 | + | let $t05250452655 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
1402 | + | if (($t05250452655 == $t05250452655)) | |
1392 | 1403 | then { | |
1393 | - | let outInAmountAsset = $ | |
1394 | - | let bonus = $ | |
1395 | - | let feeAmount = $ | |
1396 | - | let commonState = $ | |
1397 | - | let amountEstimated = $ | |
1404 | + | let outInAmountAsset = $t05250452655._5 | |
1405 | + | let bonus = $t05250452655._4 | |
1406 | + | let feeAmount = $t05250452655._3 | |
1407 | + | let commonState = $t05250452655._2 | |
1408 | + | let amountEstimated = $t05250452655._1 | |
1398 | 1409 | let amount = if (if ((minOutAmount > 0)) | |
1399 | 1410 | then (minOutAmount > amountEstimated) | |
1400 | 1411 | else false) | |
1401 | 1412 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1402 | 1413 | else amountEstimated | |
1403 | 1414 | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1404 | 1415 | if ((burnInv == burnInv)) | |
1405 | 1416 | then { | |
1406 | - | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
1407 | - | let sendFee = if ((feeAmount > 0)) | |
1408 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1409 | - | else nil | |
1410 | - | let $t05278853035 = { | |
1411 | - | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1412 | - | then 0 | |
1413 | - | else feeAmount | |
1414 | - | if (outInAmountAsset) | |
1415 | - | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1416 | - | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1417 | - | } | |
1418 | - | let amountAssetBalanceDelta = $t05278853035._1 | |
1419 | - | let priceAssetBalanceDelta = $t05278853035._2 | |
1420 | - | let $t05303853146 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1421 | - | let refreshKLpActions = $t05303853146._1 | |
1422 | - | let updatedKLp = $t05303853146._2 | |
1423 | - | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1424 | - | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1425 | - | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1417 | + | let withdrawState = getWithdrawAssetState(outAssetIdStr, amount) | |
1418 | + | if ((withdrawState == withdrawState)) | |
1419 | + | then { | |
1420 | + | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
1421 | + | let sendFee = if ((feeAmount > 0)) | |
1422 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1423 | + | else nil | |
1424 | + | let $t05322053467 = { | |
1425 | + | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1426 | + | then 0 | |
1427 | + | else feeAmount | |
1428 | + | if (outInAmountAsset) | |
1429 | + | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1430 | + | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1431 | + | } | |
1432 | + | let amountAssetBalanceDelta = $t05322053467._1 | |
1433 | + | let priceAssetBalanceDelta = $t05322053467._2 | |
1434 | + | let $t05347053578 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1435 | + | let refreshKLpActions = $t05347053578._1 | |
1436 | + | let updatedKLp = $t05347053578._2 | |
1437 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1438 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1439 | + | then { | |
1440 | + | let reb = invoke(this, "rebalance", nil, nil) | |
1441 | + | if ((reb == reb)) | |
1442 | + | then $Tuple2(((((commonState ++ withdrawState) ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1443 | + | else throw("Strict value is not equal to itself.") | |
1444 | + | } | |
1445 | + | else throw("Strict value is not equal to itself.") | |
1446 | + | } | |
1426 | 1447 | else throw("Strict value is not equal to itself.") | |
1427 | 1448 | } | |
1428 | 1449 | else throw("Strict value is not equal to itself.") | |
1429 | 1450 | } | |
1430 | 1451 | else throw("Strict value is not equal to itself.") | |
1431 | 1452 | } | |
1432 | 1453 | else throw("Strict value is not equal to itself.") | |
1433 | 1454 | } | |
1434 | 1455 | else throw("Strict value is not equal to itself.") | |
1435 | 1456 | } | |
1436 | 1457 | else throw("Strict value is not equal to itself.") | |
1437 | 1458 | } | |
1438 | 1459 | ||
1439 | 1460 | ||
1440 | 1461 | ||
1441 | 1462 | @Callable(i) | |
1442 | 1463 | func get () = { | |
1443 | 1464 | let res = commonGet(i) | |
1444 | 1465 | let outAmtAmt = res._1 | |
1445 | 1466 | let outPrAmt = res._2 | |
1446 | 1467 | let pmtAmt = res._3 | |
1447 | 1468 | let pmtAssetId = res._4 | |
1448 | 1469 | let state = res._5 | |
1449 | 1470 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1450 | 1471 | if ((currentKLp == currentKLp)) | |
1451 | 1472 | then { | |
1452 | 1473 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1453 | 1474 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1454 | 1475 | then { | |
1455 | - | let $ | |
1456 | - | let refreshKLpActions = $ | |
1457 | - | let updatedKLp = $ | |
1476 | + | let $t05459254674 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1477 | + | let refreshKLpActions = $t05459254674._1 | |
1478 | + | let updatedKLp = $t05459254674._2 | |
1458 | 1479 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1459 | 1480 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1460 | 1481 | then (state ++ refreshKLpActions) | |
1461 | 1482 | else throw("Strict value is not equal to itself.") | |
1462 | 1483 | } | |
1463 | 1484 | else throw("Strict value is not equal to itself.") | |
1464 | 1485 | } | |
1465 | 1486 | else throw("Strict value is not equal to itself.") | |
1466 | 1487 | } | |
1467 | 1488 | ||
1468 | 1489 | ||
1469 | 1490 | ||
1470 | 1491 | @Callable(i) | |
1471 | 1492 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
1472 | 1493 | let res = commonGet(i) | |
1473 | 1494 | let outAmAmt = res._1 | |
1474 | 1495 | let outPrAmt = res._2 | |
1475 | 1496 | let pmtAmt = res._3 | |
1476 | 1497 | let pmtAssetId = res._4 | |
1477 | 1498 | let state = res._5 | |
1478 | 1499 | if ((noLessThenAmtAsset > outAmAmt)) | |
1479 | 1500 | then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
1480 | 1501 | else if ((noLessThenPriceAsset > outPrAmt)) | |
1481 | 1502 | then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
1482 | 1503 | else { | |
1483 | 1504 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1484 | 1505 | if ((currentKLp == currentKLp)) | |
1485 | 1506 | then { | |
1486 | 1507 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1487 | 1508 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1488 | 1509 | then { | |
1489 | - | let $ | |
1490 | - | let refreshKLpActions = $ | |
1491 | - | let updatedKLp = $ | |
1510 | + | let $t05562355704 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1511 | + | let refreshKLpActions = $t05562355704._1 | |
1512 | + | let updatedKLp = $t05562355704._2 | |
1492 | 1513 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1493 | 1514 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1494 | 1515 | then (state ++ refreshKLpActions) | |
1495 | 1516 | else throw("Strict value is not equal to itself.") | |
1496 | 1517 | } | |
1497 | 1518 | else throw("Strict value is not equal to itself.") | |
1498 | 1519 | } | |
1499 | 1520 | else throw("Strict value is not equal to itself.") | |
1500 | 1521 | } | |
1501 | 1522 | } | |
1502 | 1523 | ||
1503 | 1524 | ||
1504 | 1525 | ||
1505 | 1526 | @Callable(i) | |
1506 | 1527 | func unstakeAndGet (amount) = { | |
1507 | 1528 | let checkPayments = if ((size(i.payments) != 0)) | |
1508 | 1529 | then throw("No payments are expected") | |
1509 | 1530 | else true | |
1510 | 1531 | if ((checkPayments == checkPayments)) | |
1511 | 1532 | then { | |
1512 | 1533 | let cfg = getPoolConfig() | |
1513 | 1534 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1514 | 1535 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1515 | 1536 | if ((currentKLp == currentKLp)) | |
1516 | 1537 | then { | |
1517 | 1538 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1518 | 1539 | if ((unstakeInv == unstakeInv)) | |
1519 | 1540 | then { | |
1520 | 1541 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1521 | 1542 | let outAmAmt = res._1 | |
1522 | 1543 | let outPrAmt = res._2 | |
1523 | 1544 | let poolStatus = parseIntValue(res._9) | |
1524 | 1545 | let state = res._10 | |
1525 | 1546 | let checkPoolStatus = if (if (isGlobalShutdown()) | |
1526 | 1547 | then true | |
1527 | 1548 | else (poolStatus == PoolShutdown)) | |
1528 | 1549 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
1529 | 1550 | else true | |
1530 | 1551 | if ((checkPoolStatus == checkPoolStatus)) | |
1531 | 1552 | then { | |
1532 | 1553 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1533 | 1554 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1534 | 1555 | then { | |
1535 | - | let $ | |
1536 | - | let refreshKLpActions = $ | |
1537 | - | let updatedKLp = $ | |
1556 | + | let $t05683056911 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1557 | + | let refreshKLpActions = $t05683056911._1 | |
1558 | + | let updatedKLp = $t05683056911._2 | |
1538 | 1559 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1539 | 1560 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1540 | 1561 | then (state ++ refreshKLpActions) | |
1541 | 1562 | else throw("Strict value is not equal to itself.") | |
1542 | 1563 | } | |
1543 | 1564 | else throw("Strict value is not equal to itself.") | |
1544 | 1565 | } | |
1545 | 1566 | else throw("Strict value is not equal to itself.") | |
1546 | 1567 | } | |
1547 | 1568 | else throw("Strict value is not equal to itself.") | |
1548 | 1569 | } | |
1549 | 1570 | else throw("Strict value is not equal to itself.") | |
1550 | 1571 | } | |
1551 | 1572 | else throw("Strict value is not equal to itself.") | |
1552 | 1573 | } | |
1553 | 1574 | ||
1554 | 1575 | ||
1555 | 1576 | ||
1556 | 1577 | @Callable(i) | |
1557 | 1578 | func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = { | |
1558 | 1579 | let isGetDisabled = if (isGlobalShutdown()) | |
1559 | 1580 | then true | |
1560 | 1581 | else (cfgPoolStatus == PoolShutdown) | |
1561 | 1582 | let checks = [if (!(isGetDisabled)) | |
1562 | 1583 | then true | |
1563 | 1584 | else throw("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1564 | 1585 | then true | |
1565 | 1586 | else throw("no payments are expected")] | |
1566 | 1587 | if ((checks == checks)) | |
1567 | 1588 | then { | |
1568 | 1589 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1569 | 1590 | if ((currentKLp == currentKLp)) | |
1570 | 1591 | then { | |
1571 | 1592 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1572 | 1593 | if ((unstakeInv == unstakeInv)) | |
1573 | 1594 | then { | |
1574 | 1595 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1575 | 1596 | let outAmAmt = res._1 | |
1576 | 1597 | let outPrAmt = res._2 | |
1577 | 1598 | let state = res._10 | |
1578 | 1599 | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1579 | 1600 | then true | |
1580 | 1601 | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1581 | 1602 | then true | |
1582 | 1603 | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1583 | 1604 | if ((checkAmounts == checkAmounts)) | |
1584 | 1605 | then { | |
1585 | 1606 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1586 | 1607 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1587 | 1608 | then { | |
1588 | - | let $ | |
1589 | - | let refreshKLpActions = $ | |
1590 | - | let updatedKLp = $ | |
1609 | + | let $t05820658287 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1610 | + | let refreshKLpActions = $t05820658287._1 | |
1611 | + | let updatedKLp = $t05820658287._2 | |
1591 | 1612 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1592 | 1613 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1593 | 1614 | then (state ++ refreshKLpActions) | |
1594 | 1615 | else throw("Strict value is not equal to itself.") | |
1595 | 1616 | } | |
1596 | 1617 | else throw("Strict value is not equal to itself.") | |
1597 | 1618 | } | |
1598 | 1619 | else throw("Strict value is not equal to itself.") | |
1599 | 1620 | } | |
1600 | 1621 | else throw("Strict value is not equal to itself.") | |
1601 | 1622 | } | |
1602 | 1623 | else throw("Strict value is not equal to itself.") | |
1603 | 1624 | } | |
1604 | 1625 | else throw("Strict value is not equal to itself.") | |
1605 | 1626 | } | |
1606 | 1627 | ||
1607 | 1628 | ||
1608 | 1629 | ||
1609 | 1630 | @Callable(i) | |
1610 | 1631 | func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract))) | |
1611 | 1632 | then throw("permissions denied") | |
1612 | 1633 | else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success") | |
1613 | 1634 | ||
1614 | 1635 | ||
1615 | 1636 | ||
1616 | 1637 | @Callable(i) | |
1617 | 1638 | func refreshKLp () = { | |
1618 | 1639 | let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0) | |
1619 | 1640 | let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay)) | |
1620 | 1641 | then unit | |
1621 | 1642 | else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1622 | 1643 | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1623 | 1644 | then { | |
1624 | 1645 | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
1625 | - | let $ | |
1626 | - | let kLpUpdateActions = $ | |
1627 | - | let updatedKLp = $ | |
1646 | + | let $t05947459538 = refreshKLpInternal(0, 0, 0) | |
1647 | + | let kLpUpdateActions = $t05947459538._1 | |
1648 | + | let updatedKLp = $t05947459538._2 | |
1628 | 1649 | let actions = if ((kLp != updatedKLp)) | |
1629 | 1650 | then kLpUpdateActions | |
1630 | 1651 | else throwErr("nothing to refresh") | |
1631 | 1652 | $Tuple2(actions, toString(updatedKLp)) | |
1632 | 1653 | } | |
1633 | 1654 | else throw("Strict value is not equal to itself.") | |
1634 | 1655 | } | |
1635 | 1656 | ||
1636 | 1657 | ||
1637 | 1658 | ||
1638 | 1659 | @Callable(i) | |
1639 | 1660 | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig()) | |
1640 | 1661 | ||
1641 | 1662 | ||
1642 | 1663 | ||
1643 | 1664 | @Callable(i) | |
1644 | 1665 | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
1645 | 1666 | ||
1646 | 1667 | ||
1647 | 1668 | ||
1648 | 1669 | @Callable(i) | |
1649 | 1670 | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
1650 | 1671 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
1651 | 1672 | $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])]) | |
1652 | 1673 | } | |
1653 | 1674 | ||
1654 | 1675 | ||
1655 | 1676 | ||
1656 | 1677 | @Callable(i) | |
1657 | 1678 | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult))) | |
1658 | 1679 | ||
1659 | 1680 | ||
1660 | 1681 | ||
1661 | 1682 | @Callable(i) | |
1662 | 1683 | func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult)) | |
1663 | 1684 | ||
1664 | 1685 | ||
1665 | 1686 | ||
1666 | 1687 | @Callable(i) | |
1667 | 1688 | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
1668 | 1689 | ||
1669 | 1690 | ||
1670 | 1691 | ||
1671 | 1692 | @Callable(i) | |
1672 | 1693 | func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp)) | |
1673 | 1694 | ||
1674 | 1695 | ||
1675 | 1696 | ||
1676 | 1697 | @Callable(i) | |
1677 | 1698 | func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
1678 | 1699 | let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress)) | |
1679 | 1700 | $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10)) | |
1680 | 1701 | } | |
1681 | 1702 | ||
1682 | 1703 | ||
1683 | 1704 | ||
1684 | 1705 | @Callable(i) | |
1685 | 1706 | func statsREADONLY () = { | |
1686 | 1707 | let cfg = getPoolConfig() | |
1687 | 1708 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1688 | 1709 | let amtAssetId = cfg[idxAmtAssetId] | |
1689 | 1710 | let priceAssetId = cfg[idxPriceAssetId] | |
1690 | 1711 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
1691 | 1712 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
1692 | 1713 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1693 | 1714 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1694 | 1715 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1695 | 1716 | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
1696 | 1717 | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
1697 | 1718 | let pricesList = if ((poolLPBalance == 0)) | |
1698 | 1719 | then [zeroBigInt, zeroBigInt, zeroBigInt] | |
1699 | 1720 | else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance) | |
1700 | 1721 | let curPrice = 0 | |
1701 | 1722 | let lpAmtAssetShare = fromX18(pricesList[1], scale8) | |
1702 | 1723 | let lpPriceAssetShare = fromX18(pricesList[2], scale8) | |
1703 | 1724 | let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this)))) | |
1704 | 1725 | $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)) | |
1705 | 1726 | } | |
1706 | 1727 | ||
1707 | 1728 | ||
1708 | 1729 | ||
1709 | 1730 | @Callable(i) | |
1710 | 1731 | func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = { | |
1711 | 1732 | let cfg = getPoolConfig() | |
1712 | 1733 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1713 | 1734 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1714 | 1735 | let amAssetId = fromBase58String(amAssetIdStr) | |
1715 | 1736 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1716 | 1737 | let prAssetId = fromBase58String(prAssetIdStr) | |
1717 | 1738 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1718 | 1739 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1719 | 1740 | let poolStatus = cfg[idxPoolStatus] | |
1720 | 1741 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1721 | 1742 | let accAmtAssetBalance = getAccBalance(amAssetIdStr) | |
1722 | 1743 | let accPriceAssetBalance = getAccBalance(prAssetIdStr) | |
1723 | 1744 | let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm) | |
1724 | 1745 | let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm) | |
1725 | 1746 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1726 | 1747 | then zeroBigInt | |
1727 | 1748 | else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
1728 | 1749 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
1729 | 1750 | let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
1730 | 1751 | let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm) | |
1731 | 1752 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1732 | 1753 | let calcLpAmt = estPut._1 | |
1733 | 1754 | let curPriceCalc = estPut._3 | |
1734 | 1755 | let amBalance = estPut._4 | |
1735 | 1756 | let prBalance = estPut._5 | |
1736 | 1757 | let lpEmission = estPut._6 | |
1737 | 1758 | $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)) | |
1738 | 1759 | } | |
1739 | 1760 | ||
1740 | 1761 | ||
1741 | 1762 | ||
1742 | 1763 | @Callable(i) | |
1743 | 1764 | func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = { | |
1744 | 1765 | let cfg = getPoolConfig() | |
1745 | 1766 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1746 | 1767 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1747 | 1768 | let amAssetId = fromBase58String(amAssetIdStr) | |
1748 | 1769 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1749 | 1770 | let prAssetId = fromBase58String(prAssetIdStr) | |
1750 | 1771 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1751 | 1772 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1752 | 1773 | let poolStatus = cfg[idxPoolStatus] | |
1753 | 1774 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1754 | 1775 | let amBalanceRaw = getAccBalance(amAssetIdStr) | |
1755 | 1776 | let prBalanceRaw = getAccBalance(prAssetIdStr) | |
1756 | 1777 | let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm) | |
1757 | 1778 | let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm) | |
1758 | 1779 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1759 | 1780 | then zeroBigInt | |
1760 | 1781 | else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18) | |
1761 | 1782 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
1762 | 1783 | let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
1763 | 1784 | let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm) | |
1764 | 1785 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1765 | 1786 | let calcLpAmt = estPut._1 | |
1766 | 1787 | let curPriceCalc = estPut._3 | |
1767 | 1788 | let amBalance = estPut._4 | |
1768 | 1789 | let prBalance = estPut._5 | |
1769 | 1790 | let lpEmission = estPut._6 | |
1770 | 1791 | $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)) | |
1771 | 1792 | } | |
1772 | 1793 | ||
1773 | 1794 | ||
1774 | 1795 | ||
1775 | 1796 | @Callable(i) | |
1776 | 1797 | func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = { | |
1777 | 1798 | let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this) | |
1778 | 1799 | let outAmAmt = res._1 | |
1779 | 1800 | let outPrAmt = res._2 | |
1780 | 1801 | let amBalance = res._5 | |
1781 | 1802 | let prBalance = res._6 | |
1782 | 1803 | let lpEmission = res._7 | |
1783 | 1804 | let curPrice = res._8 | |
1784 | 1805 | let poolStatus = parseIntValue(res._9) | |
1785 | 1806 | $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)) | |
1786 | 1807 | } | |
1787 | 1808 | ||
1788 | 1809 | ||
1789 | 1810 | @Verifier(tx) | |
1790 | 1811 | func verify () = { | |
1791 | 1812 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
1792 | 1813 | case pk: ByteVector => | |
1793 | 1814 | pk | |
1794 | 1815 | case _: Unit => | |
1795 | 1816 | tx.senderPublicKey | |
1796 | 1817 | case _ => | |
1797 | 1818 | throw("Match error") | |
1798 | 1819 | } | |
1799 | 1820 | match tx { | |
1800 | 1821 | case order: Order => | |
1801 | 1822 | let matcherPub = getMatcherPubOrFail() | |
1802 | - | let $ | |
1803 | - | let orderValid = $ | |
1804 | - | let orderValidInfo = $ | |
1823 | + | let $t06820068269 = validateMatcherOrderAllowed(order) | |
1824 | + | let orderValid = $t06820068269._1 | |
1825 | + | let orderValidInfo = $t06820068269._2 | |
1805 | 1826 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1806 | 1827 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1807 | 1828 | if (if (if (orderValid) | |
1808 | 1829 | then senderValid | |
1809 | 1830 | else false) | |
1810 | 1831 | then matcherValid | |
1811 | 1832 | else false) | |
1812 | 1833 | then true | |
1813 | 1834 | else throwOrderError(orderValid, orderValidInfo, senderValid, matcherValid) | |
1814 | 1835 | case s: SetScriptTransaction => | |
1815 | 1836 | if (sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)) | |
1816 | 1837 | then true | |
1817 | 1838 | else { | |
1818 | 1839 | let newHash = blake2b256(value(s.script)) | |
1819 | 1840 | let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash()))) | |
1820 | 1841 | let currentHash = scriptHash(this) | |
1821 | 1842 | if ((allowedHash == newHash)) | |
1822 | 1843 | then (currentHash != newHash) | |
1823 | 1844 | else false | |
1824 | 1845 | } | |
1825 | 1846 | case _ => | |
1826 | 1847 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1827 | 1848 | } | |
1828 | 1849 | } | |
1829 | 1850 |
github/deemru/w8io/026f985 229.88 ms ◑