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