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