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