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