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