tx · 8a1PcJ1eLprZGsHPdKsHjFT7LTCtVY3gPDoRxYGq8xHb 3N5TAAx2ixWXBqkfzGcdhtrtDeHrKmBpUT6: -0.03300000 Waves 2022.11.28 16:00 [2336988] smart account 3N5TAAx2ixWXBqkfzGcdhtrtDeHrKmBpUT6 > SELF 0.00000000 Waves
{ "type": 13, "id": "8a1PcJ1eLprZGsHPdKsHjFT7LTCtVY3gPDoRxYGq8xHb", "fee": 3300000, "feeAssetId": null, "timestamp": 1669640376239, "version": 1, "sender": "3N5TAAx2ixWXBqkfzGcdhtrtDeHrKmBpUT6", "senderPublicKey": "2XpKKUppa69BngPvVZi8LE5Rt8hdJtNn1DEpdsKxt48P", "proofs": [ "2xLKPq61emURUMAcyWGy1gC5BPYTytQzocY2kq6AhrqKfdTG9j8iE7ypvjFrj1LBGvxY5GiVN4XSqc67ddyZ81qK" ], "script": "base64:BgL+KwgCEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgQKAggBEgQKAggBEgQKAggBEgUKAwEIARIAEgQKAgEBEgMKAQESBQoDAQEBEgQKAggIEgASABIDCgEIEgUKAwEBARIECgIBARIECgIIARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCBIAEgMKAQESAwoBARIECgIIASIKbFBkZWNpbWFscyIGc2NhbGU4IgxzY2FsZThCaWdJbnQiB3NjYWxlMTgiCnplcm9CaWdJbnQiBGJpZzAiBGJpZzEiBGJpZzIiC3dhdmVzU3RyaW5nIgNTRVAiClBvb2xBY3RpdmUiD1Bvb2xQdXREaXNhYmxlZCITUG9vbE1hdGNoZXJEaXNhYmxlZCIMUG9vbFNodXRkb3duIg5pZHhQb29sQWRkcmVzcyINaWR4UG9vbFN0YXR1cyIQaWR4UG9vbExQQXNzZXRJZCINaWR4QW10QXNzZXRJZCIPaWR4UHJpY2VBc3NldElkIg5pZHhBbXRBc3NldERjbSIQaWR4UHJpY2VBc3NldERjbSIOaWR4SUFtdEFzc2V0SWQiEGlkeElQcmljZUFzc2V0SWQiD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zkJAJQKAgUDbmlsCQC5CQIJAMwIAgIOJWQlZCVkJWQlZCVkJWQJAMwIAgkApAMBBQJjbQkAzAgCCQCkAwEFAmNuCQDMCAIJAKQDAQUCY2MJAMwIAgkApAMBBQJjZQkAzAgCCQCkAwEFAmNiCQDMCAIJAKYDAQUCY2gJAMwIAgkApAMBBQJjYQUDbmlsBQFqAQJncgECZ3MABAJndAQCZEkJAQJlSwADCQABAgUCZEkCCkJ5dGVWZWN0b3IEAmVPBQJkSQUCZU8DCQABAgUCZEkCBFVuaXQIBQJncg9zZW5kZXJQdWJsaWNLZXkJAAIBAgtNYXRjaCBlcnJvcgQCZEkFAmdyAwkAAQIFAmRJAgVPcmRlcgQCZGoFAmRJBAJndQkBAmFNAAQCYXoJAQJkaQEFAmRqBAJhQQkA9AMDCAUCZGoJYm9keUJ5dGVzCQCRAwIIBQJkagZwcm9vZnMAAAgFAmRqD3NlbmRlclB1YmxpY0tleQQCYUIJAPQDAwgFAmRqCWJvZHlCeXRlcwkAkQMCCAUCZGoGcHJvb2ZzAAEFAmd1AwMDBQJhegUCYUEHBQJhQgcGCQECYXkDBQJhegUCYUEFAmFCAwkAAQIFAmRJAhRTZXRTY3JpcHRUcmFuc2FjdGlvbgQCZUwFAmRJBAJndgkA9gMBCQEFdmFsdWUBCAUCZUwGc2NyaXB0BAJndwkA2wQBCQEFdmFsdWUBCQCdCAIFAmFKCQECYXcABAJneAkA8QcBBQR0aGlzAwMJAAACBQJndwUCZ3YJAQIhPQIFAmd4BQJndgcGCQD0AwMIBQJncglib2R5Qnl0ZXMJAJEDAggFAmdyBnByb29mcwAABQJndAkA9AMDCAUCZ3IJYm9keUJ5dGVzCQCRAwIIBQJncgZwcm9vZnMAAAUCZ3RFDX3+", "chainId": 84, "height": 2336988, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9haM2BLJzVzoHWbhYaQ9vMSM9bBmjqSwzDBkRhViSKqg Next: 3MKczecCnnikY2wbH9VmPwTiNLqYVSPRJJmYE5TwTxoA Diff:
Old | New | Differences | |
---|---|---|---|
373 | 373 | } | |
374 | 374 | ||
375 | 375 | ||
376 | + | func calcKLp (amountBalance,priceBalance,lpEmission) = { | |
377 | + | let updatedKLp = fraction(pow((amountBalance * priceBalance), 0, toBigInt(5), 1, 0, DOWN), scale18, lpEmission) | |
378 | + | updatedKLp | |
379 | + | } | |
380 | + | ||
381 | + | ||
382 | + | func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
383 | + | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
384 | + | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
385 | + | let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta) | |
386 | + | let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
387 | + | let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))] | |
388 | + | $Tuple2(actions, updatedKLp) | |
389 | + | } | |
390 | + | ||
391 | + | ||
376 | 392 | func validateMatcherOrderAllowed (order) = { | |
377 | 393 | let cfg = getPoolConfig() | |
378 | 394 | let amtAssetId = cfg[idxAmtAssetId] | |
380 | 396 | let poolStatus = parseIntValue(cfg[idxPoolStatus]) | |
381 | 397 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
382 | 398 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
383 | - | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
384 | - | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
385 | - | let curPriceX18 = if ((order.orderType == Buy)) | |
386 | - | then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance) | |
387 | - | else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance) | |
388 | - | let curPrice = fromX18(curPriceX18, scale8) | |
399 | + | let amountAssetAmount = order.amount | |
400 | + | let priceAssetAmount = fraction(order.amount, order.price, scale8) | |
401 | + | let $t01983820050 = if ((order.orderType == Buy)) | |
402 | + | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
403 | + | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
404 | + | let amountAssetBalanceDelta = $t01983820050._1 | |
405 | + | let priceAssetBalanceDelta = $t01983820050._2 | |
389 | 406 | if (if (if (isGlobalShutdown()) | |
390 | 407 | then true | |
391 | 408 | else (poolStatus == PoolMatcherDisabled)) | |
393 | 410 | else (poolStatus == PoolShutdown)) | |
394 | 411 | then throw("Exchange operations disabled") | |
395 | 412 | else { | |
396 | - | let orderAmtAsset = order.assetPair.amountAsset | |
397 | - | let orderAmtAssetStr = if ((orderAmtAsset == unit)) | |
398 | - | then "WAVES" | |
399 | - | else toBase58String(value(orderAmtAsset)) | |
400 | - | let orderPriceAsset = order.assetPair.priceAsset | |
401 | - | let orderPriceAssetStr = if ((orderPriceAsset == unit)) | |
402 | - | then "WAVES" | |
403 | - | else toBase58String(value(orderPriceAsset)) | |
413 | + | let orderAmtAssetStr = assetIdToString(value(order.assetPair.amountAsset)) | |
414 | + | let orderPriceAssetStr = assetIdToString(value(order.assetPair.priceAsset)) | |
404 | 415 | if (if ((orderAmtAssetStr != amtAssetId)) | |
405 | 416 | then true | |
406 | 417 | else (orderPriceAssetStr != priceAssetId)) | |
407 | 418 | then throw("Wrong order assets.") | |
408 | 419 | else { | |
409 | - | let orderPrice = order.price | |
410 | - | let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm) | |
411 | - | let castedOrderPrice = toScale(orderPrice, scale8, priceDcm) | |
412 | - | let isOrderPriceValid = if ((order.orderType == Buy)) | |
413 | - | then (curPrice >= castedOrderPrice) | |
414 | - | else (castedOrderPrice >= curPrice) | |
415 | - | let kLp = valueOrErrorMessage(getInteger(this, keyKLp), fmtErr("kLp is required")) | |
416 | - | let kLpNew = 0 | |
420 | + | let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp")) | |
421 | + | let $t02064520745 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
422 | + | let unusedActions = $t02064520745._1 | |
423 | + | let kLpNew = $t02064520745._2 | |
417 | 424 | let isOrderValid = (kLpNew > kLp) | |
418 | 425 | isOrderValid | |
419 | 426 | } | |
490 | 497 | else if ((paymentAssetId == cfgPriceAssetId)) | |
491 | 498 | then false | |
492 | 499 | else throwErr("invalid asset") | |
493 | - | let $ | |
500 | + | let $t02342923722 = if (isEval) | |
494 | 501 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
495 | 502 | else if (paymentInAmountAsset) | |
496 | 503 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
497 | 504 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
498 | - | let amountBalanceOld = $ | |
499 | - | let priceBalanceOld = $ | |
500 | - | let $ | |
505 | + | let amountBalanceOld = $t02342923722._1 | |
506 | + | let priceBalanceOld = $t02342923722._2 | |
507 | + | let $t02372623875 = if (paymentInAmountAsset) | |
501 | 508 | then $Tuple2(paymentAmountRaw, 0) | |
502 | 509 | else $Tuple2(0, paymentAmountRaw) | |
503 | - | let amountAssetAmountRaw = $ | |
504 | - | let priceAssetAmountRaw = $ | |
510 | + | let amountAssetAmountRaw = $t02372623875._1 | |
511 | + | let priceAssetAmountRaw = $t02372623875._2 | |
505 | 512 | let amountAssetAmount = takeFee(amountAssetAmountRaw)._1 | |
506 | 513 | let priceAssetAmount = takeFee(priceAssetAmountRaw)._1 | |
507 | - | let $ | |
508 | - | let paymentAmount = $ | |
509 | - | let feeAmount = $ | |
514 | + | let $t02399724056 = takeFee(paymentAmountRaw) | |
515 | + | let paymentAmount = $t02399724056._1 | |
516 | + | let feeAmount = $t02399724056._2 | |
510 | 517 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
511 | 518 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
512 | 519 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
529 | 536 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
530 | 537 | let priceOld = fromX18(priceOldX18, scale8) | |
531 | 538 | let loss = { | |
532 | - | let $ | |
539 | + | let $t02553325700 = if (paymentInAmountAsset) | |
533 | 540 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
534 | 541 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
535 | - | let amount = $ | |
536 | - | let balance = $ | |
542 | + | let amount = $t02553325700._1 | |
543 | + | let balance = $t02553325700._2 | |
537 | 544 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
538 | 545 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
539 | 546 | } | |
567 | 574 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
568 | 575 | let redeemedBigInt = toBigInt(paymentAmount) | |
569 | 576 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
570 | - | let $ | |
571 | - | let totalAmount = $ | |
572 | - | let feeAmount = $ | |
573 | - | let $ | |
577 | + | let $t02730227352 = takeFee(amountRaw) | |
578 | + | let totalAmount = $t02730227352._1 | |
579 | + | let feeAmount = $t02730227352._2 | |
580 | + | let $t02735627582 = if (outInAmountAsset) | |
574 | 581 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
575 | 582 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
576 | - | let outAmAmount = $ | |
577 | - | let outPrAmount = $ | |
578 | - | let amBalanceNew = $ | |
579 | - | let prBalanceNew = $ | |
583 | + | let outAmAmount = $t02735627582._1 | |
584 | + | let outPrAmount = $t02735627582._2 | |
585 | + | let amBalanceNew = $t02735627582._3 | |
586 | + | let prBalanceNew = $t02735627582._4 | |
580 | 587 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
581 | 588 | let priceNew = fromX18(priceNewX18, scale8) | |
582 | 589 | let commonState = if (isEval) | |
591 | 598 | $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset) | |
592 | 599 | } | |
593 | 600 | else throw("Strict value is not equal to itself.") | |
594 | - | } | |
595 | - | ||
596 | - | ||
597 | - | func calcKLp (amountBalance,priceBalance,lpEmission) = { | |
598 | - | let updatedKLp = fraction(pow((amountBalance * priceBalance), 0, toBigInt(5), 1, 0, DOWN), scale18, lpEmission) | |
599 | - | updatedKLp | |
600 | - | } | |
601 | - | ||
602 | - | ||
603 | - | func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
604 | - | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
605 | - | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
606 | - | let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta) | |
607 | - | let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
608 | - | let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))] | |
609 | - | $Tuple2(actions, updatedKLp) | |
610 | 601 | } | |
611 | 602 | ||
612 | 603 | ||
733 | 724 | else throw("Strict value is not equal to itself.") | |
734 | 725 | } | |
735 | 726 | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
736 | - | let $ | |
737 | - | let refreshKLpActions = $ | |
738 | - | let updatedKLp = $ | |
727 | + | let $t03153331598 = refreshKLpInternal(0, 0, 0) | |
728 | + | let refreshKLpActions = $t03153331598._1 | |
729 | + | let updatedKLp = $t03153331598._2 | |
739 | 730 | ((state ++ lpTransfer) ++ refreshKLpActions) | |
740 | 731 | } | |
741 | 732 | else throw("Strict value is not equal to itself.") | |
755 | 746 | else { | |
756 | 747 | let estPut = commonPut(i, maxSlippage, false) | |
757 | 748 | let state = estPut._9 | |
758 | - | let $ | |
759 | - | let refreshKLpActions = $ | |
760 | - | let updatedKLp = $ | |
749 | + | let $t03188431949 = refreshKLpInternal(0, 0, 0) | |
750 | + | let refreshKLpActions = $t03188431949._1 | |
751 | + | let updatedKLp = $t03188431949._2 | |
761 | 752 | (state ++ refreshKLpActions) | |
762 | 753 | } | |
763 | 754 | ||
792 | 783 | let paymentAmountRaw = payment.amount | |
793 | 784 | let userAddress = i.caller | |
794 | 785 | let txId = i.transactionId | |
795 | - | let $ | |
796 | - | let emitAmountEstimated = $ | |
797 | - | let commonState = $ | |
798 | - | let feeAmount = $ | |
799 | - | let bonus = $ | |
800 | - | let paymentInAmountAsset = $ | |
786 | + | let $t03272532874 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
787 | + | let emitAmountEstimated = $t03272532874._1 | |
788 | + | let commonState = $t03272532874._2 | |
789 | + | let feeAmount = $t03272532874._3 | |
790 | + | let bonus = $t03272532874._4 | |
791 | + | let paymentInAmountAsset = $t03272532874._5 | |
801 | 792 | let emitAmount = if (if ((minOutAmount > 0)) | |
802 | 793 | then (minOutAmount > emitAmountEstimated) | |
803 | 794 | else false) | |
817 | 808 | let sendFee = if ((feeAmount > 0)) | |
818 | 809 | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
819 | 810 | else nil | |
820 | - | let $ | |
811 | + | let $t03346033657 = if ((this == feeCollectorAddress)) | |
821 | 812 | then $Tuple2(0, 0) | |
822 | 813 | else if (paymentInAmountAsset) | |
823 | 814 | then $Tuple2(-(feeAmount), 0) | |
824 | 815 | else $Tuple2(0, -(feeAmount)) | |
825 | - | let amountAssetBalanceDelta = $ | |
826 | - | let priceAssetBalanceDelta = $ | |
827 | - | let $ | |
828 | - | let refreshKLpActions = $ | |
829 | - | let updatedKLp = $ | |
816 | + | let amountAssetBalanceDelta = $t03346033657._1 | |
817 | + | let priceAssetBalanceDelta = $t03346033657._2 | |
818 | + | let $t03366033768 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
819 | + | let refreshKLpActions = $t03366033768._1 | |
820 | + | let updatedKLp = $t03366033768._2 | |
830 | 821 | $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
831 | 822 | } | |
832 | 823 | else throw("Strict value is not equal to itself.") | |
838 | 829 | ||
839 | 830 | @Callable(i) | |
840 | 831 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
841 | - | let $ | |
842 | - | let emitAmountEstimated = $ | |
843 | - | let commonState = $ | |
844 | - | let feeAmount = $ | |
845 | - | let bonus = $ | |
846 | - | let paymentInAmountAsset = $ | |
832 | + | let $t03396134118 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
833 | + | let emitAmountEstimated = $t03396134118._1 | |
834 | + | let commonState = $t03396134118._2 | |
835 | + | let feeAmount = $t03396134118._3 | |
836 | + | let bonus = $t03396134118._4 | |
837 | + | let paymentInAmountAsset = $t03396134118._5 | |
847 | 838 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
848 | 839 | } | |
849 | 840 | ||
877 | 868 | let paymentAmount = payment.amount | |
878 | 869 | let userAddress = i.caller | |
879 | 870 | let txId = i.transactionId | |
880 | - | let $ | |
881 | - | let amountEstimated = $ | |
882 | - | let commonState = $ | |
883 | - | let feeAmount = $ | |
884 | - | let bonus = $ | |
885 | - | let outInAmountAsset = $ | |
871 | + | let $t03492335073 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
872 | + | let amountEstimated = $t03492335073._1 | |
873 | + | let commonState = $t03492335073._2 | |
874 | + | let feeAmount = $t03492335073._3 | |
875 | + | let bonus = $t03492335073._4 | |
876 | + | let outInAmountAsset = $t03492335073._5 | |
886 | 877 | let amount = if (if ((minOutAmount > 0)) | |
887 | 878 | then (minOutAmount > amountEstimated) | |
888 | 879 | else false) | |
895 | 886 | let sendFee = if ((feeAmount > 0)) | |
896 | 887 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
897 | 888 | else nil | |
898 | - | let $ | |
889 | + | let $t03557335820 = { | |
899 | 890 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
900 | 891 | then 0 | |
901 | 892 | else feeAmount | |
903 | 894 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
904 | 895 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
905 | 896 | } | |
906 | - | let amountAssetBalanceDelta = $ | |
907 | - | let priceAssetBalanceDelta = $ | |
908 | - | let $ | |
909 | - | let refreshKLpActions = $ | |
910 | - | let updatedKLp = $ | |
897 | + | let amountAssetBalanceDelta = $t03557335820._1 | |
898 | + | let priceAssetBalanceDelta = $t03557335820._2 | |
899 | + | let $t03582335931 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
900 | + | let refreshKLpActions = $t03582335931._1 | |
901 | + | let updatedKLp = $t03582335931._2 | |
911 | 902 | $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
912 | 903 | } | |
913 | 904 | else throw("Strict value is not equal to itself.") | |
919 | 910 | ||
920 | 911 | @Callable(i) | |
921 | 912 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
922 | - | let $ | |
923 | - | let amountEstimated = $ | |
924 | - | let commonState = $ | |
925 | - | let feeAmount = $ | |
926 | - | let bonus = $ | |
927 | - | let outInAmountAsset = $ | |
913 | + | let $t03611536271 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
914 | + | let amountEstimated = $t03611536271._1 | |
915 | + | let commonState = $t03611536271._2 | |
916 | + | let feeAmount = $t03611536271._3 | |
917 | + | let bonus = $t03611536271._4 | |
918 | + | let outInAmountAsset = $t03611536271._5 | |
928 | 919 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
929 | 920 | } | |
930 | 921 | ||
958 | 949 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
959 | 950 | if ((unstakeInv == unstakeInv)) | |
960 | 951 | then { | |
961 | - | let $ | |
962 | - | let amountEstimated = $ | |
963 | - | let commonState = $ | |
964 | - | let feeAmount = $ | |
965 | - | let bonus = $ | |
966 | - | let outInAmountAsset = $ | |
952 | + | let $t03709637244 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
953 | + | let amountEstimated = $t03709637244._1 | |
954 | + | let commonState = $t03709637244._2 | |
955 | + | let feeAmount = $t03709637244._3 | |
956 | + | let bonus = $t03709637244._4 | |
957 | + | let outInAmountAsset = $t03709637244._5 | |
967 | 958 | let amount = if (if ((minOutAmount > 0)) | |
968 | 959 | then (minOutAmount > amountEstimated) | |
969 | 960 | else false) | |
976 | 967 | let sendFee = if ((feeAmount > 0)) | |
977 | 968 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
978 | 969 | else nil | |
979 | - | let $ | |
970 | + | let $t03773937986 = { | |
980 | 971 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
981 | 972 | then 0 | |
982 | 973 | else feeAmount | |
984 | 975 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
985 | 976 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
986 | 977 | } | |
987 | - | let amountAssetBalanceDelta = $ | |
988 | - | let priceAssetBalanceDelta = $ | |
989 | - | let $ | |
990 | - | let refreshKLpActions = $ | |
991 | - | let updatedKLp = $ | |
978 | + | let amountAssetBalanceDelta = $t03773937986._1 | |
979 | + | let priceAssetBalanceDelta = $t03773937986._2 | |
980 | + | let $t03798938097 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
981 | + | let refreshKLpActions = $t03798938097._1 | |
982 | + | let updatedKLp = $t03798938097._2 | |
992 | 983 | $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
993 | 984 | } | |
994 | 985 | else throw("Strict value is not equal to itself.") | |
1011 | 1002 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1012 | 1003 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1013 | 1004 | then { | |
1014 | - | let $ | |
1015 | - | let refreshKLpActions = $ | |
1016 | - | let updatedKLp = $ | |
1005 | + | let $t03888938971 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1006 | + | let refreshKLpActions = $t03888938971._1 | |
1007 | + | let updatedKLp = $t03888938971._2 | |
1017 | 1008 | (state ++ refreshKLpActions) | |
1018 | 1009 | } | |
1019 | 1010 | else throw("Strict value is not equal to itself.") | |
1037 | 1028 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1038 | 1029 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1039 | 1030 | then { | |
1040 | - | let $ | |
1041 | - | let refreshKLpActions = $ | |
1042 | - | let updatedKLp = $ | |
1031 | + | let $t03976739848 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1032 | + | let refreshKLpActions = $t03976739848._1 | |
1033 | + | let updatedKLp = $t03976739848._2 | |
1043 | 1034 | (state ++ refreshKLpActions) | |
1044 | 1035 | } | |
1045 | 1036 | else throw("Strict value is not equal to itself.") | |
1075 | 1066 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1076 | 1067 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1077 | 1068 | then { | |
1078 | - | let $ | |
1079 | - | let refreshKLpActions = $ | |
1080 | - | let updatedKLp = $ | |
1069 | + | let $t04082140902 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1070 | + | let refreshKLpActions = $t04082140902._1 | |
1071 | + | let updatedKLp = $t04082140902._2 | |
1081 | 1072 | (state ++ refreshKLpActions) | |
1082 | 1073 | } | |
1083 | 1074 | else throw("Strict value is not equal to itself.") | |
1120 | 1111 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1121 | 1112 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1122 | 1113 | then { | |
1123 | - | let $ | |
1124 | - | let refreshKLpActions = $ | |
1125 | - | let updatedKLp = $ | |
1114 | + | let $t04204242123 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1115 | + | let refreshKLpActions = $t04204242123._1 | |
1116 | + | let updatedKLp = $t04204242123._2 | |
1126 | 1117 | (state ++ refreshKLpActions) | |
1127 | 1118 | } | |
1128 | 1119 | else throw("Strict value is not equal to itself.") | |
1151 | 1142 | else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1152 | 1143 | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1153 | 1144 | then { | |
1154 | - | let $ | |
1155 | - | let actions = $ | |
1156 | - | let updatedKLp = $ | |
1145 | + | let $t04311143166 = refreshKLpInternal(0, 0, 0) | |
1146 | + | let actions = $t04311143166._1 | |
1147 | + | let updatedKLp = $t04311143166._2 | |
1157 | 1148 | $Tuple2(actions, toString(updatedKLp)) | |
1158 | 1149 | } | |
1159 | 1150 | else throw("Strict value is not equal to itself.") |
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 fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18)) | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
69 | 69 | ||
70 | 70 | ||
71 | 71 | func abs (val) = if ((0 > val)) | |
72 | 72 | then -(val) | |
73 | 73 | else val | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | func absBigInt (val) = if ((zeroBigInt > val)) | |
77 | 77 | then -(val) | |
78 | 78 | else val | |
79 | 79 | ||
80 | 80 | ||
81 | 81 | func fc () = "%s__factoryContract" | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | func mpk () = "%s__managerPublicKey" | |
85 | 85 | ||
86 | 86 | ||
87 | 87 | func pmpk () = "%s__pendingManagerPublicKey" | |
88 | 88 | ||
89 | 89 | ||
90 | 90 | func pl () = "%s%s__price__last" | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | func ph (h,timestamp) = makeString(["%s%s%d%d__price__history", toString(h), toString(timestamp)], SEP) | |
94 | 94 | ||
95 | 95 | ||
96 | 96 | func pau (userAddress,txId) = ((("%s%s%s__P__" + userAddress) + "__") + txId) | |
97 | 97 | ||
98 | 98 | ||
99 | 99 | func gau (userAddress,txId) = ((("%s%s%s__G__" + userAddress) + "__") + txId) | |
100 | 100 | ||
101 | 101 | ||
102 | 102 | func aa () = "%s__amountAsset" | |
103 | 103 | ||
104 | 104 | ||
105 | 105 | func pa () = "%s__priceAsset" | |
106 | 106 | ||
107 | 107 | ||
108 | 108 | let keyFee = "%s__fee" | |
109 | 109 | ||
110 | 110 | let feeDefault = fraction(10, scale8, 10000) | |
111 | 111 | ||
112 | 112 | let fee = valueOrElse(getInteger(this, keyFee), feeDefault) | |
113 | 113 | ||
114 | 114 | let keyKLp = makeString(["%s", "kLp"], SEP) | |
115 | 115 | ||
116 | 116 | let keyKLpRefreshedHeight = makeString(["%s", "kLpRefreshedHeight"], SEP) | |
117 | 117 | ||
118 | 118 | let keyKLpRefreshDelay = makeString(["%s", "refreshKLpDelay"], SEP) | |
119 | 119 | ||
120 | 120 | let kLpRefreshDelayDefault = 30 | |
121 | 121 | ||
122 | 122 | let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault) | |
123 | 123 | ||
124 | 124 | func keyFactoryConfig () = "%s__factoryConfig" | |
125 | 125 | ||
126 | 126 | ||
127 | 127 | func keyMatcherPub () = "%s%s__matcher__publicKey" | |
128 | 128 | ||
129 | 129 | ||
130 | 130 | func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset") | |
131 | 131 | ||
132 | 132 | ||
133 | 133 | func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config") | |
134 | 134 | ||
135 | 135 | ||
136 | 136 | func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr) | |
137 | 137 | ||
138 | 138 | ||
139 | 139 | func keyAllPoolsShutdown () = "%s__shutdown" | |
140 | 140 | ||
141 | 141 | ||
142 | 142 | func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress) | |
143 | 143 | ||
144 | 144 | ||
145 | 145 | func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash" | |
146 | 146 | ||
147 | 147 | ||
148 | 148 | let keyFeeCollectorAddress = "%s__feeCollectorAddress" | |
149 | 149 | ||
150 | 150 | func throwOrderError (orderValid,senderValid,matcherValid) = throw(((((("order validation failed: orderValid=" + toString(orderValid)) + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid))) | |
151 | 151 | ||
152 | 152 | ||
153 | 153 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
154 | 154 | ||
155 | 155 | ||
156 | 156 | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
157 | 157 | ||
158 | 158 | ||
159 | 159 | func throwErr (msg) = throw(makeString(["lp.ride:", msg], " ")) | |
160 | 160 | ||
161 | 161 | ||
162 | 162 | func fmtErr (msg) = makeString(["lp.ride:", msg], " ") | |
163 | 163 | ||
164 | 164 | ||
165 | 165 | let factoryContract = addressFromStringValue(getStringOrFail(this, fc())) | |
166 | 166 | ||
167 | 167 | let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress)) | |
168 | 168 | ||
169 | 169 | func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false) | |
170 | 170 | ||
171 | 171 | ||
172 | 172 | func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub())) | |
173 | 173 | ||
174 | 174 | ||
175 | 175 | func getPoolConfig () = { | |
176 | 176 | let amtAsset = getStringOrFail(this, aa()) | |
177 | 177 | let priceAsset = getStringOrFail(this, pa()) | |
178 | 178 | let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset)) | |
179 | 179 | let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset)) | |
180 | 180 | split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP) | |
181 | 181 | } | |
182 | 182 | ||
183 | 183 | ||
184 | 184 | func parseAssetId (input) = if ((input == wavesString)) | |
185 | 185 | then unit | |
186 | 186 | else fromBase58String(input) | |
187 | 187 | ||
188 | 188 | ||
189 | 189 | func assetIdToString (input) = if ((input == unit)) | |
190 | 190 | then wavesString | |
191 | 191 | else toBase58String(value(input)) | |
192 | 192 | ||
193 | 193 | ||
194 | 194 | 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])) | |
195 | 195 | ||
196 | 196 | ||
197 | 197 | let poolConfigParsed = parsePoolConfig(getPoolConfig()) | |
198 | 198 | ||
199 | 199 | let $t079158081 = poolConfigParsed | |
200 | 200 | ||
201 | 201 | let cfgPoolAddress = $t079158081._1 | |
202 | 202 | ||
203 | 203 | let cfgPoolStatus = $t079158081._2 | |
204 | 204 | ||
205 | 205 | let cfgLpAssetId = $t079158081._3 | |
206 | 206 | ||
207 | 207 | let cfgAmountAssetId = $t079158081._4 | |
208 | 208 | ||
209 | 209 | let cfgPriceAssetId = $t079158081._5 | |
210 | 210 | ||
211 | 211 | let cfgAmountAssetDecimals = $t079158081._6 | |
212 | 212 | ||
213 | 213 | let cfgPriceAssetDecimals = $t079158081._7 | |
214 | 214 | ||
215 | 215 | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
216 | 216 | ||
217 | 217 | ||
218 | 218 | let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address") | |
219 | 219 | ||
220 | 220 | let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address") | |
221 | 221 | ||
222 | 222 | 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) | |
223 | 223 | ||
224 | 224 | ||
225 | 225 | 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) | |
226 | 226 | ||
227 | 227 | ||
228 | 228 | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
229 | 229 | then wavesBalance(this).available | |
230 | 230 | else assetBalance(this, fromBase58String(assetId)) | |
231 | 231 | ||
232 | 232 | ||
233 | 233 | func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
234 | 234 | ||
235 | 235 | ||
236 | 236 | func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
237 | 237 | let amtAssetAmtX18 = toX18(amAmt, amAssetDcm) | |
238 | 238 | let priceAssetAmtX18 = toX18(prAmt, prAssetDcm) | |
239 | 239 | calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
240 | 240 | } | |
241 | 241 | ||
242 | 242 | ||
243 | 243 | func calcPrices (amAmt,prAmt,lpAmt) = { | |
244 | 244 | let cfg = getPoolConfig() | |
245 | 245 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
246 | 246 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
247 | 247 | let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt) | |
248 | 248 | let amAmtX18 = toX18(amAmt, amtAssetDcm) | |
249 | 249 | let prAmtX18 = toX18(prAmt, priceAssetDcm) | |
250 | 250 | let lpAmtX18 = toX18(lpAmt, scale8) | |
251 | 251 | let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18) | |
252 | 252 | let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18) | |
253 | 253 | [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18] | |
254 | 254 | } | |
255 | 255 | ||
256 | 256 | ||
257 | 257 | func calculatePrices (amAmt,prAmt,lpAmt) = { | |
258 | 258 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
259 | 259 | [fromX18(prices[0], scale8), fromX18(prices[1], scale8), fromX18(prices[2], scale8)] | |
260 | 260 | } | |
261 | 261 | ||
262 | 262 | ||
263 | 263 | func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
264 | 264 | let cfg = getPoolConfig() | |
265 | 265 | let lpAssetId = cfg[idxPoolLPAssetId] | |
266 | 266 | let amAssetId = cfg[idxAmtAssetId] | |
267 | 267 | let prAssetId = cfg[idxPriceAssetId] | |
268 | 268 | let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
269 | 269 | let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
270 | 270 | let poolStatus = cfg[idxPoolStatus] | |
271 | 271 | let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity | |
272 | 272 | if ((lpAssetId != pmtAssetId)) | |
273 | 273 | then throw("Invalid asset passed.") | |
274 | 274 | else { | |
275 | 275 | let amBalance = getAccBalance(amAssetId) | |
276 | 276 | let amBalanceX18 = toX18(amBalance, amAssetDcm) | |
277 | 277 | let prBalance = getAccBalance(prAssetId) | |
278 | 278 | let prBalanceX18 = toX18(prBalance, prAssetDcm) | |
279 | 279 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
280 | 280 | let curPrice = fromX18(curPriceX18, scale8) | |
281 | 281 | let pmtLpAmtX18 = toX18(pmtLpAmt, scale8) | |
282 | 282 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
283 | 283 | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
284 | 284 | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
285 | 285 | let outAmAmt = fromX18(outAmAmtX18, amAssetDcm) | |
286 | 286 | let outPrAmt = fromX18(outPrAmtX18, prAssetDcm) | |
287 | 287 | let state = if ((txId58 == "")) | |
288 | 288 | then nil | |
289 | 289 | else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
290 | 290 | then unit | |
291 | 291 | else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES")) | |
292 | 292 | then unit | |
293 | 293 | 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)] | |
294 | 294 | $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state) | |
295 | 295 | } | |
296 | 296 | } | |
297 | 297 | ||
298 | 298 | ||
299 | 299 | func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = { | |
300 | 300 | let cfg = getPoolConfig() | |
301 | 301 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
302 | 302 | let amAssetIdStr = cfg[idxAmtAssetId] | |
303 | 303 | let prAssetIdStr = cfg[idxPriceAssetId] | |
304 | 304 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
305 | 305 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
306 | 306 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
307 | 307 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
308 | 308 | let poolStatus = cfg[idxPoolStatus] | |
309 | 309 | let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
310 | 310 | let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES"))) | |
311 | 311 | let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES"))) | |
312 | 312 | if (if ((amAssetIdStr != inAmAssetIdStr)) | |
313 | 313 | then true | |
314 | 314 | else (prAssetIdStr != inPrAssetIdStr)) | |
315 | 315 | then throw("Invalid amt or price asset passed.") | |
316 | 316 | else { | |
317 | 317 | let amBalance = if (isEvaluate) | |
318 | 318 | then getAccBalance(amAssetIdStr) | |
319 | 319 | else (getAccBalance(amAssetIdStr) - inAmAssetAmt) | |
320 | 320 | let prBalance = if (isEvaluate) | |
321 | 321 | then getAccBalance(prAssetIdStr) | |
322 | 322 | else (getAccBalance(prAssetIdStr) - inPrAssetAmt) | |
323 | 323 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
324 | 324 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
325 | 325 | let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18) | |
326 | 326 | let amBalanceX18 = toX18(amBalance, amtAssetDcm) | |
327 | 327 | let prBalanceX18 = toX18(prBalance, priceAssetDcm) | |
328 | 328 | let res = if ((lpEmission == 0)) | |
329 | 329 | then { | |
330 | 330 | let curPriceX18 = zeroBigInt | |
331 | 331 | let slippageX18 = zeroBigInt | |
332 | 332 | let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN) | |
333 | 333 | $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
334 | 334 | } | |
335 | 335 | else { | |
336 | 336 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
337 | 337 | let slippageX18 = fraction(absBigInt((curPriceX18 - userPriceX18)), scale18, curPriceX18) | |
338 | 338 | let slippageToleranceX18 = toX18(slippageTolerance, scale8) | |
339 | 339 | if (if ((curPriceX18 != zeroBigInt)) | |
340 | 340 | then (slippageX18 > slippageToleranceX18) | |
341 | 341 | else false) | |
342 | 342 | then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18))) | |
343 | 343 | else { | |
344 | 344 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
345 | 345 | let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
346 | 346 | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
347 | 347 | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
348 | 348 | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
349 | 349 | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
350 | 350 | let expAmtAssetAmtX18 = expectedAmts._1 | |
351 | 351 | let expPriceAssetAmtX18 = expectedAmts._2 | |
352 | 352 | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18) | |
353 | 353 | $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18) | |
354 | 354 | } | |
355 | 355 | } | |
356 | 356 | let calcLpAmt = res._1 | |
357 | 357 | let calcAmAssetPmt = res._2 | |
358 | 358 | let calcPrAssetPmt = res._3 | |
359 | 359 | let curPrice = fromX18(res._4, scale8) | |
360 | 360 | let slippageCalc = fromX18(res._5, scale8) | |
361 | 361 | if ((0 >= calcLpAmt)) | |
362 | 362 | then throw("Invalid calculations. LP calculated is less than zero.") | |
363 | 363 | else { | |
364 | 364 | let emitLpAmt = if (!(emitLp)) | |
365 | 365 | then 0 | |
366 | 366 | else calcLpAmt | |
367 | 367 | let amDiff = (inAmAssetAmt - calcAmAssetPmt) | |
368 | 368 | let prDiff = (inPrAssetAmt - calcPrAssetPmt) | |
369 | 369 | 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))] | |
370 | 370 | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId) | |
371 | 371 | } | |
372 | 372 | } | |
373 | 373 | } | |
374 | 374 | ||
375 | 375 | ||
376 | + | func calcKLp (amountBalance,priceBalance,lpEmission) = { | |
377 | + | let updatedKLp = fraction(pow((amountBalance * priceBalance), 0, toBigInt(5), 1, 0, DOWN), scale18, lpEmission) | |
378 | + | updatedKLp | |
379 | + | } | |
380 | + | ||
381 | + | ||
382 | + | func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
383 | + | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
384 | + | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
385 | + | let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta) | |
386 | + | let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
387 | + | let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))] | |
388 | + | $Tuple2(actions, updatedKLp) | |
389 | + | } | |
390 | + | ||
391 | + | ||
376 | 392 | func validateMatcherOrderAllowed (order) = { | |
377 | 393 | let cfg = getPoolConfig() | |
378 | 394 | let amtAssetId = cfg[idxAmtAssetId] | |
379 | 395 | let priceAssetId = cfg[idxPriceAssetId] | |
380 | 396 | let poolStatus = parseIntValue(cfg[idxPoolStatus]) | |
381 | 397 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
382 | 398 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
383 | - | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
384 | - | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
385 | - | let curPriceX18 = if ((order.orderType == Buy)) | |
386 | - | then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance) | |
387 | - | else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance) | |
388 | - | let curPrice = fromX18(curPriceX18, scale8) | |
399 | + | let amountAssetAmount = order.amount | |
400 | + | let priceAssetAmount = fraction(order.amount, order.price, scale8) | |
401 | + | let $t01983820050 = if ((order.orderType == Buy)) | |
402 | + | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
403 | + | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
404 | + | let amountAssetBalanceDelta = $t01983820050._1 | |
405 | + | let priceAssetBalanceDelta = $t01983820050._2 | |
389 | 406 | if (if (if (isGlobalShutdown()) | |
390 | 407 | then true | |
391 | 408 | else (poolStatus == PoolMatcherDisabled)) | |
392 | 409 | then true | |
393 | 410 | else (poolStatus == PoolShutdown)) | |
394 | 411 | then throw("Exchange operations disabled") | |
395 | 412 | else { | |
396 | - | let orderAmtAsset = order.assetPair.amountAsset | |
397 | - | let orderAmtAssetStr = if ((orderAmtAsset == unit)) | |
398 | - | then "WAVES" | |
399 | - | else toBase58String(value(orderAmtAsset)) | |
400 | - | let orderPriceAsset = order.assetPair.priceAsset | |
401 | - | let orderPriceAssetStr = if ((orderPriceAsset == unit)) | |
402 | - | then "WAVES" | |
403 | - | else toBase58String(value(orderPriceAsset)) | |
413 | + | let orderAmtAssetStr = assetIdToString(value(order.assetPair.amountAsset)) | |
414 | + | let orderPriceAssetStr = assetIdToString(value(order.assetPair.priceAsset)) | |
404 | 415 | if (if ((orderAmtAssetStr != amtAssetId)) | |
405 | 416 | then true | |
406 | 417 | else (orderPriceAssetStr != priceAssetId)) | |
407 | 418 | then throw("Wrong order assets.") | |
408 | 419 | else { | |
409 | - | let orderPrice = order.price | |
410 | - | let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm) | |
411 | - | let castedOrderPrice = toScale(orderPrice, scale8, priceDcm) | |
412 | - | let isOrderPriceValid = if ((order.orderType == Buy)) | |
413 | - | then (curPrice >= castedOrderPrice) | |
414 | - | else (castedOrderPrice >= curPrice) | |
415 | - | let kLp = valueOrErrorMessage(getInteger(this, keyKLp), fmtErr("kLp is required")) | |
416 | - | let kLpNew = 0 | |
420 | + | let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp")) | |
421 | + | let $t02064520745 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
422 | + | let unusedActions = $t02064520745._1 | |
423 | + | let kLpNew = $t02064520745._2 | |
417 | 424 | let isOrderValid = (kLpNew > kLp) | |
418 | 425 | isOrderValid | |
419 | 426 | } | |
420 | 427 | } | |
421 | 428 | } | |
422 | 429 | ||
423 | 430 | ||
424 | 431 | func commonGet (i) = if ((size(i.payments) != 1)) | |
425 | 432 | then throw("exactly 1 payment is expected") | |
426 | 433 | else { | |
427 | 434 | let pmt = value(i.payments[0]) | |
428 | 435 | let pmtAssetId = value(pmt.assetId) | |
429 | 436 | let pmtAmt = pmt.amount | |
430 | 437 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
431 | 438 | let outAmAmt = res._1 | |
432 | 439 | let outPrAmt = res._2 | |
433 | 440 | let poolStatus = parseIntValue(res._9) | |
434 | 441 | let state = res._10 | |
435 | 442 | if (if (isGlobalShutdown()) | |
436 | 443 | then true | |
437 | 444 | else (poolStatus == PoolShutdown)) | |
438 | 445 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
439 | 446 | else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state) | |
440 | 447 | } | |
441 | 448 | ||
442 | 449 | ||
443 | 450 | func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2)) | |
444 | 451 | then throw("exactly 2 payments are expected") | |
445 | 452 | else { | |
446 | 453 | let amAssetPmt = value(i.payments[0]) | |
447 | 454 | let prAssetPmt = value(i.payments[1]) | |
448 | 455 | let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp) | |
449 | 456 | let poolStatus = parseIntValue(estPut._8) | |
450 | 457 | if (if (if (isGlobalShutdown()) | |
451 | 458 | then true | |
452 | 459 | else (poolStatus == PoolPutDisabled)) | |
453 | 460 | then true | |
454 | 461 | else (poolStatus == PoolShutdown)) | |
455 | 462 | then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus))) | |
456 | 463 | else estPut | |
457 | 464 | } | |
458 | 465 | ||
459 | 466 | ||
460 | 467 | func emit (amount) = { | |
461 | 468 | let emitInv = invoke(factoryContract, "emit", [amount], nil) | |
462 | 469 | if ((emitInv == emitInv)) | |
463 | 470 | then { | |
464 | 471 | let emitInvLegacy = match emitInv { | |
465 | 472 | case legacyFactoryContract: Address => | |
466 | 473 | invoke(legacyFactoryContract, "emit", [amount], nil) | |
467 | 474 | case _ => | |
468 | 475 | unit | |
469 | 476 | } | |
470 | 477 | if ((emitInvLegacy == emitInvLegacy)) | |
471 | 478 | then amount | |
472 | 479 | else throw("Strict value is not equal to itself.") | |
473 | 480 | } | |
474 | 481 | else throw("Strict value is not equal to itself.") | |
475 | 482 | } | |
476 | 483 | ||
477 | 484 | ||
478 | 485 | func takeFee (amount) = { | |
479 | 486 | let feeAmount = fraction(amount, fee, scale8) | |
480 | 487 | $Tuple2((amount - feeAmount), feeAmount) | |
481 | 488 | } | |
482 | 489 | ||
483 | 490 | ||
484 | 491 | func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = { | |
485 | 492 | let isEval = (txId == unit) | |
486 | 493 | let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
487 | 494 | let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
488 | 495 | let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId)) | |
489 | 496 | then true | |
490 | 497 | else if ((paymentAssetId == cfgPriceAssetId)) | |
491 | 498 | then false | |
492 | 499 | else throwErr("invalid asset") | |
493 | - | let $ | |
500 | + | let $t02342923722 = if (isEval) | |
494 | 501 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
495 | 502 | else if (paymentInAmountAsset) | |
496 | 503 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
497 | 504 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
498 | - | let amountBalanceOld = $ | |
499 | - | let priceBalanceOld = $ | |
500 | - | let $ | |
505 | + | let amountBalanceOld = $t02342923722._1 | |
506 | + | let priceBalanceOld = $t02342923722._2 | |
507 | + | let $t02372623875 = if (paymentInAmountAsset) | |
501 | 508 | then $Tuple2(paymentAmountRaw, 0) | |
502 | 509 | else $Tuple2(0, paymentAmountRaw) | |
503 | - | let amountAssetAmountRaw = $ | |
504 | - | let priceAssetAmountRaw = $ | |
510 | + | let amountAssetAmountRaw = $t02372623875._1 | |
511 | + | let priceAssetAmountRaw = $t02372623875._2 | |
505 | 512 | let amountAssetAmount = takeFee(amountAssetAmountRaw)._1 | |
506 | 513 | let priceAssetAmount = takeFee(priceAssetAmountRaw)._1 | |
507 | - | let $ | |
508 | - | let paymentAmount = $ | |
509 | - | let feeAmount = $ | |
514 | + | let $t02399724056 = takeFee(paymentAmountRaw) | |
515 | + | let paymentAmount = $t02399724056._1 | |
516 | + | let feeAmount = $t02399724056._2 | |
510 | 517 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
511 | 518 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
512 | 519 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
513 | 520 | let priceNew = fromX18(priceNewX18, scale8) | |
514 | 521 | let paymentBalance = if (paymentInAmountAsset) | |
515 | 522 | then amountBalanceOld | |
516 | 523 | else priceBalanceOld | |
517 | 524 | let paymentBalanceBigInt = toBigInt(paymentBalance) | |
518 | 525 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
519 | 526 | let chechSupply = if ((supplyBigInt > big0)) | |
520 | 527 | then true | |
521 | 528 | else throwErr("initial deposit requires all coins") | |
522 | 529 | if ((chechSupply == chechSupply)) | |
523 | 530 | then { | |
524 | 531 | let depositBigInt = toBigInt(paymentAmount) | |
525 | 532 | let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))]) | |
526 | 533 | let commonState = if (isEval) | |
527 | 534 | then nil | |
528 | 535 | 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))] | |
529 | 536 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
530 | 537 | let priceOld = fromX18(priceOldX18, scale8) | |
531 | 538 | let loss = { | |
532 | - | let $ | |
539 | + | let $t02553325700 = if (paymentInAmountAsset) | |
533 | 540 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
534 | 541 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
535 | - | let amount = $ | |
536 | - | let balance = $ | |
542 | + | let amount = $t02553325700._1 | |
543 | + | let balance = $t02553325700._2 | |
537 | 544 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
538 | 545 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
539 | 546 | } | |
540 | 547 | $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset) | |
541 | 548 | } | |
542 | 549 | else throw("Strict value is not equal to itself.") | |
543 | 550 | } | |
544 | 551 | ||
545 | 552 | ||
546 | 553 | func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = { | |
547 | 554 | let isEval = (txId == unit) | |
548 | 555 | let checks = [if ((paymentAssetId == cfgLpAssetId)) | |
549 | 556 | then true | |
550 | 557 | else throwErr("invalid lp asset")] | |
551 | 558 | if ((checks == checks)) | |
552 | 559 | then { | |
553 | 560 | let outInAmountAsset = if ((outAssetId == cfgAmountAssetId)) | |
554 | 561 | then true | |
555 | 562 | else if ((outAssetId == cfgPriceAssetId)) | |
556 | 563 | then false | |
557 | 564 | else throwErr("invalid asset") | |
558 | 565 | let balanceBigInt = if (outInAmountAsset) | |
559 | 566 | then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) | |
560 | 567 | else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) | |
561 | 568 | let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
562 | 569 | let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
563 | 570 | let outBalance = if (outInAmountAsset) | |
564 | 571 | then amBalanceOld | |
565 | 572 | else prBalanceOld | |
566 | 573 | let outBalanceBigInt = toBigInt(outBalance) | |
567 | 574 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
568 | 575 | let redeemedBigInt = toBigInt(paymentAmount) | |
569 | 576 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
570 | - | let $ | |
571 | - | let totalAmount = $ | |
572 | - | let feeAmount = $ | |
573 | - | let $ | |
577 | + | let $t02730227352 = takeFee(amountRaw) | |
578 | + | let totalAmount = $t02730227352._1 | |
579 | + | let feeAmount = $t02730227352._2 | |
580 | + | let $t02735627582 = if (outInAmountAsset) | |
574 | 581 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
575 | 582 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
576 | - | let outAmAmount = $ | |
577 | - | let outPrAmount = $ | |
578 | - | let amBalanceNew = $ | |
579 | - | let prBalanceNew = $ | |
583 | + | let outAmAmount = $t02735627582._1 | |
584 | + | let outPrAmount = $t02735627582._2 | |
585 | + | let amBalanceNew = $t02735627582._3 | |
586 | + | let prBalanceNew = $t02735627582._4 | |
580 | 587 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
581 | 588 | let priceNew = fromX18(priceNewX18, scale8) | |
582 | 589 | let commonState = if (isEval) | |
583 | 590 | then nil | |
584 | 591 | 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)] | |
585 | 592 | let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals)) | |
586 | 593 | let priceOld = fromX18(priceOldX18, scale8) | |
587 | 594 | let loss = { | |
588 | 595 | let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2) | |
589 | 596 | fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset) | |
590 | 597 | } | |
591 | 598 | $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset) | |
592 | 599 | } | |
593 | 600 | else throw("Strict value is not equal to itself.") | |
594 | - | } | |
595 | - | ||
596 | - | ||
597 | - | func calcKLp (amountBalance,priceBalance,lpEmission) = { | |
598 | - | let updatedKLp = fraction(pow((amountBalance * priceBalance), 0, toBigInt(5), 1, 0, DOWN), scale18, lpEmission) | |
599 | - | updatedKLp | |
600 | - | } | |
601 | - | ||
602 | - | ||
603 | - | func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
604 | - | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
605 | - | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
606 | - | let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta) | |
607 | - | let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
608 | - | let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))] | |
609 | - | $Tuple2(actions, updatedKLp) | |
610 | 601 | } | |
611 | 602 | ||
612 | 603 | ||
613 | 604 | func managerPublicKeyOrUnit () = match getString(mpk()) { | |
614 | 605 | case s: String => | |
615 | 606 | fromBase58String(s) | |
616 | 607 | case _: Unit => | |
617 | 608 | unit | |
618 | 609 | case _ => | |
619 | 610 | throw("Match error") | |
620 | 611 | } | |
621 | 612 | ||
622 | 613 | ||
623 | 614 | func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) { | |
624 | 615 | case s: String => | |
625 | 616 | fromBase58String(s) | |
626 | 617 | case _: Unit => | |
627 | 618 | unit | |
628 | 619 | case _ => | |
629 | 620 | throw("Match error") | |
630 | 621 | } | |
631 | 622 | ||
632 | 623 | ||
633 | 624 | func isManager (i) = match managerPublicKeyOrUnit() { | |
634 | 625 | case pk: ByteVector => | |
635 | 626 | (i.callerPublicKey == pk) | |
636 | 627 | case _: Unit => | |
637 | 628 | (i.caller == this) | |
638 | 629 | case _ => | |
639 | 630 | throw("Match error") | |
640 | 631 | } | |
641 | 632 | ||
642 | 633 | ||
643 | 634 | func mustManager (i) = { | |
644 | 635 | let pd = throw("Permission denied") | |
645 | 636 | match managerPublicKeyOrUnit() { | |
646 | 637 | case pk: ByteVector => | |
647 | 638 | if ((i.callerPublicKey == pk)) | |
648 | 639 | then true | |
649 | 640 | else pd | |
650 | 641 | case _: Unit => | |
651 | 642 | if ((i.caller == this)) | |
652 | 643 | then true | |
653 | 644 | else pd | |
654 | 645 | case _ => | |
655 | 646 | throw("Match error") | |
656 | 647 | } | |
657 | 648 | } | |
658 | 649 | ||
659 | 650 | ||
660 | 651 | @Callable(i) | |
661 | 652 | func setManager (pendingManagerPublicKey) = { | |
662 | 653 | let checkCaller = mustManager(i) | |
663 | 654 | if ((checkCaller == checkCaller)) | |
664 | 655 | then { | |
665 | 656 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
666 | 657 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
667 | 658 | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
668 | 659 | else throw("Strict value is not equal to itself.") | |
669 | 660 | } | |
670 | 661 | else throw("Strict value is not equal to itself.") | |
671 | 662 | } | |
672 | 663 | ||
673 | 664 | ||
674 | 665 | ||
675 | 666 | @Callable(i) | |
676 | 667 | func confirmManager () = { | |
677 | 668 | let pm = pendingManagerPublicKeyOrUnit() | |
678 | 669 | let hasPM = if (isDefined(pm)) | |
679 | 670 | then true | |
680 | 671 | else throw("No pending manager") | |
681 | 672 | if ((hasPM == hasPM)) | |
682 | 673 | then { | |
683 | 674 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
684 | 675 | then true | |
685 | 676 | else throw("You are not pending manager") | |
686 | 677 | if ((checkPM == checkPM)) | |
687 | 678 | then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())] | |
688 | 679 | else throw("Strict value is not equal to itself.") | |
689 | 680 | } | |
690 | 681 | else throw("Strict value is not equal to itself.") | |
691 | 682 | } | |
692 | 683 | ||
693 | 684 | ||
694 | 685 | ||
695 | 686 | @Callable(i) | |
696 | 687 | func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance)) | |
697 | 688 | then throw("Invalid slippageTolerance passed") | |
698 | 689 | else { | |
699 | 690 | let estPut = commonPut(i, slippageTolerance, true) | |
700 | 691 | let emitLpAmt = estPut._2 | |
701 | 692 | let lpAssetId = estPut._7 | |
702 | 693 | let state = estPut._9 | |
703 | 694 | let amDiff = estPut._10 | |
704 | 695 | let prDiff = estPut._11 | |
705 | 696 | let amId = estPut._12 | |
706 | 697 | let prId = estPut._13 | |
707 | 698 | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
708 | 699 | if ((emitInv == emitInv)) | |
709 | 700 | then { | |
710 | 701 | let emitInvLegacy = match emitInv { | |
711 | 702 | case legacyFactoryContract: Address => | |
712 | 703 | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
713 | 704 | case _ => | |
714 | 705 | unit | |
715 | 706 | } | |
716 | 707 | if ((emitInvLegacy == emitInvLegacy)) | |
717 | 708 | then { | |
718 | 709 | let slippageAInv = if ((amDiff > 0)) | |
719 | 710 | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
720 | 711 | else nil | |
721 | 712 | if ((slippageAInv == slippageAInv)) | |
722 | 713 | then { | |
723 | 714 | let slippagePInv = if ((prDiff > 0)) | |
724 | 715 | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
725 | 716 | else nil | |
726 | 717 | if ((slippagePInv == slippagePInv)) | |
727 | 718 | then { | |
728 | 719 | let lpTransfer = if (shouldAutoStake) | |
729 | 720 | then { | |
730 | 721 | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
731 | 722 | if ((slpStakeInv == slpStakeInv)) | |
732 | 723 | then nil | |
733 | 724 | else throw("Strict value is not equal to itself.") | |
734 | 725 | } | |
735 | 726 | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
736 | - | let $ | |
737 | - | let refreshKLpActions = $ | |
738 | - | let updatedKLp = $ | |
727 | + | let $t03153331598 = refreshKLpInternal(0, 0, 0) | |
728 | + | let refreshKLpActions = $t03153331598._1 | |
729 | + | let updatedKLp = $t03153331598._2 | |
739 | 730 | ((state ++ lpTransfer) ++ refreshKLpActions) | |
740 | 731 | } | |
741 | 732 | else throw("Strict value is not equal to itself.") | |
742 | 733 | } | |
743 | 734 | else throw("Strict value is not equal to itself.") | |
744 | 735 | } | |
745 | 736 | else throw("Strict value is not equal to itself.") | |
746 | 737 | } | |
747 | 738 | else throw("Strict value is not equal to itself.") | |
748 | 739 | } | |
749 | 740 | ||
750 | 741 | ||
751 | 742 | ||
752 | 743 | @Callable(i) | |
753 | 744 | func putForFree (maxSlippage) = if ((0 > maxSlippage)) | |
754 | 745 | then throw("Invalid value passed") | |
755 | 746 | else { | |
756 | 747 | let estPut = commonPut(i, maxSlippage, false) | |
757 | 748 | let state = estPut._9 | |
758 | - | let $ | |
759 | - | let refreshKLpActions = $ | |
760 | - | let updatedKLp = $ | |
749 | + | let $t03188431949 = refreshKLpInternal(0, 0, 0) | |
750 | + | let refreshKLpActions = $t03188431949._1 | |
751 | + | let updatedKLp = $t03188431949._2 | |
761 | 752 | (state ++ refreshKLpActions) | |
762 | 753 | } | |
763 | 754 | ||
764 | 755 | ||
765 | 756 | ||
766 | 757 | @Callable(i) | |
767 | 758 | func putOneTkn (minOutAmount,autoStake) = { | |
768 | 759 | let isPoolOneTokenOperationsDisabled = { | |
769 | 760 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
770 | 761 | if ($isInstanceOf(@, "Boolean")) | |
771 | 762 | then @ | |
772 | 763 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
773 | 764 | } | |
774 | 765 | let isPutDisabled = if (if (if (isGlobalShutdown()) | |
775 | 766 | then true | |
776 | 767 | else (cfgPoolStatus == PoolPutDisabled)) | |
777 | 768 | then true | |
778 | 769 | else (cfgPoolStatus == PoolShutdown)) | |
779 | 770 | then true | |
780 | 771 | else isPoolOneTokenOperationsDisabled | |
781 | 772 | let checks = [if (if (!(isPutDisabled)) | |
782 | 773 | then true | |
783 | 774 | else isManager(i)) | |
784 | 775 | then true | |
785 | 776 | else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1)) | |
786 | 777 | then true | |
787 | 778 | else throwErr("exactly 1 payment are expected")] | |
788 | 779 | if ((checks == checks)) | |
789 | 780 | then { | |
790 | 781 | let payment = i.payments[0] | |
791 | 782 | let paymentAssetId = payment.assetId | |
792 | 783 | let paymentAmountRaw = payment.amount | |
793 | 784 | let userAddress = i.caller | |
794 | 785 | let txId = i.transactionId | |
795 | - | let $ | |
796 | - | let emitAmountEstimated = $ | |
797 | - | let commonState = $ | |
798 | - | let feeAmount = $ | |
799 | - | let bonus = $ | |
800 | - | let paymentInAmountAsset = $ | |
786 | + | let $t03272532874 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
787 | + | let emitAmountEstimated = $t03272532874._1 | |
788 | + | let commonState = $t03272532874._2 | |
789 | + | let feeAmount = $t03272532874._3 | |
790 | + | let bonus = $t03272532874._4 | |
791 | + | let paymentInAmountAsset = $t03272532874._5 | |
801 | 792 | let emitAmount = if (if ((minOutAmount > 0)) | |
802 | 793 | then (minOutAmount > emitAmountEstimated) | |
803 | 794 | else false) | |
804 | 795 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
805 | 796 | else emitAmountEstimated | |
806 | 797 | let emitInv = emit(emitAmount) | |
807 | 798 | if ((emitInv == emitInv)) | |
808 | 799 | then { | |
809 | 800 | let lpTransfer = if (autoStake) | |
810 | 801 | then { | |
811 | 802 | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
812 | 803 | if ((stakeInv == stakeInv)) | |
813 | 804 | then nil | |
814 | 805 | else throw("Strict value is not equal to itself.") | |
815 | 806 | } | |
816 | 807 | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
817 | 808 | let sendFee = if ((feeAmount > 0)) | |
818 | 809 | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
819 | 810 | else nil | |
820 | - | let $ | |
811 | + | let $t03346033657 = if ((this == feeCollectorAddress)) | |
821 | 812 | then $Tuple2(0, 0) | |
822 | 813 | else if (paymentInAmountAsset) | |
823 | 814 | then $Tuple2(-(feeAmount), 0) | |
824 | 815 | else $Tuple2(0, -(feeAmount)) | |
825 | - | let amountAssetBalanceDelta = $ | |
826 | - | let priceAssetBalanceDelta = $ | |
827 | - | let $ | |
828 | - | let refreshKLpActions = $ | |
829 | - | let updatedKLp = $ | |
816 | + | let amountAssetBalanceDelta = $t03346033657._1 | |
817 | + | let priceAssetBalanceDelta = $t03346033657._2 | |
818 | + | let $t03366033768 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
819 | + | let refreshKLpActions = $t03366033768._1 | |
820 | + | let updatedKLp = $t03366033768._2 | |
830 | 821 | $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
831 | 822 | } | |
832 | 823 | else throw("Strict value is not equal to itself.") | |
833 | 824 | } | |
834 | 825 | else throw("Strict value is not equal to itself.") | |
835 | 826 | } | |
836 | 827 | ||
837 | 828 | ||
838 | 829 | ||
839 | 830 | @Callable(i) | |
840 | 831 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
841 | - | let $ | |
842 | - | let emitAmountEstimated = $ | |
843 | - | let commonState = $ | |
844 | - | let feeAmount = $ | |
845 | - | let bonus = $ | |
846 | - | let paymentInAmountAsset = $ | |
832 | + | let $t03396134118 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
833 | + | let emitAmountEstimated = $t03396134118._1 | |
834 | + | let commonState = $t03396134118._2 | |
835 | + | let feeAmount = $t03396134118._3 | |
836 | + | let bonus = $t03396134118._4 | |
837 | + | let paymentInAmountAsset = $t03396134118._5 | |
847 | 838 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
848 | 839 | } | |
849 | 840 | ||
850 | 841 | ||
851 | 842 | ||
852 | 843 | @Callable(i) | |
853 | 844 | func getOneTkn (outAssetIdStr,minOutAmount) = { | |
854 | 845 | let isPoolOneTokenOperationsDisabled = { | |
855 | 846 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
856 | 847 | if ($isInstanceOf(@, "Boolean")) | |
857 | 848 | then @ | |
858 | 849 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
859 | 850 | } | |
860 | 851 | let isGetDisabled = if (if (isGlobalShutdown()) | |
861 | 852 | then true | |
862 | 853 | else (cfgPoolStatus == PoolShutdown)) | |
863 | 854 | then true | |
864 | 855 | else isPoolOneTokenOperationsDisabled | |
865 | 856 | let checks = [if (if (!(isGetDisabled)) | |
866 | 857 | then true | |
867 | 858 | else isManager(i)) | |
868 | 859 | then true | |
869 | 860 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1)) | |
870 | 861 | then true | |
871 | 862 | else throwErr("exactly 1 payment are expected")] | |
872 | 863 | if ((checks == checks)) | |
873 | 864 | then { | |
874 | 865 | let outAssetId = parseAssetId(outAssetIdStr) | |
875 | 866 | let payment = i.payments[0] | |
876 | 867 | let paymentAssetId = payment.assetId | |
877 | 868 | let paymentAmount = payment.amount | |
878 | 869 | let userAddress = i.caller | |
879 | 870 | let txId = i.transactionId | |
880 | - | let $ | |
881 | - | let amountEstimated = $ | |
882 | - | let commonState = $ | |
883 | - | let feeAmount = $ | |
884 | - | let bonus = $ | |
885 | - | let outInAmountAsset = $ | |
871 | + | let $t03492335073 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
872 | + | let amountEstimated = $t03492335073._1 | |
873 | + | let commonState = $t03492335073._2 | |
874 | + | let feeAmount = $t03492335073._3 | |
875 | + | let bonus = $t03492335073._4 | |
876 | + | let outInAmountAsset = $t03492335073._5 | |
886 | 877 | let amount = if (if ((minOutAmount > 0)) | |
887 | 878 | then (minOutAmount > amountEstimated) | |
888 | 879 | else false) | |
889 | 880 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
890 | 881 | else amountEstimated | |
891 | 882 | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
892 | 883 | if ((burnInv == burnInv)) | |
893 | 884 | then { | |
894 | 885 | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
895 | 886 | let sendFee = if ((feeAmount > 0)) | |
896 | 887 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
897 | 888 | else nil | |
898 | - | let $ | |
889 | + | let $t03557335820 = { | |
899 | 890 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
900 | 891 | then 0 | |
901 | 892 | else feeAmount | |
902 | 893 | if (outInAmountAsset) | |
903 | 894 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
904 | 895 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
905 | 896 | } | |
906 | - | let amountAssetBalanceDelta = $ | |
907 | - | let priceAssetBalanceDelta = $ | |
908 | - | let $ | |
909 | - | let refreshKLpActions = $ | |
910 | - | let updatedKLp = $ | |
897 | + | let amountAssetBalanceDelta = $t03557335820._1 | |
898 | + | let priceAssetBalanceDelta = $t03557335820._2 | |
899 | + | let $t03582335931 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
900 | + | let refreshKLpActions = $t03582335931._1 | |
901 | + | let updatedKLp = $t03582335931._2 | |
911 | 902 | $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
912 | 903 | } | |
913 | 904 | else throw("Strict value is not equal to itself.") | |
914 | 905 | } | |
915 | 906 | else throw("Strict value is not equal to itself.") | |
916 | 907 | } | |
917 | 908 | ||
918 | 909 | ||
919 | 910 | ||
920 | 911 | @Callable(i) | |
921 | 912 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
922 | - | let $ | |
923 | - | let amountEstimated = $ | |
924 | - | let commonState = $ | |
925 | - | let feeAmount = $ | |
926 | - | let bonus = $ | |
927 | - | let outInAmountAsset = $ | |
913 | + | let $t03611536271 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
914 | + | let amountEstimated = $t03611536271._1 | |
915 | + | let commonState = $t03611536271._2 | |
916 | + | let feeAmount = $t03611536271._3 | |
917 | + | let bonus = $t03611536271._4 | |
918 | + | let outInAmountAsset = $t03611536271._5 | |
928 | 919 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
929 | 920 | } | |
930 | 921 | ||
931 | 922 | ||
932 | 923 | ||
933 | 924 | @Callable(i) | |
934 | 925 | func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = { | |
935 | 926 | let isPoolOneTokenOperationsDisabled = { | |
936 | 927 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
937 | 928 | if ($isInstanceOf(@, "Boolean")) | |
938 | 929 | then @ | |
939 | 930 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
940 | 931 | } | |
941 | 932 | let isGetDisabled = if (if (isGlobalShutdown()) | |
942 | 933 | then true | |
943 | 934 | else (cfgPoolStatus == PoolShutdown)) | |
944 | 935 | then true | |
945 | 936 | else isPoolOneTokenOperationsDisabled | |
946 | 937 | let checks = [if (if (!(isGetDisabled)) | |
947 | 938 | then true | |
948 | 939 | else isManager(i)) | |
949 | 940 | then true | |
950 | 941 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
951 | 942 | then true | |
952 | 943 | else throwErr("no payments are expected")] | |
953 | 944 | if ((checks == checks)) | |
954 | 945 | then { | |
955 | 946 | let outAssetId = parseAssetId(outAssetIdStr) | |
956 | 947 | let userAddress = i.caller | |
957 | 948 | let txId = i.transactionId | |
958 | 949 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
959 | 950 | if ((unstakeInv == unstakeInv)) | |
960 | 951 | then { | |
961 | - | let $ | |
962 | - | let amountEstimated = $ | |
963 | - | let commonState = $ | |
964 | - | let feeAmount = $ | |
965 | - | let bonus = $ | |
966 | - | let outInAmountAsset = $ | |
952 | + | let $t03709637244 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
953 | + | let amountEstimated = $t03709637244._1 | |
954 | + | let commonState = $t03709637244._2 | |
955 | + | let feeAmount = $t03709637244._3 | |
956 | + | let bonus = $t03709637244._4 | |
957 | + | let outInAmountAsset = $t03709637244._5 | |
967 | 958 | let amount = if (if ((minOutAmount > 0)) | |
968 | 959 | then (minOutAmount > amountEstimated) | |
969 | 960 | else false) | |
970 | 961 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
971 | 962 | else amountEstimated | |
972 | 963 | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
973 | 964 | if ((burnInv == burnInv)) | |
974 | 965 | then { | |
975 | 966 | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
976 | 967 | let sendFee = if ((feeAmount > 0)) | |
977 | 968 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
978 | 969 | else nil | |
979 | - | let $ | |
970 | + | let $t03773937986 = { | |
980 | 971 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
981 | 972 | then 0 | |
982 | 973 | else feeAmount | |
983 | 974 | if (outInAmountAsset) | |
984 | 975 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
985 | 976 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
986 | 977 | } | |
987 | - | let amountAssetBalanceDelta = $ | |
988 | - | let priceAssetBalanceDelta = $ | |
989 | - | let $ | |
990 | - | let refreshKLpActions = $ | |
991 | - | let updatedKLp = $ | |
978 | + | let amountAssetBalanceDelta = $t03773937986._1 | |
979 | + | let priceAssetBalanceDelta = $t03773937986._2 | |
980 | + | let $t03798938097 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
981 | + | let refreshKLpActions = $t03798938097._1 | |
982 | + | let updatedKLp = $t03798938097._2 | |
992 | 983 | $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
993 | 984 | } | |
994 | 985 | else throw("Strict value is not equal to itself.") | |
995 | 986 | } | |
996 | 987 | else throw("Strict value is not equal to itself.") | |
997 | 988 | } | |
998 | 989 | else throw("Strict value is not equal to itself.") | |
999 | 990 | } | |
1000 | 991 | ||
1001 | 992 | ||
1002 | 993 | ||
1003 | 994 | @Callable(i) | |
1004 | 995 | func get () = { | |
1005 | 996 | let res = commonGet(i) | |
1006 | 997 | let outAmtAmt = res._1 | |
1007 | 998 | let outPrAmt = res._2 | |
1008 | 999 | let pmtAmt = res._3 | |
1009 | 1000 | let pmtAssetId = res._4 | |
1010 | 1001 | let state = res._5 | |
1011 | 1002 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1012 | 1003 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1013 | 1004 | then { | |
1014 | - | let $ | |
1015 | - | let refreshKLpActions = $ | |
1016 | - | let updatedKLp = $ | |
1005 | + | let $t03888938971 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1006 | + | let refreshKLpActions = $t03888938971._1 | |
1007 | + | let updatedKLp = $t03888938971._2 | |
1017 | 1008 | (state ++ refreshKLpActions) | |
1018 | 1009 | } | |
1019 | 1010 | else throw("Strict value is not equal to itself.") | |
1020 | 1011 | } | |
1021 | 1012 | ||
1022 | 1013 | ||
1023 | 1014 | ||
1024 | 1015 | @Callable(i) | |
1025 | 1016 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
1026 | 1017 | let res = commonGet(i) | |
1027 | 1018 | let outAmAmt = res._1 | |
1028 | 1019 | let outPrAmt = res._2 | |
1029 | 1020 | let pmtAmt = res._3 | |
1030 | 1021 | let pmtAssetId = res._4 | |
1031 | 1022 | let state = res._5 | |
1032 | 1023 | if ((noLessThenAmtAsset > outAmAmt)) | |
1033 | 1024 | then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
1034 | 1025 | else if ((noLessThenPriceAsset > outPrAmt)) | |
1035 | 1026 | then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
1036 | 1027 | else { | |
1037 | 1028 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1038 | 1029 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1039 | 1030 | then { | |
1040 | - | let $ | |
1041 | - | let refreshKLpActions = $ | |
1042 | - | let updatedKLp = $ | |
1031 | + | let $t03976739848 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1032 | + | let refreshKLpActions = $t03976739848._1 | |
1033 | + | let updatedKLp = $t03976739848._2 | |
1043 | 1034 | (state ++ refreshKLpActions) | |
1044 | 1035 | } | |
1045 | 1036 | else throw("Strict value is not equal to itself.") | |
1046 | 1037 | } | |
1047 | 1038 | } | |
1048 | 1039 | ||
1049 | 1040 | ||
1050 | 1041 | ||
1051 | 1042 | @Callable(i) | |
1052 | 1043 | func unstakeAndGet (amount) = { | |
1053 | 1044 | let checkPayments = if ((size(i.payments) != 0)) | |
1054 | 1045 | then throw("No payments are expected") | |
1055 | 1046 | else true | |
1056 | 1047 | if ((checkPayments == checkPayments)) | |
1057 | 1048 | then { | |
1058 | 1049 | let cfg = getPoolConfig() | |
1059 | 1050 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1060 | 1051 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1061 | 1052 | if ((unstakeInv == unstakeInv)) | |
1062 | 1053 | then { | |
1063 | 1054 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1064 | 1055 | let outAmAmt = res._1 | |
1065 | 1056 | let outPrAmt = res._2 | |
1066 | 1057 | let poolStatus = parseIntValue(res._9) | |
1067 | 1058 | let state = res._10 | |
1068 | 1059 | let checkPoolStatus = if (if (isGlobalShutdown()) | |
1069 | 1060 | then true | |
1070 | 1061 | else (poolStatus == PoolShutdown)) | |
1071 | 1062 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
1072 | 1063 | else true | |
1073 | 1064 | if ((checkPoolStatus == checkPoolStatus)) | |
1074 | 1065 | then { | |
1075 | 1066 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1076 | 1067 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1077 | 1068 | then { | |
1078 | - | let $ | |
1079 | - | let refreshKLpActions = $ | |
1080 | - | let updatedKLp = $ | |
1069 | + | let $t04082140902 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1070 | + | let refreshKLpActions = $t04082140902._1 | |
1071 | + | let updatedKLp = $t04082140902._2 | |
1081 | 1072 | (state ++ refreshKLpActions) | |
1082 | 1073 | } | |
1083 | 1074 | else throw("Strict value is not equal to itself.") | |
1084 | 1075 | } | |
1085 | 1076 | else throw("Strict value is not equal to itself.") | |
1086 | 1077 | } | |
1087 | 1078 | else throw("Strict value is not equal to itself.") | |
1088 | 1079 | } | |
1089 | 1080 | else throw("Strict value is not equal to itself.") | |
1090 | 1081 | } | |
1091 | 1082 | ||
1092 | 1083 | ||
1093 | 1084 | ||
1094 | 1085 | @Callable(i) | |
1095 | 1086 | func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = { | |
1096 | 1087 | let isGetDisabled = if (isGlobalShutdown()) | |
1097 | 1088 | then true | |
1098 | 1089 | else (cfgPoolStatus == PoolShutdown) | |
1099 | 1090 | let checks = [if (!(isGetDisabled)) | |
1100 | 1091 | then true | |
1101 | 1092 | else throw("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1102 | 1093 | then true | |
1103 | 1094 | else throw("no payments are expected")] | |
1104 | 1095 | if ((checks == checks)) | |
1105 | 1096 | then { | |
1106 | 1097 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1107 | 1098 | if ((unstakeInv == unstakeInv)) | |
1108 | 1099 | then { | |
1109 | 1100 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1110 | 1101 | let outAmAmt = res._1 | |
1111 | 1102 | let outPrAmt = res._2 | |
1112 | 1103 | let state = res._10 | |
1113 | 1104 | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1114 | 1105 | then true | |
1115 | 1106 | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1116 | 1107 | then true | |
1117 | 1108 | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1118 | 1109 | if ((checkAmounts == checkAmounts)) | |
1119 | 1110 | then { | |
1120 | 1111 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1121 | 1112 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1122 | 1113 | then { | |
1123 | - | let $ | |
1124 | - | let refreshKLpActions = $ | |
1125 | - | let updatedKLp = $ | |
1114 | + | let $t04204242123 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1115 | + | let refreshKLpActions = $t04204242123._1 | |
1116 | + | let updatedKLp = $t04204242123._2 | |
1126 | 1117 | (state ++ refreshKLpActions) | |
1127 | 1118 | } | |
1128 | 1119 | else throw("Strict value is not equal to itself.") | |
1129 | 1120 | } | |
1130 | 1121 | else throw("Strict value is not equal to itself.") | |
1131 | 1122 | } | |
1132 | 1123 | else throw("Strict value is not equal to itself.") | |
1133 | 1124 | } | |
1134 | 1125 | else throw("Strict value is not equal to itself.") | |
1135 | 1126 | } | |
1136 | 1127 | ||
1137 | 1128 | ||
1138 | 1129 | ||
1139 | 1130 | @Callable(i) | |
1140 | 1131 | func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract))) | |
1141 | 1132 | then throw("permissions denied") | |
1142 | 1133 | else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success") | |
1143 | 1134 | ||
1144 | 1135 | ||
1145 | 1136 | ||
1146 | 1137 | @Callable(i) | |
1147 | 1138 | func refreshKLp () = { | |
1148 | 1139 | let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0) | |
1149 | 1140 | let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay)) | |
1150 | 1141 | then unit | |
1151 | 1142 | else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1152 | 1143 | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1153 | 1144 | then { | |
1154 | - | let $ | |
1155 | - | let actions = $ | |
1156 | - | let updatedKLp = $ | |
1145 | + | let $t04311143166 = refreshKLpInternal(0, 0, 0) | |
1146 | + | let actions = $t04311143166._1 | |
1147 | + | let updatedKLp = $t04311143166._2 | |
1157 | 1148 | $Tuple2(actions, toString(updatedKLp)) | |
1158 | 1149 | } | |
1159 | 1150 | else throw("Strict value is not equal to itself.") | |
1160 | 1151 | } | |
1161 | 1152 | ||
1162 | 1153 | ||
1163 | 1154 | ||
1164 | 1155 | @Callable(i) | |
1165 | 1156 | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig()) | |
1166 | 1157 | ||
1167 | 1158 | ||
1168 | 1159 | ||
1169 | 1160 | @Callable(i) | |
1170 | 1161 | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
1171 | 1162 | ||
1172 | 1163 | ||
1173 | 1164 | ||
1174 | 1165 | @Callable(i) | |
1175 | 1166 | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
1176 | 1167 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
1177 | 1168 | $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])]) | |
1178 | 1169 | } | |
1179 | 1170 | ||
1180 | 1171 | ||
1181 | 1172 | ||
1182 | 1173 | @Callable(i) | |
1183 | 1174 | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult))) | |
1184 | 1175 | ||
1185 | 1176 | ||
1186 | 1177 | ||
1187 | 1178 | @Callable(i) | |
1188 | 1179 | func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult)) | |
1189 | 1180 | ||
1190 | 1181 | ||
1191 | 1182 | ||
1192 | 1183 | @Callable(i) | |
1193 | 1184 | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
1194 | 1185 | ||
1195 | 1186 | ||
1196 | 1187 | ||
1197 | 1188 | @Callable(i) | |
1198 | 1189 | func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp)) | |
1199 | 1190 | ||
1200 | 1191 | ||
1201 | 1192 | ||
1202 | 1193 | @Callable(i) | |
1203 | 1194 | func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
1204 | 1195 | let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress)) | |
1205 | 1196 | $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10)) | |
1206 | 1197 | } | |
1207 | 1198 | ||
1208 | 1199 | ||
1209 | 1200 | ||
1210 | 1201 | @Callable(i) | |
1211 | 1202 | func statsREADONLY () = { | |
1212 | 1203 | let cfg = getPoolConfig() | |
1213 | 1204 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1214 | 1205 | let amtAssetId = cfg[idxAmtAssetId] | |
1215 | 1206 | let priceAssetId = cfg[idxPriceAssetId] | |
1216 | 1207 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
1217 | 1208 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
1218 | 1209 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1219 | 1210 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1220 | 1211 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1221 | 1212 | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
1222 | 1213 | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
1223 | 1214 | let pricesList = if ((poolLPBalance == 0)) | |
1224 | 1215 | then [zeroBigInt, zeroBigInt, zeroBigInt] | |
1225 | 1216 | else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance) | |
1226 | 1217 | let curPrice = 0 | |
1227 | 1218 | let lpAmtAssetShare = fromX18(pricesList[1], scale8) | |
1228 | 1219 | let lpPriceAssetShare = fromX18(pricesList[2], scale8) | |
1229 | 1220 | let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this)))) | |
1230 | 1221 | $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)) | |
1231 | 1222 | } | |
1232 | 1223 | ||
1233 | 1224 | ||
1234 | 1225 | ||
1235 | 1226 | @Callable(i) | |
1236 | 1227 | func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = { | |
1237 | 1228 | let cfg = getPoolConfig() | |
1238 | 1229 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1239 | 1230 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1240 | 1231 | let amAssetId = fromBase58String(amAssetIdStr) | |
1241 | 1232 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1242 | 1233 | let prAssetId = fromBase58String(prAssetIdStr) | |
1243 | 1234 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1244 | 1235 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1245 | 1236 | let poolStatus = cfg[idxPoolStatus] | |
1246 | 1237 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1247 | 1238 | let accAmtAssetBalance = getAccBalance(amAssetIdStr) | |
1248 | 1239 | let accPriceAssetBalance = getAccBalance(prAssetIdStr) | |
1249 | 1240 | let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm) | |
1250 | 1241 | let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm) | |
1251 | 1242 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1252 | 1243 | then zeroBigInt | |
1253 | 1244 | else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
1254 | 1245 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
1255 | 1246 | let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
1256 | 1247 | let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm) | |
1257 | 1248 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1258 | 1249 | let calcLpAmt = estPut._1 | |
1259 | 1250 | let curPriceCalc = estPut._3 | |
1260 | 1251 | let amBalance = estPut._4 | |
1261 | 1252 | let prBalance = estPut._5 | |
1262 | 1253 | let lpEmission = estPut._6 | |
1263 | 1254 | $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)) | |
1264 | 1255 | } | |
1265 | 1256 | ||
1266 | 1257 | ||
1267 | 1258 | ||
1268 | 1259 | @Callable(i) | |
1269 | 1260 | func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = { | |
1270 | 1261 | let cfg = getPoolConfig() | |
1271 | 1262 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1272 | 1263 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1273 | 1264 | let amAssetId = fromBase58String(amAssetIdStr) | |
1274 | 1265 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1275 | 1266 | let prAssetId = fromBase58String(prAssetIdStr) | |
1276 | 1267 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1277 | 1268 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1278 | 1269 | let poolStatus = cfg[idxPoolStatus] | |
1279 | 1270 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1280 | 1271 | let amBalanceRaw = getAccBalance(amAssetIdStr) | |
1281 | 1272 | let prBalanceRaw = getAccBalance(prAssetIdStr) | |
1282 | 1273 | let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm) | |
1283 | 1274 | let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm) | |
1284 | 1275 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1285 | 1276 | then zeroBigInt | |
1286 | 1277 | else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18) | |
1287 | 1278 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
1288 | 1279 | let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
1289 | 1280 | let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm) | |
1290 | 1281 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1291 | 1282 | let calcLpAmt = estPut._1 | |
1292 | 1283 | let curPriceCalc = estPut._3 | |
1293 | 1284 | let amBalance = estPut._4 | |
1294 | 1285 | let prBalance = estPut._5 | |
1295 | 1286 | let lpEmission = estPut._6 | |
1296 | 1287 | $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)) | |
1297 | 1288 | } | |
1298 | 1289 | ||
1299 | 1290 | ||
1300 | 1291 | ||
1301 | 1292 | @Callable(i) | |
1302 | 1293 | func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = { | |
1303 | 1294 | let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this) | |
1304 | 1295 | let outAmAmt = res._1 | |
1305 | 1296 | let outPrAmt = res._2 | |
1306 | 1297 | let amBalance = res._5 | |
1307 | 1298 | let prBalance = res._6 | |
1308 | 1299 | let lpEmission = res._7 | |
1309 | 1300 | let curPrice = res._8 | |
1310 | 1301 | let poolStatus = parseIntValue(res._9) | |
1311 | 1302 | $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)) | |
1312 | 1303 | } | |
1313 | 1304 | ||
1314 | 1305 | ||
1315 | 1306 | @Verifier(tx) | |
1316 | 1307 | func verify () = { | |
1317 | 1308 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
1318 | 1309 | case pk: ByteVector => | |
1319 | 1310 | pk | |
1320 | 1311 | case _: Unit => | |
1321 | 1312 | tx.senderPublicKey | |
1322 | 1313 | case _ => | |
1323 | 1314 | throw("Match error") | |
1324 | 1315 | } | |
1325 | 1316 | match tx { | |
1326 | 1317 | case order: Order => | |
1327 | 1318 | let matcherPub = getMatcherPubOrFail() | |
1328 | 1319 | let orderValid = validateMatcherOrderAllowed(order) | |
1329 | 1320 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1330 | 1321 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1331 | 1322 | if (if (if (orderValid) | |
1332 | 1323 | then senderValid | |
1333 | 1324 | else false) | |
1334 | 1325 | then matcherValid | |
1335 | 1326 | else false) | |
1336 | 1327 | then true | |
1337 | 1328 | else throwOrderError(orderValid, senderValid, matcherValid) | |
1338 | 1329 | case s: SetScriptTransaction => | |
1339 | 1330 | let newHash = blake2b256(value(s.script)) | |
1340 | 1331 | let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash()))) | |
1341 | 1332 | let currentHash = scriptHash(this) | |
1342 | 1333 | if (if ((allowedHash == newHash)) | |
1343 | 1334 | then (currentHash != newHash) | |
1344 | 1335 | else false) | |
1345 | 1336 | then true | |
1346 | 1337 | else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1347 | 1338 | case _ => | |
1348 | 1339 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1349 | 1340 | } | |
1350 | 1341 | } | |
1351 | 1342 |
github/deemru/w8io/026f985 160.35 ms ◑