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