tx · 8abw8MN1mzBZBDspc1uPq3nSKvVUTo3mbk1CX28bhkL3 3N6wAa7PMFZJu4Zrmp3avXmMnRTrRpMM9Lh: -0.04200000 Waves 2023.04.06 11:01 [2522423] smart account 3N6wAa7PMFZJu4Zrmp3avXmMnRTrRpMM9Lh > SELF 0.00000000 Waves
{ "type": 13, "id": "8abw8MN1mzBZBDspc1uPq3nSKvVUTo3mbk1CX28bhkL3", "fee": 4200000, "feeAssetId": null, "timestamp": 1680768098991, "version": 2, "chainId": 84, "sender": "3N6wAa7PMFZJu4Zrmp3avXmMnRTrRpMM9Lh", "senderPublicKey": "Cr8D7eozSzJh7XHsYTjBinPpo3SS83BrCGiBAJsjGxBo", "proofs": [ "2DXmBfWaNmPK5nS6NXSRja7wXKXvBEFWsdfnEtj8izPCdPdJWM1mLgoSFXDVC4Hv7iXpNKs6swE3xn9SZfRbdqJq" ], "script": "base64:BgKQNwgCEgASBQoDAQQBEgcKBQEEAQgBEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgQKAggBEgQKAggBEgQKAggBEgUKAwEIARIAEgQKAgEBEgMKAQESBQoDAQEBEgQKAggIEgASABIDCgEIEgUKAwEBARIECgIBARIECgIIARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCBIAEgMKAQESAwoBARIECgIIASIKbFBkZWNpbWFscyIGc2NhbGU4IgxzY2FsZThCaWdJbnQiB3NjYWxlMTgiCnplcm9CaWdJbnQiBGJpZzAiBGJpZzEiBGJpZzIiC3dhdmVzU3RyaW5nIgNTRVAiClBvb2xBY3RpdmUiD1Bvb2xQdXREaXNhYmxlZCITUG9vbE1hdGNoZXJEaXNhYmxlZCIMUG9vbFNodXRkb3duIg5pZHhQb29sQWRkcmVzcyINaWR4UG9vbFN0YXR1cyIQaWR4UG9vbExQQXNzZXRJZCINaWR4QW10QXNzZXRJZCIPaWR4UHJpY2VBc3NldElkIg5pZHhBbXRBc3NldERjbSIQaWR4UHJpY2VBc3NldERjbSIOaWR4SUFtdEF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mlvBQJpbQcJAPQDAwgFAmloCWJvZHlCeXRlcwkAkQMCCAUCaWgGcHJvb2ZzAAAFAmlqM22mKQ==", "height": 2522423, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 8zoQe5RB7mf8NrwrUV3G4N1vXt37cwqYCdTBW8dpJGrL Next: Dnav4vhgNucxxQvM1ZHuENuVwwjtFvdAkUwXu9NXmckh Diff:
Old | New | Differences | |
---|---|---|---|
502 | 502 | let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR) | |
503 | 503 | let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR) | |
504 | 504 | let AmAmtWithdrawState = withdrawAndRebalanceAsset(amAssetId, outAmAmt) | |
505 | - | if ((AmAmtWithdrawState == AmAmtWithdrawState)) | |
506 | - | then { | |
507 | - | let PrAmtWithdrawState = withdrawAndRebalanceAsset(prAssetId, outPrAmt) | |
508 | - | if ((PrAmtWithdrawState == PrAmtWithdrawState)) | |
509 | - | then { | |
510 | - | let state = if ((txId58 == "")) | |
511 | - | then nil | |
512 | - | else ((AmAmtWithdrawState ++ PrAmtWithdrawState) ++ [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
513 | - | then unit | |
514 | - | else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES")) | |
515 | - | then unit | |
516 | - | else fromBase58String(prAssetId)), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAmAmt, outPrAmt, pmtLpAmt, curPrice, height, lastBlock.timestamp)), IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice)]) | |
517 | - | $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state) | |
518 | - | } | |
519 | - | else throw("Strict value is not equal to itself.") | |
520 | - | } | |
521 | - | else throw("Strict value is not equal to itself.") | |
505 | + | let PrAmtWithdrawState = withdrawAndRebalanceAsset(prAssetId, outPrAmt) | |
506 | + | let state = if ((txId58 == "")) | |
507 | + | then nil | |
508 | + | else ((AmAmtWithdrawState ++ PrAmtWithdrawState) ++ [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
509 | + | then unit | |
510 | + | else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES")) | |
511 | + | 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)]) | |
513 | + | $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state) | |
522 | 514 | } | |
523 | 515 | } | |
524 | 516 | ||
639 | 631 | let priceAssetBalance = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
640 | 632 | let amountAssetAmount = order.amount | |
641 | 633 | let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR) | |
642 | - | let $ | |
634 | + | let $t02814728359 = if ((order.orderType == Buy)) | |
643 | 635 | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
644 | 636 | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
645 | - | let amountAssetBalanceDelta = $ | |
646 | - | let priceAssetBalanceDelta = $ | |
637 | + | let amountAssetBalanceDelta = $t02814728359._1 | |
638 | + | let priceAssetBalanceDelta = $t02814728359._2 | |
647 | 639 | if (if (if (isGlobalShutdown()) | |
648 | 640 | then true | |
649 | 641 | else (cfgPoolStatus == PoolMatcherDisabled)) | |
656 | 648 | then throw("Wrong order assets.") | |
657 | 649 | else { | |
658 | 650 | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
659 | - | let $ | |
660 | - | let unusedActions = $ | |
661 | - | let kLpNew = $ | |
651 | + | let $t02879928899 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
652 | + | let unusedActions = $t02879928899._1 | |
653 | + | let kLpNew = $t02879928899._2 | |
662 | 654 | let isOrderValid = (kLpNew >= kLp) | |
663 | 655 | let info = makeString(["kLp=", toString(kLp), " kLpNew=", toString(kLpNew), " amountAssetBalance=", toString(amountAssetBalance), " priceAssetBalance=", toString(priceAssetBalance), " amountAssetBalanceDelta=", toString(amountAssetBalanceDelta), " priceAssetBalanceDelta=", toString(priceAssetBalanceDelta), " height=", toString(height)], "") | |
664 | 656 | $Tuple2(isOrderValid, info) | |
737 | 729 | else if ((paymentAssetId == cfgPriceAssetId)) | |
738 | 730 | then false | |
739 | 731 | else throwErr("invalid asset") | |
740 | - | let $ | |
732 | + | let $t03201232305 = if (isEval) | |
741 | 733 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
742 | 734 | else if (paymentInAmountAsset) | |
743 | 735 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
744 | 736 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
745 | - | let amountBalanceOld = $ | |
746 | - | let priceBalanceOld = $ | |
747 | - | let $ | |
737 | + | let amountBalanceOld = $t03201232305._1 | |
738 | + | let priceBalanceOld = $t03201232305._2 | |
739 | + | let $t03230932458 = if (paymentInAmountAsset) | |
748 | 740 | then $Tuple2(paymentAmountRaw, 0) | |
749 | 741 | else $Tuple2(0, paymentAmountRaw) | |
750 | - | let amountAssetAmountRaw = $ | |
751 | - | let priceAssetAmountRaw = $ | |
742 | + | let amountAssetAmountRaw = $t03230932458._1 | |
743 | + | let priceAssetAmountRaw = $t03230932458._2 | |
752 | 744 | let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1 | |
753 | 745 | let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1 | |
754 | - | let $ | |
755 | - | let paymentAmount = $ | |
756 | - | let feeAmount = $ | |
746 | + | let $t03259032654 = takeFee(paymentAmountRaw, inFee) | |
747 | + | let paymentAmount = $t03259032654._1 | |
748 | + | let feeAmount = $t03259032654._2 | |
757 | 749 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
758 | 750 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
759 | 751 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
776 | 768 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
777 | 769 | let priceOld = fromX18(priceOldX18, scale8) | |
778 | 770 | let loss = { | |
779 | - | let $ | |
771 | + | let $t03433534502 = if (paymentInAmountAsset) | |
780 | 772 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
781 | 773 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
782 | - | let amount = $ | |
783 | - | let balance = $ | |
774 | + | let amount = $t03433534502._1 | |
775 | + | let balance = $t03433534502._2 | |
784 | 776 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
785 | 777 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
786 | 778 | } | |
820 | 812 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
821 | 813 | let redeemedBigInt = toBigInt(paymentAmount) | |
822 | 814 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
823 | - | let $ | |
824 | - | let totalAmount = $ | |
825 | - | let feeAmount = $ | |
826 | - | let $ | |
815 | + | let $t03658036636 = takeFee(amountRaw, outFee) | |
816 | + | let totalAmount = $t03658036636._1 | |
817 | + | let feeAmount = $t03658036636._2 | |
818 | + | let $t03664036866 = if (outInAmountAsset) | |
827 | 819 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
828 | 820 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
829 | - | let outAmAmount = $ | |
830 | - | let outPrAmount = $ | |
831 | - | let amBalanceNew = $ | |
832 | - | let prBalanceNew = $ | |
821 | + | let outAmAmount = $t03664036866._1 | |
822 | + | let outPrAmount = $t03664036866._2 | |
823 | + | let amBalanceNew = $t03664036866._3 | |
824 | + | let prBalanceNew = $t03664036866._4 | |
833 | 825 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
834 | 826 | let priceNew = fromX18(priceNewX18, scale8) | |
835 | 827 | let commonState = if (isEval) | |
901 | 893 | ||
902 | 894 | @Callable(i) | |
903 | 895 | func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse,feePoolAmount) = { | |
904 | - | let $ | |
896 | + | let $t03875239057 = if ((isReverse == false)) | |
905 | 897 | then { | |
906 | 898 | let assetOut = getStringOrFail(this, pa()) | |
907 | 899 | let assetIn = getStringOrFail(this, aa()) | |
912 | 904 | let assetIn = getStringOrFail(this, pa()) | |
913 | 905 | $Tuple2(assetOut, assetIn) | |
914 | 906 | } | |
915 | - | let assetOut = $ | |
916 | - | let assetIn = $ | |
907 | + | let assetOut = $t03875239057._1 | |
908 | + | let assetIn = $t03875239057._2 | |
917 | 909 | let poolAssetInBalance = getAccBalance(assetIn) | |
918 | 910 | let poolAssetOutBalance = getAccBalance(assetOut) | |
919 | 911 | let amountOut = fraction(poolAssetOutBalance, cleanAmountIn, (poolAssetInBalance + cleanAmountIn)) | |
1064 | 1056 | else throw("Strict value is not equal to itself.") | |
1065 | 1057 | } | |
1066 | 1058 | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
1067 | - | let $ | |
1068 | - | if (($ | |
1059 | + | let $t04410344565 = refreshKLpInternal(0, 0, 0) | |
1060 | + | if (($t04410344565 == $t04410344565)) | |
1069 | 1061 | then { | |
1070 | - | let updatedKLp = $ | |
1071 | - | let refreshKLpActions = $ | |
1062 | + | let updatedKLp = $t04410344565._2 | |
1063 | + | let refreshKLpActions = $t04410344565._1 | |
1072 | 1064 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1073 | 1065 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1074 | 1066 | then { | |
1105 | 1097 | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
1106 | 1098 | if ((currentKLp == currentKLp)) | |
1107 | 1099 | then { | |
1108 | - | let $ | |
1109 | - | let refreshKLpActions = $ | |
1110 | - | let updatedKLp = $ | |
1100 | + | let $t04517745242 = refreshKLpInternal(0, 0, 0) | |
1101 | + | let refreshKLpActions = $t04517745242._1 | |
1102 | + | let updatedKLp = $t04517745242._2 | |
1111 | 1103 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1112 | 1104 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1113 | 1105 | then (state ++ refreshKLpActions) | |
1154 | 1146 | then { | |
1155 | 1147 | let userAddress = i.caller | |
1156 | 1148 | let txId = i.transactionId | |
1157 | - | let $ | |
1158 | - | if (($ | |
1149 | + | let $t04643046582 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
1150 | + | if (($t04643046582 == $t04643046582)) | |
1159 | 1151 | then { | |
1160 | - | let paymentInAmountAsset = $ | |
1161 | - | let bonus = $ | |
1162 | - | let feeAmount = $ | |
1163 | - | let commonState = $ | |
1164 | - | let emitAmountEstimated = $ | |
1152 | + | let paymentInAmountAsset = $t04643046582._5 | |
1153 | + | let bonus = $t04643046582._4 | |
1154 | + | let feeAmount = $t04643046582._3 | |
1155 | + | let commonState = $t04643046582._2 | |
1156 | + | let emitAmountEstimated = $t04643046582._1 | |
1165 | 1157 | let emitAmount = if (if ((minOutAmount > 0)) | |
1166 | 1158 | then (minOutAmount > emitAmountEstimated) | |
1167 | 1159 | else false) | |
1181 | 1173 | let sendFee = if ((feeAmount > 0)) | |
1182 | 1174 | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
1183 | 1175 | else nil | |
1184 | - | let $ | |
1176 | + | let $t04716847365 = if ((this == feeCollectorAddress)) | |
1185 | 1177 | then $Tuple2(0, 0) | |
1186 | 1178 | else if (paymentInAmountAsset) | |
1187 | 1179 | then $Tuple2(-(feeAmount), 0) | |
1188 | 1180 | else $Tuple2(0, -(feeAmount)) | |
1189 | - | let amountAssetBalanceDelta = $ | |
1190 | - | let priceAssetBalanceDelta = $ | |
1191 | - | let $ | |
1192 | - | let refreshKLpActions = $ | |
1193 | - | let updatedKLp = $ | |
1181 | + | let amountAssetBalanceDelta = $t04716847365._1 | |
1182 | + | let priceAssetBalanceDelta = $t04716847365._2 | |
1183 | + | let $t04736847476 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1184 | + | let refreshKLpActions = $t04736847476._1 | |
1185 | + | let updatedKLp = $t04736847476._2 | |
1194 | 1186 | let kLp = value(getString(keyKLp)) | |
1195 | 1187 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1196 | 1188 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1215 | 1207 | ||
1216 | 1208 | @Callable(i) | |
1217 | 1209 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
1218 | - | let $ | |
1219 | - | let emitAmountEstimated = $ | |
1220 | - | let commonState = $ | |
1221 | - | let feeAmount = $ | |
1222 | - | let bonus = $ | |
1223 | - | let paymentInAmountAsset = $ | |
1210 | + | let $t04783147988 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
1211 | + | let emitAmountEstimated = $t04783147988._1 | |
1212 | + | let commonState = $t04783147988._2 | |
1213 | + | let feeAmount = $t04783147988._3 | |
1214 | + | let bonus = $t04783147988._4 | |
1215 | + | let paymentInAmountAsset = $t04783147988._5 | |
1224 | 1216 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
1225 | 1217 | } | |
1226 | 1218 | ||
1257 | 1249 | then { | |
1258 | 1250 | let userAddress = i.caller | |
1259 | 1251 | let txId = i.transactionId | |
1260 | - | let $ | |
1261 | - | if (($ | |
1252 | + | let $t04887349026 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
1253 | + | if (($t04887349026 == $t04887349026)) | |
1262 | 1254 | then { | |
1263 | - | let outInAmountAsset = $ | |
1264 | - | let bonus = $ | |
1265 | - | let feeAmount = $ | |
1266 | - | let commonState = $ | |
1267 | - | let amountEstimated = $ | |
1255 | + | let outInAmountAsset = $t04887349026._5 | |
1256 | + | let bonus = $t04887349026._4 | |
1257 | + | let feeAmount = $t04887349026._3 | |
1258 | + | let commonState = $t04887349026._2 | |
1259 | + | let amountEstimated = $t04887349026._1 | |
1268 | 1260 | let amount = if (if ((minOutAmount > 0)) | |
1269 | 1261 | then (minOutAmount > amountEstimated) | |
1270 | 1262 | else false) | |
1274 | 1266 | if ((burnInv == burnInv)) | |
1275 | 1267 | then { | |
1276 | 1268 | let withdrawState = withdrawAndRebalanceAsset(outAssetIdStr, amount) | |
1277 | - | if ((withdrawState == withdrawState)) | |
1278 | - | then { | |
1279 | - | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
1280 | - | let sendFee = if ((feeAmount > 0)) | |
1281 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1282 | - | else nil | |
1283 | - | let $t04960649853 = { | |
1284 | - | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1285 | - | then 0 | |
1286 | - | else feeAmount | |
1287 | - | if (outInAmountAsset) | |
1288 | - | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1289 | - | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1290 | - | } | |
1291 | - | let amountAssetBalanceDelta = $t04960649853._1 | |
1292 | - | let priceAssetBalanceDelta = $t04960649853._2 | |
1293 | - | let $t04985649964 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1294 | - | let refreshKLpActions = $t04985649964._1 | |
1295 | - | let updatedKLp = $t04985649964._2 | |
1296 | - | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1297 | - | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1298 | - | then $Tuple2(((((commonState ++ withdrawState) ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1299 | - | else throw("Strict value is not equal to itself.") | |
1300 | - | } | |
1269 | + | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
1270 | + | let sendFee = if ((feeAmount > 0)) | |
1271 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1272 | + | else nil | |
1273 | + | let $t04959749844 = { | |
1274 | + | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1275 | + | then 0 | |
1276 | + | else feeAmount | |
1277 | + | if (outInAmountAsset) | |
1278 | + | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1279 | + | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1280 | + | } | |
1281 | + | let amountAssetBalanceDelta = $t04959749844._1 | |
1282 | + | let priceAssetBalanceDelta = $t04959749844._2 | |
1283 | + | let $t04984749955 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1284 | + | let refreshKLpActions = $t04984749955._1 | |
1285 | + | let updatedKLp = $t04984749955._2 | |
1286 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1287 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1288 | + | then $Tuple2(((((commonState ++ withdrawState) ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1301 | 1289 | else throw("Strict value is not equal to itself.") | |
1302 | 1290 | } | |
1303 | 1291 | else throw("Strict value is not equal to itself.") | |
1313 | 1301 | ||
1314 | 1302 | @Callable(i) | |
1315 | 1303 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
1316 | - | let $ | |
1317 | - | let amountEstimated = $ | |
1318 | - | let commonState = $ | |
1319 | - | let feeAmount = $ | |
1320 | - | let bonus = $ | |
1321 | - | let outInAmountAsset = $ | |
1304 | + | let $t05023350389 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
1305 | + | let amountEstimated = $t05023350389._1 | |
1306 | + | let commonState = $t05023350389._2 | |
1307 | + | let feeAmount = $t05023350389._3 | |
1308 | + | let bonus = $t05023350389._4 | |
1309 | + | let outInAmountAsset = $t05023350389._5 | |
1322 | 1310 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
1323 | 1311 | } | |
1324 | 1312 | ||
1355 | 1343 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1356 | 1344 | if ((unstakeInv == unstakeInv)) | |
1357 | 1345 | then { | |
1358 | - | let $ | |
1359 | - | if (($ | |
1346 | + | let $t05129451445 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
1347 | + | if (($t05129451445 == $t05129451445)) | |
1360 | 1348 | then { | |
1361 | - | let outInAmountAsset = $ | |
1362 | - | let bonus = $ | |
1363 | - | let feeAmount = $ | |
1364 | - | let commonState = $ | |
1365 | - | let amountEstimated = $ | |
1349 | + | let outInAmountAsset = $t05129451445._5 | |
1350 | + | let bonus = $t05129451445._4 | |
1351 | + | let feeAmount = $t05129451445._3 | |
1352 | + | let commonState = $t05129451445._2 | |
1353 | + | let amountEstimated = $t05129451445._1 | |
1366 | 1354 | let amount = if (if ((minOutAmount > 0)) | |
1367 | 1355 | then (minOutAmount > amountEstimated) | |
1368 | 1356 | else false) | |
1372 | 1360 | if ((burnInv == burnInv)) | |
1373 | 1361 | then { | |
1374 | 1362 | let withdrawState = withdrawAndRebalanceAsset(outAssetIdStr, amount) | |
1375 | - | if ((withdrawState == withdrawState)) | |
1376 | - | then { | |
1377 | - | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
1378 | - | let sendFee = if ((feeAmount > 0)) | |
1379 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1380 | - | else nil | |
1381 | - | let $t05202352270 = { | |
1382 | - | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1383 | - | then 0 | |
1384 | - | else feeAmount | |
1385 | - | if (outInAmountAsset) | |
1386 | - | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1387 | - | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1388 | - | } | |
1389 | - | let amountAssetBalanceDelta = $t05202352270._1 | |
1390 | - | let priceAssetBalanceDelta = $t05202352270._2 | |
1391 | - | let $t05227352381 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1392 | - | let refreshKLpActions = $t05227352381._1 | |
1393 | - | let updatedKLp = $t05227352381._2 | |
1394 | - | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1395 | - | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1396 | - | then $Tuple2(((((commonState ++ withdrawState) ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1397 | - | else throw("Strict value is not equal to itself.") | |
1398 | - | } | |
1363 | + | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
1364 | + | let sendFee = if ((feeAmount > 0)) | |
1365 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1366 | + | else nil | |
1367 | + | let $t05201152258 = { | |
1368 | + | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1369 | + | then 0 | |
1370 | + | else feeAmount | |
1371 | + | if (outInAmountAsset) | |
1372 | + | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1373 | + | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1374 | + | } | |
1375 | + | let amountAssetBalanceDelta = $t05201152258._1 | |
1376 | + | let priceAssetBalanceDelta = $t05201152258._2 | |
1377 | + | let $t05226152369 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1378 | + | let refreshKLpActions = $t05226152369._1 | |
1379 | + | let updatedKLp = $t05226152369._2 | |
1380 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1381 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1382 | + | then $Tuple2(((((commonState ++ withdrawState) ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1399 | 1383 | else throw("Strict value is not equal to itself.") | |
1400 | 1384 | } | |
1401 | 1385 | else throw("Strict value is not equal to itself.") | |
1425 | 1409 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1426 | 1410 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1427 | 1411 | then { | |
1428 | - | let $ | |
1429 | - | let refreshKLpActions = $ | |
1430 | - | let updatedKLp = $ | |
1412 | + | let $t05333653418 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1413 | + | let refreshKLpActions = $t05333653418._1 | |
1414 | + | let updatedKLp = $t05333653418._2 | |
1431 | 1415 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1432 | 1416 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1433 | 1417 | then (state ++ refreshKLpActions) | |
1459 | 1443 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1460 | 1444 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1461 | 1445 | then { | |
1462 | - | let $ | |
1463 | - | let refreshKLpActions = $ | |
1464 | - | let updatedKLp = $ | |
1446 | + | let $t05436754448 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1447 | + | let refreshKLpActions = $t05436754448._1 | |
1448 | + | let updatedKLp = $t05436754448._2 | |
1465 | 1449 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1466 | 1450 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1467 | 1451 | then (state ++ refreshKLpActions) | |
1505 | 1489 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1506 | 1490 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1507 | 1491 | then { | |
1508 | - | let $ | |
1509 | - | let refreshKLpActions = $ | |
1510 | - | let updatedKLp = $ | |
1492 | + | let $t05557455655 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1493 | + | let refreshKLpActions = $t05557455655._1 | |
1494 | + | let updatedKLp = $t05557455655._2 | |
1511 | 1495 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1512 | 1496 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1513 | 1497 | then (state ++ refreshKLpActions) | |
1558 | 1542 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1559 | 1543 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1560 | 1544 | then { | |
1561 | - | let $ | |
1562 | - | let refreshKLpActions = $ | |
1563 | - | let updatedKLp = $ | |
1545 | + | let $t05695057031 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1546 | + | let refreshKLpActions = $t05695057031._1 | |
1547 | + | let updatedKLp = $t05695057031._2 | |
1564 | 1548 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1565 | 1549 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1566 | 1550 | then (state ++ refreshKLpActions) | |
1595 | 1579 | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1596 | 1580 | then { | |
1597 | 1581 | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
1598 | - | let $ | |
1599 | - | let kLpUpdateActions = $ | |
1600 | - | let updatedKLp = $ | |
1582 | + | let $t05821858282 = refreshKLpInternal(0, 0, 0) | |
1583 | + | let kLpUpdateActions = $t05821858282._1 | |
1584 | + | let updatedKLp = $t05821858282._2 | |
1601 | 1585 | let actions = if ((kLp != updatedKLp)) | |
1602 | 1586 | then kLpUpdateActions | |
1603 | 1587 | else throwErr("nothing to refresh") | |
1772 | 1756 | match tx { | |
1773 | 1757 | case order: Order => | |
1774 | 1758 | let matcherPub = getMatcherPubOrFail() | |
1775 | - | let $ | |
1776 | - | let orderValid = $ | |
1777 | - | let orderValidInfo = $ | |
1759 | + | let $t06694467013 = validateMatcherOrderAllowed(order) | |
1760 | + | let orderValid = $t06694467013._1 | |
1761 | + | let orderValidInfo = $t06694467013._2 | |
1778 | 1762 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1779 | 1763 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1780 | 1764 | 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 | 453 | func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
454 | 454 | let amtAssetAmtX18 = toX18(amAmt, amAssetDcm) | |
455 | 455 | let priceAssetAmtX18 = toX18(prAmt, prAssetDcm) | |
456 | 456 | calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
457 | 457 | } | |
458 | 458 | ||
459 | 459 | ||
460 | 460 | func calcPrices (amAmt,prAmt,lpAmt) = { | |
461 | 461 | let cfg = getPoolConfig() | |
462 | 462 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
463 | 463 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
464 | 464 | let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt) | |
465 | 465 | let amAmtX18 = toX18(amAmt, amtAssetDcm) | |
466 | 466 | let prAmtX18 = toX18(prAmt, priceAssetDcm) | |
467 | 467 | let lpAmtX18 = toX18(lpAmt, scale8) | |
468 | 468 | let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18) | |
469 | 469 | let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18) | |
470 | 470 | [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18] | |
471 | 471 | } | |
472 | 472 | ||
473 | 473 | ||
474 | 474 | func calculatePrices (amAmt,prAmt,lpAmt) = { | |
475 | 475 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
476 | 476 | [fromX18(prices[0], scale8), fromX18(prices[1], scale8), fromX18(prices[2], scale8)] | |
477 | 477 | } | |
478 | 478 | ||
479 | 479 | ||
480 | 480 | func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
481 | 481 | let cfg = getPoolConfig() | |
482 | 482 | let lpAssetId = cfg[idxPoolLPAssetId] | |
483 | 483 | let amAssetId = cfg[idxAmtAssetId] | |
484 | 484 | let prAssetId = cfg[idxPriceAssetId] | |
485 | 485 | let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
486 | 486 | let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
487 | 487 | let poolStatus = cfg[idxPoolStatus] | |
488 | 488 | let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity | |
489 | 489 | if ((lpAssetId != pmtAssetId)) | |
490 | 490 | then throw("Invalid asset passed.") | |
491 | 491 | else { | |
492 | 492 | let amBalance = getAccBalance(amAssetId) | |
493 | 493 | let amBalanceX18 = toX18(amBalance, amAssetDcm) | |
494 | 494 | let prBalance = getAccBalance(prAssetId) | |
495 | 495 | let prBalanceX18 = toX18(prBalance, prAssetDcm) | |
496 | 496 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
497 | 497 | let curPrice = fromX18(curPriceX18, scale8) | |
498 | 498 | let pmtLpAmtX18 = toX18(pmtLpAmt, scale8) | |
499 | 499 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
500 | 500 | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
501 | 501 | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
502 | 502 | let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR) | |
503 | 503 | let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR) | |
504 | 504 | let AmAmtWithdrawState = withdrawAndRebalanceAsset(amAssetId, outAmAmt) | |
505 | - | if ((AmAmtWithdrawState == AmAmtWithdrawState)) | |
506 | - | then { | |
507 | - | let PrAmtWithdrawState = withdrawAndRebalanceAsset(prAssetId, outPrAmt) | |
508 | - | if ((PrAmtWithdrawState == PrAmtWithdrawState)) | |
509 | - | then { | |
510 | - | let state = if ((txId58 == "")) | |
511 | - | then nil | |
512 | - | else ((AmAmtWithdrawState ++ PrAmtWithdrawState) ++ [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
513 | - | then unit | |
514 | - | else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES")) | |
515 | - | then unit | |
516 | - | else fromBase58String(prAssetId)), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAmAmt, outPrAmt, pmtLpAmt, curPrice, height, lastBlock.timestamp)), IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice)]) | |
517 | - | $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state) | |
518 | - | } | |
519 | - | else throw("Strict value is not equal to itself.") | |
520 | - | } | |
521 | - | else throw("Strict value is not equal to itself.") | |
505 | + | let PrAmtWithdrawState = withdrawAndRebalanceAsset(prAssetId, outPrAmt) | |
506 | + | let state = if ((txId58 == "")) | |
507 | + | then nil | |
508 | + | else ((AmAmtWithdrawState ++ PrAmtWithdrawState) ++ [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
509 | + | then unit | |
510 | + | else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES")) | |
511 | + | 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)]) | |
513 | + | $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state) | |
522 | 514 | } | |
523 | 515 | } | |
524 | 516 | ||
525 | 517 | ||
526 | 518 | func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = { | |
527 | 519 | let cfg = getPoolConfig() | |
528 | 520 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
529 | 521 | let amAssetIdStr = cfg[idxAmtAssetId] | |
530 | 522 | let prAssetIdStr = cfg[idxPriceAssetId] | |
531 | 523 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
532 | 524 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
533 | 525 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
534 | 526 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
535 | 527 | let poolStatus = cfg[idxPoolStatus] | |
536 | 528 | let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
537 | 529 | let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES"))) | |
538 | 530 | let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES"))) | |
539 | 531 | if (if ((amAssetIdStr != inAmAssetIdStr)) | |
540 | 532 | then true | |
541 | 533 | else (prAssetIdStr != inPrAssetIdStr)) | |
542 | 534 | then throw("Invalid amt or price asset passed.") | |
543 | 535 | else { | |
544 | 536 | let amBalance = if (isEvaluate) | |
545 | 537 | then getAccBalance(amAssetIdStr) | |
546 | 538 | else (getAccBalance(amAssetIdStr) - inAmAssetAmt) | |
547 | 539 | let prBalance = if (isEvaluate) | |
548 | 540 | then getAccBalance(prAssetIdStr) | |
549 | 541 | else (getAccBalance(prAssetIdStr) - inPrAssetAmt) | |
550 | 542 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
551 | 543 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
552 | 544 | let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18) | |
553 | 545 | let amBalanceX18 = toX18(amBalance, amtAssetDcm) | |
554 | 546 | let prBalanceX18 = toX18(prBalance, priceAssetDcm) | |
555 | 547 | let res = if ((lpEmission == 0)) | |
556 | 548 | then { | |
557 | 549 | let curPriceX18 = zeroBigInt | |
558 | 550 | let slippageX18 = zeroBigInt | |
559 | 551 | let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN) | |
560 | 552 | $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
561 | 553 | } | |
562 | 554 | else { | |
563 | 555 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
564 | 556 | let slippageX18 = fraction(absBigInt((curPriceX18 - userPriceX18)), scale18, curPriceX18) | |
565 | 557 | let slippageToleranceX18 = toX18(slippageTolerance, scale8) | |
566 | 558 | if (if ((curPriceX18 != zeroBigInt)) | |
567 | 559 | then (slippageX18 > slippageToleranceX18) | |
568 | 560 | else false) | |
569 | 561 | then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18))) | |
570 | 562 | else { | |
571 | 563 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
572 | 564 | let prViaAmX18 = fraction(inAmAssetAmtX18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING) | |
573 | 565 | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, FLOOR), CEILING) | |
574 | 566 | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
575 | 567 | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
576 | 568 | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
577 | 569 | let expAmtAssetAmtX18 = expectedAmts._1 | |
578 | 570 | let expPriceAssetAmtX18 = expectedAmts._2 | |
579 | 571 | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR) | |
580 | 572 | $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtAssetDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceAssetDcm, CEILING), curPriceX18, slippageX18) | |
581 | 573 | } | |
582 | 574 | } | |
583 | 575 | let calcLpAmt = res._1 | |
584 | 576 | let calcAmAssetPmt = res._2 | |
585 | 577 | let calcPrAssetPmt = res._3 | |
586 | 578 | let curPrice = fromX18(res._4, scale8) | |
587 | 579 | let slippageCalc = fromX18(res._5, scale8) | |
588 | 580 | if ((0 >= calcLpAmt)) | |
589 | 581 | then throw("Invalid calculations. LP calculated is less than zero.") | |
590 | 582 | else { | |
591 | 583 | let emitLpAmt = if (!(emitLp)) | |
592 | 584 | then 0 | |
593 | 585 | else calcLpAmt | |
594 | 586 | let amDiff = (inAmAssetAmt - calcAmAssetPmt) | |
595 | 587 | let prDiff = (inPrAssetAmt - calcPrAssetPmt) | |
596 | 588 | 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))] | |
597 | 589 | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId) | |
598 | 590 | } | |
599 | 591 | } | |
600 | 592 | } | |
601 | 593 | ||
602 | 594 | ||
603 | 595 | func calcKLp (amountBalance,priceBalance,lpEmission) = { | |
604 | 596 | let amountBalanceX18 = toX18BigInt(amountBalance, toBigInt(cfgAmountAssetDecimals)) | |
605 | 597 | let priceBalanceX18 = toX18BigInt(priceBalance, toBigInt(cfgPriceAssetDecimals)) | |
606 | 598 | let updatedKLp = fraction(pow((amountBalanceX18 * priceBalanceX18), 0, toBigInt(5), 1, 18, DOWN), big1, lpEmission) | |
607 | 599 | if ((lpEmission == big0)) | |
608 | 600 | then big0 | |
609 | 601 | else updatedKLp | |
610 | 602 | } | |
611 | 603 | ||
612 | 604 | ||
613 | 605 | func calcCurrentKLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = { | |
614 | 606 | let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta) | |
615 | 607 | let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta) | |
616 | 608 | let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta) | |
617 | 609 | let currentKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpAssetEmission) | |
618 | 610 | currentKLp | |
619 | 611 | } | |
620 | 612 | ||
621 | 613 | ||
622 | 614 | func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
623 | 615 | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
624 | 616 | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
625 | 617 | let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta) | |
626 | 618 | let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
627 | 619 | let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))] | |
628 | 620 | $Tuple2(actions, updatedKLp) | |
629 | 621 | } | |
630 | 622 | ||
631 | 623 | ||
632 | 624 | func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp)) | |
633 | 625 | then true | |
634 | 626 | else throwErr(makeString(["updated KLp lower than current KLp", toString(oldKLp), toString(updatedKLp)], " ")) | |
635 | 627 | ||
636 | 628 | ||
637 | 629 | func validateMatcherOrderAllowed (order) = { | |
638 | 630 | let amountAssetBalance = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
639 | 631 | let priceAssetBalance = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
640 | 632 | let amountAssetAmount = order.amount | |
641 | 633 | let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR) | |
642 | - | let $ | |
634 | + | let $t02814728359 = if ((order.orderType == Buy)) | |
643 | 635 | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
644 | 636 | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
645 | - | let amountAssetBalanceDelta = $ | |
646 | - | let priceAssetBalanceDelta = $ | |
637 | + | let amountAssetBalanceDelta = $t02814728359._1 | |
638 | + | let priceAssetBalanceDelta = $t02814728359._2 | |
647 | 639 | if (if (if (isGlobalShutdown()) | |
648 | 640 | then true | |
649 | 641 | else (cfgPoolStatus == PoolMatcherDisabled)) | |
650 | 642 | then true | |
651 | 643 | else (cfgPoolStatus == PoolShutdown)) | |
652 | 644 | then throw("Exchange operations disabled") | |
653 | 645 | else if (if ((order.assetPair.amountAsset != cfgAmountAssetId)) | |
654 | 646 | then true | |
655 | 647 | else (order.assetPair.priceAsset != cfgPriceAssetId)) | |
656 | 648 | then throw("Wrong order assets.") | |
657 | 649 | else { | |
658 | 650 | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
659 | - | let $ | |
660 | - | let unusedActions = $ | |
661 | - | let kLpNew = $ | |
651 | + | let $t02879928899 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
652 | + | let unusedActions = $t02879928899._1 | |
653 | + | let kLpNew = $t02879928899._2 | |
662 | 654 | let isOrderValid = (kLpNew >= kLp) | |
663 | 655 | let info = makeString(["kLp=", toString(kLp), " kLpNew=", toString(kLpNew), " amountAssetBalance=", toString(amountAssetBalance), " priceAssetBalance=", toString(priceAssetBalance), " amountAssetBalanceDelta=", toString(amountAssetBalanceDelta), " priceAssetBalanceDelta=", toString(priceAssetBalanceDelta), " height=", toString(height)], "") | |
664 | 656 | $Tuple2(isOrderValid, info) | |
665 | 657 | } | |
666 | 658 | } | |
667 | 659 | ||
668 | 660 | ||
669 | 661 | func commonGet (i) = if ((size(i.payments) != 1)) | |
670 | 662 | then throw("exactly 1 payment is expected") | |
671 | 663 | else { | |
672 | 664 | let pmt = value(i.payments[0]) | |
673 | 665 | let pmtAssetId = value(pmt.assetId) | |
674 | 666 | let pmtAmt = pmt.amount | |
675 | 667 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
676 | 668 | let outAmAmt = res._1 | |
677 | 669 | let outPrAmt = res._2 | |
678 | 670 | let poolStatus = parseIntValue(res._9) | |
679 | 671 | let state = res._10 | |
680 | 672 | if (if (isGlobalShutdown()) | |
681 | 673 | then true | |
682 | 674 | else (poolStatus == PoolShutdown)) | |
683 | 675 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
684 | 676 | else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state) | |
685 | 677 | } | |
686 | 678 | ||
687 | 679 | ||
688 | 680 | func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2)) | |
689 | 681 | then throw("exactly 2 payments are expected") | |
690 | 682 | else { | |
691 | 683 | let amAssetPmt = value(i.payments[0]) | |
692 | 684 | let prAssetPmt = value(i.payments[1]) | |
693 | 685 | let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp) | |
694 | 686 | let poolStatus = parseIntValue(estPut._8) | |
695 | 687 | if (if (if (isGlobalShutdown()) | |
696 | 688 | then true | |
697 | 689 | else (poolStatus == PoolPutDisabled)) | |
698 | 690 | then true | |
699 | 691 | else (poolStatus == PoolShutdown)) | |
700 | 692 | then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus))) | |
701 | 693 | else estPut | |
702 | 694 | } | |
703 | 695 | ||
704 | 696 | ||
705 | 697 | func emit (amount) = { | |
706 | 698 | let emitInv = invoke(factoryContract, "emit", [amount], nil) | |
707 | 699 | if ((emitInv == emitInv)) | |
708 | 700 | then { | |
709 | 701 | let emitInvLegacy = match emitInv { | |
710 | 702 | case legacyFactoryContract: Address => | |
711 | 703 | invoke(legacyFactoryContract, "emit", [amount], nil) | |
712 | 704 | case _ => | |
713 | 705 | unit | |
714 | 706 | } | |
715 | 707 | if ((emitInvLegacy == emitInvLegacy)) | |
716 | 708 | then amount | |
717 | 709 | else throw("Strict value is not equal to itself.") | |
718 | 710 | } | |
719 | 711 | else throw("Strict value is not equal to itself.") | |
720 | 712 | } | |
721 | 713 | ||
722 | 714 | ||
723 | 715 | func takeFee (amount,fee) = { | |
724 | 716 | let feeAmount = if ((fee == 0)) | |
725 | 717 | then 0 | |
726 | 718 | else fraction(amount, fee, scale8) | |
727 | 719 | $Tuple2((amount - feeAmount), feeAmount) | |
728 | 720 | } | |
729 | 721 | ||
730 | 722 | ||
731 | 723 | func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = { | |
732 | 724 | let isEval = (txId == unit) | |
733 | 725 | let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
734 | 726 | let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
735 | 727 | let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId)) | |
736 | 728 | then true | |
737 | 729 | else if ((paymentAssetId == cfgPriceAssetId)) | |
738 | 730 | then false | |
739 | 731 | else throwErr("invalid asset") | |
740 | - | let $ | |
732 | + | let $t03201232305 = if (isEval) | |
741 | 733 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
742 | 734 | else if (paymentInAmountAsset) | |
743 | 735 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
744 | 736 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
745 | - | let amountBalanceOld = $ | |
746 | - | let priceBalanceOld = $ | |
747 | - | let $ | |
737 | + | let amountBalanceOld = $t03201232305._1 | |
738 | + | let priceBalanceOld = $t03201232305._2 | |
739 | + | let $t03230932458 = if (paymentInAmountAsset) | |
748 | 740 | then $Tuple2(paymentAmountRaw, 0) | |
749 | 741 | else $Tuple2(0, paymentAmountRaw) | |
750 | - | let amountAssetAmountRaw = $ | |
751 | - | let priceAssetAmountRaw = $ | |
742 | + | let amountAssetAmountRaw = $t03230932458._1 | |
743 | + | let priceAssetAmountRaw = $t03230932458._2 | |
752 | 744 | let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1 | |
753 | 745 | let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1 | |
754 | - | let $ | |
755 | - | let paymentAmount = $ | |
756 | - | let feeAmount = $ | |
746 | + | let $t03259032654 = takeFee(paymentAmountRaw, inFee) | |
747 | + | let paymentAmount = $t03259032654._1 | |
748 | + | let feeAmount = $t03259032654._2 | |
757 | 749 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
758 | 750 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
759 | 751 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
760 | 752 | let priceNew = fromX18(priceNewX18, scale8) | |
761 | 753 | let paymentBalance = if (paymentInAmountAsset) | |
762 | 754 | then amountBalanceOld | |
763 | 755 | else priceBalanceOld | |
764 | 756 | let paymentBalanceBigInt = toBigInt(paymentBalance) | |
765 | 757 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
766 | 758 | let chechSupply = if ((supplyBigInt > big0)) | |
767 | 759 | then true | |
768 | 760 | else throwErr("initial deposit requires all coins") | |
769 | 761 | if ((chechSupply == chechSupply)) | |
770 | 762 | then { | |
771 | 763 | let depositBigInt = toBigInt(paymentAmount) | |
772 | 764 | let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))]) | |
773 | 765 | let commonState = if (isEval) | |
774 | 766 | then nil | |
775 | 767 | 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))] | |
776 | 768 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
777 | 769 | let priceOld = fromX18(priceOldX18, scale8) | |
778 | 770 | let loss = { | |
779 | - | let $ | |
771 | + | let $t03433534502 = if (paymentInAmountAsset) | |
780 | 772 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
781 | 773 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
782 | - | let amount = $ | |
783 | - | let balance = $ | |
774 | + | let amount = $t03433534502._1 | |
775 | + | let balance = $t03433534502._2 | |
784 | 776 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
785 | 777 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
786 | 778 | } | |
787 | 779 | $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset) | |
788 | 780 | } | |
789 | 781 | else throw("Strict value is not equal to itself.") | |
790 | 782 | } | |
791 | 783 | ||
792 | 784 | ||
793 | 785 | func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = { | |
794 | 786 | let isEval = (txId == unit) | |
795 | 787 | let cfg = getPoolConfig() | |
796 | 788 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
797 | 789 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
798 | 790 | let checks = [if ((paymentAssetId == cfgLpAssetId)) | |
799 | 791 | then true | |
800 | 792 | else throwErr("invalid lp asset")] | |
801 | 793 | if ((checks == checks)) | |
802 | 794 | then { | |
803 | 795 | let outInAmountAsset = if ((outAssetId == cfgAmountAssetId)) | |
804 | 796 | then true | |
805 | 797 | else if ((outAssetId == cfgPriceAssetId)) | |
806 | 798 | then false | |
807 | 799 | else throwErr("invalid asset") | |
808 | 800 | let balanceBigInt = if (outInAmountAsset) | |
809 | 801 | then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) | |
810 | 802 | else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) | |
811 | 803 | let outInAmountAssetDecimals = if (outInAmountAsset) | |
812 | 804 | then amtAssetDcm | |
813 | 805 | else priceAssetDcm | |
814 | 806 | let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
815 | 807 | let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
816 | 808 | let outBalance = if (outInAmountAsset) | |
817 | 809 | then amBalanceOld | |
818 | 810 | else prBalanceOld | |
819 | 811 | let outBalanceBigInt = toBigInt(outBalance) | |
820 | 812 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
821 | 813 | let redeemedBigInt = toBigInt(paymentAmount) | |
822 | 814 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
823 | - | let $ | |
824 | - | let totalAmount = $ | |
825 | - | let feeAmount = $ | |
826 | - | let $ | |
815 | + | let $t03658036636 = takeFee(amountRaw, outFee) | |
816 | + | let totalAmount = $t03658036636._1 | |
817 | + | let feeAmount = $t03658036636._2 | |
818 | + | let $t03664036866 = if (outInAmountAsset) | |
827 | 819 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
828 | 820 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
829 | - | let outAmAmount = $ | |
830 | - | let outPrAmount = $ | |
831 | - | let amBalanceNew = $ | |
832 | - | let prBalanceNew = $ | |
821 | + | let outAmAmount = $t03664036866._1 | |
822 | + | let outPrAmount = $t03664036866._2 | |
823 | + | let amBalanceNew = $t03664036866._3 | |
824 | + | let prBalanceNew = $t03664036866._4 | |
833 | 825 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
834 | 826 | let priceNew = fromX18(priceNewX18, scale8) | |
835 | 827 | let commonState = if (isEval) | |
836 | 828 | then nil | |
837 | 829 | 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)] | |
838 | 830 | let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals)) | |
839 | 831 | let priceOld = fromX18(priceOldX18, scale8) | |
840 | 832 | let loss = { | |
841 | 833 | let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2) | |
842 | 834 | fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset) | |
843 | 835 | } | |
844 | 836 | $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset) | |
845 | 837 | } | |
846 | 838 | else throw("Strict value is not equal to itself.") | |
847 | 839 | } | |
848 | 840 | ||
849 | 841 | ||
850 | 842 | func managerPublicKeyOrUnit () = match getString(mpk()) { | |
851 | 843 | case s: String => | |
852 | 844 | fromBase58String(s) | |
853 | 845 | case _: Unit => | |
854 | 846 | unit | |
855 | 847 | case _ => | |
856 | 848 | throw("Match error") | |
857 | 849 | } | |
858 | 850 | ||
859 | 851 | ||
860 | 852 | func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) { | |
861 | 853 | case s: String => | |
862 | 854 | fromBase58String(s) | |
863 | 855 | case _: Unit => | |
864 | 856 | unit | |
865 | 857 | case _ => | |
866 | 858 | throw("Match error") | |
867 | 859 | } | |
868 | 860 | ||
869 | 861 | ||
870 | 862 | func isManager (i) = match managerPublicKeyOrUnit() { | |
871 | 863 | case pk: ByteVector => | |
872 | 864 | (i.callerPublicKey == pk) | |
873 | 865 | case _: Unit => | |
874 | 866 | (i.caller == this) | |
875 | 867 | case _ => | |
876 | 868 | throw("Match error") | |
877 | 869 | } | |
878 | 870 | ||
879 | 871 | ||
880 | 872 | func mustManager (i) = { | |
881 | 873 | let pd = throw("Permission denied") | |
882 | 874 | match managerPublicKeyOrUnit() { | |
883 | 875 | case pk: ByteVector => | |
884 | 876 | if ((i.callerPublicKey == pk)) | |
885 | 877 | then true | |
886 | 878 | else pd | |
887 | 879 | case _: Unit => | |
888 | 880 | if ((i.caller == this)) | |
889 | 881 | then true | |
890 | 882 | else pd | |
891 | 883 | case _ => | |
892 | 884 | throw("Match error") | |
893 | 885 | } | |
894 | 886 | } | |
895 | 887 | ||
896 | 888 | ||
897 | 889 | @Callable(i) | |
898 | 890 | func rebalance () = (rebalanceAsset(getStringOrFail(this, aa())) ++ rebalanceAsset(getStringOrFail(this, pa()))) | |
899 | 891 | ||
900 | 892 | ||
901 | 893 | ||
902 | 894 | @Callable(i) | |
903 | 895 | func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse,feePoolAmount) = { | |
904 | - | let $ | |
896 | + | let $t03875239057 = if ((isReverse == false)) | |
905 | 897 | then { | |
906 | 898 | let assetOut = getStringOrFail(this, pa()) | |
907 | 899 | let assetIn = getStringOrFail(this, aa()) | |
908 | 900 | $Tuple2(assetOut, assetIn) | |
909 | 901 | } | |
910 | 902 | else { | |
911 | 903 | let assetOut = getStringOrFail(this, aa()) | |
912 | 904 | let assetIn = getStringOrFail(this, pa()) | |
913 | 905 | $Tuple2(assetOut, assetIn) | |
914 | 906 | } | |
915 | - | let assetOut = $ | |
916 | - | let assetIn = $ | |
907 | + | let assetOut = $t03875239057._1 | |
908 | + | let assetIn = $t03875239057._2 | |
917 | 909 | let poolAssetInBalance = getAccBalance(assetIn) | |
918 | 910 | let poolAssetOutBalance = getAccBalance(assetOut) | |
919 | 911 | let amountOut = fraction(poolAssetOutBalance, cleanAmountIn, (poolAssetInBalance + cleanAmountIn)) | |
920 | 912 | let oldK = (toBigInt(poolAssetInBalance) * toBigInt(poolAssetOutBalance)) | |
921 | 913 | let newK = (((toBigInt(getAccBalance(assetIn)) + toBigInt(cleanAmountIn)) + toBigInt(feePoolAmount)) * (toBigInt(getAccBalance(assetOut)) - toBigInt(amountOut))) | |
922 | 914 | let checkK = if ((newK >= oldK)) | |
923 | 915 | then true | |
924 | 916 | else throw("new K is fewer error") | |
925 | 917 | if ((checkK == checkK)) | |
926 | 918 | then $Tuple2(nil, amountOut) | |
927 | 919 | else throw("Strict value is not equal to itself.") | |
928 | 920 | } | |
929 | 921 | ||
930 | 922 | ||
931 | 923 | ||
932 | 924 | @Callable(i) | |
933 | 925 | func calculateAmountOutForSwapAndSendTokens (cleanAmountIn,isReverse,amountOutMin,addressTo,feePoolAmount) = { | |
934 | 926 | let swapContact = { | |
935 | 927 | let @ = invoke(factoryContract, "getSwapContractREADONLY", nil, nil) | |
936 | 928 | if ($isInstanceOf(@, "String")) | |
937 | 929 | then @ | |
938 | 930 | else throw(($getType(@) + " couldn't be cast to String")) | |
939 | 931 | } | |
940 | 932 | let checks = [if ((value(i.payments[0]).amount >= cleanAmountIn)) | |
941 | 933 | then true | |
942 | 934 | else throwErr("Wrong amount"), if ((i.caller == addressFromStringValue(swapContact))) | |
943 | 935 | then true | |
944 | 936 | else throwErr("Permission denied")] | |
945 | 937 | if ((checks == checks)) | |
946 | 938 | then { | |
947 | 939 | let pmt = value(i.payments[0]) | |
948 | 940 | let assetIn = assetIdToString(pmt.assetId) | |
949 | 941 | let assetOut = if ((isReverse == false)) | |
950 | 942 | then getStringOrFail(this, pa()) | |
951 | 943 | else getStringOrFail(this, aa()) | |
952 | 944 | let poolAssetInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount) | |
953 | 945 | let poolAssetOutBalance = getAccBalance(assetOut) | |
954 | 946 | let amountOut = fraction(poolAssetOutBalance, cleanAmountIn, (poolAssetInBalance + cleanAmountIn)) | |
955 | 947 | let oldK = (toBigInt(poolAssetInBalance) * toBigInt(poolAssetOutBalance)) | |
956 | 948 | let newK = ((toBigInt(getAccBalance(assetIn)) + toBigInt(feePoolAmount)) * (toBigInt(getAccBalance(assetOut)) - toBigInt(amountOut))) | |
957 | 949 | let checkK = if ((newK >= oldK)) | |
958 | 950 | then true | |
959 | 951 | else throw("new K is fewer error") | |
960 | 952 | if ((checkK == checkK)) | |
961 | 953 | then { | |
962 | 954 | let checkMin = if ((amountOut >= amountOutMin)) | |
963 | 955 | then true | |
964 | 956 | else throw("Exchange result is fewer coins than expected") | |
965 | 957 | if ((checkMin == checkMin)) | |
966 | 958 | then { | |
967 | 959 | let rebalanceState = rebalanceAsset(assetIn) | |
968 | 960 | if ((rebalanceState == rebalanceState)) | |
969 | 961 | then { | |
970 | 962 | let withdrawState = withdrawAndRebalanceAsset(assetOut, amountOut) | |
971 | 963 | if ((withdrawState == withdrawState)) | |
972 | 964 | then $Tuple2(((withdrawState ++ rebalanceState) ++ [ScriptTransfer(addressFromStringValue(addressTo), amountOut, parseAssetId(assetOut))]), amountOut) | |
973 | 965 | else throw("Strict value is not equal to itself.") | |
974 | 966 | } | |
975 | 967 | else throw("Strict value is not equal to itself.") | |
976 | 968 | } | |
977 | 969 | else throw("Strict value is not equal to itself.") | |
978 | 970 | } | |
979 | 971 | else throw("Strict value is not equal to itself.") | |
980 | 972 | } | |
981 | 973 | else throw("Strict value is not equal to itself.") | |
982 | 974 | } | |
983 | 975 | ||
984 | 976 | ||
985 | 977 | ||
986 | 978 | @Callable(i) | |
987 | 979 | func setManager (pendingManagerPublicKey) = { | |
988 | 980 | let checkCaller = mustManager(i) | |
989 | 981 | if ((checkCaller == checkCaller)) | |
990 | 982 | then { | |
991 | 983 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
992 | 984 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
993 | 985 | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
994 | 986 | else throw("Strict value is not equal to itself.") | |
995 | 987 | } | |
996 | 988 | else throw("Strict value is not equal to itself.") | |
997 | 989 | } | |
998 | 990 | ||
999 | 991 | ||
1000 | 992 | ||
1001 | 993 | @Callable(i) | |
1002 | 994 | func confirmManager () = { | |
1003 | 995 | let pm = pendingManagerPublicKeyOrUnit() | |
1004 | 996 | let hasPM = if (isDefined(pm)) | |
1005 | 997 | then true | |
1006 | 998 | else throw("No pending manager") | |
1007 | 999 | if ((hasPM == hasPM)) | |
1008 | 1000 | then { | |
1009 | 1001 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
1010 | 1002 | then true | |
1011 | 1003 | else throw("You are not pending manager") | |
1012 | 1004 | if ((checkPM == checkPM)) | |
1013 | 1005 | then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())] | |
1014 | 1006 | else throw("Strict value is not equal to itself.") | |
1015 | 1007 | } | |
1016 | 1008 | else throw("Strict value is not equal to itself.") | |
1017 | 1009 | } | |
1018 | 1010 | ||
1019 | 1011 | ||
1020 | 1012 | ||
1021 | 1013 | @Callable(i) | |
1022 | 1014 | func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance)) | |
1023 | 1015 | then throw("Invalid slippageTolerance passed") | |
1024 | 1016 | else { | |
1025 | 1017 | let estPut = commonPut(i, slippageTolerance, true) | |
1026 | 1018 | let emitLpAmt = estPut._2 | |
1027 | 1019 | let lpAssetId = estPut._7 | |
1028 | 1020 | let state = estPut._9 | |
1029 | 1021 | let amDiff = estPut._10 | |
1030 | 1022 | let prDiff = estPut._11 | |
1031 | 1023 | let amId = estPut._12 | |
1032 | 1024 | let prId = estPut._13 | |
1033 | 1025 | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
1034 | 1026 | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
1035 | 1027 | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
1036 | 1028 | if ((currentKLp == currentKLp)) | |
1037 | 1029 | then { | |
1038 | 1030 | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
1039 | 1031 | if ((emitInv == emitInv)) | |
1040 | 1032 | then { | |
1041 | 1033 | let emitInvLegacy = match emitInv { | |
1042 | 1034 | case legacyFactoryContract: Address => | |
1043 | 1035 | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
1044 | 1036 | case _ => | |
1045 | 1037 | unit | |
1046 | 1038 | } | |
1047 | 1039 | if ((emitInvLegacy == emitInvLegacy)) | |
1048 | 1040 | then { | |
1049 | 1041 | let slippageAInv = if ((amDiff > 0)) | |
1050 | 1042 | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
1051 | 1043 | else nil | |
1052 | 1044 | if ((slippageAInv == slippageAInv)) | |
1053 | 1045 | then { | |
1054 | 1046 | let slippagePInv = if ((prDiff > 0)) | |
1055 | 1047 | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
1056 | 1048 | else nil | |
1057 | 1049 | if ((slippagePInv == slippagePInv)) | |
1058 | 1050 | then { | |
1059 | 1051 | let lpTransfer = if (shouldAutoStake) | |
1060 | 1052 | then { | |
1061 | 1053 | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
1062 | 1054 | if ((slpStakeInv == slpStakeInv)) | |
1063 | 1055 | then nil | |
1064 | 1056 | else throw("Strict value is not equal to itself.") | |
1065 | 1057 | } | |
1066 | 1058 | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
1067 | - | let $ | |
1068 | - | if (($ | |
1059 | + | let $t04410344565 = refreshKLpInternal(0, 0, 0) | |
1060 | + | if (($t04410344565 == $t04410344565)) | |
1069 | 1061 | then { | |
1070 | - | let updatedKLp = $ | |
1071 | - | let refreshKLpActions = $ | |
1062 | + | let updatedKLp = $t04410344565._2 | |
1063 | + | let refreshKLpActions = $t04410344565._1 | |
1072 | 1064 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1073 | 1065 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1074 | 1066 | then { | |
1075 | 1067 | let reb = invoke(this, "rebalance", nil, nil) | |
1076 | 1068 | if ((reb == reb)) | |
1077 | 1069 | then ((state ++ lpTransfer) ++ refreshKLpActions) | |
1078 | 1070 | else throw("Strict value is not equal to itself.") | |
1079 | 1071 | } | |
1080 | 1072 | else throw("Strict value is not equal to itself.") | |
1081 | 1073 | } | |
1082 | 1074 | else throw("Strict value is not equal to itself.") | |
1083 | 1075 | } | |
1084 | 1076 | else throw("Strict value is not equal to itself.") | |
1085 | 1077 | } | |
1086 | 1078 | else throw("Strict value is not equal to itself.") | |
1087 | 1079 | } | |
1088 | 1080 | else throw("Strict value is not equal to itself.") | |
1089 | 1081 | } | |
1090 | 1082 | else throw("Strict value is not equal to itself.") | |
1091 | 1083 | } | |
1092 | 1084 | else throw("Strict value is not equal to itself.") | |
1093 | 1085 | } | |
1094 | 1086 | ||
1095 | 1087 | ||
1096 | 1088 | ||
1097 | 1089 | @Callable(i) | |
1098 | 1090 | func putForFree (maxSlippage) = if ((0 > maxSlippage)) | |
1099 | 1091 | then throw("Invalid value passed") | |
1100 | 1092 | else { | |
1101 | 1093 | let estPut = commonPut(i, maxSlippage, false) | |
1102 | 1094 | let state = estPut._9 | |
1103 | 1095 | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
1104 | 1096 | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
1105 | 1097 | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
1106 | 1098 | if ((currentKLp == currentKLp)) | |
1107 | 1099 | then { | |
1108 | - | let $ | |
1109 | - | let refreshKLpActions = $ | |
1110 | - | let updatedKLp = $ | |
1100 | + | let $t04517745242 = refreshKLpInternal(0, 0, 0) | |
1101 | + | let refreshKLpActions = $t04517745242._1 | |
1102 | + | let updatedKLp = $t04517745242._2 | |
1111 | 1103 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1112 | 1104 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1113 | 1105 | then (state ++ refreshKLpActions) | |
1114 | 1106 | else throw("Strict value is not equal to itself.") | |
1115 | 1107 | } | |
1116 | 1108 | else throw("Strict value is not equal to itself.") | |
1117 | 1109 | } | |
1118 | 1110 | ||
1119 | 1111 | ||
1120 | 1112 | ||
1121 | 1113 | @Callable(i) | |
1122 | 1114 | func putOneTkn (minOutAmount,autoStake) = { | |
1123 | 1115 | let isPoolOneTokenOperationsDisabled = { | |
1124 | 1116 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
1125 | 1117 | if ($isInstanceOf(@, "Boolean")) | |
1126 | 1118 | then @ | |
1127 | 1119 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
1128 | 1120 | } | |
1129 | 1121 | let isPutDisabled = if (if (if (isGlobalShutdown()) | |
1130 | 1122 | then true | |
1131 | 1123 | else (cfgPoolStatus == PoolPutDisabled)) | |
1132 | 1124 | then true | |
1133 | 1125 | else (cfgPoolStatus == PoolShutdown)) | |
1134 | 1126 | then true | |
1135 | 1127 | else isPoolOneTokenOperationsDisabled | |
1136 | 1128 | let checks = [if (if (!(isPutDisabled)) | |
1137 | 1129 | then true | |
1138 | 1130 | else isManager(i)) | |
1139 | 1131 | then true | |
1140 | 1132 | else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1)) | |
1141 | 1133 | then true | |
1142 | 1134 | else throwErr("exactly 1 payment are expected")] | |
1143 | 1135 | if ((checks == checks)) | |
1144 | 1136 | then { | |
1145 | 1137 | let payment = i.payments[0] | |
1146 | 1138 | let paymentAssetId = payment.assetId | |
1147 | 1139 | let paymentAmountRaw = payment.amount | |
1148 | 1140 | let currentKLp = if ((paymentAssetId == cfgAmountAssetId)) | |
1149 | 1141 | then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0)) | |
1150 | 1142 | else if ((paymentAssetId == cfgPriceAssetId)) | |
1151 | 1143 | then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0)) | |
1152 | 1144 | else throwErr("payment asset is not supported") | |
1153 | 1145 | if ((currentKLp == currentKLp)) | |
1154 | 1146 | then { | |
1155 | 1147 | let userAddress = i.caller | |
1156 | 1148 | let txId = i.transactionId | |
1157 | - | let $ | |
1158 | - | if (($ | |
1149 | + | let $t04643046582 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
1150 | + | if (($t04643046582 == $t04643046582)) | |
1159 | 1151 | then { | |
1160 | - | let paymentInAmountAsset = $ | |
1161 | - | let bonus = $ | |
1162 | - | let feeAmount = $ | |
1163 | - | let commonState = $ | |
1164 | - | let emitAmountEstimated = $ | |
1152 | + | let paymentInAmountAsset = $t04643046582._5 | |
1153 | + | let bonus = $t04643046582._4 | |
1154 | + | let feeAmount = $t04643046582._3 | |
1155 | + | let commonState = $t04643046582._2 | |
1156 | + | let emitAmountEstimated = $t04643046582._1 | |
1165 | 1157 | let emitAmount = if (if ((minOutAmount > 0)) | |
1166 | 1158 | then (minOutAmount > emitAmountEstimated) | |
1167 | 1159 | else false) | |
1168 | 1160 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1169 | 1161 | else emitAmountEstimated | |
1170 | 1162 | let emitInv = emit(emitAmount) | |
1171 | 1163 | if ((emitInv == emitInv)) | |
1172 | 1164 | then { | |
1173 | 1165 | let lpTransfer = if (autoStake) | |
1174 | 1166 | then { | |
1175 | 1167 | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
1176 | 1168 | if ((stakeInv == stakeInv)) | |
1177 | 1169 | then nil | |
1178 | 1170 | else throw("Strict value is not equal to itself.") | |
1179 | 1171 | } | |
1180 | 1172 | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
1181 | 1173 | let sendFee = if ((feeAmount > 0)) | |
1182 | 1174 | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
1183 | 1175 | else nil | |
1184 | - | let $ | |
1176 | + | let $t04716847365 = if ((this == feeCollectorAddress)) | |
1185 | 1177 | then $Tuple2(0, 0) | |
1186 | 1178 | else if (paymentInAmountAsset) | |
1187 | 1179 | then $Tuple2(-(feeAmount), 0) | |
1188 | 1180 | else $Tuple2(0, -(feeAmount)) | |
1189 | - | let amountAssetBalanceDelta = $ | |
1190 | - | let priceAssetBalanceDelta = $ | |
1191 | - | let $ | |
1192 | - | let refreshKLpActions = $ | |
1193 | - | let updatedKLp = $ | |
1181 | + | let amountAssetBalanceDelta = $t04716847365._1 | |
1182 | + | let priceAssetBalanceDelta = $t04716847365._2 | |
1183 | + | let $t04736847476 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1184 | + | let refreshKLpActions = $t04736847476._1 | |
1185 | + | let updatedKLp = $t04736847476._2 | |
1194 | 1186 | let kLp = value(getString(keyKLp)) | |
1195 | 1187 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1196 | 1188 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1197 | 1189 | then { | |
1198 | 1190 | let reb = invoke(this, "rebalance", nil, nil) | |
1199 | 1191 | if ((reb == reb)) | |
1200 | 1192 | then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
1201 | 1193 | else throw("Strict value is not equal to itself.") | |
1202 | 1194 | } | |
1203 | 1195 | else throw("Strict value is not equal to itself.") | |
1204 | 1196 | } | |
1205 | 1197 | else throw("Strict value is not equal to itself.") | |
1206 | 1198 | } | |
1207 | 1199 | else throw("Strict value is not equal to itself.") | |
1208 | 1200 | } | |
1209 | 1201 | else throw("Strict value is not equal to itself.") | |
1210 | 1202 | } | |
1211 | 1203 | else throw("Strict value is not equal to itself.") | |
1212 | 1204 | } | |
1213 | 1205 | ||
1214 | 1206 | ||
1215 | 1207 | ||
1216 | 1208 | @Callable(i) | |
1217 | 1209 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
1218 | - | let $ | |
1219 | - | let emitAmountEstimated = $ | |
1220 | - | let commonState = $ | |
1221 | - | let feeAmount = $ | |
1222 | - | let bonus = $ | |
1223 | - | let paymentInAmountAsset = $ | |
1210 | + | let $t04783147988 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
1211 | + | let emitAmountEstimated = $t04783147988._1 | |
1212 | + | let commonState = $t04783147988._2 | |
1213 | + | let feeAmount = $t04783147988._3 | |
1214 | + | let bonus = $t04783147988._4 | |
1215 | + | let paymentInAmountAsset = $t04783147988._5 | |
1224 | 1216 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
1225 | 1217 | } | |
1226 | 1218 | ||
1227 | 1219 | ||
1228 | 1220 | ||
1229 | 1221 | @Callable(i) | |
1230 | 1222 | func getOneTkn (outAssetIdStr,minOutAmount) = { | |
1231 | 1223 | let isPoolOneTokenOperationsDisabled = { | |
1232 | 1224 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
1233 | 1225 | if ($isInstanceOf(@, "Boolean")) | |
1234 | 1226 | then @ | |
1235 | 1227 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
1236 | 1228 | } | |
1237 | 1229 | let isGetDisabled = if (if (isGlobalShutdown()) | |
1238 | 1230 | then true | |
1239 | 1231 | else (cfgPoolStatus == PoolShutdown)) | |
1240 | 1232 | then true | |
1241 | 1233 | else isPoolOneTokenOperationsDisabled | |
1242 | 1234 | let checks = [if (if (!(isGetDisabled)) | |
1243 | 1235 | then true | |
1244 | 1236 | else isManager(i)) | |
1245 | 1237 | then true | |
1246 | 1238 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1)) | |
1247 | 1239 | then true | |
1248 | 1240 | else throwErr("exactly 1 payment are expected")] | |
1249 | 1241 | if ((checks == checks)) | |
1250 | 1242 | then { | |
1251 | 1243 | let outAssetId = parseAssetId(outAssetIdStr) | |
1252 | 1244 | let payment = i.payments[0] | |
1253 | 1245 | let paymentAssetId = payment.assetId | |
1254 | 1246 | let paymentAmount = payment.amount | |
1255 | 1247 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1256 | 1248 | if ((currentKLp == currentKLp)) | |
1257 | 1249 | then { | |
1258 | 1250 | let userAddress = i.caller | |
1259 | 1251 | let txId = i.transactionId | |
1260 | - | let $ | |
1261 | - | if (($ | |
1252 | + | let $t04887349026 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
1253 | + | if (($t04887349026 == $t04887349026)) | |
1262 | 1254 | then { | |
1263 | - | let outInAmountAsset = $ | |
1264 | - | let bonus = $ | |
1265 | - | let feeAmount = $ | |
1266 | - | let commonState = $ | |
1267 | - | let amountEstimated = $ | |
1255 | + | let outInAmountAsset = $t04887349026._5 | |
1256 | + | let bonus = $t04887349026._4 | |
1257 | + | let feeAmount = $t04887349026._3 | |
1258 | + | let commonState = $t04887349026._2 | |
1259 | + | let amountEstimated = $t04887349026._1 | |
1268 | 1260 | let amount = if (if ((minOutAmount > 0)) | |
1269 | 1261 | then (minOutAmount > amountEstimated) | |
1270 | 1262 | else false) | |
1271 | 1263 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1272 | 1264 | else amountEstimated | |
1273 | 1265 | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
1274 | 1266 | if ((burnInv == burnInv)) | |
1275 | 1267 | then { | |
1276 | 1268 | let withdrawState = withdrawAndRebalanceAsset(outAssetIdStr, amount) | |
1277 | - | if ((withdrawState == withdrawState)) | |
1278 | - | then { | |
1279 | - | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
1280 | - | let sendFee = if ((feeAmount > 0)) | |
1281 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1282 | - | else nil | |
1283 | - | let $t04960649853 = { | |
1284 | - | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1285 | - | then 0 | |
1286 | - | else feeAmount | |
1287 | - | if (outInAmountAsset) | |
1288 | - | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1289 | - | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1290 | - | } | |
1291 | - | let amountAssetBalanceDelta = $t04960649853._1 | |
1292 | - | let priceAssetBalanceDelta = $t04960649853._2 | |
1293 | - | let $t04985649964 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1294 | - | let refreshKLpActions = $t04985649964._1 | |
1295 | - | let updatedKLp = $t04985649964._2 | |
1296 | - | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1297 | - | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1298 | - | then $Tuple2(((((commonState ++ withdrawState) ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1299 | - | else throw("Strict value is not equal to itself.") | |
1300 | - | } | |
1269 | + | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
1270 | + | let sendFee = if ((feeAmount > 0)) | |
1271 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1272 | + | else nil | |
1273 | + | let $t04959749844 = { | |
1274 | + | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1275 | + | then 0 | |
1276 | + | else feeAmount | |
1277 | + | if (outInAmountAsset) | |
1278 | + | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1279 | + | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1280 | + | } | |
1281 | + | let amountAssetBalanceDelta = $t04959749844._1 | |
1282 | + | let priceAssetBalanceDelta = $t04959749844._2 | |
1283 | + | let $t04984749955 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1284 | + | let refreshKLpActions = $t04984749955._1 | |
1285 | + | let updatedKLp = $t04984749955._2 | |
1286 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1287 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1288 | + | then $Tuple2(((((commonState ++ withdrawState) ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1301 | 1289 | else throw("Strict value is not equal to itself.") | |
1302 | 1290 | } | |
1303 | 1291 | else throw("Strict value is not equal to itself.") | |
1304 | 1292 | } | |
1305 | 1293 | else throw("Strict value is not equal to itself.") | |
1306 | 1294 | } | |
1307 | 1295 | else throw("Strict value is not equal to itself.") | |
1308 | 1296 | } | |
1309 | 1297 | else throw("Strict value is not equal to itself.") | |
1310 | 1298 | } | |
1311 | 1299 | ||
1312 | 1300 | ||
1313 | 1301 | ||
1314 | 1302 | @Callable(i) | |
1315 | 1303 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
1316 | - | let $ | |
1317 | - | let amountEstimated = $ | |
1318 | - | let commonState = $ | |
1319 | - | let feeAmount = $ | |
1320 | - | let bonus = $ | |
1321 | - | let outInAmountAsset = $ | |
1304 | + | let $t05023350389 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
1305 | + | let amountEstimated = $t05023350389._1 | |
1306 | + | let commonState = $t05023350389._2 | |
1307 | + | let feeAmount = $t05023350389._3 | |
1308 | + | let bonus = $t05023350389._4 | |
1309 | + | let outInAmountAsset = $t05023350389._5 | |
1322 | 1310 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
1323 | 1311 | } | |
1324 | 1312 | ||
1325 | 1313 | ||
1326 | 1314 | ||
1327 | 1315 | @Callable(i) | |
1328 | 1316 | func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = { | |
1329 | 1317 | let isPoolOneTokenOperationsDisabled = { | |
1330 | 1318 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
1331 | 1319 | if ($isInstanceOf(@, "Boolean")) | |
1332 | 1320 | then @ | |
1333 | 1321 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
1334 | 1322 | } | |
1335 | 1323 | let isGetDisabled = if (if (isGlobalShutdown()) | |
1336 | 1324 | then true | |
1337 | 1325 | else (cfgPoolStatus == PoolShutdown)) | |
1338 | 1326 | then true | |
1339 | 1327 | else isPoolOneTokenOperationsDisabled | |
1340 | 1328 | let checks = [if (if (!(isGetDisabled)) | |
1341 | 1329 | then true | |
1342 | 1330 | else isManager(i)) | |
1343 | 1331 | then true | |
1344 | 1332 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1345 | 1333 | then true | |
1346 | 1334 | else throwErr("no payments are expected")] | |
1347 | 1335 | if ((checks == checks)) | |
1348 | 1336 | then { | |
1349 | 1337 | let outAssetId = parseAssetId(outAssetIdStr) | |
1350 | 1338 | let userAddress = i.caller | |
1351 | 1339 | let txId = i.transactionId | |
1352 | 1340 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1353 | 1341 | if ((currentKLp == currentKLp)) | |
1354 | 1342 | then { | |
1355 | 1343 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1356 | 1344 | if ((unstakeInv == unstakeInv)) | |
1357 | 1345 | then { | |
1358 | - | let $ | |
1359 | - | if (($ | |
1346 | + | let $t05129451445 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
1347 | + | if (($t05129451445 == $t05129451445)) | |
1360 | 1348 | then { | |
1361 | - | let outInAmountAsset = $ | |
1362 | - | let bonus = $ | |
1363 | - | let feeAmount = $ | |
1364 | - | let commonState = $ | |
1365 | - | let amountEstimated = $ | |
1349 | + | let outInAmountAsset = $t05129451445._5 | |
1350 | + | let bonus = $t05129451445._4 | |
1351 | + | let feeAmount = $t05129451445._3 | |
1352 | + | let commonState = $t05129451445._2 | |
1353 | + | let amountEstimated = $t05129451445._1 | |
1366 | 1354 | let amount = if (if ((minOutAmount > 0)) | |
1367 | 1355 | then (minOutAmount > amountEstimated) | |
1368 | 1356 | else false) | |
1369 | 1357 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1370 | 1358 | else amountEstimated | |
1371 | 1359 | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1372 | 1360 | if ((burnInv == burnInv)) | |
1373 | 1361 | then { | |
1374 | 1362 | let withdrawState = withdrawAndRebalanceAsset(outAssetIdStr, amount) | |
1375 | - | if ((withdrawState == withdrawState)) | |
1376 | - | then { | |
1377 | - | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
1378 | - | let sendFee = if ((feeAmount > 0)) | |
1379 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1380 | - | else nil | |
1381 | - | let $t05202352270 = { | |
1382 | - | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1383 | - | then 0 | |
1384 | - | else feeAmount | |
1385 | - | if (outInAmountAsset) | |
1386 | - | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1387 | - | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1388 | - | } | |
1389 | - | let amountAssetBalanceDelta = $t05202352270._1 | |
1390 | - | let priceAssetBalanceDelta = $t05202352270._2 | |
1391 | - | let $t05227352381 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1392 | - | let refreshKLpActions = $t05227352381._1 | |
1393 | - | let updatedKLp = $t05227352381._2 | |
1394 | - | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1395 | - | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1396 | - | then $Tuple2(((((commonState ++ withdrawState) ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1397 | - | else throw("Strict value is not equal to itself.") | |
1398 | - | } | |
1363 | + | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
1364 | + | let sendFee = if ((feeAmount > 0)) | |
1365 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1366 | + | else nil | |
1367 | + | let $t05201152258 = { | |
1368 | + | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1369 | + | then 0 | |
1370 | + | else feeAmount | |
1371 | + | if (outInAmountAsset) | |
1372 | + | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1373 | + | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1374 | + | } | |
1375 | + | let amountAssetBalanceDelta = $t05201152258._1 | |
1376 | + | let priceAssetBalanceDelta = $t05201152258._2 | |
1377 | + | let $t05226152369 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1378 | + | let refreshKLpActions = $t05226152369._1 | |
1379 | + | let updatedKLp = $t05226152369._2 | |
1380 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1381 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1382 | + | then $Tuple2(((((commonState ++ withdrawState) ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1399 | 1383 | else throw("Strict value is not equal to itself.") | |
1400 | 1384 | } | |
1401 | 1385 | else throw("Strict value is not equal to itself.") | |
1402 | 1386 | } | |
1403 | 1387 | else throw("Strict value is not equal to itself.") | |
1404 | 1388 | } | |
1405 | 1389 | else throw("Strict value is not equal to itself.") | |
1406 | 1390 | } | |
1407 | 1391 | else throw("Strict value is not equal to itself.") | |
1408 | 1392 | } | |
1409 | 1393 | else throw("Strict value is not equal to itself.") | |
1410 | 1394 | } | |
1411 | 1395 | ||
1412 | 1396 | ||
1413 | 1397 | ||
1414 | 1398 | @Callable(i) | |
1415 | 1399 | func get () = { | |
1416 | 1400 | let res = commonGet(i) | |
1417 | 1401 | let outAmtAmt = res._1 | |
1418 | 1402 | let outPrAmt = res._2 | |
1419 | 1403 | let pmtAmt = res._3 | |
1420 | 1404 | let pmtAssetId = res._4 | |
1421 | 1405 | let state = res._5 | |
1422 | 1406 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1423 | 1407 | if ((currentKLp == currentKLp)) | |
1424 | 1408 | then { | |
1425 | 1409 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1426 | 1410 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1427 | 1411 | then { | |
1428 | - | let $ | |
1429 | - | let refreshKLpActions = $ | |
1430 | - | let updatedKLp = $ | |
1412 | + | let $t05333653418 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1413 | + | let refreshKLpActions = $t05333653418._1 | |
1414 | + | let updatedKLp = $t05333653418._2 | |
1431 | 1415 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1432 | 1416 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1433 | 1417 | then (state ++ refreshKLpActions) | |
1434 | 1418 | else throw("Strict value is not equal to itself.") | |
1435 | 1419 | } | |
1436 | 1420 | else throw("Strict value is not equal to itself.") | |
1437 | 1421 | } | |
1438 | 1422 | else throw("Strict value is not equal to itself.") | |
1439 | 1423 | } | |
1440 | 1424 | ||
1441 | 1425 | ||
1442 | 1426 | ||
1443 | 1427 | @Callable(i) | |
1444 | 1428 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
1445 | 1429 | let res = commonGet(i) | |
1446 | 1430 | let outAmAmt = res._1 | |
1447 | 1431 | let outPrAmt = res._2 | |
1448 | 1432 | let pmtAmt = res._3 | |
1449 | 1433 | let pmtAssetId = res._4 | |
1450 | 1434 | let state = res._5 | |
1451 | 1435 | if ((noLessThenAmtAsset > outAmAmt)) | |
1452 | 1436 | then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
1453 | 1437 | else if ((noLessThenPriceAsset > outPrAmt)) | |
1454 | 1438 | then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
1455 | 1439 | else { | |
1456 | 1440 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1457 | 1441 | if ((currentKLp == currentKLp)) | |
1458 | 1442 | then { | |
1459 | 1443 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1460 | 1444 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1461 | 1445 | then { | |
1462 | - | let $ | |
1463 | - | let refreshKLpActions = $ | |
1464 | - | let updatedKLp = $ | |
1446 | + | let $t05436754448 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1447 | + | let refreshKLpActions = $t05436754448._1 | |
1448 | + | let updatedKLp = $t05436754448._2 | |
1465 | 1449 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1466 | 1450 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1467 | 1451 | then (state ++ refreshKLpActions) | |
1468 | 1452 | else throw("Strict value is not equal to itself.") | |
1469 | 1453 | } | |
1470 | 1454 | else throw("Strict value is not equal to itself.") | |
1471 | 1455 | } | |
1472 | 1456 | else throw("Strict value is not equal to itself.") | |
1473 | 1457 | } | |
1474 | 1458 | } | |
1475 | 1459 | ||
1476 | 1460 | ||
1477 | 1461 | ||
1478 | 1462 | @Callable(i) | |
1479 | 1463 | func unstakeAndGet (amount) = { | |
1480 | 1464 | let checkPayments = if ((size(i.payments) != 0)) | |
1481 | 1465 | then throw("No payments are expected") | |
1482 | 1466 | else true | |
1483 | 1467 | if ((checkPayments == checkPayments)) | |
1484 | 1468 | then { | |
1485 | 1469 | let cfg = getPoolConfig() | |
1486 | 1470 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1487 | 1471 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1488 | 1472 | if ((currentKLp == currentKLp)) | |
1489 | 1473 | then { | |
1490 | 1474 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1491 | 1475 | if ((unstakeInv == unstakeInv)) | |
1492 | 1476 | then { | |
1493 | 1477 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1494 | 1478 | let outAmAmt = res._1 | |
1495 | 1479 | let outPrAmt = res._2 | |
1496 | 1480 | let poolStatus = parseIntValue(res._9) | |
1497 | 1481 | let state = res._10 | |
1498 | 1482 | let checkPoolStatus = if (if (isGlobalShutdown()) | |
1499 | 1483 | then true | |
1500 | 1484 | else (poolStatus == PoolShutdown)) | |
1501 | 1485 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
1502 | 1486 | else true | |
1503 | 1487 | if ((checkPoolStatus == checkPoolStatus)) | |
1504 | 1488 | then { | |
1505 | 1489 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1506 | 1490 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1507 | 1491 | then { | |
1508 | - | let $ | |
1509 | - | let refreshKLpActions = $ | |
1510 | - | let updatedKLp = $ | |
1492 | + | let $t05557455655 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1493 | + | let refreshKLpActions = $t05557455655._1 | |
1494 | + | let updatedKLp = $t05557455655._2 | |
1511 | 1495 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1512 | 1496 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1513 | 1497 | then (state ++ refreshKLpActions) | |
1514 | 1498 | else throw("Strict value is not equal to itself.") | |
1515 | 1499 | } | |
1516 | 1500 | else throw("Strict value is not equal to itself.") | |
1517 | 1501 | } | |
1518 | 1502 | else throw("Strict value is not equal to itself.") | |
1519 | 1503 | } | |
1520 | 1504 | else throw("Strict value is not equal to itself.") | |
1521 | 1505 | } | |
1522 | 1506 | else throw("Strict value is not equal to itself.") | |
1523 | 1507 | } | |
1524 | 1508 | else throw("Strict value is not equal to itself.") | |
1525 | 1509 | } | |
1526 | 1510 | ||
1527 | 1511 | ||
1528 | 1512 | ||
1529 | 1513 | @Callable(i) | |
1530 | 1514 | func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = { | |
1531 | 1515 | let isGetDisabled = if (isGlobalShutdown()) | |
1532 | 1516 | then true | |
1533 | 1517 | else (cfgPoolStatus == PoolShutdown) | |
1534 | 1518 | let checks = [if (!(isGetDisabled)) | |
1535 | 1519 | then true | |
1536 | 1520 | else throw("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1537 | 1521 | then true | |
1538 | 1522 | else throw("no payments are expected")] | |
1539 | 1523 | if ((checks == checks)) | |
1540 | 1524 | then { | |
1541 | 1525 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1542 | 1526 | if ((currentKLp == currentKLp)) | |
1543 | 1527 | then { | |
1544 | 1528 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1545 | 1529 | if ((unstakeInv == unstakeInv)) | |
1546 | 1530 | then { | |
1547 | 1531 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1548 | 1532 | let outAmAmt = res._1 | |
1549 | 1533 | let outPrAmt = res._2 | |
1550 | 1534 | let state = res._10 | |
1551 | 1535 | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1552 | 1536 | then true | |
1553 | 1537 | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1554 | 1538 | then true | |
1555 | 1539 | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1556 | 1540 | if ((checkAmounts == checkAmounts)) | |
1557 | 1541 | then { | |
1558 | 1542 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1559 | 1543 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1560 | 1544 | then { | |
1561 | - | let $ | |
1562 | - | let refreshKLpActions = $ | |
1563 | - | let updatedKLp = $ | |
1545 | + | let $t05695057031 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1546 | + | let refreshKLpActions = $t05695057031._1 | |
1547 | + | let updatedKLp = $t05695057031._2 | |
1564 | 1548 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1565 | 1549 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1566 | 1550 | then (state ++ refreshKLpActions) | |
1567 | 1551 | else throw("Strict value is not equal to itself.") | |
1568 | 1552 | } | |
1569 | 1553 | else throw("Strict value is not equal to itself.") | |
1570 | 1554 | } | |
1571 | 1555 | else throw("Strict value is not equal to itself.") | |
1572 | 1556 | } | |
1573 | 1557 | else throw("Strict value is not equal to itself.") | |
1574 | 1558 | } | |
1575 | 1559 | else throw("Strict value is not equal to itself.") | |
1576 | 1560 | } | |
1577 | 1561 | else throw("Strict value is not equal to itself.") | |
1578 | 1562 | } | |
1579 | 1563 | ||
1580 | 1564 | ||
1581 | 1565 | ||
1582 | 1566 | @Callable(i) | |
1583 | 1567 | func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract))) | |
1584 | 1568 | then throw("permissions denied") | |
1585 | 1569 | else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success") | |
1586 | 1570 | ||
1587 | 1571 | ||
1588 | 1572 | ||
1589 | 1573 | @Callable(i) | |
1590 | 1574 | func refreshKLp () = { | |
1591 | 1575 | let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0) | |
1592 | 1576 | let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay)) | |
1593 | 1577 | then unit | |
1594 | 1578 | else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1595 | 1579 | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1596 | 1580 | then { | |
1597 | 1581 | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
1598 | - | let $ | |
1599 | - | let kLpUpdateActions = $ | |
1600 | - | let updatedKLp = $ | |
1582 | + | let $t05821858282 = refreshKLpInternal(0, 0, 0) | |
1583 | + | let kLpUpdateActions = $t05821858282._1 | |
1584 | + | let updatedKLp = $t05821858282._2 | |
1601 | 1585 | let actions = if ((kLp != updatedKLp)) | |
1602 | 1586 | then kLpUpdateActions | |
1603 | 1587 | else throwErr("nothing to refresh") | |
1604 | 1588 | $Tuple2(actions, toString(updatedKLp)) | |
1605 | 1589 | } | |
1606 | 1590 | else throw("Strict value is not equal to itself.") | |
1607 | 1591 | } | |
1608 | 1592 | ||
1609 | 1593 | ||
1610 | 1594 | ||
1611 | 1595 | @Callable(i) | |
1612 | 1596 | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig()) | |
1613 | 1597 | ||
1614 | 1598 | ||
1615 | 1599 | ||
1616 | 1600 | @Callable(i) | |
1617 | 1601 | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
1618 | 1602 | ||
1619 | 1603 | ||
1620 | 1604 | ||
1621 | 1605 | @Callable(i) | |
1622 | 1606 | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
1623 | 1607 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
1624 | 1608 | $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])]) | |
1625 | 1609 | } | |
1626 | 1610 | ||
1627 | 1611 | ||
1628 | 1612 | ||
1629 | 1613 | @Callable(i) | |
1630 | 1614 | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult))) | |
1631 | 1615 | ||
1632 | 1616 | ||
1633 | 1617 | ||
1634 | 1618 | @Callable(i) | |
1635 | 1619 | func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult)) | |
1636 | 1620 | ||
1637 | 1621 | ||
1638 | 1622 | ||
1639 | 1623 | @Callable(i) | |
1640 | 1624 | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
1641 | 1625 | ||
1642 | 1626 | ||
1643 | 1627 | ||
1644 | 1628 | @Callable(i) | |
1645 | 1629 | func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp)) | |
1646 | 1630 | ||
1647 | 1631 | ||
1648 | 1632 | ||
1649 | 1633 | @Callable(i) | |
1650 | 1634 | func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
1651 | 1635 | let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress)) | |
1652 | 1636 | $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10)) | |
1653 | 1637 | } | |
1654 | 1638 | ||
1655 | 1639 | ||
1656 | 1640 | ||
1657 | 1641 | @Callable(i) | |
1658 | 1642 | func statsREADONLY () = { | |
1659 | 1643 | let cfg = getPoolConfig() | |
1660 | 1644 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1661 | 1645 | let amtAssetId = cfg[idxAmtAssetId] | |
1662 | 1646 | let priceAssetId = cfg[idxPriceAssetId] | |
1663 | 1647 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
1664 | 1648 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
1665 | 1649 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1666 | 1650 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1667 | 1651 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1668 | 1652 | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
1669 | 1653 | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
1670 | 1654 | let pricesList = if ((poolLPBalance == 0)) | |
1671 | 1655 | then [zeroBigInt, zeroBigInt, zeroBigInt] | |
1672 | 1656 | else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance) | |
1673 | 1657 | let curPrice = 0 | |
1674 | 1658 | let lpAmtAssetShare = fromX18(pricesList[1], scale8) | |
1675 | 1659 | let lpPriceAssetShare = fromX18(pricesList[2], scale8) | |
1676 | 1660 | let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this)))) | |
1677 | 1661 | $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)) | |
1678 | 1662 | } | |
1679 | 1663 | ||
1680 | 1664 | ||
1681 | 1665 | ||
1682 | 1666 | @Callable(i) | |
1683 | 1667 | func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = { | |
1684 | 1668 | let cfg = getPoolConfig() | |
1685 | 1669 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1686 | 1670 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1687 | 1671 | let amAssetId = fromBase58String(amAssetIdStr) | |
1688 | 1672 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1689 | 1673 | let prAssetId = fromBase58String(prAssetIdStr) | |
1690 | 1674 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1691 | 1675 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1692 | 1676 | let poolStatus = cfg[idxPoolStatus] | |
1693 | 1677 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1694 | 1678 | let accAmtAssetBalance = getAccBalance(amAssetIdStr) | |
1695 | 1679 | let accPriceAssetBalance = getAccBalance(prAssetIdStr) | |
1696 | 1680 | let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm) | |
1697 | 1681 | let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm) | |
1698 | 1682 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1699 | 1683 | then zeroBigInt | |
1700 | 1684 | else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
1701 | 1685 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
1702 | 1686 | let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
1703 | 1687 | let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm) | |
1704 | 1688 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1705 | 1689 | let calcLpAmt = estPut._1 | |
1706 | 1690 | let curPriceCalc = estPut._3 | |
1707 | 1691 | let amBalance = estPut._4 | |
1708 | 1692 | let prBalance = estPut._5 | |
1709 | 1693 | let lpEmission = estPut._6 | |
1710 | 1694 | $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)) | |
1711 | 1695 | } | |
1712 | 1696 | ||
1713 | 1697 | ||
1714 | 1698 | ||
1715 | 1699 | @Callable(i) | |
1716 | 1700 | func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = { | |
1717 | 1701 | let cfg = getPoolConfig() | |
1718 | 1702 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1719 | 1703 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1720 | 1704 | let amAssetId = fromBase58String(amAssetIdStr) | |
1721 | 1705 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1722 | 1706 | let prAssetId = fromBase58String(prAssetIdStr) | |
1723 | 1707 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1724 | 1708 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1725 | 1709 | let poolStatus = cfg[idxPoolStatus] | |
1726 | 1710 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1727 | 1711 | let amBalanceRaw = getAccBalance(amAssetIdStr) | |
1728 | 1712 | let prBalanceRaw = getAccBalance(prAssetIdStr) | |
1729 | 1713 | let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm) | |
1730 | 1714 | let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm) | |
1731 | 1715 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1732 | 1716 | then zeroBigInt | |
1733 | 1717 | else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18) | |
1734 | 1718 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
1735 | 1719 | let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
1736 | 1720 | let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm) | |
1737 | 1721 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1738 | 1722 | let calcLpAmt = estPut._1 | |
1739 | 1723 | let curPriceCalc = estPut._3 | |
1740 | 1724 | let amBalance = estPut._4 | |
1741 | 1725 | let prBalance = estPut._5 | |
1742 | 1726 | let lpEmission = estPut._6 | |
1743 | 1727 | $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)) | |
1744 | 1728 | } | |
1745 | 1729 | ||
1746 | 1730 | ||
1747 | 1731 | ||
1748 | 1732 | @Callable(i) | |
1749 | 1733 | func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = { | |
1750 | 1734 | let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this) | |
1751 | 1735 | let outAmAmt = res._1 | |
1752 | 1736 | let outPrAmt = res._2 | |
1753 | 1737 | let amBalance = res._5 | |
1754 | 1738 | let prBalance = res._6 | |
1755 | 1739 | let lpEmission = res._7 | |
1756 | 1740 | let curPrice = res._8 | |
1757 | 1741 | let poolStatus = parseIntValue(res._9) | |
1758 | 1742 | $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)) | |
1759 | 1743 | } | |
1760 | 1744 | ||
1761 | 1745 | ||
1762 | 1746 | @Verifier(tx) | |
1763 | 1747 | func verify () = { | |
1764 | 1748 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
1765 | 1749 | case pk: ByteVector => | |
1766 | 1750 | pk | |
1767 | 1751 | case _: Unit => | |
1768 | 1752 | tx.senderPublicKey | |
1769 | 1753 | case _ => | |
1770 | 1754 | throw("Match error") | |
1771 | 1755 | } | |
1772 | 1756 | match tx { | |
1773 | 1757 | case order: Order => | |
1774 | 1758 | let matcherPub = getMatcherPubOrFail() | |
1775 | - | let $ | |
1776 | - | let orderValid = $ | |
1777 | - | let orderValidInfo = $ | |
1759 | + | let $t06694467013 = validateMatcherOrderAllowed(order) | |
1760 | + | let orderValid = $t06694467013._1 | |
1761 | + | let orderValidInfo = $t06694467013._2 | |
1778 | 1762 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1779 | 1763 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1780 | 1764 | if (if (if (orderValid) | |
1781 | 1765 | then senderValid | |
1782 | 1766 | else false) | |
1783 | 1767 | then matcherValid | |
1784 | 1768 | else false) | |
1785 | 1769 | then true | |
1786 | 1770 | else throwOrderError(orderValid, orderValidInfo, senderValid, matcherValid) | |
1787 | 1771 | case s: SetScriptTransaction => | |
1788 | 1772 | if (sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)) | |
1789 | 1773 | then true | |
1790 | 1774 | else { | |
1791 | 1775 | let newHash = blake2b256(value(s.script)) | |
1792 | 1776 | let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash()))) | |
1793 | 1777 | let currentHash = scriptHash(this) | |
1794 | 1778 | if ((allowedHash == newHash)) | |
1795 | 1779 | then (currentHash != newHash) | |
1796 | 1780 | else false | |
1797 | 1781 | } | |
1798 | 1782 | case _ => | |
1799 | 1783 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1800 | 1784 | } | |
1801 | 1785 | } | |
1802 | 1786 |
github/deemru/w8io/026f985 218.08 ms ◑