tx · BJiAw3Gaebfsxkv7EkNCahETQWcBXA21FtPHktc1c5Rd 3N55kCyUFy8M2ooKRwierKnP7L6viqzScNn: -0.03000000 Waves 2022.11.30 15:11 [2339818] smart account 3N55kCyUFy8M2ooKRwierKnP7L6viqzScNn > SELF 0.00000000 Waves
{ "type": 13, "id": "BJiAw3Gaebfsxkv7EkNCahETQWcBXA21FtPHktc1c5Rd", "fee": 3000000, "feeAssetId": null, "timestamp": 1669810271846, "version": 1, "sender": "3N55kCyUFy8M2ooKRwierKnP7L6viqzScNn", "senderPublicKey": "HpuFV1RhaXZ5gaJNgeLjyAKy3D5q7fMKdNFYYbPDafnb", "proofs": [ "515k84ZzSVz4VZgRUhm5DwiH8dWYis7uqgFBeSVSgiNrML1UHqfP7mvPtU9syJfrjC7SEQvVkj63ocnC4rCrokEe" ], "script": "base64:BgK8JwgCEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgQKAggBEgQKAggBEgQKAggBEgUKAwEIARIAEgQKAgEBEgMKAQESBQoDAQEBEgQKAggIEgASAwoBCBIFCgMBAQESBAoCAQESBAoCCAESBAoCCAgSCwoJCAEBAgECCAQEEgYKBAgIAQgSABIDCgEBEgMKAQESBAoCCAEiCmxQZGVjaW1hbHMiBnNjYWxlOCIMc2NhbGU4QmlnSW50IgdzY2FsZTE4Igp6ZXJvQmlnSW50IgRiaWcwIgRiaWcxIgRiaWcyIgt3YXZlc1N0cmluZyIDU0VQIgpQb29sQWN0aXZlIg9Qb29sUHV0RGlzYWJsZWQiE1Bvb2xNYXRjaGVyRGlzYWJsZWQiDFBvb2xTaHV0ZG93biIOaWR4UG9vbEFkZHJlc3MiDWlkeFBvb2xTdGF0dXMiEGlkeFBvb2xMUEFzc2V0SWQiDWlkeEFtdEFzc2V0SWQiD2lkeFByaWNlQXNzZXRJZCIOaWR4QW10QXNzZXREY20iEGlkeFByaWNlQXNzZXREY20iDmlkeElBbXRBc3NldElkIhBpZHhJUHJpY2VBc3NldElkIg1pZHhMUEFz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eeded", "spentComplexity": 0 } View: original | compacted Prev: BHxSq7pJM8RaVAE9Tem7MZBu8Mo6yLjj9s3zZKqaPVGV Next: Gykwn9MCTqx7LQAbfcqvKZXRRaYAxHbnLJYPT2iayPRB Diff:
Old | New | Differences | |
---|---|---|---|
111 | 111 | ||
112 | 112 | let fee = valueOrElse(getInteger(this, keyFee), feeDefault) | |
113 | 113 | ||
114 | - | let keyKLp = makeString(["%s", "kLp"], SEP) | |
115 | - | ||
116 | - | let keyKLpRefreshedHeight = makeString(["%s", "kLpRefreshedHeight"], SEP) | |
117 | - | ||
118 | - | let keyKLpRefreshDelay = makeString(["%s", "refreshKLpDelay"], SEP) | |
119 | - | ||
120 | - | let kLpRefreshDelayDefault = 30 | |
121 | - | ||
122 | - | let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault) | |
123 | - | ||
124 | 114 | func keyFactoryConfig () = "%s__factoryConfig" | |
125 | 115 | ||
126 | 116 | ||
159 | 149 | func throwErr (msg) = throw(makeString(["lp.ride:", msg], " ")) | |
160 | 150 | ||
161 | 151 | ||
162 | - | func fmtErr (msg) = makeString(["lp.ride:", msg], " ") | |
163 | - | ||
164 | - | ||
165 | 152 | let factoryContract = addressFromStringValue(getStringOrFail(this, fc())) | |
166 | 153 | ||
167 | 154 | let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress)) | |
196 | 183 | ||
197 | 184 | let poolConfigParsed = parsePoolConfig(getPoolConfig()) | |
198 | 185 | ||
199 | - | let $ | |
186 | + | let $t075447710 = poolConfigParsed | |
200 | 187 | ||
201 | - | let cfgPoolAddress = $ | |
188 | + | let cfgPoolAddress = $t075447710._1 | |
202 | 189 | ||
203 | - | let cfgPoolStatus = $ | |
190 | + | let cfgPoolStatus = $t075447710._2 | |
204 | 191 | ||
205 | - | let cfgLpAssetId = $ | |
192 | + | let cfgLpAssetId = $t075447710._3 | |
206 | 193 | ||
207 | - | let cfgAmountAssetId = $ | |
194 | + | let cfgAmountAssetId = $t075447710._4 | |
208 | 195 | ||
209 | - | let cfgPriceAssetId = $ | |
196 | + | let cfgPriceAssetId = $t075447710._5 | |
210 | 197 | ||
211 | - | let cfgAmountAssetDecimals = $ | |
198 | + | let cfgAmountAssetDecimals = $t075447710._6 | |
212 | 199 | ||
213 | - | let cfgPriceAssetDecimals = $ | |
200 | + | let cfgPriceAssetDecimals = $t075447710._7 | |
214 | 201 | ||
215 | 202 | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
216 | 203 | ||
373 | 360 | } | |
374 | 361 | ||
375 | 362 | ||
376 | - | func calcKLp (amountBalance,priceBalance,lpEmission) = { | |
377 | - | let updatedKLp = fraction(pow((amountBalance * priceBalance), 0, toBigInt(5), 1, 0, DOWN), scale18, lpEmission) | |
378 | - | updatedKLp | |
379 | - | } | |
380 | - | ||
381 | - | ||
382 | - | func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
383 | - | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
384 | - | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
385 | - | let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta) | |
386 | - | let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
387 | - | let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))] | |
388 | - | $Tuple2(actions, updatedKLp) | |
389 | - | } | |
390 | - | ||
391 | - | ||
392 | 363 | func validateMatcherOrderAllowed (order) = { | |
393 | - | let amountAssetAmount = order.amount | |
394 | - | let priceAssetAmount = fraction(order.amount, order.price, scale8) | |
395 | - | let $t01955919771 = if ((order.orderType == Buy)) | |
396 | - | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
397 | - | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
398 | - | let amountAssetBalanceDelta = $t01955919771._1 | |
399 | - | let priceAssetBalanceDelta = $t01955919771._2 | |
364 | + | let cfg = getPoolConfig() | |
365 | + | let amtAssetId = cfg[idxAmtAssetId] | |
366 | + | let priceAssetId = cfg[idxPriceAssetId] | |
367 | + | let poolStatus = parseIntValue(cfg[idxPoolStatus]) | |
368 | + | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
369 | + | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
370 | + | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
371 | + | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
372 | + | let curPriceX18 = if ((order.orderType == Buy)) | |
373 | + | then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance) | |
374 | + | else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance) | |
375 | + | let curPrice = fromX18(curPriceX18, scale8) | |
400 | 376 | if (if (if (isGlobalShutdown()) | |
401 | 377 | then true | |
402 | - | else ( | |
378 | + | else (poolStatus == PoolMatcherDisabled)) | |
403 | 379 | then true | |
404 | - | else ( | |
380 | + | else (poolStatus == PoolShutdown)) | |
405 | 381 | then throw("Exchange operations disabled") | |
406 | - | else if (if ((order.assetPair.amountAsset != cfgAmountAssetId)) | |
407 | - | then true | |
408 | - | else (order.assetPair.priceAsset != cfgPriceAssetId)) | |
409 | - | then throw("Wrong order assets.") | |
410 | - | else { | |
411 | - | let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp")) | |
412 | - | let $t02024220342 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
413 | - | let unusedActions = $t02024220342._1 | |
414 | - | let kLpNew = $t02024220342._2 | |
415 | - | let isOrderValid = (kLpNew > kLp) | |
416 | - | isOrderValid | |
417 | - | } | |
382 | + | else { | |
383 | + | let orderAmtAsset = order.assetPair.amountAsset | |
384 | + | let orderAmtAssetStr = if ((orderAmtAsset == unit)) | |
385 | + | then "WAVES" | |
386 | + | else toBase58String(value(orderAmtAsset)) | |
387 | + | let orderPriceAsset = order.assetPair.priceAsset | |
388 | + | let orderPriceAssetStr = if ((orderPriceAsset == unit)) | |
389 | + | then "WAVES" | |
390 | + | else toBase58String(value(orderPriceAsset)) | |
391 | + | if (if ((orderAmtAssetStr != amtAssetId)) | |
392 | + | then true | |
393 | + | else (orderPriceAssetStr != priceAssetId)) | |
394 | + | then throw("Wrong order assets.") | |
395 | + | else { | |
396 | + | let orderPrice = order.price | |
397 | + | let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm) | |
398 | + | let castedOrderPrice = toScale(orderPrice, scale8, priceDcm) | |
399 | + | let isOrderPriceValid = if ((order.orderType == Buy)) | |
400 | + | then (curPrice >= castedOrderPrice) | |
401 | + | else (castedOrderPrice >= curPrice) | |
402 | + | true | |
403 | + | } | |
404 | + | } | |
418 | 405 | } | |
419 | 406 | ||
420 | 407 | ||
487 | 474 | else if ((paymentAssetId == cfgPriceAssetId)) | |
488 | 475 | then false | |
489 | 476 | else throwErr("invalid asset") | |
490 | - | let $ | |
477 | + | let $t02257122864 = if (isEval) | |
491 | 478 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
492 | 479 | else if (paymentInAmountAsset) | |
493 | 480 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
494 | 481 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
495 | - | let amountBalanceOld = $ | |
496 | - | let priceBalanceOld = $ | |
497 | - | let $ | |
482 | + | let amountBalanceOld = $t02257122864._1 | |
483 | + | let priceBalanceOld = $t02257122864._2 | |
484 | + | let $t02286823017 = if (paymentInAmountAsset) | |
498 | 485 | then $Tuple2(paymentAmountRaw, 0) | |
499 | 486 | else $Tuple2(0, paymentAmountRaw) | |
500 | - | let amountAssetAmountRaw = $ | |
501 | - | let priceAssetAmountRaw = $ | |
487 | + | let amountAssetAmountRaw = $t02286823017._1 | |
488 | + | let priceAssetAmountRaw = $t02286823017._2 | |
502 | 489 | let amountAssetAmount = takeFee(amountAssetAmountRaw)._1 | |
503 | 490 | let priceAssetAmount = takeFee(priceAssetAmountRaw)._1 | |
504 | - | let $ | |
505 | - | let paymentAmount = $ | |
506 | - | let feeAmount = $ | |
491 | + | let $t02313923198 = takeFee(paymentAmountRaw) | |
492 | + | let paymentAmount = $t02313923198._1 | |
493 | + | let feeAmount = $t02313923198._2 | |
507 | 494 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
508 | 495 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
509 | 496 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
526 | 513 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
527 | 514 | let priceOld = fromX18(priceOldX18, scale8) | |
528 | 515 | let loss = { | |
529 | - | let $ | |
516 | + | let $t02467524842 = if (paymentInAmountAsset) | |
530 | 517 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
531 | 518 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
532 | - | let amount = $ | |
533 | - | let balance = $ | |
519 | + | let amount = $t02467524842._1 | |
520 | + | let balance = $t02467524842._2 | |
534 | 521 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
535 | 522 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
536 | 523 | } | |
537 | - | $ | |
524 | + | $Tuple4(issueAmount, commonState, feeAmount, loss) | |
538 | 525 | } | |
539 | 526 | else throw("Strict value is not equal to itself.") | |
540 | 527 | } | |
564 | 551 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
565 | 552 | let redeemedBigInt = toBigInt(paymentAmount) | |
566 | 553 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
567 | - | let $ | |
568 | - | let totalAmount = $ | |
569 | - | let feeAmount = $ | |
570 | - | let $ | |
554 | + | let $t02642226472 = takeFee(amountRaw) | |
555 | + | let totalAmount = $t02642226472._1 | |
556 | + | let feeAmount = $t02642226472._2 | |
557 | + | let $t02647626702 = if (outInAmountAsset) | |
571 | 558 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
572 | 559 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
573 | - | let outAmAmount = $ | |
574 | - | let outPrAmount = $ | |
575 | - | let amBalanceNew = $ | |
576 | - | let prBalanceNew = $ | |
560 | + | let outAmAmount = $t02647626702._1 | |
561 | + | let outPrAmount = $t02647626702._2 | |
562 | + | let amBalanceNew = $t02647626702._3 | |
563 | + | let prBalanceNew = $t02647626702._4 | |
577 | 564 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
578 | 565 | let priceNew = fromX18(priceNewX18, scale8) | |
579 | 566 | let commonState = if (isEval) | |
585 | 572 | let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2) | |
586 | 573 | fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset) | |
587 | 574 | } | |
588 | - | $ | |
575 | + | $Tuple4(totalAmount, commonState, feeAmount, loss) | |
589 | 576 | } | |
590 | 577 | else throw("Strict value is not equal to itself.") | |
591 | 578 | } | |
714 | 701 | else throw("Strict value is not equal to itself.") | |
715 | 702 | } | |
716 | 703 | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
717 | - | let $t03113031195 = refreshKLpInternal(0, 0, 0) | |
718 | - | let refreshKLpActions = $t03113031195._1 | |
719 | - | let updatedKLp = $t03113031195._2 | |
720 | - | ((state ++ lpTransfer) ++ refreshKLpActions) | |
704 | + | (state ++ lpTransfer) | |
721 | 705 | } | |
722 | 706 | else throw("Strict value is not equal to itself.") | |
723 | 707 | } | |
735 | 719 | then throw("Invalid value passed") | |
736 | 720 | else { | |
737 | 721 | let estPut = commonPut(i, maxSlippage, false) | |
738 | - | let state = estPut._9 | |
739 | - | let $t03148131546 = refreshKLpInternal(0, 0, 0) | |
740 | - | let refreshKLpActions = $t03148131546._1 | |
741 | - | let updatedKLp = $t03148131546._2 | |
742 | - | (state ++ refreshKLpActions) | |
722 | + | estPut._9 | |
743 | 723 | } | |
744 | 724 | ||
745 | 725 | ||
773 | 753 | let paymentAmountRaw = payment.amount | |
774 | 754 | let userAddress = i.caller | |
775 | 755 | let txId = i.transactionId | |
776 | - | let $t03232232474 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
777 | - | if (($t03232232474 == $t03232232474)) | |
756 | + | let $t03160931736 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
757 | + | let emitAmountEstimated = $t03160931736._1 | |
758 | + | let commonState = $t03160931736._2 | |
759 | + | let feeAmount = $t03160931736._3 | |
760 | + | let bonus = $t03160931736._4 | |
761 | + | let emitAmount = if (if ((minOutAmount > 0)) | |
762 | + | then (minOutAmount > emitAmountEstimated) | |
763 | + | else false) | |
764 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
765 | + | else emitAmountEstimated | |
766 | + | let emitInv = emit(emitAmount) | |
767 | + | if ((emitInv == emitInv)) | |
778 | 768 | then { | |
779 | - | let paymentInAmountAsset = $t03232232474._5 | |
780 | - | let bonus = $t03232232474._4 | |
781 | - | let feeAmount = $t03232232474._3 | |
782 | - | let commonState = $t03232232474._2 | |
783 | - | let emitAmountEstimated = $t03232232474._1 | |
784 | - | let emitAmount = if (if ((minOutAmount > 0)) | |
785 | - | then (minOutAmount > emitAmountEstimated) | |
786 | - | else false) | |
787 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
788 | - | else emitAmountEstimated | |
789 | - | let emitInv = emit(emitAmount) | |
790 | - | if ((emitInv == emitInv)) | |
769 | + | let lpTransfer = if (autoStake) | |
791 | 770 | then { | |
792 | - | let lpTransfer = if (autoStake) | |
793 | - | then { | |
794 | - | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
795 | - | if ((stakeInv == stakeInv)) | |
796 | - | then nil | |
797 | - | else throw("Strict value is not equal to itself.") | |
798 | - | } | |
799 | - | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
800 | - | let sendFee = if ((feeAmount > 0)) | |
801 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
802 | - | else nil | |
803 | - | let $t03306033257 = if ((this == feeCollectorAddress)) | |
804 | - | then $Tuple2(0, 0) | |
805 | - | else if (paymentInAmountAsset) | |
806 | - | then $Tuple2(-(feeAmount), 0) | |
807 | - | else $Tuple2(0, -(feeAmount)) | |
808 | - | let amountAssetBalanceDelta = $t03306033257._1 | |
809 | - | let priceAssetBalanceDelta = $t03306033257._2 | |
810 | - | let $t03326033368 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
811 | - | let refreshKLpActions = $t03326033368._1 | |
812 | - | let updatedKLp = $t03326033368._2 | |
813 | - | $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
771 | + | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
772 | + | if ((stakeInv == stakeInv)) | |
773 | + | then nil | |
774 | + | else throw("Strict value is not equal to itself.") | |
814 | 775 | } | |
815 | - | else throw("Strict value is not equal to itself.") | |
776 | + | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
777 | + | let sendFee = if ((feeAmount > 0)) | |
778 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
779 | + | else nil | |
780 | + | $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount) | |
816 | 781 | } | |
817 | 782 | else throw("Strict value is not equal to itself.") | |
818 | 783 | } | |
823 | 788 | ||
824 | 789 | @Callable(i) | |
825 | 790 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
826 | - | let $t03356133718 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
827 | - | let emitAmountEstimated = $t03356133718._1 | |
828 | - | let commonState = $t03356133718._2 | |
829 | - | let feeAmount = $t03356133718._3 | |
830 | - | let bonus = $t03356133718._4 | |
831 | - | let paymentInAmountAsset = $t03356133718._5 | |
791 | + | let $t03246532600 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
792 | + | let emitAmountEstimated = $t03246532600._1 | |
793 | + | let commonState = $t03246532600._2 | |
794 | + | let feeAmount = $t03246532600._3 | |
795 | + | let bonus = $t03246532600._4 | |
832 | 796 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
833 | 797 | } | |
834 | 798 | ||
862 | 826 | let paymentAmount = payment.amount | |
863 | 827 | let userAddress = i.caller | |
864 | 828 | let txId = i.transactionId | |
865 | - | let $t03452334676 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
866 | - | if (($t03452334676 == $t03452334676)) | |
829 | + | let $t03340533537 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
830 | + | let amountEstimated = $t03340533537._1 | |
831 | + | let commonState = $t03340533537._2 | |
832 | + | let feeAmount = $t03340533537._3 | |
833 | + | let bonus = $t03340533537._4 | |
834 | + | let amount = if (if ((minOutAmount > 0)) | |
835 | + | then (minOutAmount > amountEstimated) | |
836 | + | else false) | |
837 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
838 | + | else amountEstimated | |
839 | + | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
840 | + | if ((burnInv == burnInv)) | |
867 | 841 | then { | |
868 | - | let outInAmountAsset = $t03452334676._5 | |
869 | - | let bonus = $t03452334676._4 | |
870 | - | let feeAmount = $t03452334676._3 | |
871 | - | let commonState = $t03452334676._2 | |
872 | - | let amountEstimated = $t03452334676._1 | |
873 | - | let amount = if (if ((minOutAmount > 0)) | |
874 | - | then (minOutAmount > amountEstimated) | |
875 | - | else false) | |
876 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
877 | - | else amountEstimated | |
878 | - | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
879 | - | if ((burnInv == burnInv)) | |
880 | - | then { | |
881 | - | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
882 | - | let sendFee = if ((feeAmount > 0)) | |
883 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
884 | - | else nil | |
885 | - | let $t03517635423 = { | |
886 | - | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
887 | - | then 0 | |
888 | - | else feeAmount | |
889 | - | if (outInAmountAsset) | |
890 | - | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
891 | - | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
892 | - | } | |
893 | - | let amountAssetBalanceDelta = $t03517635423._1 | |
894 | - | let priceAssetBalanceDelta = $t03517635423._2 | |
895 | - | let $t03542635534 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
896 | - | let refreshKLpActions = $t03542635534._1 | |
897 | - | let updatedKLp = $t03542635534._2 | |
898 | - | $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
899 | - | } | |
900 | - | else throw("Strict value is not equal to itself.") | |
842 | + | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
843 | + | let sendFee = if ((feeAmount > 0)) | |
844 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
845 | + | else nil | |
846 | + | $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount) | |
901 | 847 | } | |
902 | 848 | else throw("Strict value is not equal to itself.") | |
903 | 849 | } | |
908 | 854 | ||
909 | 855 | @Callable(i) | |
910 | 856 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
911 | - | let $t03571835874 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
912 | - | let amountEstimated = $t03571835874._1 | |
913 | - | let commonState = $t03571835874._2 | |
914 | - | let feeAmount = $t03571835874._3 | |
915 | - | let bonus = $t03571835874._4 | |
916 | - | let outInAmountAsset = $t03571835874._5 | |
857 | + | let $t03417234310 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
858 | + | let amountEstimated = $t03417234310._1 | |
859 | + | let commonState = $t03417234310._2 | |
860 | + | let feeAmount = $t03417234310._3 | |
861 | + | let bonus = $t03417234310._4 | |
917 | 862 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
918 | 863 | } | |
919 | 864 | ||
947 | 892 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
948 | 893 | if ((unstakeInv == unstakeInv)) | |
949 | 894 | then { | |
950 | - | let $t03669936850 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
951 | - | if (($t03669936850 == $t03669936850)) | |
895 | + | let $t03513535265 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
896 | + | let amountEstimated = $t03513535265._1 | |
897 | + | let commonState = $t03513535265._2 | |
898 | + | let feeAmount = $t03513535265._3 | |
899 | + | let bonus = $t03513535265._4 | |
900 | + | let amount = if (if ((minOutAmount > 0)) | |
901 | + | then (minOutAmount > amountEstimated) | |
902 | + | else false) | |
903 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
904 | + | else amountEstimated | |
905 | + | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
906 | + | if ((burnInv == burnInv)) | |
952 | 907 | then { | |
953 | - | let outInAmountAsset = $t03669936850._5 | |
954 | - | let bonus = $t03669936850._4 | |
955 | - | let feeAmount = $t03669936850._3 | |
956 | - | let commonState = $t03669936850._2 | |
957 | - | let amountEstimated = $t03669936850._1 | |
958 | - | let amount = if (if ((minOutAmount > 0)) | |
959 | - | then (minOutAmount > amountEstimated) | |
960 | - | else false) | |
961 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
962 | - | else amountEstimated | |
963 | - | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
964 | - | if ((burnInv == burnInv)) | |
965 | - | then { | |
966 | - | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
967 | - | let sendFee = if ((feeAmount > 0)) | |
968 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
969 | - | else nil | |
970 | - | let $t03734537592 = { | |
971 | - | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
972 | - | then 0 | |
973 | - | else feeAmount | |
974 | - | if (outInAmountAsset) | |
975 | - | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
976 | - | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
977 | - | } | |
978 | - | let amountAssetBalanceDelta = $t03734537592._1 | |
979 | - | let priceAssetBalanceDelta = $t03734537592._2 | |
980 | - | let $t03759537703 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
981 | - | let refreshKLpActions = $t03759537703._1 | |
982 | - | let updatedKLp = $t03759537703._2 | |
983 | - | $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
984 | - | } | |
985 | - | else throw("Strict value is not equal to itself.") | |
908 | + | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
909 | + | let sendFee = if ((feeAmount > 0)) | |
910 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
911 | + | else nil | |
912 | + | $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount) | |
986 | 913 | } | |
987 | 914 | else throw("Strict value is not equal to itself.") | |
988 | 915 | } | |
1003 | 930 | let state = res._5 | |
1004 | 931 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1005 | 932 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1006 | - | then { | |
1007 | - | let $t03849538577 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1008 | - | let refreshKLpActions = $t03849538577._1 | |
1009 | - | let updatedKLp = $t03849538577._2 | |
1010 | - | (state ++ refreshKLpActions) | |
1011 | - | } | |
933 | + | then state | |
1012 | 934 | else throw("Strict value is not equal to itself.") | |
1013 | 935 | } | |
1014 | 936 | ||
1029 | 951 | else { | |
1030 | 952 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1031 | 953 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1032 | - | then { | |
1033 | - | let $t03937339454 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1034 | - | let refreshKLpActions = $t03937339454._1 | |
1035 | - | let updatedKLp = $t03937339454._2 | |
1036 | - | (state ++ refreshKLpActions) | |
1037 | - | } | |
954 | + | then state | |
1038 | 955 | else throw("Strict value is not equal to itself.") | |
1039 | 956 | } | |
1040 | 957 | } | |
1054 | 971 | if ((unstakeInv == unstakeInv)) | |
1055 | 972 | then { | |
1056 | 973 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1057 | - | let outAmAmt = res._1 | |
1058 | - | let outPrAmt = res._2 | |
1059 | 974 | let poolStatus = parseIntValue(res._9) | |
1060 | 975 | let state = res._10 | |
1061 | 976 | let checkPoolStatus = if (if (isGlobalShutdown()) | |
1067 | 982 | then { | |
1068 | 983 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1069 | 984 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1070 | - | then { | |
1071 | - | let $t04042740508 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1072 | - | let refreshKLpActions = $t04042740508._1 | |
1073 | - | let updatedKLp = $t04042740508._2 | |
1074 | - | (state ++ refreshKLpActions) | |
1075 | - | } | |
985 | + | then state | |
1076 | 986 | else throw("Strict value is not equal to itself.") | |
1077 | 987 | } | |
1078 | 988 | else throw("Strict value is not equal to itself.") | |
1112 | 1022 | then { | |
1113 | 1023 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1114 | 1024 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1115 | - | then { | |
1116 | - | let $t04164841729 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1117 | - | let refreshKLpActions = $t04164841729._1 | |
1118 | - | let updatedKLp = $t04164841729._2 | |
1119 | - | (state ++ refreshKLpActions) | |
1120 | - | } | |
1025 | + | then state | |
1121 | 1026 | else throw("Strict value is not equal to itself.") | |
1122 | 1027 | } | |
1123 | 1028 | else throw("Strict value is not equal to itself.") | |
1133 | 1038 | func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract))) | |
1134 | 1039 | then throw("permissions denied") | |
1135 | 1040 | else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success") | |
1136 | - | ||
1137 | - | ||
1138 | - | ||
1139 | - | @Callable(i) | |
1140 | - | func refreshKLp () = { | |
1141 | - | let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0) | |
1142 | - | let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay)) | |
1143 | - | then unit | |
1144 | - | else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1145 | - | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1146 | - | then { | |
1147 | - | let $t04271742772 = refreshKLpInternal(0, 0, 0) | |
1148 | - | let actions = $t04271742772._1 | |
1149 | - | let updatedKLp = $t04271742772._2 | |
1150 | - | $Tuple2(actions, toString(updatedKLp)) | |
1151 | - | } | |
1152 | - | else throw("Strict value is not equal to itself.") | |
1153 | - | } | |
1154 | 1041 | ||
1155 | 1042 | ||
1156 | 1043 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let lPdecimals = 8 | |
5 | 5 | ||
6 | 6 | let scale8 = 100000000 | |
7 | 7 | ||
8 | 8 | let scale8BigInt = toBigInt(100000000) | |
9 | 9 | ||
10 | 10 | let scale18 = toBigInt(1000000000000000000) | |
11 | 11 | ||
12 | 12 | let zeroBigInt = toBigInt(0) | |
13 | 13 | ||
14 | 14 | let big0 = toBigInt(0) | |
15 | 15 | ||
16 | 16 | let big1 = toBigInt(1) | |
17 | 17 | ||
18 | 18 | let big2 = toBigInt(2) | |
19 | 19 | ||
20 | 20 | let wavesString = "WAVES" | |
21 | 21 | ||
22 | 22 | let SEP = "__" | |
23 | 23 | ||
24 | 24 | let PoolActive = 1 | |
25 | 25 | ||
26 | 26 | let PoolPutDisabled = 2 | |
27 | 27 | ||
28 | 28 | let PoolMatcherDisabled = 3 | |
29 | 29 | ||
30 | 30 | let PoolShutdown = 4 | |
31 | 31 | ||
32 | 32 | let idxPoolAddress = 1 | |
33 | 33 | ||
34 | 34 | let idxPoolStatus = 2 | |
35 | 35 | ||
36 | 36 | let idxPoolLPAssetId = 3 | |
37 | 37 | ||
38 | 38 | let idxAmtAssetId = 4 | |
39 | 39 | ||
40 | 40 | let idxPriceAssetId = 5 | |
41 | 41 | ||
42 | 42 | let idxAmtAssetDcm = 6 | |
43 | 43 | ||
44 | 44 | let idxPriceAssetDcm = 7 | |
45 | 45 | ||
46 | 46 | let idxIAmtAssetId = 8 | |
47 | 47 | ||
48 | 48 | let idxIPriceAssetId = 9 | |
49 | 49 | ||
50 | 50 | let idxLPAssetDcm = 10 | |
51 | 51 | ||
52 | 52 | let idxPoolAmtAssetAmt = 1 | |
53 | 53 | ||
54 | 54 | let idxPoolPriceAssetAmt = 2 | |
55 | 55 | ||
56 | 56 | let idxPoolLPAssetAmt = 3 | |
57 | 57 | ||
58 | 58 | let idxFactoryStakingContract = 1 | |
59 | 59 | ||
60 | 60 | let idxFactorySlippageContract = 7 | |
61 | 61 | ||
62 | 62 | func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult)) | |
63 | 63 | ||
64 | 64 | ||
65 | 65 | func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18)) | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
69 | 69 | ||
70 | 70 | ||
71 | 71 | func abs (val) = if ((0 > val)) | |
72 | 72 | then -(val) | |
73 | 73 | else val | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | func absBigInt (val) = if ((zeroBigInt > val)) | |
77 | 77 | then -(val) | |
78 | 78 | else val | |
79 | 79 | ||
80 | 80 | ||
81 | 81 | func fc () = "%s__factoryContract" | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | func mpk () = "%s__managerPublicKey" | |
85 | 85 | ||
86 | 86 | ||
87 | 87 | func pmpk () = "%s__pendingManagerPublicKey" | |
88 | 88 | ||
89 | 89 | ||
90 | 90 | func pl () = "%s%s__price__last" | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | func ph (h,timestamp) = makeString(["%s%s%d%d__price__history", toString(h), toString(timestamp)], SEP) | |
94 | 94 | ||
95 | 95 | ||
96 | 96 | func pau (userAddress,txId) = ((("%s%s%s__P__" + userAddress) + "__") + txId) | |
97 | 97 | ||
98 | 98 | ||
99 | 99 | func gau (userAddress,txId) = ((("%s%s%s__G__" + userAddress) + "__") + txId) | |
100 | 100 | ||
101 | 101 | ||
102 | 102 | func aa () = "%s__amountAsset" | |
103 | 103 | ||
104 | 104 | ||
105 | 105 | func pa () = "%s__priceAsset" | |
106 | 106 | ||
107 | 107 | ||
108 | 108 | let keyFee = "%s__fee" | |
109 | 109 | ||
110 | 110 | let feeDefault = fraction(10, scale8, 10000) | |
111 | 111 | ||
112 | 112 | let fee = valueOrElse(getInteger(this, keyFee), feeDefault) | |
113 | 113 | ||
114 | - | let keyKLp = makeString(["%s", "kLp"], SEP) | |
115 | - | ||
116 | - | let keyKLpRefreshedHeight = makeString(["%s", "kLpRefreshedHeight"], SEP) | |
117 | - | ||
118 | - | let keyKLpRefreshDelay = makeString(["%s", "refreshKLpDelay"], SEP) | |
119 | - | ||
120 | - | let kLpRefreshDelayDefault = 30 | |
121 | - | ||
122 | - | let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault) | |
123 | - | ||
124 | 114 | func keyFactoryConfig () = "%s__factoryConfig" | |
125 | 115 | ||
126 | 116 | ||
127 | 117 | func keyMatcherPub () = "%s%s__matcher__publicKey" | |
128 | 118 | ||
129 | 119 | ||
130 | 120 | func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset") | |
131 | 121 | ||
132 | 122 | ||
133 | 123 | func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config") | |
134 | 124 | ||
135 | 125 | ||
136 | 126 | func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr) | |
137 | 127 | ||
138 | 128 | ||
139 | 129 | func keyAllPoolsShutdown () = "%s__shutdown" | |
140 | 130 | ||
141 | 131 | ||
142 | 132 | func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress) | |
143 | 133 | ||
144 | 134 | ||
145 | 135 | func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash" | |
146 | 136 | ||
147 | 137 | ||
148 | 138 | let keyFeeCollectorAddress = "%s__feeCollectorAddress" | |
149 | 139 | ||
150 | 140 | func throwOrderError (orderValid,senderValid,matcherValid) = throw(((((("order validation failed: orderValid=" + toString(orderValid)) + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid))) | |
151 | 141 | ||
152 | 142 | ||
153 | 143 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
154 | 144 | ||
155 | 145 | ||
156 | 146 | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
157 | 147 | ||
158 | 148 | ||
159 | 149 | func throwErr (msg) = throw(makeString(["lp.ride:", msg], " ")) | |
160 | 150 | ||
161 | 151 | ||
162 | - | func fmtErr (msg) = makeString(["lp.ride:", msg], " ") | |
163 | - | ||
164 | - | ||
165 | 152 | let factoryContract = addressFromStringValue(getStringOrFail(this, fc())) | |
166 | 153 | ||
167 | 154 | let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress)) | |
168 | 155 | ||
169 | 156 | func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false) | |
170 | 157 | ||
171 | 158 | ||
172 | 159 | func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub())) | |
173 | 160 | ||
174 | 161 | ||
175 | 162 | func getPoolConfig () = { | |
176 | 163 | let amtAsset = getStringOrFail(this, aa()) | |
177 | 164 | let priceAsset = getStringOrFail(this, pa()) | |
178 | 165 | let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset)) | |
179 | 166 | let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset)) | |
180 | 167 | split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP) | |
181 | 168 | } | |
182 | 169 | ||
183 | 170 | ||
184 | 171 | func parseAssetId (input) = if ((input == wavesString)) | |
185 | 172 | then unit | |
186 | 173 | else fromBase58String(input) | |
187 | 174 | ||
188 | 175 | ||
189 | 176 | func assetIdToString (input) = if ((input == unit)) | |
190 | 177 | then wavesString | |
191 | 178 | else toBase58String(value(input)) | |
192 | 179 | ||
193 | 180 | ||
194 | 181 | 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])) | |
195 | 182 | ||
196 | 183 | ||
197 | 184 | let poolConfigParsed = parsePoolConfig(getPoolConfig()) | |
198 | 185 | ||
199 | - | let $ | |
186 | + | let $t075447710 = poolConfigParsed | |
200 | 187 | ||
201 | - | let cfgPoolAddress = $ | |
188 | + | let cfgPoolAddress = $t075447710._1 | |
202 | 189 | ||
203 | - | let cfgPoolStatus = $ | |
190 | + | let cfgPoolStatus = $t075447710._2 | |
204 | 191 | ||
205 | - | let cfgLpAssetId = $ | |
192 | + | let cfgLpAssetId = $t075447710._3 | |
206 | 193 | ||
207 | - | let cfgAmountAssetId = $ | |
194 | + | let cfgAmountAssetId = $t075447710._4 | |
208 | 195 | ||
209 | - | let cfgPriceAssetId = $ | |
196 | + | let cfgPriceAssetId = $t075447710._5 | |
210 | 197 | ||
211 | - | let cfgAmountAssetDecimals = $ | |
198 | + | let cfgAmountAssetDecimals = $t075447710._6 | |
212 | 199 | ||
213 | - | let cfgPriceAssetDecimals = $ | |
200 | + | let cfgPriceAssetDecimals = $t075447710._7 | |
214 | 201 | ||
215 | 202 | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
216 | 203 | ||
217 | 204 | ||
218 | 205 | let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address") | |
219 | 206 | ||
220 | 207 | let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address") | |
221 | 208 | ||
222 | 209 | 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) | |
223 | 210 | ||
224 | 211 | ||
225 | 212 | 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) | |
226 | 213 | ||
227 | 214 | ||
228 | 215 | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
229 | 216 | then wavesBalance(this).available | |
230 | 217 | else assetBalance(this, fromBase58String(assetId)) | |
231 | 218 | ||
232 | 219 | ||
233 | 220 | func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
234 | 221 | ||
235 | 222 | ||
236 | 223 | func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
237 | 224 | let amtAssetAmtX18 = toX18(amAmt, amAssetDcm) | |
238 | 225 | let priceAssetAmtX18 = toX18(prAmt, prAssetDcm) | |
239 | 226 | calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
240 | 227 | } | |
241 | 228 | ||
242 | 229 | ||
243 | 230 | func calcPrices (amAmt,prAmt,lpAmt) = { | |
244 | 231 | let cfg = getPoolConfig() | |
245 | 232 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
246 | 233 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
247 | 234 | let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt) | |
248 | 235 | let amAmtX18 = toX18(amAmt, amtAssetDcm) | |
249 | 236 | let prAmtX18 = toX18(prAmt, priceAssetDcm) | |
250 | 237 | let lpAmtX18 = toX18(lpAmt, scale8) | |
251 | 238 | let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18) | |
252 | 239 | let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18) | |
253 | 240 | [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18] | |
254 | 241 | } | |
255 | 242 | ||
256 | 243 | ||
257 | 244 | func calculatePrices (amAmt,prAmt,lpAmt) = { | |
258 | 245 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
259 | 246 | [fromX18(prices[0], scale8), fromX18(prices[1], scale8), fromX18(prices[2], scale8)] | |
260 | 247 | } | |
261 | 248 | ||
262 | 249 | ||
263 | 250 | func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
264 | 251 | let cfg = getPoolConfig() | |
265 | 252 | let lpAssetId = cfg[idxPoolLPAssetId] | |
266 | 253 | let amAssetId = cfg[idxAmtAssetId] | |
267 | 254 | let prAssetId = cfg[idxPriceAssetId] | |
268 | 255 | let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
269 | 256 | let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
270 | 257 | let poolStatus = cfg[idxPoolStatus] | |
271 | 258 | let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity | |
272 | 259 | if ((lpAssetId != pmtAssetId)) | |
273 | 260 | then throw("Invalid asset passed.") | |
274 | 261 | else { | |
275 | 262 | let amBalance = getAccBalance(amAssetId) | |
276 | 263 | let amBalanceX18 = toX18(amBalance, amAssetDcm) | |
277 | 264 | let prBalance = getAccBalance(prAssetId) | |
278 | 265 | let prBalanceX18 = toX18(prBalance, prAssetDcm) | |
279 | 266 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
280 | 267 | let curPrice = fromX18(curPriceX18, scale8) | |
281 | 268 | let pmtLpAmtX18 = toX18(pmtLpAmt, scale8) | |
282 | 269 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
283 | 270 | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
284 | 271 | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
285 | 272 | let outAmAmt = fromX18(outAmAmtX18, amAssetDcm) | |
286 | 273 | let outPrAmt = fromX18(outPrAmtX18, prAssetDcm) | |
287 | 274 | let state = if ((txId58 == "")) | |
288 | 275 | then nil | |
289 | 276 | else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
290 | 277 | then unit | |
291 | 278 | else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES")) | |
292 | 279 | then unit | |
293 | 280 | 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)] | |
294 | 281 | $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state) | |
295 | 282 | } | |
296 | 283 | } | |
297 | 284 | ||
298 | 285 | ||
299 | 286 | func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = { | |
300 | 287 | let cfg = getPoolConfig() | |
301 | 288 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
302 | 289 | let amAssetIdStr = cfg[idxAmtAssetId] | |
303 | 290 | let prAssetIdStr = cfg[idxPriceAssetId] | |
304 | 291 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
305 | 292 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
306 | 293 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
307 | 294 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
308 | 295 | let poolStatus = cfg[idxPoolStatus] | |
309 | 296 | let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
310 | 297 | let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES"))) | |
311 | 298 | let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES"))) | |
312 | 299 | if (if ((amAssetIdStr != inAmAssetIdStr)) | |
313 | 300 | then true | |
314 | 301 | else (prAssetIdStr != inPrAssetIdStr)) | |
315 | 302 | then throw("Invalid amt or price asset passed.") | |
316 | 303 | else { | |
317 | 304 | let amBalance = if (isEvaluate) | |
318 | 305 | then getAccBalance(amAssetIdStr) | |
319 | 306 | else (getAccBalance(amAssetIdStr) - inAmAssetAmt) | |
320 | 307 | let prBalance = if (isEvaluate) | |
321 | 308 | then getAccBalance(prAssetIdStr) | |
322 | 309 | else (getAccBalance(prAssetIdStr) - inPrAssetAmt) | |
323 | 310 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
324 | 311 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
325 | 312 | let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18) | |
326 | 313 | let amBalanceX18 = toX18(amBalance, amtAssetDcm) | |
327 | 314 | let prBalanceX18 = toX18(prBalance, priceAssetDcm) | |
328 | 315 | let res = if ((lpEmission == 0)) | |
329 | 316 | then { | |
330 | 317 | let curPriceX18 = zeroBigInt | |
331 | 318 | let slippageX18 = zeroBigInt | |
332 | 319 | let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN) | |
333 | 320 | $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
334 | 321 | } | |
335 | 322 | else { | |
336 | 323 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
337 | 324 | let slippageX18 = fraction(absBigInt((curPriceX18 - userPriceX18)), scale18, curPriceX18) | |
338 | 325 | let slippageToleranceX18 = toX18(slippageTolerance, scale8) | |
339 | 326 | if (if ((curPriceX18 != zeroBigInt)) | |
340 | 327 | then (slippageX18 > slippageToleranceX18) | |
341 | 328 | else false) | |
342 | 329 | then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18))) | |
343 | 330 | else { | |
344 | 331 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
345 | 332 | let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
346 | 333 | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
347 | 334 | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
348 | 335 | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
349 | 336 | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
350 | 337 | let expAmtAssetAmtX18 = expectedAmts._1 | |
351 | 338 | let expPriceAssetAmtX18 = expectedAmts._2 | |
352 | 339 | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18) | |
353 | 340 | $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18) | |
354 | 341 | } | |
355 | 342 | } | |
356 | 343 | let calcLpAmt = res._1 | |
357 | 344 | let calcAmAssetPmt = res._2 | |
358 | 345 | let calcPrAssetPmt = res._3 | |
359 | 346 | let curPrice = fromX18(res._4, scale8) | |
360 | 347 | let slippageCalc = fromX18(res._5, scale8) | |
361 | 348 | if ((0 >= calcLpAmt)) | |
362 | 349 | then throw("Invalid calculations. LP calculated is less than zero.") | |
363 | 350 | else { | |
364 | 351 | let emitLpAmt = if (!(emitLp)) | |
365 | 352 | then 0 | |
366 | 353 | else calcLpAmt | |
367 | 354 | let amDiff = (inAmAssetAmt - calcAmAssetPmt) | |
368 | 355 | let prDiff = (inPrAssetAmt - calcPrAssetPmt) | |
369 | 356 | 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))] | |
370 | 357 | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId) | |
371 | 358 | } | |
372 | 359 | } | |
373 | 360 | } | |
374 | 361 | ||
375 | 362 | ||
376 | - | func calcKLp (amountBalance,priceBalance,lpEmission) = { | |
377 | - | let updatedKLp = fraction(pow((amountBalance * priceBalance), 0, toBigInt(5), 1, 0, DOWN), scale18, lpEmission) | |
378 | - | updatedKLp | |
379 | - | } | |
380 | - | ||
381 | - | ||
382 | - | func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
383 | - | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
384 | - | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
385 | - | let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta) | |
386 | - | let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
387 | - | let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))] | |
388 | - | $Tuple2(actions, updatedKLp) | |
389 | - | } | |
390 | - | ||
391 | - | ||
392 | 363 | func validateMatcherOrderAllowed (order) = { | |
393 | - | let amountAssetAmount = order.amount | |
394 | - | let priceAssetAmount = fraction(order.amount, order.price, scale8) | |
395 | - | let $t01955919771 = if ((order.orderType == Buy)) | |
396 | - | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
397 | - | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
398 | - | let amountAssetBalanceDelta = $t01955919771._1 | |
399 | - | let priceAssetBalanceDelta = $t01955919771._2 | |
364 | + | let cfg = getPoolConfig() | |
365 | + | let amtAssetId = cfg[idxAmtAssetId] | |
366 | + | let priceAssetId = cfg[idxPriceAssetId] | |
367 | + | let poolStatus = parseIntValue(cfg[idxPoolStatus]) | |
368 | + | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
369 | + | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
370 | + | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
371 | + | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
372 | + | let curPriceX18 = if ((order.orderType == Buy)) | |
373 | + | then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance) | |
374 | + | else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance) | |
375 | + | let curPrice = fromX18(curPriceX18, scale8) | |
400 | 376 | if (if (if (isGlobalShutdown()) | |
401 | 377 | then true | |
402 | - | else ( | |
378 | + | else (poolStatus == PoolMatcherDisabled)) | |
403 | 379 | then true | |
404 | - | else ( | |
380 | + | else (poolStatus == PoolShutdown)) | |
405 | 381 | then throw("Exchange operations disabled") | |
406 | - | else if (if ((order.assetPair.amountAsset != cfgAmountAssetId)) | |
407 | - | then true | |
408 | - | else (order.assetPair.priceAsset != cfgPriceAssetId)) | |
409 | - | then throw("Wrong order assets.") | |
410 | - | else { | |
411 | - | let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp")) | |
412 | - | let $t02024220342 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
413 | - | let unusedActions = $t02024220342._1 | |
414 | - | let kLpNew = $t02024220342._2 | |
415 | - | let isOrderValid = (kLpNew > kLp) | |
416 | - | isOrderValid | |
417 | - | } | |
382 | + | else { | |
383 | + | let orderAmtAsset = order.assetPair.amountAsset | |
384 | + | let orderAmtAssetStr = if ((orderAmtAsset == unit)) | |
385 | + | then "WAVES" | |
386 | + | else toBase58String(value(orderAmtAsset)) | |
387 | + | let orderPriceAsset = order.assetPair.priceAsset | |
388 | + | let orderPriceAssetStr = if ((orderPriceAsset == unit)) | |
389 | + | then "WAVES" | |
390 | + | else toBase58String(value(orderPriceAsset)) | |
391 | + | if (if ((orderAmtAssetStr != amtAssetId)) | |
392 | + | then true | |
393 | + | else (orderPriceAssetStr != priceAssetId)) | |
394 | + | then throw("Wrong order assets.") | |
395 | + | else { | |
396 | + | let orderPrice = order.price | |
397 | + | let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm) | |
398 | + | let castedOrderPrice = toScale(orderPrice, scale8, priceDcm) | |
399 | + | let isOrderPriceValid = if ((order.orderType == Buy)) | |
400 | + | then (curPrice >= castedOrderPrice) | |
401 | + | else (castedOrderPrice >= curPrice) | |
402 | + | true | |
403 | + | } | |
404 | + | } | |
418 | 405 | } | |
419 | 406 | ||
420 | 407 | ||
421 | 408 | func commonGet (i) = if ((size(i.payments) != 1)) | |
422 | 409 | then throw("exactly 1 payment is expected") | |
423 | 410 | else { | |
424 | 411 | let pmt = value(i.payments[0]) | |
425 | 412 | let pmtAssetId = value(pmt.assetId) | |
426 | 413 | let pmtAmt = pmt.amount | |
427 | 414 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
428 | 415 | let outAmAmt = res._1 | |
429 | 416 | let outPrAmt = res._2 | |
430 | 417 | let poolStatus = parseIntValue(res._9) | |
431 | 418 | let state = res._10 | |
432 | 419 | if (if (isGlobalShutdown()) | |
433 | 420 | then true | |
434 | 421 | else (poolStatus == PoolShutdown)) | |
435 | 422 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
436 | 423 | else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state) | |
437 | 424 | } | |
438 | 425 | ||
439 | 426 | ||
440 | 427 | func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2)) | |
441 | 428 | then throw("exactly 2 payments are expected") | |
442 | 429 | else { | |
443 | 430 | let amAssetPmt = value(i.payments[0]) | |
444 | 431 | let prAssetPmt = value(i.payments[1]) | |
445 | 432 | let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp) | |
446 | 433 | let poolStatus = parseIntValue(estPut._8) | |
447 | 434 | if (if (if (isGlobalShutdown()) | |
448 | 435 | then true | |
449 | 436 | else (poolStatus == PoolPutDisabled)) | |
450 | 437 | then true | |
451 | 438 | else (poolStatus == PoolShutdown)) | |
452 | 439 | then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus))) | |
453 | 440 | else estPut | |
454 | 441 | } | |
455 | 442 | ||
456 | 443 | ||
457 | 444 | func emit (amount) = { | |
458 | 445 | let emitInv = invoke(factoryContract, "emit", [amount], nil) | |
459 | 446 | if ((emitInv == emitInv)) | |
460 | 447 | then { | |
461 | 448 | let emitInvLegacy = match emitInv { | |
462 | 449 | case legacyFactoryContract: Address => | |
463 | 450 | invoke(legacyFactoryContract, "emit", [amount], nil) | |
464 | 451 | case _ => | |
465 | 452 | unit | |
466 | 453 | } | |
467 | 454 | if ((emitInvLegacy == emitInvLegacy)) | |
468 | 455 | then amount | |
469 | 456 | else throw("Strict value is not equal to itself.") | |
470 | 457 | } | |
471 | 458 | else throw("Strict value is not equal to itself.") | |
472 | 459 | } | |
473 | 460 | ||
474 | 461 | ||
475 | 462 | func takeFee (amount) = { | |
476 | 463 | let feeAmount = fraction(amount, fee, scale8) | |
477 | 464 | $Tuple2((amount - feeAmount), feeAmount) | |
478 | 465 | } | |
479 | 466 | ||
480 | 467 | ||
481 | 468 | func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = { | |
482 | 469 | let isEval = (txId == unit) | |
483 | 470 | let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
484 | 471 | let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
485 | 472 | let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId)) | |
486 | 473 | then true | |
487 | 474 | else if ((paymentAssetId == cfgPriceAssetId)) | |
488 | 475 | then false | |
489 | 476 | else throwErr("invalid asset") | |
490 | - | let $ | |
477 | + | let $t02257122864 = if (isEval) | |
491 | 478 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
492 | 479 | else if (paymentInAmountAsset) | |
493 | 480 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
494 | 481 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
495 | - | let amountBalanceOld = $ | |
496 | - | let priceBalanceOld = $ | |
497 | - | let $ | |
482 | + | let amountBalanceOld = $t02257122864._1 | |
483 | + | let priceBalanceOld = $t02257122864._2 | |
484 | + | let $t02286823017 = if (paymentInAmountAsset) | |
498 | 485 | then $Tuple2(paymentAmountRaw, 0) | |
499 | 486 | else $Tuple2(0, paymentAmountRaw) | |
500 | - | let amountAssetAmountRaw = $ | |
501 | - | let priceAssetAmountRaw = $ | |
487 | + | let amountAssetAmountRaw = $t02286823017._1 | |
488 | + | let priceAssetAmountRaw = $t02286823017._2 | |
502 | 489 | let amountAssetAmount = takeFee(amountAssetAmountRaw)._1 | |
503 | 490 | let priceAssetAmount = takeFee(priceAssetAmountRaw)._1 | |
504 | - | let $ | |
505 | - | let paymentAmount = $ | |
506 | - | let feeAmount = $ | |
491 | + | let $t02313923198 = takeFee(paymentAmountRaw) | |
492 | + | let paymentAmount = $t02313923198._1 | |
493 | + | let feeAmount = $t02313923198._2 | |
507 | 494 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
508 | 495 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
509 | 496 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
510 | 497 | let priceNew = fromX18(priceNewX18, scale8) | |
511 | 498 | let paymentBalance = if (paymentInAmountAsset) | |
512 | 499 | then amountBalanceOld | |
513 | 500 | else priceBalanceOld | |
514 | 501 | let paymentBalanceBigInt = toBigInt(paymentBalance) | |
515 | 502 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
516 | 503 | let chechSupply = if ((supplyBigInt > big0)) | |
517 | 504 | then true | |
518 | 505 | else throwErr("initial deposit requires all coins") | |
519 | 506 | if ((chechSupply == chechSupply)) | |
520 | 507 | then { | |
521 | 508 | let depositBigInt = toBigInt(paymentAmount) | |
522 | 509 | let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))]) | |
523 | 510 | let commonState = if (isEval) | |
524 | 511 | then nil | |
525 | 512 | 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))] | |
526 | 513 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
527 | 514 | let priceOld = fromX18(priceOldX18, scale8) | |
528 | 515 | let loss = { | |
529 | - | let $ | |
516 | + | let $t02467524842 = if (paymentInAmountAsset) | |
530 | 517 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
531 | 518 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
532 | - | let amount = $ | |
533 | - | let balance = $ | |
519 | + | let amount = $t02467524842._1 | |
520 | + | let balance = $t02467524842._2 | |
534 | 521 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
535 | 522 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
536 | 523 | } | |
537 | - | $ | |
524 | + | $Tuple4(issueAmount, commonState, feeAmount, loss) | |
538 | 525 | } | |
539 | 526 | else throw("Strict value is not equal to itself.") | |
540 | 527 | } | |
541 | 528 | ||
542 | 529 | ||
543 | 530 | func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = { | |
544 | 531 | let isEval = (txId == unit) | |
545 | 532 | let checks = [if ((paymentAssetId == cfgLpAssetId)) | |
546 | 533 | then true | |
547 | 534 | else throwErr("invalid lp asset")] | |
548 | 535 | if ((checks == checks)) | |
549 | 536 | then { | |
550 | 537 | let outInAmountAsset = if ((outAssetId == cfgAmountAssetId)) | |
551 | 538 | then true | |
552 | 539 | else if ((outAssetId == cfgPriceAssetId)) | |
553 | 540 | then false | |
554 | 541 | else throwErr("invalid asset") | |
555 | 542 | let balanceBigInt = if (outInAmountAsset) | |
556 | 543 | then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) | |
557 | 544 | else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) | |
558 | 545 | let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
559 | 546 | let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
560 | 547 | let outBalance = if (outInAmountAsset) | |
561 | 548 | then amBalanceOld | |
562 | 549 | else prBalanceOld | |
563 | 550 | let outBalanceBigInt = toBigInt(outBalance) | |
564 | 551 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
565 | 552 | let redeemedBigInt = toBigInt(paymentAmount) | |
566 | 553 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
567 | - | let $ | |
568 | - | let totalAmount = $ | |
569 | - | let feeAmount = $ | |
570 | - | let $ | |
554 | + | let $t02642226472 = takeFee(amountRaw) | |
555 | + | let totalAmount = $t02642226472._1 | |
556 | + | let feeAmount = $t02642226472._2 | |
557 | + | let $t02647626702 = if (outInAmountAsset) | |
571 | 558 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
572 | 559 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
573 | - | let outAmAmount = $ | |
574 | - | let outPrAmount = $ | |
575 | - | let amBalanceNew = $ | |
576 | - | let prBalanceNew = $ | |
560 | + | let outAmAmount = $t02647626702._1 | |
561 | + | let outPrAmount = $t02647626702._2 | |
562 | + | let amBalanceNew = $t02647626702._3 | |
563 | + | let prBalanceNew = $t02647626702._4 | |
577 | 564 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
578 | 565 | let priceNew = fromX18(priceNewX18, scale8) | |
579 | 566 | let commonState = if (isEval) | |
580 | 567 | then nil | |
581 | 568 | 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)] | |
582 | 569 | let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals)) | |
583 | 570 | let priceOld = fromX18(priceOldX18, scale8) | |
584 | 571 | let loss = { | |
585 | 572 | let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2) | |
586 | 573 | fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset) | |
587 | 574 | } | |
588 | - | $ | |
575 | + | $Tuple4(totalAmount, commonState, feeAmount, loss) | |
589 | 576 | } | |
590 | 577 | else throw("Strict value is not equal to itself.") | |
591 | 578 | } | |
592 | 579 | ||
593 | 580 | ||
594 | 581 | func managerPublicKeyOrUnit () = match getString(mpk()) { | |
595 | 582 | case s: String => | |
596 | 583 | fromBase58String(s) | |
597 | 584 | case _: Unit => | |
598 | 585 | unit | |
599 | 586 | case _ => | |
600 | 587 | throw("Match error") | |
601 | 588 | } | |
602 | 589 | ||
603 | 590 | ||
604 | 591 | func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) { | |
605 | 592 | case s: String => | |
606 | 593 | fromBase58String(s) | |
607 | 594 | case _: Unit => | |
608 | 595 | unit | |
609 | 596 | case _ => | |
610 | 597 | throw("Match error") | |
611 | 598 | } | |
612 | 599 | ||
613 | 600 | ||
614 | 601 | func isManager (i) = match managerPublicKeyOrUnit() { | |
615 | 602 | case pk: ByteVector => | |
616 | 603 | (i.callerPublicKey == pk) | |
617 | 604 | case _: Unit => | |
618 | 605 | (i.caller == this) | |
619 | 606 | case _ => | |
620 | 607 | throw("Match error") | |
621 | 608 | } | |
622 | 609 | ||
623 | 610 | ||
624 | 611 | func mustManager (i) = { | |
625 | 612 | let pd = throw("Permission denied") | |
626 | 613 | match managerPublicKeyOrUnit() { | |
627 | 614 | case pk: ByteVector => | |
628 | 615 | if ((i.callerPublicKey == pk)) | |
629 | 616 | then true | |
630 | 617 | else pd | |
631 | 618 | case _: Unit => | |
632 | 619 | if ((i.caller == this)) | |
633 | 620 | then true | |
634 | 621 | else pd | |
635 | 622 | case _ => | |
636 | 623 | throw("Match error") | |
637 | 624 | } | |
638 | 625 | } | |
639 | 626 | ||
640 | 627 | ||
641 | 628 | @Callable(i) | |
642 | 629 | func setManager (pendingManagerPublicKey) = { | |
643 | 630 | let checkCaller = mustManager(i) | |
644 | 631 | if ((checkCaller == checkCaller)) | |
645 | 632 | then { | |
646 | 633 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
647 | 634 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
648 | 635 | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
649 | 636 | else throw("Strict value is not equal to itself.") | |
650 | 637 | } | |
651 | 638 | else throw("Strict value is not equal to itself.") | |
652 | 639 | } | |
653 | 640 | ||
654 | 641 | ||
655 | 642 | ||
656 | 643 | @Callable(i) | |
657 | 644 | func confirmManager () = { | |
658 | 645 | let pm = pendingManagerPublicKeyOrUnit() | |
659 | 646 | let hasPM = if (isDefined(pm)) | |
660 | 647 | then true | |
661 | 648 | else throw("No pending manager") | |
662 | 649 | if ((hasPM == hasPM)) | |
663 | 650 | then { | |
664 | 651 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
665 | 652 | then true | |
666 | 653 | else throw("You are not pending manager") | |
667 | 654 | if ((checkPM == checkPM)) | |
668 | 655 | then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())] | |
669 | 656 | else throw("Strict value is not equal to itself.") | |
670 | 657 | } | |
671 | 658 | else throw("Strict value is not equal to itself.") | |
672 | 659 | } | |
673 | 660 | ||
674 | 661 | ||
675 | 662 | ||
676 | 663 | @Callable(i) | |
677 | 664 | func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance)) | |
678 | 665 | then throw("Invalid slippageTolerance passed") | |
679 | 666 | else { | |
680 | 667 | let estPut = commonPut(i, slippageTolerance, true) | |
681 | 668 | let emitLpAmt = estPut._2 | |
682 | 669 | let lpAssetId = estPut._7 | |
683 | 670 | let state = estPut._9 | |
684 | 671 | let amDiff = estPut._10 | |
685 | 672 | let prDiff = estPut._11 | |
686 | 673 | let amId = estPut._12 | |
687 | 674 | let prId = estPut._13 | |
688 | 675 | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
689 | 676 | if ((emitInv == emitInv)) | |
690 | 677 | then { | |
691 | 678 | let emitInvLegacy = match emitInv { | |
692 | 679 | case legacyFactoryContract: Address => | |
693 | 680 | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
694 | 681 | case _ => | |
695 | 682 | unit | |
696 | 683 | } | |
697 | 684 | if ((emitInvLegacy == emitInvLegacy)) | |
698 | 685 | then { | |
699 | 686 | let slippageAInv = if ((amDiff > 0)) | |
700 | 687 | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
701 | 688 | else nil | |
702 | 689 | if ((slippageAInv == slippageAInv)) | |
703 | 690 | then { | |
704 | 691 | let slippagePInv = if ((prDiff > 0)) | |
705 | 692 | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
706 | 693 | else nil | |
707 | 694 | if ((slippagePInv == slippagePInv)) | |
708 | 695 | then { | |
709 | 696 | let lpTransfer = if (shouldAutoStake) | |
710 | 697 | then { | |
711 | 698 | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
712 | 699 | if ((slpStakeInv == slpStakeInv)) | |
713 | 700 | then nil | |
714 | 701 | else throw("Strict value is not equal to itself.") | |
715 | 702 | } | |
716 | 703 | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
717 | - | let $t03113031195 = refreshKLpInternal(0, 0, 0) | |
718 | - | let refreshKLpActions = $t03113031195._1 | |
719 | - | let updatedKLp = $t03113031195._2 | |
720 | - | ((state ++ lpTransfer) ++ refreshKLpActions) | |
704 | + | (state ++ lpTransfer) | |
721 | 705 | } | |
722 | 706 | else throw("Strict value is not equal to itself.") | |
723 | 707 | } | |
724 | 708 | else throw("Strict value is not equal to itself.") | |
725 | 709 | } | |
726 | 710 | else throw("Strict value is not equal to itself.") | |
727 | 711 | } | |
728 | 712 | else throw("Strict value is not equal to itself.") | |
729 | 713 | } | |
730 | 714 | ||
731 | 715 | ||
732 | 716 | ||
733 | 717 | @Callable(i) | |
734 | 718 | func putForFree (maxSlippage) = if ((0 > maxSlippage)) | |
735 | 719 | then throw("Invalid value passed") | |
736 | 720 | else { | |
737 | 721 | let estPut = commonPut(i, maxSlippage, false) | |
738 | - | let state = estPut._9 | |
739 | - | let $t03148131546 = refreshKLpInternal(0, 0, 0) | |
740 | - | let refreshKLpActions = $t03148131546._1 | |
741 | - | let updatedKLp = $t03148131546._2 | |
742 | - | (state ++ refreshKLpActions) | |
722 | + | estPut._9 | |
743 | 723 | } | |
744 | 724 | ||
745 | 725 | ||
746 | 726 | ||
747 | 727 | @Callable(i) | |
748 | 728 | func putOneTkn (minOutAmount,autoStake) = { | |
749 | 729 | let isPoolOneTokenOperationsDisabled = { | |
750 | 730 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
751 | 731 | if ($isInstanceOf(@, "Boolean")) | |
752 | 732 | then @ | |
753 | 733 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
754 | 734 | } | |
755 | 735 | let isPutDisabled = if (if (if (isGlobalShutdown()) | |
756 | 736 | then true | |
757 | 737 | else (cfgPoolStatus == PoolPutDisabled)) | |
758 | 738 | then true | |
759 | 739 | else (cfgPoolStatus == PoolShutdown)) | |
760 | 740 | then true | |
761 | 741 | else isPoolOneTokenOperationsDisabled | |
762 | 742 | let checks = [if (if (!(isPutDisabled)) | |
763 | 743 | then true | |
764 | 744 | else isManager(i)) | |
765 | 745 | then true | |
766 | 746 | else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1)) | |
767 | 747 | then true | |
768 | 748 | else throwErr("exactly 1 payment are expected")] | |
769 | 749 | if ((checks == checks)) | |
770 | 750 | then { | |
771 | 751 | let payment = i.payments[0] | |
772 | 752 | let paymentAssetId = payment.assetId | |
773 | 753 | let paymentAmountRaw = payment.amount | |
774 | 754 | let userAddress = i.caller | |
775 | 755 | let txId = i.transactionId | |
776 | - | let $t03232232474 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
777 | - | if (($t03232232474 == $t03232232474)) | |
756 | + | let $t03160931736 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
757 | + | let emitAmountEstimated = $t03160931736._1 | |
758 | + | let commonState = $t03160931736._2 | |
759 | + | let feeAmount = $t03160931736._3 | |
760 | + | let bonus = $t03160931736._4 | |
761 | + | let emitAmount = if (if ((minOutAmount > 0)) | |
762 | + | then (minOutAmount > emitAmountEstimated) | |
763 | + | else false) | |
764 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
765 | + | else emitAmountEstimated | |
766 | + | let emitInv = emit(emitAmount) | |
767 | + | if ((emitInv == emitInv)) | |
778 | 768 | then { | |
779 | - | let paymentInAmountAsset = $t03232232474._5 | |
780 | - | let bonus = $t03232232474._4 | |
781 | - | let feeAmount = $t03232232474._3 | |
782 | - | let commonState = $t03232232474._2 | |
783 | - | let emitAmountEstimated = $t03232232474._1 | |
784 | - | let emitAmount = if (if ((minOutAmount > 0)) | |
785 | - | then (minOutAmount > emitAmountEstimated) | |
786 | - | else false) | |
787 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
788 | - | else emitAmountEstimated | |
789 | - | let emitInv = emit(emitAmount) | |
790 | - | if ((emitInv == emitInv)) | |
769 | + | let lpTransfer = if (autoStake) | |
791 | 770 | then { | |
792 | - | let lpTransfer = if (autoStake) | |
793 | - | then { | |
794 | - | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
795 | - | if ((stakeInv == stakeInv)) | |
796 | - | then nil | |
797 | - | else throw("Strict value is not equal to itself.") | |
798 | - | } | |
799 | - | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
800 | - | let sendFee = if ((feeAmount > 0)) | |
801 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
802 | - | else nil | |
803 | - | let $t03306033257 = if ((this == feeCollectorAddress)) | |
804 | - | then $Tuple2(0, 0) | |
805 | - | else if (paymentInAmountAsset) | |
806 | - | then $Tuple2(-(feeAmount), 0) | |
807 | - | else $Tuple2(0, -(feeAmount)) | |
808 | - | let amountAssetBalanceDelta = $t03306033257._1 | |
809 | - | let priceAssetBalanceDelta = $t03306033257._2 | |
810 | - | let $t03326033368 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
811 | - | let refreshKLpActions = $t03326033368._1 | |
812 | - | let updatedKLp = $t03326033368._2 | |
813 | - | $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
771 | + | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
772 | + | if ((stakeInv == stakeInv)) | |
773 | + | then nil | |
774 | + | else throw("Strict value is not equal to itself.") | |
814 | 775 | } | |
815 | - | else throw("Strict value is not equal to itself.") | |
776 | + | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
777 | + | let sendFee = if ((feeAmount > 0)) | |
778 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
779 | + | else nil | |
780 | + | $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount) | |
816 | 781 | } | |
817 | 782 | else throw("Strict value is not equal to itself.") | |
818 | 783 | } | |
819 | 784 | else throw("Strict value is not equal to itself.") | |
820 | 785 | } | |
821 | 786 | ||
822 | 787 | ||
823 | 788 | ||
824 | 789 | @Callable(i) | |
825 | 790 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
826 | - | let $t03356133718 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
827 | - | let emitAmountEstimated = $t03356133718._1 | |
828 | - | let commonState = $t03356133718._2 | |
829 | - | let feeAmount = $t03356133718._3 | |
830 | - | let bonus = $t03356133718._4 | |
831 | - | let paymentInAmountAsset = $t03356133718._5 | |
791 | + | let $t03246532600 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
792 | + | let emitAmountEstimated = $t03246532600._1 | |
793 | + | let commonState = $t03246532600._2 | |
794 | + | let feeAmount = $t03246532600._3 | |
795 | + | let bonus = $t03246532600._4 | |
832 | 796 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
833 | 797 | } | |
834 | 798 | ||
835 | 799 | ||
836 | 800 | ||
837 | 801 | @Callable(i) | |
838 | 802 | func getOneTkn (outAssetIdStr,minOutAmount) = { | |
839 | 803 | let isPoolOneTokenOperationsDisabled = { | |
840 | 804 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
841 | 805 | if ($isInstanceOf(@, "Boolean")) | |
842 | 806 | then @ | |
843 | 807 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
844 | 808 | } | |
845 | 809 | let isGetDisabled = if (if (isGlobalShutdown()) | |
846 | 810 | then true | |
847 | 811 | else (cfgPoolStatus == PoolShutdown)) | |
848 | 812 | then true | |
849 | 813 | else isPoolOneTokenOperationsDisabled | |
850 | 814 | let checks = [if (if (!(isGetDisabled)) | |
851 | 815 | then true | |
852 | 816 | else isManager(i)) | |
853 | 817 | then true | |
854 | 818 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1)) | |
855 | 819 | then true | |
856 | 820 | else throwErr("exactly 1 payment are expected")] | |
857 | 821 | if ((checks == checks)) | |
858 | 822 | then { | |
859 | 823 | let outAssetId = parseAssetId(outAssetIdStr) | |
860 | 824 | let payment = i.payments[0] | |
861 | 825 | let paymentAssetId = payment.assetId | |
862 | 826 | let paymentAmount = payment.amount | |
863 | 827 | let userAddress = i.caller | |
864 | 828 | let txId = i.transactionId | |
865 | - | let $t03452334676 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
866 | - | if (($t03452334676 == $t03452334676)) | |
829 | + | let $t03340533537 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
830 | + | let amountEstimated = $t03340533537._1 | |
831 | + | let commonState = $t03340533537._2 | |
832 | + | let feeAmount = $t03340533537._3 | |
833 | + | let bonus = $t03340533537._4 | |
834 | + | let amount = if (if ((minOutAmount > 0)) | |
835 | + | then (minOutAmount > amountEstimated) | |
836 | + | else false) | |
837 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
838 | + | else amountEstimated | |
839 | + | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
840 | + | if ((burnInv == burnInv)) | |
867 | 841 | then { | |
868 | - | let outInAmountAsset = $t03452334676._5 | |
869 | - | let bonus = $t03452334676._4 | |
870 | - | let feeAmount = $t03452334676._3 | |
871 | - | let commonState = $t03452334676._2 | |
872 | - | let amountEstimated = $t03452334676._1 | |
873 | - | let amount = if (if ((minOutAmount > 0)) | |
874 | - | then (minOutAmount > amountEstimated) | |
875 | - | else false) | |
876 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
877 | - | else amountEstimated | |
878 | - | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
879 | - | if ((burnInv == burnInv)) | |
880 | - | then { | |
881 | - | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
882 | - | let sendFee = if ((feeAmount > 0)) | |
883 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
884 | - | else nil | |
885 | - | let $t03517635423 = { | |
886 | - | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
887 | - | then 0 | |
888 | - | else feeAmount | |
889 | - | if (outInAmountAsset) | |
890 | - | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
891 | - | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
892 | - | } | |
893 | - | let amountAssetBalanceDelta = $t03517635423._1 | |
894 | - | let priceAssetBalanceDelta = $t03517635423._2 | |
895 | - | let $t03542635534 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
896 | - | let refreshKLpActions = $t03542635534._1 | |
897 | - | let updatedKLp = $t03542635534._2 | |
898 | - | $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
899 | - | } | |
900 | - | else throw("Strict value is not equal to itself.") | |
842 | + | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
843 | + | let sendFee = if ((feeAmount > 0)) | |
844 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
845 | + | else nil | |
846 | + | $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount) | |
901 | 847 | } | |
902 | 848 | else throw("Strict value is not equal to itself.") | |
903 | 849 | } | |
904 | 850 | else throw("Strict value is not equal to itself.") | |
905 | 851 | } | |
906 | 852 | ||
907 | 853 | ||
908 | 854 | ||
909 | 855 | @Callable(i) | |
910 | 856 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
911 | - | let $t03571835874 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
912 | - | let amountEstimated = $t03571835874._1 | |
913 | - | let commonState = $t03571835874._2 | |
914 | - | let feeAmount = $t03571835874._3 | |
915 | - | let bonus = $t03571835874._4 | |
916 | - | let outInAmountAsset = $t03571835874._5 | |
857 | + | let $t03417234310 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
858 | + | let amountEstimated = $t03417234310._1 | |
859 | + | let commonState = $t03417234310._2 | |
860 | + | let feeAmount = $t03417234310._3 | |
861 | + | let bonus = $t03417234310._4 | |
917 | 862 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
918 | 863 | } | |
919 | 864 | ||
920 | 865 | ||
921 | 866 | ||
922 | 867 | @Callable(i) | |
923 | 868 | func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = { | |
924 | 869 | let isPoolOneTokenOperationsDisabled = { | |
925 | 870 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
926 | 871 | if ($isInstanceOf(@, "Boolean")) | |
927 | 872 | then @ | |
928 | 873 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
929 | 874 | } | |
930 | 875 | let isGetDisabled = if (if (isGlobalShutdown()) | |
931 | 876 | then true | |
932 | 877 | else (cfgPoolStatus == PoolShutdown)) | |
933 | 878 | then true | |
934 | 879 | else isPoolOneTokenOperationsDisabled | |
935 | 880 | let checks = [if (if (!(isGetDisabled)) | |
936 | 881 | then true | |
937 | 882 | else isManager(i)) | |
938 | 883 | then true | |
939 | 884 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
940 | 885 | then true | |
941 | 886 | else throwErr("no payments are expected")] | |
942 | 887 | if ((checks == checks)) | |
943 | 888 | then { | |
944 | 889 | let outAssetId = parseAssetId(outAssetIdStr) | |
945 | 890 | let userAddress = i.caller | |
946 | 891 | let txId = i.transactionId | |
947 | 892 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
948 | 893 | if ((unstakeInv == unstakeInv)) | |
949 | 894 | then { | |
950 | - | let $t03669936850 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
951 | - | if (($t03669936850 == $t03669936850)) | |
895 | + | let $t03513535265 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
896 | + | let amountEstimated = $t03513535265._1 | |
897 | + | let commonState = $t03513535265._2 | |
898 | + | let feeAmount = $t03513535265._3 | |
899 | + | let bonus = $t03513535265._4 | |
900 | + | let amount = if (if ((minOutAmount > 0)) | |
901 | + | then (minOutAmount > amountEstimated) | |
902 | + | else false) | |
903 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
904 | + | else amountEstimated | |
905 | + | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
906 | + | if ((burnInv == burnInv)) | |
952 | 907 | then { | |
953 | - | let outInAmountAsset = $t03669936850._5 | |
954 | - | let bonus = $t03669936850._4 | |
955 | - | let feeAmount = $t03669936850._3 | |
956 | - | let commonState = $t03669936850._2 | |
957 | - | let amountEstimated = $t03669936850._1 | |
958 | - | let amount = if (if ((minOutAmount > 0)) | |
959 | - | then (minOutAmount > amountEstimated) | |
960 | - | else false) | |
961 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
962 | - | else amountEstimated | |
963 | - | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
964 | - | if ((burnInv == burnInv)) | |
965 | - | then { | |
966 | - | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
967 | - | let sendFee = if ((feeAmount > 0)) | |
968 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
969 | - | else nil | |
970 | - | let $t03734537592 = { | |
971 | - | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
972 | - | then 0 | |
973 | - | else feeAmount | |
974 | - | if (outInAmountAsset) | |
975 | - | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
976 | - | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
977 | - | } | |
978 | - | let amountAssetBalanceDelta = $t03734537592._1 | |
979 | - | let priceAssetBalanceDelta = $t03734537592._2 | |
980 | - | let $t03759537703 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
981 | - | let refreshKLpActions = $t03759537703._1 | |
982 | - | let updatedKLp = $t03759537703._2 | |
983 | - | $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
984 | - | } | |
985 | - | else throw("Strict value is not equal to itself.") | |
908 | + | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
909 | + | let sendFee = if ((feeAmount > 0)) | |
910 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
911 | + | else nil | |
912 | + | $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount) | |
986 | 913 | } | |
987 | 914 | else throw("Strict value is not equal to itself.") | |
988 | 915 | } | |
989 | 916 | else throw("Strict value is not equal to itself.") | |
990 | 917 | } | |
991 | 918 | else throw("Strict value is not equal to itself.") | |
992 | 919 | } | |
993 | 920 | ||
994 | 921 | ||
995 | 922 | ||
996 | 923 | @Callable(i) | |
997 | 924 | func get () = { | |
998 | 925 | let res = commonGet(i) | |
999 | 926 | let outAmtAmt = res._1 | |
1000 | 927 | let outPrAmt = res._2 | |
1001 | 928 | let pmtAmt = res._3 | |
1002 | 929 | let pmtAssetId = res._4 | |
1003 | 930 | let state = res._5 | |
1004 | 931 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1005 | 932 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1006 | - | then { | |
1007 | - | let $t03849538577 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1008 | - | let refreshKLpActions = $t03849538577._1 | |
1009 | - | let updatedKLp = $t03849538577._2 | |
1010 | - | (state ++ refreshKLpActions) | |
1011 | - | } | |
933 | + | then state | |
1012 | 934 | else throw("Strict value is not equal to itself.") | |
1013 | 935 | } | |
1014 | 936 | ||
1015 | 937 | ||
1016 | 938 | ||
1017 | 939 | @Callable(i) | |
1018 | 940 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
1019 | 941 | let res = commonGet(i) | |
1020 | 942 | let outAmAmt = res._1 | |
1021 | 943 | let outPrAmt = res._2 | |
1022 | 944 | let pmtAmt = res._3 | |
1023 | 945 | let pmtAssetId = res._4 | |
1024 | 946 | let state = res._5 | |
1025 | 947 | if ((noLessThenAmtAsset > outAmAmt)) | |
1026 | 948 | then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
1027 | 949 | else if ((noLessThenPriceAsset > outPrAmt)) | |
1028 | 950 | then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
1029 | 951 | else { | |
1030 | 952 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1031 | 953 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1032 | - | then { | |
1033 | - | let $t03937339454 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1034 | - | let refreshKLpActions = $t03937339454._1 | |
1035 | - | let updatedKLp = $t03937339454._2 | |
1036 | - | (state ++ refreshKLpActions) | |
1037 | - | } | |
954 | + | then state | |
1038 | 955 | else throw("Strict value is not equal to itself.") | |
1039 | 956 | } | |
1040 | 957 | } | |
1041 | 958 | ||
1042 | 959 | ||
1043 | 960 | ||
1044 | 961 | @Callable(i) | |
1045 | 962 | func unstakeAndGet (amount) = { | |
1046 | 963 | let checkPayments = if ((size(i.payments) != 0)) | |
1047 | 964 | then throw("No payments are expected") | |
1048 | 965 | else true | |
1049 | 966 | if ((checkPayments == checkPayments)) | |
1050 | 967 | then { | |
1051 | 968 | let cfg = getPoolConfig() | |
1052 | 969 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1053 | 970 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1054 | 971 | if ((unstakeInv == unstakeInv)) | |
1055 | 972 | then { | |
1056 | 973 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1057 | - | let outAmAmt = res._1 | |
1058 | - | let outPrAmt = res._2 | |
1059 | 974 | let poolStatus = parseIntValue(res._9) | |
1060 | 975 | let state = res._10 | |
1061 | 976 | let checkPoolStatus = if (if (isGlobalShutdown()) | |
1062 | 977 | then true | |
1063 | 978 | else (poolStatus == PoolShutdown)) | |
1064 | 979 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
1065 | 980 | else true | |
1066 | 981 | if ((checkPoolStatus == checkPoolStatus)) | |
1067 | 982 | then { | |
1068 | 983 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1069 | 984 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1070 | - | then { | |
1071 | - | let $t04042740508 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1072 | - | let refreshKLpActions = $t04042740508._1 | |
1073 | - | let updatedKLp = $t04042740508._2 | |
1074 | - | (state ++ refreshKLpActions) | |
1075 | - | } | |
985 | + | then state | |
1076 | 986 | else throw("Strict value is not equal to itself.") | |
1077 | 987 | } | |
1078 | 988 | else throw("Strict value is not equal to itself.") | |
1079 | 989 | } | |
1080 | 990 | else throw("Strict value is not equal to itself.") | |
1081 | 991 | } | |
1082 | 992 | else throw("Strict value is not equal to itself.") | |
1083 | 993 | } | |
1084 | 994 | ||
1085 | 995 | ||
1086 | 996 | ||
1087 | 997 | @Callable(i) | |
1088 | 998 | func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = { | |
1089 | 999 | let isGetDisabled = if (isGlobalShutdown()) | |
1090 | 1000 | then true | |
1091 | 1001 | else (cfgPoolStatus == PoolShutdown) | |
1092 | 1002 | let checks = [if (!(isGetDisabled)) | |
1093 | 1003 | then true | |
1094 | 1004 | else throw("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1095 | 1005 | then true | |
1096 | 1006 | else throw("no payments are expected")] | |
1097 | 1007 | if ((checks == checks)) | |
1098 | 1008 | then { | |
1099 | 1009 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1100 | 1010 | if ((unstakeInv == unstakeInv)) | |
1101 | 1011 | then { | |
1102 | 1012 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1103 | 1013 | let outAmAmt = res._1 | |
1104 | 1014 | let outPrAmt = res._2 | |
1105 | 1015 | let state = res._10 | |
1106 | 1016 | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1107 | 1017 | then true | |
1108 | 1018 | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1109 | 1019 | then true | |
1110 | 1020 | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1111 | 1021 | if ((checkAmounts == checkAmounts)) | |
1112 | 1022 | then { | |
1113 | 1023 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1114 | 1024 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1115 | - | then { | |
1116 | - | let $t04164841729 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1117 | - | let refreshKLpActions = $t04164841729._1 | |
1118 | - | let updatedKLp = $t04164841729._2 | |
1119 | - | (state ++ refreshKLpActions) | |
1120 | - | } | |
1025 | + | then state | |
1121 | 1026 | else throw("Strict value is not equal to itself.") | |
1122 | 1027 | } | |
1123 | 1028 | else throw("Strict value is not equal to itself.") | |
1124 | 1029 | } | |
1125 | 1030 | else throw("Strict value is not equal to itself.") | |
1126 | 1031 | } | |
1127 | 1032 | else throw("Strict value is not equal to itself.") | |
1128 | 1033 | } | |
1129 | 1034 | ||
1130 | 1035 | ||
1131 | 1036 | ||
1132 | 1037 | @Callable(i) | |
1133 | 1038 | func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract))) | |
1134 | 1039 | then throw("permissions denied") | |
1135 | 1040 | else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success") | |
1136 | - | ||
1137 | - | ||
1138 | - | ||
1139 | - | @Callable(i) | |
1140 | - | func refreshKLp () = { | |
1141 | - | let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0) | |
1142 | - | let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay)) | |
1143 | - | then unit | |
1144 | - | else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1145 | - | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1146 | - | then { | |
1147 | - | let $t04271742772 = refreshKLpInternal(0, 0, 0) | |
1148 | - | let actions = $t04271742772._1 | |
1149 | - | let updatedKLp = $t04271742772._2 | |
1150 | - | $Tuple2(actions, toString(updatedKLp)) | |
1151 | - | } | |
1152 | - | else throw("Strict value is not equal to itself.") | |
1153 | - | } | |
1154 | 1041 | ||
1155 | 1042 | ||
1156 | 1043 | ||
1157 | 1044 | @Callable(i) | |
1158 | 1045 | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig()) | |
1159 | 1046 | ||
1160 | 1047 | ||
1161 | 1048 | ||
1162 | 1049 | @Callable(i) | |
1163 | 1050 | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
1164 | 1051 | ||
1165 | 1052 | ||
1166 | 1053 | ||
1167 | 1054 | @Callable(i) | |
1168 | 1055 | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
1169 | 1056 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
1170 | 1057 | $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])]) | |
1171 | 1058 | } | |
1172 | 1059 | ||
1173 | 1060 | ||
1174 | 1061 | ||
1175 | 1062 | @Callable(i) | |
1176 | 1063 | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult))) | |
1177 | 1064 | ||
1178 | 1065 | ||
1179 | 1066 | ||
1180 | 1067 | @Callable(i) | |
1181 | 1068 | func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult)) | |
1182 | 1069 | ||
1183 | 1070 | ||
1184 | 1071 | ||
1185 | 1072 | @Callable(i) | |
1186 | 1073 | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
1187 | 1074 | ||
1188 | 1075 | ||
1189 | 1076 | ||
1190 | 1077 | @Callable(i) | |
1191 | 1078 | func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp)) | |
1192 | 1079 | ||
1193 | 1080 | ||
1194 | 1081 | ||
1195 | 1082 | @Callable(i) | |
1196 | 1083 | func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
1197 | 1084 | let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress)) | |
1198 | 1085 | $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10)) | |
1199 | 1086 | } | |
1200 | 1087 | ||
1201 | 1088 | ||
1202 | 1089 | ||
1203 | 1090 | @Callable(i) | |
1204 | 1091 | func statsREADONLY () = { | |
1205 | 1092 | let cfg = getPoolConfig() | |
1206 | 1093 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1207 | 1094 | let amtAssetId = cfg[idxAmtAssetId] | |
1208 | 1095 | let priceAssetId = cfg[idxPriceAssetId] | |
1209 | 1096 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
1210 | 1097 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
1211 | 1098 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1212 | 1099 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1213 | 1100 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1214 | 1101 | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
1215 | 1102 | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
1216 | 1103 | let pricesList = if ((poolLPBalance == 0)) | |
1217 | 1104 | then [zeroBigInt, zeroBigInt, zeroBigInt] | |
1218 | 1105 | else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance) | |
1219 | 1106 | let curPrice = 0 | |
1220 | 1107 | let lpAmtAssetShare = fromX18(pricesList[1], scale8) | |
1221 | 1108 | let lpPriceAssetShare = fromX18(pricesList[2], scale8) | |
1222 | 1109 | let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this)))) | |
1223 | 1110 | $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)) | |
1224 | 1111 | } | |
1225 | 1112 | ||
1226 | 1113 | ||
1227 | 1114 | ||
1228 | 1115 | @Callable(i) | |
1229 | 1116 | func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = { | |
1230 | 1117 | let cfg = getPoolConfig() | |
1231 | 1118 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1232 | 1119 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1233 | 1120 | let amAssetId = fromBase58String(amAssetIdStr) | |
1234 | 1121 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1235 | 1122 | let prAssetId = fromBase58String(prAssetIdStr) | |
1236 | 1123 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1237 | 1124 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1238 | 1125 | let poolStatus = cfg[idxPoolStatus] | |
1239 | 1126 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1240 | 1127 | let accAmtAssetBalance = getAccBalance(amAssetIdStr) | |
1241 | 1128 | let accPriceAssetBalance = getAccBalance(prAssetIdStr) | |
1242 | 1129 | let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm) | |
1243 | 1130 | let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm) | |
1244 | 1131 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1245 | 1132 | then zeroBigInt | |
1246 | 1133 | else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
1247 | 1134 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
1248 | 1135 | let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
1249 | 1136 | let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm) | |
1250 | 1137 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1251 | 1138 | let calcLpAmt = estPut._1 | |
1252 | 1139 | let curPriceCalc = estPut._3 | |
1253 | 1140 | let amBalance = estPut._4 | |
1254 | 1141 | let prBalance = estPut._5 | |
1255 | 1142 | let lpEmission = estPut._6 | |
1256 | 1143 | $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)) | |
1257 | 1144 | } | |
1258 | 1145 | ||
1259 | 1146 | ||
1260 | 1147 | ||
1261 | 1148 | @Callable(i) | |
1262 | 1149 | func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = { | |
1263 | 1150 | let cfg = getPoolConfig() | |
1264 | 1151 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1265 | 1152 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1266 | 1153 | let amAssetId = fromBase58String(amAssetIdStr) | |
1267 | 1154 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1268 | 1155 | let prAssetId = fromBase58String(prAssetIdStr) | |
1269 | 1156 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1270 | 1157 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1271 | 1158 | let poolStatus = cfg[idxPoolStatus] | |
1272 | 1159 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1273 | 1160 | let amBalanceRaw = getAccBalance(amAssetIdStr) | |
1274 | 1161 | let prBalanceRaw = getAccBalance(prAssetIdStr) | |
1275 | 1162 | let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm) | |
1276 | 1163 | let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm) | |
1277 | 1164 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1278 | 1165 | then zeroBigInt | |
1279 | 1166 | else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18) | |
1280 | 1167 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
1281 | 1168 | let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
1282 | 1169 | let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm) | |
1283 | 1170 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1284 | 1171 | let calcLpAmt = estPut._1 | |
1285 | 1172 | let curPriceCalc = estPut._3 | |
1286 | 1173 | let amBalance = estPut._4 | |
1287 | 1174 | let prBalance = estPut._5 | |
1288 | 1175 | let lpEmission = estPut._6 | |
1289 | 1176 | $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)) | |
1290 | 1177 | } | |
1291 | 1178 | ||
1292 | 1179 | ||
1293 | 1180 | ||
1294 | 1181 | @Callable(i) | |
1295 | 1182 | func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = { | |
1296 | 1183 | let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this) | |
1297 | 1184 | let outAmAmt = res._1 | |
1298 | 1185 | let outPrAmt = res._2 | |
1299 | 1186 | let amBalance = res._5 | |
1300 | 1187 | let prBalance = res._6 | |
1301 | 1188 | let lpEmission = res._7 | |
1302 | 1189 | let curPrice = res._8 | |
1303 | 1190 | let poolStatus = parseIntValue(res._9) | |
1304 | 1191 | $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)) | |
1305 | 1192 | } | |
1306 | 1193 | ||
1307 | 1194 | ||
1308 | 1195 | @Verifier(tx) | |
1309 | 1196 | func verify () = { | |
1310 | 1197 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
1311 | 1198 | case pk: ByteVector => | |
1312 | 1199 | pk | |
1313 | 1200 | case _: Unit => | |
1314 | 1201 | tx.senderPublicKey | |
1315 | 1202 | case _ => | |
1316 | 1203 | throw("Match error") | |
1317 | 1204 | } | |
1318 | 1205 | match tx { | |
1319 | 1206 | case order: Order => | |
1320 | 1207 | let matcherPub = getMatcherPubOrFail() | |
1321 | 1208 | let orderValid = validateMatcherOrderAllowed(order) | |
1322 | 1209 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1323 | 1210 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1324 | 1211 | if (if (if (orderValid) | |
1325 | 1212 | then senderValid | |
1326 | 1213 | else false) | |
1327 | 1214 | then matcherValid | |
1328 | 1215 | else false) | |
1329 | 1216 | then true | |
1330 | 1217 | else throwOrderError(orderValid, senderValid, matcherValid) | |
1331 | 1218 | case s: SetScriptTransaction => | |
1332 | 1219 | let newHash = blake2b256(value(s.script)) | |
1333 | 1220 | let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash()))) | |
1334 | 1221 | let currentHash = scriptHash(this) | |
1335 | 1222 | if (if ((allowedHash == newHash)) | |
1336 | 1223 | then (currentHash != newHash) | |
1337 | 1224 | else false) | |
1338 | 1225 | then true | |
1339 | 1226 | else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1340 | 1227 | case _ => | |
1341 | 1228 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1342 | 1229 | } | |
1343 | 1230 | } | |
1344 | 1231 |
github/deemru/w8io/026f985 148.49 ms ◑