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