tx · DQqrz3F1MFERcBBP4qE4pmMMFWgBioPqLwMQbdK5fEyE 3MzKSdTH2jFbypLsoNfrH7QgkzSbx3EYwCA: -0.02900000 Waves 2022.09.14 15:48 [2228790] smart account 3MzKSdTH2jFbypLsoNfrH7QgkzSbx3EYwCA > SELF 0.00000000 Waves
{ "type": 13, "id": "DQqrz3F1MFERcBBP4qE4pmMMFWgBioPqLwMQbdK5fEyE", "fee": 2900000, "feeAssetId": null, "timestamp": 1663159730500, "version": 1, "sender": "3MzKSdTH2jFbypLsoNfrH7QgkzSbx3EYwCA", "senderPublicKey": "35yd3qw1gxKDxKwGAykHN9fANbXNWwseaUwbWDj24o3x", "proofs": [ "iYt3mGq7wbQxbetqRxmBgLfcPMXcPNMWzi8MMXCcWNwfwxxF7NWdJeS9AE6DMGbZoL8UWKSZsEzwuABU7hC2tux" ], "script": "base64:BgJ/CAISAwoBCBIDCgEIEgASBAoCAQQSBwoFAQEBAQQSAwoBARIAEgcKBQEBAQgBEgQKAgEBEgMKAQESBAoCCAgSBAoCCAgSBAoCCAESABIDCgEIEgUKAwEBARIECgIIARIECgIBARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCFIABnNjYWxlOACAwtcvAAxzY2FsZThCaWdJbnQJALYCAQCAwtcvAAdzY2FsZTE4CQC2AgEAgICQu7rWrfANAAh0aG91c2FuZADoBwAKemVyb0JpZ0ludAkAtgIBAAAACW9uZUJpZ0ludAkAtgIBAAEACnNsaXBwYWdlNEQJALYCAQkAZQIFBnNjYWxlOAkAaQIJAGgCBQZzY2FsZTgAAQUGc2NhbGU4AAVBbXVsdAIDMTAwAAVEY29udgIBMQADU0VQAgJfXwAFRU1QVFkCAAAKUG9vbEFjdGl2ZQABAApQb29sUHV0RGlzAAIADlBvb2xNYXRjaGVyRGlzAAMADFBvb2xTaHV0ZG93bgAEAA5pZHhQb29sQWRkcmVzcwABAAlpZHhQb29sU3QAAgAJaWR4TFBBc0lkAAMACWlkeEFtQXNJZAAEAAlpZHhQ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AnR4BnByb29mcwAABQ90YXJnZXRQdWJsaWNLZXkJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAFD3RhcmdldFB1YmxpY0tleei8Leo=", "chainId": 84, "height": 2228790, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5obmnocF7rafTFHbeJ4dvFwQ11FXKjq6AzjzkPj1WHF6 Next: 43WEka1CrkCccKrAkVzm6Zj3AzHQhpHa67ZS9E9pUjsJ Diff:
Old | New | Differences | |
---|---|---|---|
6 | 6 | let scale8BigInt = toBigInt(100000000) | |
7 | 7 | ||
8 | 8 | let scale18 = toBigInt(1000000000000000000) | |
9 | + | ||
10 | + | let thousand = 1000 | |
9 | 11 | ||
10 | 12 | let zeroBigInt = toBigInt(0) | |
11 | 13 | ||
53 | 55 | ||
54 | 56 | let idxFactGwxRewCntr = 10 | |
55 | 57 | ||
56 | - | let | |
58 | + | let feePermilleDefault = 0 | |
57 | 59 | ||
58 | 60 | func t1 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult)) | |
59 | 61 | ||
102 | 104 | func ada () = "%s__addonAddr" | |
103 | 105 | ||
104 | 106 | ||
105 | - | ||
107 | + | let keyFeePermille = "%s__feePermille" | |
106 | 108 | ||
107 | - | ||
108 | - | func lsotc (caller) = makeString(["%s%s__lastPutOneTknCall", caller], SEP) | |
109 | - | ||
109 | + | let feePermille = valueOrElse(getInteger(this, keyFeePermille), feePermilleDefault) | |
110 | 110 | ||
111 | 111 | func fcfg () = "%s__factoryConfig" | |
112 | 112 | ||
124 | 124 | ||
125 | 125 | ||
126 | 126 | func keyAllowedLpStableScriptHash () = "%s__allowedLpStableScriptHash" | |
127 | + | ||
128 | + | ||
129 | + | func keyFeeCollectorAddress () = "%s__feeCollectorAddress" | |
127 | 130 | ||
128 | 131 | ||
129 | 132 | func toe (orV,sendrV,matchV) = throw(((((("Failed: ordValid=" + toString(orV)) + " sndrValid=") + toString(sendrV)) + " mtchrValid=") + toString(matchV))) | |
153 | 156 | func mp () = fromBase58String(strf(fca, mtpk())) | |
154 | 157 | ||
155 | 158 | ||
159 | + | let feeCollectorAddress = addressFromStringValue(strf(fca, keyFeeCollectorAddress())) | |
160 | + | ||
156 | 161 | func gpc () = { | |
157 | 162 | let amtAs = strf(this, aa()) | |
158 | 163 | let priceAs = strf(this, pa()) | |
164 | 169 | ||
165 | 170 | func gfc () = split(strf(fca, fcfg()), SEP) | |
166 | 171 | ||
167 | - | ||
168 | - | let factoryConfig = gfc() | |
169 | - | ||
170 | - | let stakingContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactStakCntr]), "Invalid staking contract address") | |
171 | - | ||
172 | - | let slipageContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactSlippCntr]), "Invalid slipage contract address") | |
173 | - | ||
174 | - | let gwxContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactGwxRewCntr]), "Invalid gwx contract address") | |
175 | 172 | ||
176 | 173 | func dataPutActionInfo (inAmtAssetAmt,inPriceAssetAmt,outLpAmt,price,slipByUser,slippageReal,txHeight,txTimestamp,slipageAmAmt,slipagePrAmt) = makeString(["%d%d%d%d%d%d%d%d%d%d", toString(inAmtAssetAmt), toString(inPriceAssetAmt), toString(outLpAmt), toString(price), toString(slipByUser), toString(slippageReal), toString(txHeight), toString(txTimestamp), toString(slipageAmAmt), toString(slipagePrAmt)], SEP) | |
177 | 174 | ||
270 | 267 | } | |
271 | 268 | ||
272 | 269 | ||
273 | - | func epo (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,userAddress,isEval,emitLp,isOneAsset, | |
270 | + | func epo (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,userAddress,isEval,emitLp,isOneAsset,pmtAmt,pmtId) = { | |
274 | 271 | let cfg = gpc() | |
275 | 272 | let lpId = fromBase58String(cfg[idxLPAsId]) | |
276 | 273 | let amIdStr = cfg[idxAmAsId] | |
315 | 312 | let curPriceX18 = cpbi(prBalanceX18, amBalanceX18) | |
316 | 313 | let slippageRealX18 = fraction(abs((curPriceX18 - userPriceX18)), scale18, curPriceX18) | |
317 | 314 | let slippageX18 = t1(slippage, scale8) | |
318 | - | if (if (if (validateSlippage) | |
319 | - | then (curPriceX18 != zeroBigInt) | |
320 | - | else false) | |
315 | + | if (if ((curPriceX18 != zeroBigInt)) | |
321 | 316 | then (slippageRealX18 > slippageX18) | |
322 | 317 | else false) | |
323 | 318 | then throw(((("Price slippage " + toString(slippageRealX18)) + " > ") + toString(slippageX18))) | |
347 | 342 | else calcLpAmt | |
348 | 343 | let amDiff = (inAmAmt - calcAmAssetPmt) | |
349 | 344 | let prDiff = (inPrAmt - calcPrAssetPmt) | |
350 | - | let $ | |
345 | + | let $t01568216027 = if (if (isOneAsset) | |
351 | 346 | then (pmtId == amIdStr) | |
352 | 347 | else false) | |
353 | 348 | then $Tuple2(pmtAmt, 0) | |
356 | 351 | else false) | |
357 | 352 | then $Tuple2(0, pmtAmt) | |
358 | 353 | else $Tuple2(calcAmAssetPmt, calcPrAssetPmt) | |
359 | - | let writeAmAmt = $ | |
360 | - | let writePrAmt = $ | |
354 | + | let writeAmAmt = $t01568216027._1 | |
355 | + | let writePrAmt = $t01568216027._2 | |
361 | 356 | let commonState = [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(userAddress, txId58), dataPutActionInfo(writeAmAmt, writePrAmt, emitLpAmt, curPrice, slippage, slippageCalc, height, lastBlock.timestamp, amDiff, prDiff))] | |
362 | 357 | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEm, lpId, sts, commonState, amDiff, prDiff, inAmId, inPrId) | |
363 | 358 | } | |
428 | 423 | } | |
429 | 424 | ||
430 | 425 | ||
431 | - | func cp (caller,txId,amAsPmt,prAsPmt,slippage,emitLp,isOneAsset, | |
432 | - | let r = epo(txId, slippage, value(amAsPmt).amount, value(amAsPmt).assetId, value(prAsPmt).amount, value(prAsPmt).assetId, caller, false, emitLp, isOneAsset, | |
426 | + | func cp (caller,txId,amAsPmt,prAsPmt,slippage,emitLp,isOneAsset,pmtAmt,pmtId) = { | |
427 | + | let r = epo(txId, slippage, value(amAsPmt).amount, value(amAsPmt).assetId, value(prAsPmt).amount, value(prAsPmt).assetId, caller, false, emitLp, isOneAsset, pmtAmt, pmtId) | |
433 | 428 | let sts = parseIntValue(r._8) | |
434 | 429 | if (if (if (igs()) | |
435 | 430 | then true | |
441 | 436 | } | |
442 | 437 | ||
443 | 438 | ||
444 | - | func estimatePutOneTknV2 (pmtAmt,pmtAssetId,userAddress,txId) = { | |
445 | - | let poolConfig = gpc() | |
446 | - | let amId = poolConfig[idxAmAsId] | |
447 | - | let prId = poolConfig[idxPrAsId] | |
448 | - | let amBalance = getAccBalance(amId) | |
449 | - | let prBalance = getAccBalance(prId) | |
450 | - | let $t02075121200 = if ((txId == "")) | |
451 | - | then $Tuple2(amBalance, prBalance) | |
452 | - | else if ((pmtAssetId == amId)) | |
453 | - | then if ((pmtAmt > amBalance)) | |
454 | - | then throw("invalid payment amount") | |
455 | - | else $Tuple2((amBalance - pmtAmt), prBalance) | |
456 | - | else if ((pmtAssetId == prId)) | |
457 | - | then if ((pmtAmt > prBalance)) | |
458 | - | then throw("invalid payment amount") | |
459 | - | else $Tuple2(amBalance, (prBalance - pmtAmt)) | |
460 | - | else throw("wrong pmtAssetId") | |
461 | - | let amBalanceNow = $t02075121200._1 | |
462 | - | let prBalanceNow = $t02075121200._2 | |
463 | - | let $t02120421338 = if ((pmtAssetId == amId)) | |
464 | - | then $Tuple2(amBalanceNow, prBalanceNow) | |
465 | - | else $Tuple2(prBalanceNow, amBalanceNow) | |
466 | - | let amBalanceForCalc = $t02120421338._1 | |
467 | - | let prBalanceForCalc = $t02120421338._2 | |
468 | - | let xPrecision = 1 | |
469 | - | let result = { | |
470 | - | let @ = invoke(gwxContract, "calcPutXOnly", [toString(pmtAmt), toString(amBalanceForCalc), toString(prBalanceForCalc), "", A, Amult, toString(xPrecision), Dconv], nil) | |
471 | - | if ($isInstanceOf(@, "(Int, Int)")) | |
472 | - | then @ | |
473 | - | else throw(($getType(invoke(gwxContract, "calcPutXOnly", [toString(pmtAmt), toString(amBalanceForCalc), toString(prBalanceForCalc), "", A, Amult, toString(xPrecision), Dconv], nil)) + " couldn't be cast to (Int, Int)")) | |
474 | - | } | |
475 | - | let $t02180721903 = if ((pmtAssetId == amId)) | |
476 | - | then result | |
477 | - | else $Tuple2(result._2, result._1) | |
478 | - | let amAssetPart = $t02180721903._1 | |
479 | - | let prAssetPart = $t02180721903._2 | |
480 | - | let estPut = cp(userAddress, txId, AttachedPayment(fromBase58String(amId), amAssetPart), AttachedPayment(fromBase58String(prId), prAssetPart), 0, true, true, false, pmtAmt, pmtAssetId) | |
481 | - | let estimLP = estPut._2 | |
482 | - | let lpAssetId = estPut._7 | |
483 | - | let state = estPut._9 | |
484 | - | let amDiff = estPut._10 | |
485 | - | let prDiff = estPut._11 | |
486 | - | $Tuple5(estimLP, lpAssetId, state, amDiff, prDiff) | |
439 | + | func takeFee (amount) = { | |
440 | + | let fee = fraction(amount, feePermille, thousand) | |
441 | + | $Tuple2((amount - fee), fee) | |
487 | 442 | } | |
488 | 443 | ||
489 | 444 | ||
578 | 533 | else if ((size(i.payments) != 2)) | |
579 | 534 | then throw("2 pmnts expd") | |
580 | 535 | else { | |
581 | - | let e = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], slip, true, false, | |
536 | + | let e = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], slip, true, false, 0, "") | |
582 | 537 | let emitLpAmt = e._2 | |
583 | 538 | let lpAssetId = e._7 | |
584 | 539 | let state = e._9 | |
644 | 599 | let userAddress = if ((addon == toString(i.caller))) | |
645 | 600 | then i.originCaller | |
646 | 601 | else i.caller | |
647 | - | let addonContract = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(ada()), "no addons")), "addon address in not valid") | |
648 | - | let check = reentrantInvoke(addonContract, "ensureCanPutOneTkn", [toString(userAddress)], nil) | |
649 | - | if ((check == check)) | |
650 | - | then if (if (if (if ((0 >= slippage)) | |
651 | - | then true | |
652 | - | else (0 >= amAssetPart)) | |
653 | - | then true | |
654 | - | else (0 >= prAssetPart)) | |
655 | - | then true | |
656 | - | else (0 >= outLp)) | |
657 | - | then throw("Wrong params") | |
658 | - | else if ((size(i.payments) != 1)) | |
659 | - | then throw("1 pmnt expd") | |
660 | - | else { | |
661 | - | let pmt = value(i.payments[0]) | |
662 | - | let pmtAssetId = toBase58String(value(pmt.assetId)) | |
663 | - | let pmtAmt = pmt.amount | |
664 | - | if ((10000000 > pmtAmt)) | |
665 | - | then throw("Wrong pmt amt") | |
666 | - | else { | |
667 | - | let amBalance = getAccBalance(amId) | |
668 | - | let prBalance = getAccBalance(prId) | |
669 | - | let $t02731327889 = if ((pmtAssetId == amId)) | |
670 | - | then if (if ((pmtAmt > amBalance)) | |
602 | + | if (if (if (if ((0 >= slippage)) | |
603 | + | then true | |
604 | + | else (0 >= amAssetPart)) | |
605 | + | then true | |
606 | + | else (0 >= prAssetPart)) | |
607 | + | then true | |
608 | + | else (0 >= outLp)) | |
609 | + | then throw("Wrong params") | |
610 | + | else if ((size(i.payments) != 1)) | |
611 | + | then throw("1 pmnt expd") | |
612 | + | else { | |
613 | + | let pmt = value(i.payments[0]) | |
614 | + | let pmtAssetId = toBase58String(value(pmt.assetId)) | |
615 | + | let paymentAmountRaw = pmt.amount | |
616 | + | let $t02464424696 = takeFee(paymentAmountRaw) | |
617 | + | let pmtAmt = $t02464424696._1 | |
618 | + | let feeAmount = $t02464424696._2 | |
619 | + | if ((10000000 > paymentAmountRaw)) | |
620 | + | then throw("Wrong pmt amt") | |
621 | + | else { | |
622 | + | let amBalance = getAccBalance(amId) | |
623 | + | let prBalance = getAccBalance(prId) | |
624 | + | let $t02485625472 = if ((pmtAssetId == amId)) | |
625 | + | then if (if ((paymentAmountRaw > amBalance)) | |
626 | + | then true | |
627 | + | else (amAssetPart > pmtAmt)) | |
628 | + | then throw("invalid payment amount") | |
629 | + | else $Tuple6((amBalance - paymentAmountRaw), prBalance, (pmtAmt - amAssetPart), prAssetPart, 0, 0) | |
630 | + | else if ((pmtAssetId == prId)) | |
631 | + | then if (if ((paymentAmountRaw > prBalance)) | |
671 | 632 | then true | |
672 | - | else ( | |
633 | + | else (prAssetPart > pmtAmt)) | |
673 | 634 | then throw("invalid payment amount") | |
674 | - | else $Tuple6((amBalance - pmtAmt), prBalance, (pmtAmt - amAssetPart), prAssetPart, 0, 0) | |
675 | - | else if ((pmtAssetId == prId)) | |
676 | - | then if (if ((pmtAmt > prBalance)) | |
677 | - | then true | |
678 | - | else (prAssetPart > pmtAmt)) | |
679 | - | then throw("invalid payment amount") | |
680 | - | else $Tuple6(amBalance, (prBalance - pmtAmt), 0, 0, (pmtAmt - prAssetPart), amAssetPart) | |
681 | - | else throw("wrong pmtAssetId") | |
682 | - | let amBalanceNow = $t02731327889._1 | |
683 | - | let prBalanceNow = $t02731327889._2 | |
684 | - | let virtSwapInAm = $t02731327889._3 | |
685 | - | let virtSwapOutPr = $t02731327889._4 | |
686 | - | let virtSwapInPr = $t02731327889._5 | |
687 | - | let virtSwapOutAm = $t02731327889._6 | |
688 | - | let D0 = invoke(gwxCntr, "calcD", [toString(amBalanceNow), toString(prBalanceNow), A, Amult, Dconv], nil) | |
689 | - | let D1 = invoke(gwxCntr, "calcD", [toString(toBigInt(((amBalanceNow + virtSwapInAm) - virtSwapOutAm))), toString(toBigInt(((prBalanceNow + virtSwapInPr) - virtSwapOutPr))), A, Amult, Dconv], nil) | |
690 | - | let D0vsD1 = vd(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D) | |
691 | - | if ((D0vsD1 == D0vsD1)) | |
692 | - | then { | |
693 | - | let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(fromBase58String(amId), amAssetPart), AttachedPayment(fromBase58String(prId), prAssetPart), slippage, true, true, true, pmtAmt, pmtAssetId) | |
694 | - | let estimLP = estPut._2 | |
695 | - | let lpAssetId = estPut._7 | |
696 | - | let state = estPut._9 | |
697 | - | let amDiff = estPut._10 | |
698 | - | let prDiff = estPut._11 | |
699 | - | let lpCalcRes = vad(toBigInt(estimLP), toBigInt(outLp), toBigInt(slippage)) | |
700 | - | let emitLpAmt = toInt(lpCalcRes._2) | |
701 | - | let e = invoke(fca, "emit", [emitLpAmt], nil) | |
702 | - | if ((e == e)) | |
703 | - | then { | |
704 | - | let el = match e { | |
705 | - | case legacy: Address => | |
706 | - | invoke(legacy, "emit", [emitLpAmt], nil) | |
707 | - | case _ => | |
708 | - | unit | |
709 | - | } | |
710 | - | if ((el == el)) | |
711 | - | then { | |
712 | - | let sa = if ((amDiff > 0)) | |
713 | - | then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(amId), amDiff)]) | |
714 | - | else nil | |
715 | - | if ((sa == sa)) | |
716 | - | then { | |
717 | - | let sp = if ((prDiff > 0)) | |
718 | - | then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(prId), prDiff)]) | |
719 | - | else nil | |
720 | - | if ((sp == sp)) | |
721 | - | then { | |
722 | - | let lpTrnsfr = if (autoStake) | |
723 | - | then { | |
724 | - | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
725 | - | if ((ss == ss)) | |
726 | - | then nil | |
727 | - | else throw("Strict value is not equal to itself.") | |
728 | - | } | |
729 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
730 | - | (state ++ lpTrnsfr) | |
731 | - | } | |
732 | - | else throw("Strict value is not equal to itself.") | |
733 | - | } | |
734 | - | else throw("Strict value is not equal to itself.") | |
735 | - | } | |
736 | - | else throw("Strict value is not equal to itself.") | |
737 | - | } | |
738 | - | else throw("Strict value is not equal to itself.") | |
739 | - | } | |
740 | - | else throw("Strict value is not equal to itself.") | |
741 | - | } | |
742 | - | } | |
743 | - | else throw("Strict value is not equal to itself.") | |
744 | - | } | |
745 | - | ||
746 | - | ||
747 | - | ||
748 | - | @Callable(i) | |
749 | - | func putOneTknV2 (minOutAmount,autoStake) = if ((size(i.payments) != 1)) | |
750 | - | then throw("1 pmnt expd") | |
751 | - | else { | |
752 | - | let poolConfig = gpc() | |
753 | - | let amId = poolConfig[idxAmAsId] | |
754 | - | let prId = poolConfig[idxPrAsId] | |
755 | - | let amDecimals = parseIntValue(poolConfig[idxAmtAsDcm]) | |
756 | - | let prDecimals = parseIntValue(poolConfig[idxPriceAsDcm]) | |
757 | - | let userAddress = if ((i.caller == this)) | |
758 | - | then i.originCaller | |
759 | - | else i.caller | |
760 | - | let pmt = value(i.payments[0]) | |
761 | - | let pmtAssetId = toBase58String(value(pmt.assetId)) | |
762 | - | let pmtAmt = pmt.amount | |
763 | - | if ((10000000 > pmtAmt)) | |
764 | - | then throw("Wrong pmt amt") | |
765 | - | else { | |
766 | - | let $t03059830745 = estimatePutOneTknV2(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId)) | |
767 | - | let estimLP = $t03059830745._1 | |
768 | - | let lpAssetId = $t03059830745._2 | |
769 | - | let state = $t03059830745._3 | |
770 | - | let amDiff = $t03059830745._4 | |
771 | - | let prDiff = $t03059830745._5 | |
772 | - | let emitLpAmt = if (if ((minOutAmount > 0)) | |
773 | - | then (minOutAmount > estimLP) | |
774 | - | else false) | |
775 | - | then throw(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
776 | - | else estimLP | |
777 | - | let e = invoke(fca, "emit", [emitLpAmt], nil) | |
778 | - | if ((e == e)) | |
779 | - | then { | |
780 | - | let el = match e { | |
781 | - | case legacy: Address => | |
782 | - | invoke(legacy, "emit", [emitLpAmt], nil) | |
783 | - | case _ => | |
784 | - | unit | |
785 | - | } | |
786 | - | if ((el == el)) | |
635 | + | else $Tuple6(amBalance, (prBalance - paymentAmountRaw), 0, 0, (pmtAmt - prAssetPart), amAssetPart) | |
636 | + | else throw("wrong pmtAssetId") | |
637 | + | let amBalanceNow = $t02485625472._1 | |
638 | + | let prBalanceNow = $t02485625472._2 | |
639 | + | let virtSwapInAm = $t02485625472._3 | |
640 | + | let virtSwapOutPr = $t02485625472._4 | |
641 | + | let virtSwapInPr = $t02485625472._5 | |
642 | + | let virtSwapOutAm = $t02485625472._6 | |
643 | + | let D0 = invoke(gwxCntr, "calcD", [toString(amBalanceNow), toString(prBalanceNow), A, Amult, Dconv], nil) | |
644 | + | let D1 = invoke(gwxCntr, "calcD", [toString(toBigInt(((amBalanceNow + virtSwapInAm) - virtSwapOutAm))), toString(toBigInt(((prBalanceNow + virtSwapInPr) - virtSwapOutPr))), A, Amult, Dconv], nil) | |
645 | + | let D0vsD1 = vd(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D) | |
646 | + | if ((D0vsD1 == D0vsD1)) | |
787 | 647 | then { | |
788 | - | let sa = if ((amDiff > 0)) | |
789 | - | then invoke(slipageContract, "put", nil, [AttachedPayment(fromBase58String(amId), amDiff)]) | |
790 | - | else nil | |
791 | - | if ((sa == sa)) | |
648 | + | let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(fromBase58String(amId), amAssetPart), AttachedPayment(fromBase58String(prId), prAssetPart), slippage, true, true, pmtAmt, pmtAssetId) | |
649 | + | let estimLP = estPut._2 | |
650 | + | let lpAssetId = estPut._7 | |
651 | + | let state = estPut._9 | |
652 | + | let amDiff = estPut._10 | |
653 | + | let prDiff = estPut._11 | |
654 | + | let lpCalcRes = vad(toBigInt(estimLP), toBigInt(outLp), toBigInt(slippage)) | |
655 | + | let emitLpAmt = toInt(lpCalcRes._2) | |
656 | + | let e = invoke(fca, "emit", [emitLpAmt], nil) | |
657 | + | if ((e == e)) | |
792 | 658 | then { | |
793 | - | let sp = if ((prDiff > 0)) | |
794 | - | then invoke(slipageContract, "put", nil, [AttachedPayment(fromBase58String(prId), prDiff)]) | |
795 | - | else nil | |
796 | - | if ((sp == sp)) | |
659 | + | let el = match e { | |
660 | + | case legacy: Address => | |
661 | + | invoke(legacy, "emit", [emitLpAmt], nil) | |
662 | + | case _ => | |
663 | + | unit | |
664 | + | } | |
665 | + | if ((el == el)) | |
797 | 666 | then { | |
798 | - | let lpTrnsfr = if (autoStake) | |
667 | + | let sa = if ((amDiff > 0)) | |
668 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(amId), amDiff)]) | |
669 | + | else nil | |
670 | + | if ((sa == sa)) | |
799 | 671 | then { | |
800 | - | let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
801 | - | if ((ss == ss)) | |
802 | - | then nil | |
672 | + | let sp = if ((prDiff > 0)) | |
673 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(prId), prDiff)]) | |
674 | + | else nil | |
675 | + | if ((sp == sp)) | |
676 | + | then { | |
677 | + | let lpTrnsfr = if (autoStake) | |
678 | + | then { | |
679 | + | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
680 | + | if ((ss == ss)) | |
681 | + | then nil | |
682 | + | else throw("Strict value is not equal to itself.") | |
683 | + | } | |
684 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
685 | + | let sendFeeToMatcher = if ((feeAmount > 0)) | |
686 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))] | |
687 | + | else nil | |
688 | + | ((state ++ lpTrnsfr) ++ sendFeeToMatcher) | |
689 | + | } | |
803 | 690 | else throw("Strict value is not equal to itself.") | |
804 | 691 | } | |
805 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
806 | - | $Tuple2((state ++ lpTrnsfr), emitLpAmt) | |
692 | + | else throw("Strict value is not equal to itself.") | |
807 | 693 | } | |
808 | 694 | else throw("Strict value is not equal to itself.") | |
809 | 695 | } | |
811 | 697 | } | |
812 | 698 | else throw("Strict value is not equal to itself.") | |
813 | 699 | } | |
814 | - | else throw("Strict value is not equal to itself.") | |
815 | 700 | } | |
816 | - | } | |
817 | - | ||
818 | - | ||
819 | - | ||
820 | - | @Callable(i) | |
821 | - | func putOneTknV2READONLY (paymentAmount,paymentAssetId) = { | |
822 | - | let $t03183031938 = estimatePutOneTknV2(paymentAmount, paymentAssetId, "", "") | |
823 | - | let estimLP = $t03183031938._1 | |
824 | - | let lpAssetId = $t03183031938._2 | |
825 | - | let state = $t03183031938._3 | |
826 | - | let amDiff = $t03183031938._4 | |
827 | - | let prDiff = $t03183031938._5 | |
828 | - | $Tuple2(nil, estimLP) | |
829 | 701 | } | |
830 | 702 | ||
831 | 703 | ||
836 | 708 | else if ((size(i.payments) != 2)) | |
837 | 709 | then throw("2 pmnts expd") | |
838 | 710 | else { | |
839 | - | let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], maxSlpg, false, false, | |
711 | + | let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], maxSlpg, false, false, 0, "") | |
840 | 712 | estPut._9 | |
841 | 713 | } | |
842 | 714 | ||
879 | 751 | let txId58 = toBase58String(i.transactionId) | |
880 | 752 | let pmtAssetId = value(pmt.assetId) | |
881 | 753 | let pmtAmt = pmt.amount | |
882 | - | let addonContract = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(ada()), "no addons")), "addon address in not valid") | |
883 | - | let check = reentrantInvoke(addonContract, "ensureCanGetOneTkn", [toString(userAddress)], nil) | |
884 | - | if ((check == check)) | |
885 | - | then if ((1000000000 > pmtAmt)) | |
886 | - | then throw("Min pmt 10 LP") | |
887 | - | else if (if (if ((0 > slippage)) | |
888 | - | then true | |
889 | - | else (0 > exchResult)) | |
890 | - | then true | |
891 | - | else (0 > outAmount)) | |
892 | - | then throw("Wrong params") | |
893 | - | else if ((lpId != toBase58String(pmtAssetId))) | |
894 | - | then throw("Wrong LP") | |
895 | - | else { | |
896 | - | let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
897 | - | let estimAmAmt = r._1 | |
898 | - | let estimPrAmt = r._2 | |
899 | - | let amBalance = getAccBalance(amId) | |
900 | - | let prBalance = getAccBalance(prId) | |
901 | - | let $t03497635433 = if ((outAssetId == amId)) | |
902 | - | then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), exchResult, estimPrAmt, 0, 0, (estimAmAmt + exchResult)) | |
903 | - | else if ((outAssetId == prId)) | |
904 | - | then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), 0, 0, exchResult, estimAmAmt, (estimPrAmt + exchResult)) | |
905 | - | else throw("wrong outAssetId") | |
906 | - | let amBalanceNow = $t03497635433._1 | |
907 | - | let prBalanceNow = $t03497635433._2 | |
908 | - | let virtSwapInAm = $t03497635433._3 | |
909 | - | let virtSwapOutPr = $t03497635433._4 | |
910 | - | let virtSwapInPr = $t03497635433._5 | |
911 | - | let virtSwapOutAm = $t03497635433._6 | |
912 | - | let totalGet = $t03497635433._7 | |
913 | - | if (if ((0 > virtSwapInAm)) | |
914 | - | then true | |
915 | - | else (0 > virtSwapInPr)) | |
916 | - | then throw("Wrong calc") | |
917 | - | else { | |
918 | - | let D0 = invoke(gwxCntr, "calcD", [toString(amBalanceNow), toString(prBalanceNow), A, Amult, Dconv], nil) | |
919 | - | let D1 = invoke(gwxCntr, "calcD", [toString(((amBalanceNow - virtSwapInAm) + virtSwapOutAm)), toString(((prBalanceNow + virtSwapOutPr) - virtSwapInPr)), A, Amult, Dconv], nil) | |
920 | - | let D0vsD1 = vd(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D) | |
921 | - | if ((D0vsD1 == D0vsD1)) | |
922 | - | then { | |
923 | - | let finalRes = vad(toBigInt(totalGet), toBigInt(outAmount), toBigInt(slippage)) | |
924 | - | if ((finalRes == finalRes)) | |
925 | - | then { | |
926 | - | let $t03613836242 = if ((outAssetId == amId)) | |
927 | - | then $Tuple2(toInt(finalRes._2), 0) | |
928 | - | else $Tuple2(0, toInt(finalRes._2)) | |
929 | - | let outAm = $t03613836242._1 | |
930 | - | let outPr = $t03613836242._2 | |
931 | - | let curPrX18 = cpbi(t1(prBalance, prDcm), t1(amBalance, amDcm)) | |
932 | - | let curPr = f1(curPrX18, scale8) | |
933 | - | let state = [ScriptTransfer(userAddress, (outAm + outPr), if ((outAssetId == "WAVES")) | |
934 | - | then unit | |
935 | - | else fromBase58String(outAssetId)), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, pmtAmt, curPr, height, lastBlock.timestamp)), IntegerEntry(pl(), curPr), IntegerEntry(ph(height, lastBlock.timestamp), curPr)] | |
936 | - | if ((state == state)) | |
937 | - | then { | |
938 | - | let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
939 | - | if ((burn == burn)) | |
940 | - | then state | |
941 | - | else throw("Strict value is not equal to itself.") | |
942 | - | } | |
943 | - | else throw("Strict value is not equal to itself.") | |
944 | - | } | |
945 | - | else throw("Strict value is not equal to itself.") | |
946 | - | } | |
947 | - | else throw("Strict value is not equal to itself.") | |
948 | - | } | |
949 | - | } | |
950 | - | else throw("Strict value is not equal to itself.") | |
951 | - | } | |
952 | - | ||
953 | - | ||
954 | - | ||
955 | - | @Callable(i) | |
956 | - | func getOneTknV2 (outAssetId,minOutAmount) = if ((size(i.payments) != 1)) | |
957 | - | then throw("1 pmnt expd") | |
958 | - | else { | |
959 | - | let poolConfig = gpc() | |
960 | - | let lpId = poolConfig[idxLPAsId] | |
961 | - | let amId = poolConfig[idxAmAsId] | |
962 | - | let prId = poolConfig[idxPrAsId] | |
963 | - | let amDecimals = parseIntValue(poolConfig[idxAmtAsDcm]) | |
964 | - | let prDecimals = parseIntValue(poolConfig[idxPriceAsDcm]) | |
965 | - | let poolStatus = poolConfig[idxPoolSt] | |
966 | - | let userAddress = if ((i.caller == this)) | |
967 | - | then i.originCaller | |
968 | - | else i.caller | |
969 | - | let pmt = value(i.payments[0]) | |
970 | - | let pmtAssetId = value(pmt.assetId) | |
971 | - | let pmtAmt = pmt.amount | |
972 | 754 | if ((1000000000 > pmtAmt)) | |
973 | 755 | then throw("Min pmt 10 LP") | |
974 | - | else { | |
975 | - | let txId58 = toBase58String(i.transactionId) | |
976 | - | if ((lpId != toBase58String(pmtAssetId))) | |
756 | + | else if (if (if ((0 > slippage)) | |
757 | + | then true | |
758 | + | else (0 > exchResult)) | |
759 | + | then true | |
760 | + | else (0 > outAmount)) | |
761 | + | then throw("Wrong params") | |
762 | + | else if ((lpId != toBase58String(pmtAssetId))) | |
977 | 763 | then throw("Wrong LP") | |
978 | 764 | else { | |
979 | - | let r = ego( | |
765 | + | let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
980 | 766 | let estimAmAmt = r._1 | |
981 | 767 | let estimPrAmt = r._2 | |
982 | 768 | let amBalance = getAccBalance(amId) | |
983 | 769 | let prBalance = getAccBalance(prId) | |
984 | - | let totalGet = { | |
985 | - | let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil) | |
986 | - | if ($isInstanceOf(@, "Int")) | |
987 | - | then @ | |
988 | - | else throw(($getType(invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil)) + " couldn't be cast to Int")) | |
989 | - | } | |
990 | - | let totalAmount = if (if ((minOutAmount > 0)) | |
991 | - | then (minOutAmount > totalGet) | |
992 | - | else false) | |
993 | - | then throw(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
994 | - | else totalGet | |
995 | - | let $t03819038277 = if ((outAssetId == amId)) | |
996 | - | then $Tuple2(totalAmount, 0) | |
997 | - | else $Tuple2(0, totalAmount) | |
998 | - | let outAm = $t03819038277._1 | |
999 | - | let outPr = $t03819038277._2 | |
1000 | - | let curPrX18 = cpbi(t1(prBalance, prDecimals), t1(amBalance, amDecimals)) | |
1001 | - | let curPr = f1(curPrX18, scale8) | |
1002 | - | let state = [ScriptTransfer(userAddress, totalAmount, if ((outAssetId == "WAVES")) | |
1003 | - | then unit | |
1004 | - | else fromBase58String(outAssetId)), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, pmtAmt, curPr, height, lastBlock.timestamp)), IntegerEntry(pl(), curPr), IntegerEntry(ph(height, lastBlock.timestamp), curPr)] | |
1005 | - | if ((state == state)) | |
1006 | - | then { | |
1007 | - | let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1008 | - | if ((burn == burn)) | |
1009 | - | then $Tuple2(state, totalAmount) | |
770 | + | let $t03041530875 = if ((outAssetId == amId)) | |
771 | + | then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), exchResult, estimPrAmt, 0, 0, (estimAmAmt + exchResult)) | |
772 | + | else if ((outAssetId == prId)) | |
773 | + | then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), 0, 0, exchResult, estimAmAmt, (estimPrAmt + exchResult)) | |
774 | + | else throw("wrong outAssetId") | |
775 | + | let amBalanceNow = $t03041530875._1 | |
776 | + | let prBalanceNow = $t03041530875._2 | |
777 | + | let virtSwapInAm = $t03041530875._3 | |
778 | + | let virtSwapOutPr = $t03041530875._4 | |
779 | + | let virtSwapInPr = $t03041530875._5 | |
780 | + | let virtSwapOutAm = $t03041530875._6 | |
781 | + | let totalGetRaw = $t03041530875._7 | |
782 | + | if (if ((0 > virtSwapInAm)) | |
783 | + | then true | |
784 | + | else (0 > virtSwapInPr)) | |
785 | + | then throw("Wrong calc") | |
786 | + | else { | |
787 | + | let D0 = invoke(gwxCntr, "calcD", [toString(amBalanceNow), toString(prBalanceNow), A, Amult, Dconv], nil) | |
788 | + | let D1 = invoke(gwxCntr, "calcD", [toString(((amBalanceNow - virtSwapInAm) + virtSwapOutAm)), toString(((prBalanceNow + virtSwapOutPr) - virtSwapInPr)), A, Amult, Dconv], nil) | |
789 | + | let D0vsD1 = vd(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D) | |
790 | + | if ((D0vsD1 == D0vsD1)) | |
791 | + | then { | |
792 | + | let totalGet = takeFee(totalGetRaw)._1 | |
793 | + | let finalRes = vad(toBigInt(totalGet), toBigInt(outAmount), toBigInt(slippage)) | |
794 | + | if ((finalRes == finalRes)) | |
795 | + | then { | |
796 | + | let $t03162231726 = if ((outAssetId == amId)) | |
797 | + | then $Tuple2(toInt(finalRes._2), 0) | |
798 | + | else $Tuple2(0, toInt(finalRes._2)) | |
799 | + | let outAm = $t03162231726._1 | |
800 | + | let outPr = $t03162231726._2 | |
801 | + | let totalAmount = (outAm + outPr) | |
802 | + | let feeAmount = (totalGetRaw - totalGet) | |
803 | + | let outAssetIdOrWaves = if ((outAssetId == "WAVES")) | |
804 | + | then unit | |
805 | + | else fromBase58String(outAssetId) | |
806 | + | let sendFeeToMatcher = if ((feeAmount > 0)) | |
807 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)] | |
808 | + | else nil | |
809 | + | let curPrX18 = cpbi(t1(prBalance, prDcm), t1(amBalance, amDcm)) | |
810 | + | let curPr = f1(curPrX18, scale8) | |
811 | + | let state = [ScriptTransfer(userAddress, totalAmount, outAssetIdOrWaves), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, pmtAmt, curPr, height, lastBlock.timestamp)), IntegerEntry(pl(), curPr), IntegerEntry(ph(height, lastBlock.timestamp), curPr)] | |
812 | + | if ((state == state)) | |
813 | + | then { | |
814 | + | let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
815 | + | if ((burn == burn)) | |
816 | + | then (state ++ sendFeeToMatcher) | |
817 | + | else throw("Strict value is not equal to itself.") | |
818 | + | } | |
819 | + | else throw("Strict value is not equal to itself.") | |
820 | + | } | |
821 | + | else throw("Strict value is not equal to itself.") | |
822 | + | } | |
1010 | 823 | else throw("Strict value is not equal to itself.") | |
1011 | 824 | } | |
1012 | - | else throw("Strict value is not equal to itself.") | |
1013 | 825 | } | |
1014 | - | } | |
1015 | 826 | } | |
1016 | - | ||
1017 | - | ||
1018 | - | ||
1019 | - | @Callable(i) | |
1020 | - | func getOneTknV2READONLY (outAssetId,lpAssetAmount) = { | |
1021 | - | let poolConfig = gpc() | |
1022 | - | let lpId = poolConfig[idxLPAsId] | |
1023 | - | let amId = poolConfig[idxAmAsId] | |
1024 | - | let prId = poolConfig[idxPrAsId] | |
1025 | - | let r = ego("", lpId, lpAssetAmount, this) | |
1026 | - | let estimAmAmt = r._1 | |
1027 | - | let estimPrAmt = r._2 | |
1028 | - | let amBalance = getAccBalance(amId) | |
1029 | - | let prBalance = getAccBalance(prId) | |
1030 | - | let amBalanceNow = (amBalance - estimAmAmt) | |
1031 | - | let prBalanceNow = (prBalance - estimPrAmt) | |
1032 | - | let $t03937139642 = if ((outAssetId == amId)) | |
1033 | - | then $Tuple3(prBalanceNow, amBalanceNow, estimPrAmt) | |
1034 | - | else if ((outAssetId == prId)) | |
1035 | - | then $Tuple3(amBalanceNow, prBalanceNow, estimAmAmt) | |
1036 | - | else throw("wrong outAssetId") | |
1037 | - | let amountBalanceForSwap = $t03937139642._1 | |
1038 | - | let priceBalanceForSwap = $t03937139642._2 | |
1039 | - | let amountToSwap = $t03937139642._3 | |
1040 | - | let yPrecision = 1 | |
1041 | - | let exchResult = { | |
1042 | - | let @ = invoke(gwxContract, "calcSwapXToY", [toString(amountToSwap), toString(amountBalanceForSwap), toString(priceBalanceForSwap), "", A, Amult, toString(yPrecision), Dconv], nil) | |
1043 | - | if ($isInstanceOf(@, "Int")) | |
1044 | - | then @ | |
1045 | - | else throw(($getType(invoke(gwxContract, "calcSwapXToY", [toString(amountToSwap), toString(amountBalanceForSwap), toString(priceBalanceForSwap), "", A, Amult, toString(yPrecision), Dconv], nil)) + " couldn't be cast to Int")) | |
1046 | - | } | |
1047 | - | let totalGet = (exchResult + (if ((outAssetId == amId)) | |
1048 | - | then estimAmAmt | |
1049 | - | else estimPrAmt)) | |
1050 | - | $Tuple2(nil, totalGet) | |
1051 | - | } | |
1052 | 827 | ||
1053 | 828 | ||
1054 | 829 | ||
1113 | 888 | ||
1114 | 889 | ||
1115 | 890 | @Callable(i) | |
1116 | - | func unstakeAndGetOneTkn (amount,outAmount,outAssetId,slippage) = { | |
1117 | - | let checkPayments = if ((size(i.payments) != 0)) | |
1118 | - | then throw("No pmnts expd") | |
1119 | - | else true | |
1120 | - | if ((checkPayments == checkPayments)) | |
1121 | - | then { | |
1122 | - | let cfg = gpc() | |
1123 | - | let factoryCfg = gfc() | |
1124 | - | let lpAssetId = fromBase58String(cfg[idxLPAsId]) | |
1125 | - | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr") | |
1126 | - | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1127 | - | if ((unstakeInv == unstakeInv)) | |
1128 | - | then { | |
1129 | - | let outAmountResult = { | |
1130 | - | let @ = invoke(this, "getOneTknV2", [outAmount, outAssetId, slippage], [AttachedPayment(lpAssetId, amount)]) | |
1131 | - | if ($isInstanceOf(@, "Int")) | |
1132 | - | then @ | |
1133 | - | else unit | |
1134 | - | } | |
1135 | - | if ((outAmountResult == outAmountResult)) | |
1136 | - | then $Tuple2(nil, outAmountResult) | |
1137 | - | else throw("Strict value is not equal to itself.") | |
1138 | - | } | |
1139 | - | else throw("Strict value is not equal to itself.") | |
1140 | - | } | |
1141 | - | else throw("Strict value is not equal to itself.") | |
1142 | - | } | |
1143 | - | ||
1144 | - | ||
1145 | - | ||
1146 | - | @Callable(i) | |
1147 | 891 | func activate (amtAsStr,prAsStr) = if ((toString(i.caller) != toString(fca))) | |
1148 | 892 | then throw("denied") | |
1149 | 893 | else $Tuple2([StringEntry(aa(), amtAsStr), StringEntry(pa(), prAsStr)], "success") | |
1198 | 942 | ||
1199 | 943 | ||
1200 | 944 | @Callable(i) | |
1201 | - | func estimatePutOperationWrapperREADONLY (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,usrAddr,isEval,emitLp) = $Tuple2(nil, epo(txId58, slippage, inAmAmt, inAmId, inPrAmt, inPrId, usrAddr, isEval, emitLp, | |
945 | + | func estimatePutOperationWrapperREADONLY (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,usrAddr,isEval,emitLp) = $Tuple2(nil, epo(txId58, slippage, inAmAmt, inAmId, inPrAmt, inPrId, usrAddr, isEval, emitLp, false, 0, "")) | |
1202 | 946 | ||
1203 | 947 | ||
1204 | 948 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let scale8 = 100000000 | |
5 | 5 | ||
6 | 6 | let scale8BigInt = toBigInt(100000000) | |
7 | 7 | ||
8 | 8 | let scale18 = toBigInt(1000000000000000000) | |
9 | + | ||
10 | + | let thousand = 1000 | |
9 | 11 | ||
10 | 12 | let zeroBigInt = toBigInt(0) | |
11 | 13 | ||
12 | 14 | let oneBigInt = toBigInt(1) | |
13 | 15 | ||
14 | 16 | let slippage4D = toBigInt((scale8 - ((scale8 * 1) / scale8))) | |
15 | 17 | ||
16 | 18 | let Amult = "100" | |
17 | 19 | ||
18 | 20 | let Dconv = "1" | |
19 | 21 | ||
20 | 22 | let SEP = "__" | |
21 | 23 | ||
22 | 24 | let EMPTY = "" | |
23 | 25 | ||
24 | 26 | let PoolActive = 1 | |
25 | 27 | ||
26 | 28 | let PoolPutDis = 2 | |
27 | 29 | ||
28 | 30 | let PoolMatcherDis = 3 | |
29 | 31 | ||
30 | 32 | let PoolShutdown = 4 | |
31 | 33 | ||
32 | 34 | let idxPoolAddress = 1 | |
33 | 35 | ||
34 | 36 | let idxPoolSt = 2 | |
35 | 37 | ||
36 | 38 | let idxLPAsId = 3 | |
37 | 39 | ||
38 | 40 | let idxAmAsId = 4 | |
39 | 41 | ||
40 | 42 | let idxPrAsId = 5 | |
41 | 43 | ||
42 | 44 | let idxAmtAsDcm = 6 | |
43 | 45 | ||
44 | 46 | let idxPriceAsDcm = 7 | |
45 | 47 | ||
46 | 48 | let idxIAmtAsId = 8 | |
47 | 49 | ||
48 | 50 | let idxIPriceAsId = 9 | |
49 | 51 | ||
50 | 52 | let idxFactStakCntr = 1 | |
51 | 53 | ||
52 | 54 | let idxFactSlippCntr = 7 | |
53 | 55 | ||
54 | 56 | let idxFactGwxRewCntr = 10 | |
55 | 57 | ||
56 | - | let | |
58 | + | let feePermilleDefault = 0 | |
57 | 59 | ||
58 | 60 | func t1 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult)) | |
59 | 61 | ||
60 | 62 | ||
61 | 63 | func f1 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18)) | |
62 | 64 | ||
63 | 65 | ||
64 | 66 | func ts (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
65 | 67 | ||
66 | 68 | ||
67 | 69 | func abs (val) = if ((zeroBigInt > val)) | |
68 | 70 | then -(val) | |
69 | 71 | else val | |
70 | 72 | ||
71 | 73 | ||
72 | 74 | func fc () = "%s__factoryContract" | |
73 | 75 | ||
74 | 76 | ||
75 | 77 | func mpk () = "%s__managerPublicKey" | |
76 | 78 | ||
77 | 79 | ||
78 | 80 | func pmpk () = "%s__pendingManagerPublicKey" | |
79 | 81 | ||
80 | 82 | ||
81 | 83 | func pl () = "%s%s__price__last" | |
82 | 84 | ||
83 | 85 | ||
84 | 86 | func ph (h,t) = makeString(["%s%s%d%d__price__history", toString(h), toString(t)], SEP) | |
85 | 87 | ||
86 | 88 | ||
87 | 89 | func pau (ua,txId) = ((("%s%s%s__P__" + ua) + "__") + txId) | |
88 | 90 | ||
89 | 91 | ||
90 | 92 | func gau (ua,txId) = ((("%s%s%s__G__" + ua) + "__") + txId) | |
91 | 93 | ||
92 | 94 | ||
93 | 95 | func aa () = "%s__amountAsset" | |
94 | 96 | ||
95 | 97 | ||
96 | 98 | func pa () = "%s__priceAsset" | |
97 | 99 | ||
98 | 100 | ||
99 | 101 | func amp () = "%s__amp" | |
100 | 102 | ||
101 | 103 | ||
102 | 104 | func ada () = "%s__addonAddr" | |
103 | 105 | ||
104 | 106 | ||
105 | - | ||
107 | + | let keyFeePermille = "%s__feePermille" | |
106 | 108 | ||
107 | - | ||
108 | - | func lsotc (caller) = makeString(["%s%s__lastPutOneTknCall", caller], SEP) | |
109 | - | ||
109 | + | let feePermille = valueOrElse(getInteger(this, keyFeePermille), feePermilleDefault) | |
110 | 110 | ||
111 | 111 | func fcfg () = "%s__factoryConfig" | |
112 | 112 | ||
113 | 113 | ||
114 | 114 | func mtpk () = "%s%s__matcher__publicKey" | |
115 | 115 | ||
116 | 116 | ||
117 | 117 | func pc (iAmtAs,iPrAs) = (((("%d%d%s__" + iAmtAs) + "__") + iPrAs) + "__config") | |
118 | 118 | ||
119 | 119 | ||
120 | 120 | func mba (bAStr) = ("%s%s%s__mappings__baseAsset2internalId__" + bAStr) | |
121 | 121 | ||
122 | 122 | ||
123 | 123 | func aps () = "%s__shutdown" | |
124 | 124 | ||
125 | 125 | ||
126 | 126 | func keyAllowedLpStableScriptHash () = "%s__allowedLpStableScriptHash" | |
127 | + | ||
128 | + | ||
129 | + | func keyFeeCollectorAddress () = "%s__feeCollectorAddress" | |
127 | 130 | ||
128 | 131 | ||
129 | 132 | func toe (orV,sendrV,matchV) = throw(((((("Failed: ordValid=" + toString(orV)) + " sndrValid=") + toString(sendrV)) + " mtchrValid=") + toString(matchV))) | |
130 | 133 | ||
131 | 134 | ||
132 | 135 | func str (val) = match val { | |
133 | 136 | case valStr: String => | |
134 | 137 | valStr | |
135 | 138 | case _ => | |
136 | 139 | throw("fail cast to String") | |
137 | 140 | } | |
138 | 141 | ||
139 | 142 | ||
140 | 143 | func strf (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
141 | 144 | ||
142 | 145 | ||
143 | 146 | func intf (addr,key) = valueOrErrorMessage(getInteger(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
144 | 147 | ||
145 | 148 | ||
146 | 149 | let fca = addressFromStringValue(strf(this, fc())) | |
147 | 150 | ||
148 | 151 | let A = strf(this, amp()) | |
149 | 152 | ||
150 | 153 | func igs () = valueOrElse(getBoolean(fca, aps()), false) | |
151 | 154 | ||
152 | 155 | ||
153 | 156 | func mp () = fromBase58String(strf(fca, mtpk())) | |
154 | 157 | ||
155 | 158 | ||
159 | + | let feeCollectorAddress = addressFromStringValue(strf(fca, keyFeeCollectorAddress())) | |
160 | + | ||
156 | 161 | func gpc () = { | |
157 | 162 | let amtAs = strf(this, aa()) | |
158 | 163 | let priceAs = strf(this, pa()) | |
159 | 164 | let iPriceAs = intf(fca, mba(priceAs)) | |
160 | 165 | let iAmtAs = intf(fca, mba(amtAs)) | |
161 | 166 | split(strf(fca, pc(toString(iAmtAs), toString(iPriceAs))), SEP) | |
162 | 167 | } | |
163 | 168 | ||
164 | 169 | ||
165 | 170 | func gfc () = split(strf(fca, fcfg()), SEP) | |
166 | 171 | ||
167 | - | ||
168 | - | let factoryConfig = gfc() | |
169 | - | ||
170 | - | let stakingContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactStakCntr]), "Invalid staking contract address") | |
171 | - | ||
172 | - | let slipageContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactSlippCntr]), "Invalid slipage contract address") | |
173 | - | ||
174 | - | let gwxContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactGwxRewCntr]), "Invalid gwx contract address") | |
175 | 172 | ||
176 | 173 | func dataPutActionInfo (inAmtAssetAmt,inPriceAssetAmt,outLpAmt,price,slipByUser,slippageReal,txHeight,txTimestamp,slipageAmAmt,slipagePrAmt) = makeString(["%d%d%d%d%d%d%d%d%d%d", toString(inAmtAssetAmt), toString(inPriceAssetAmt), toString(outLpAmt), toString(price), toString(slipByUser), toString(slippageReal), toString(txHeight), toString(txTimestamp), toString(slipageAmAmt), toString(slipagePrAmt)], SEP) | |
177 | 174 | ||
178 | 175 | ||
179 | 176 | 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) | |
180 | 177 | ||
181 | 178 | ||
182 | 179 | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
183 | 180 | then wavesBalance(this).available | |
184 | 181 | else assetBalance(this, fromBase58String(assetId)) | |
185 | 182 | ||
186 | 183 | ||
187 | 184 | func cpbi (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
188 | 185 | ||
189 | 186 | ||
190 | 187 | func vad (A1,A2,slippage) = { | |
191 | 188 | let diff = fraction((A1 - A2), scale8BigInt, A2) | |
192 | 189 | let pass = ((slippage - abs(diff)) > zeroBigInt) | |
193 | 190 | if (!(pass)) | |
194 | 191 | then throw(("Big slpg: " + toString(diff))) | |
195 | 192 | else $Tuple2(pass, min([A1, A2])) | |
196 | 193 | } | |
197 | 194 | ||
198 | 195 | ||
199 | 196 | func vd (D1,D0,slpg) = { | |
200 | 197 | let diff = fraction(D0, scale8BigInt, D1) | |
201 | 198 | let fail = (slpg > diff) | |
202 | 199 | if (if (fail) | |
203 | 200 | then true | |
204 | 201 | else (D0 > D1)) | |
205 | 202 | then throw(((((((toString(D0) + " ") + toString(D1)) + " ") + toString(diff)) + " ") + toString(slpg))) | |
206 | 203 | else fail | |
207 | 204 | } | |
208 | 205 | ||
209 | 206 | ||
210 | 207 | func pcp (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
211 | 208 | let amtAsAmtX18 = t1(amAmt, amAssetDcm) | |
212 | 209 | let prAsAmtX18 = t1(prAmt, prAssetDcm) | |
213 | 210 | cpbi(prAsAmtX18, amtAsAmtX18) | |
214 | 211 | } | |
215 | 212 | ||
216 | 213 | ||
217 | 214 | func calcPrices (amAmt,prAmt,lpAmt) = { | |
218 | 215 | let cfg = gpc() | |
219 | 216 | let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
220 | 217 | let prAsDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
221 | 218 | let priceX18 = pcp(amtAsDcm, prAsDcm, amAmt, prAmt) | |
222 | 219 | let amAmtX18 = t1(amAmt, amtAsDcm) | |
223 | 220 | let prAmtX18 = t1(prAmt, prAsDcm) | |
224 | 221 | let lpAmtX18 = t1(lpAmt, scale8) | |
225 | 222 | let lpPrInAmAsX18 = cpbi(amAmtX18, lpAmtX18) | |
226 | 223 | let lpPrInPrAsX18 = cpbi(prAmtX18, lpAmtX18) | |
227 | 224 | [priceX18, lpPrInAmAsX18, lpPrInPrAsX18] | |
228 | 225 | } | |
229 | 226 | ||
230 | 227 | ||
231 | 228 | func calculatePrices (amAmt,prAmt,lpAmt) = { | |
232 | 229 | let p = calcPrices(amAmt, prAmt, lpAmt) | |
233 | 230 | [f1(p[0], scale8), f1(p[1], scale8), f1(p[2], scale8)] | |
234 | 231 | } | |
235 | 232 | ||
236 | 233 | ||
237 | 234 | func ego (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
238 | 235 | let cfg = gpc() | |
239 | 236 | let lpId = cfg[idxLPAsId] | |
240 | 237 | let amId = cfg[idxAmAsId] | |
241 | 238 | let prId = cfg[idxPrAsId] | |
242 | 239 | let amDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
243 | 240 | let prDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
244 | 241 | let sts = cfg[idxPoolSt] | |
245 | 242 | let lpEmiss = valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "Wrong LP id").quantity | |
246 | 243 | if ((lpId != pmtAssetId)) | |
247 | 244 | then throw("Wrong pmt asset") | |
248 | 245 | else { | |
249 | 246 | let amBalance = getAccBalance(amId) | |
250 | 247 | let amBalanceX18 = t1(amBalance, amDcm) | |
251 | 248 | let prBalance = getAccBalance(prId) | |
252 | 249 | let prBalanceX18 = t1(prBalance, prDcm) | |
253 | 250 | let curPriceX18 = cpbi(prBalanceX18, amBalanceX18) | |
254 | 251 | let curPrice = f1(curPriceX18, scale8) | |
255 | 252 | let pmtLpAmtX18 = t1(pmtLpAmt, scale8) | |
256 | 253 | let lpEmissX18 = t1(lpEmiss, scale8) | |
257 | 254 | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissX18) | |
258 | 255 | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissX18) | |
259 | 256 | let outAmAmt = f1(outAmAmtX18, amDcm) | |
260 | 257 | let outPrAmt = f1(outPrAmtX18, prDcm) | |
261 | 258 | let state = if ((txId58 == "")) | |
262 | 259 | then nil | |
263 | 260 | else [ScriptTransfer(userAddress, outAmAmt, if ((amId == "WAVES")) | |
264 | 261 | then unit | |
265 | 262 | else fromBase58String(amId)), ScriptTransfer(userAddress, outPrAmt, if ((prId == "WAVES")) | |
266 | 263 | then unit | |
267 | 264 | else fromBase58String(prId)), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAmAmt, outPrAmt, pmtLpAmt, curPrice, height, lastBlock.timestamp)), IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice)] | |
268 | 265 | $Tuple10(outAmAmt, outPrAmt, amId, prId, amBalance, prBalance, lpEmiss, curPriceX18, sts, state) | |
269 | 266 | } | |
270 | 267 | } | |
271 | 268 | ||
272 | 269 | ||
273 | - | func epo (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,userAddress,isEval,emitLp,isOneAsset, | |
270 | + | func epo (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,userAddress,isEval,emitLp,isOneAsset,pmtAmt,pmtId) = { | |
274 | 271 | let cfg = gpc() | |
275 | 272 | let lpId = fromBase58String(cfg[idxLPAsId]) | |
276 | 273 | let amIdStr = cfg[idxAmAsId] | |
277 | 274 | let prIdStr = cfg[idxPrAsId] | |
278 | 275 | let inAmIdStr = cfg[idxIAmtAsId] | |
279 | 276 | let inPrIdStr = cfg[idxIPriceAsId] | |
280 | 277 | let amtDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
281 | 278 | let priceDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
282 | 279 | let sts = cfg[idxPoolSt] | |
283 | 280 | let lpEm = valueOrErrorMessage(assetInfo(lpId), "Wr lp as").quantity | |
284 | 281 | let amBalance = if (isEval) | |
285 | 282 | then getAccBalance(amIdStr) | |
286 | 283 | else if (if (isOneAsset) | |
287 | 284 | then (pmtId == amIdStr) | |
288 | 285 | else false) | |
289 | 286 | then (getAccBalance(amIdStr) - pmtAmt) | |
290 | 287 | else if (isOneAsset) | |
291 | 288 | then getAccBalance(amIdStr) | |
292 | 289 | else (getAccBalance(amIdStr) - inAmAmt) | |
293 | 290 | let prBalance = if (isEval) | |
294 | 291 | then getAccBalance(prIdStr) | |
295 | 292 | else if (if (isOneAsset) | |
296 | 293 | then (pmtId == prIdStr) | |
297 | 294 | else false) | |
298 | 295 | then (getAccBalance(prIdStr) - pmtAmt) | |
299 | 296 | else if (isOneAsset) | |
300 | 297 | then getAccBalance(prIdStr) | |
301 | 298 | else (getAccBalance(prIdStr) - inPrAmt) | |
302 | 299 | let inAmAssetAmtX18 = t1(inAmAmt, amtDcm) | |
303 | 300 | let inPrAssetAmtX18 = t1(inPrAmt, priceDcm) | |
304 | 301 | let userPriceX18 = cpbi(inPrAssetAmtX18, inAmAssetAmtX18) | |
305 | 302 | let amBalanceX18 = t1(amBalance, amtDcm) | |
306 | 303 | let prBalanceX18 = t1(prBalance, priceDcm) | |
307 | 304 | let r = if ((lpEm == 0)) | |
308 | 305 | then { | |
309 | 306 | let curPriceX18 = zeroBigInt | |
310 | 307 | let slippageX18 = zeroBigInt | |
311 | 308 | let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN) | |
312 | 309 | $Tuple5(f1(lpAmtX18, scale8), f1(inAmAssetAmtX18, amtDcm), f1(inPrAssetAmtX18, priceDcm), cpbi((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
313 | 310 | } | |
314 | 311 | else { | |
315 | 312 | let curPriceX18 = cpbi(prBalanceX18, amBalanceX18) | |
316 | 313 | let slippageRealX18 = fraction(abs((curPriceX18 - userPriceX18)), scale18, curPriceX18) | |
317 | 314 | let slippageX18 = t1(slippage, scale8) | |
318 | - | if (if (if (validateSlippage) | |
319 | - | then (curPriceX18 != zeroBigInt) | |
320 | - | else false) | |
315 | + | if (if ((curPriceX18 != zeroBigInt)) | |
321 | 316 | then (slippageRealX18 > slippageX18) | |
322 | 317 | else false) | |
323 | 318 | then throw(((("Price slippage " + toString(slippageRealX18)) + " > ") + toString(slippageX18))) | |
324 | 319 | else { | |
325 | 320 | let lpEmissionX18 = t1(lpEm, scale8) | |
326 | 321 | let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
327 | 322 | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
328 | 323 | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
329 | 324 | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
330 | 325 | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
331 | 326 | let expAmtAssetAmtX18 = expectedAmts._1 | |
332 | 327 | let expPriceAssetAmtX18 = expectedAmts._2 | |
333 | 328 | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18) | |
334 | 329 | $Tuple5(f1(lpAmtX18, scale8), f1(expAmtAssetAmtX18, amtDcm), f1(expPriceAssetAmtX18, priceDcm), curPriceX18, slippageX18) | |
335 | 330 | } | |
336 | 331 | } | |
337 | 332 | let calcLpAmt = r._1 | |
338 | 333 | let calcAmAssetPmt = r._2 | |
339 | 334 | let calcPrAssetPmt = r._3 | |
340 | 335 | let curPrice = f1(r._4, scale8) | |
341 | 336 | let slippageCalc = f1(r._5, scale8) | |
342 | 337 | if ((0 >= calcLpAmt)) | |
343 | 338 | then throw("LP <= 0") | |
344 | 339 | else { | |
345 | 340 | let emitLpAmt = if (!(emitLp)) | |
346 | 341 | then 0 | |
347 | 342 | else calcLpAmt | |
348 | 343 | let amDiff = (inAmAmt - calcAmAssetPmt) | |
349 | 344 | let prDiff = (inPrAmt - calcPrAssetPmt) | |
350 | - | let $ | |
345 | + | let $t01568216027 = if (if (isOneAsset) | |
351 | 346 | then (pmtId == amIdStr) | |
352 | 347 | else false) | |
353 | 348 | then $Tuple2(pmtAmt, 0) | |
354 | 349 | else if (if (isOneAsset) | |
355 | 350 | then (pmtId == prIdStr) | |
356 | 351 | else false) | |
357 | 352 | then $Tuple2(0, pmtAmt) | |
358 | 353 | else $Tuple2(calcAmAssetPmt, calcPrAssetPmt) | |
359 | - | let writeAmAmt = $ | |
360 | - | let writePrAmt = $ | |
354 | + | let writeAmAmt = $t01568216027._1 | |
355 | + | let writePrAmt = $t01568216027._2 | |
361 | 356 | let commonState = [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(userAddress, txId58), dataPutActionInfo(writeAmAmt, writePrAmt, emitLpAmt, curPrice, slippage, slippageCalc, height, lastBlock.timestamp, amDiff, prDiff))] | |
362 | 357 | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEm, lpId, sts, commonState, amDiff, prDiff, inAmId, inPrId) | |
363 | 358 | } | |
364 | 359 | } | |
365 | 360 | ||
366 | 361 | ||
367 | 362 | func moa (order) = { | |
368 | 363 | let cfg = gpc() | |
369 | 364 | let amtAsId = cfg[idxAmAsId] | |
370 | 365 | let prAsId = cfg[idxPrAsId] | |
371 | 366 | let sts = parseIntValue(cfg[idxPoolSt]) | |
372 | 367 | let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
373 | 368 | let prAsDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
374 | 369 | let accAmtAsBalance = getAccBalance(amtAsId) | |
375 | 370 | let accPrAsBalance = getAccBalance(prAsId) | |
376 | 371 | let curPriceX18 = if ((order.orderType == Buy)) | |
377 | 372 | then pcp(amtAsDcm, prAsDcm, (accAmtAsBalance + order.amount), accPrAsBalance) | |
378 | 373 | else pcp(amtAsDcm, prAsDcm, (accAmtAsBalance - order.amount), accPrAsBalance) | |
379 | 374 | let curPrice = f1(curPriceX18, scale8) | |
380 | 375 | if (if (if (igs()) | |
381 | 376 | then true | |
382 | 377 | else (sts == PoolMatcherDis)) | |
383 | 378 | then true | |
384 | 379 | else (sts == PoolShutdown)) | |
385 | 380 | then throw("Admin blocked") | |
386 | 381 | else { | |
387 | 382 | let orAmtAsset = order.assetPair.amountAsset | |
388 | 383 | let orAmtAsStr = if ((orAmtAsset == unit)) | |
389 | 384 | then "WAVES" | |
390 | 385 | else toBase58String(value(orAmtAsset)) | |
391 | 386 | let orPrAsset = order.assetPair.priceAsset | |
392 | 387 | let orPrAsStr = if ((orPrAsset == unit)) | |
393 | 388 | then "WAVES" | |
394 | 389 | else toBase58String(value(orPrAsset)) | |
395 | 390 | if (if ((orAmtAsStr != amtAsId)) | |
396 | 391 | then true | |
397 | 392 | else (orPrAsStr != prAsId)) | |
398 | 393 | then throw("Wr assets") | |
399 | 394 | else { | |
400 | 395 | let orderPrice = order.price | |
401 | 396 | let priceDcm = fraction(scale8, prAsDcm, amtAsDcm) | |
402 | 397 | let castOrderPrice = ts(orderPrice, scale8, priceDcm) | |
403 | 398 | let isOrderPriceValid = if ((order.orderType == Buy)) | |
404 | 399 | then (curPrice >= castOrderPrice) | |
405 | 400 | else (castOrderPrice >= curPrice) | |
406 | 401 | true | |
407 | 402 | } | |
408 | 403 | } | |
409 | 404 | } | |
410 | 405 | ||
411 | 406 | ||
412 | 407 | func cg (i) = if ((size(i.payments) != 1)) | |
413 | 408 | then throw("1 pmnt exp") | |
414 | 409 | else { | |
415 | 410 | let pmt = value(i.payments[0]) | |
416 | 411 | let pmtAssetId = value(pmt.assetId) | |
417 | 412 | let pmtAmt = pmt.amount | |
418 | 413 | let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
419 | 414 | let outAmAmt = r._1 | |
420 | 415 | let outPrAmt = r._2 | |
421 | 416 | let sts = parseIntValue(r._9) | |
422 | 417 | let state = r._10 | |
423 | 418 | if (if (igs()) | |
424 | 419 | then true | |
425 | 420 | else (sts == PoolShutdown)) | |
426 | 421 | then throw(("Admin blocked: " + toString(sts))) | |
427 | 422 | else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state) | |
428 | 423 | } | |
429 | 424 | ||
430 | 425 | ||
431 | - | func cp (caller,txId,amAsPmt,prAsPmt,slippage,emitLp,isOneAsset, | |
432 | - | let r = epo(txId, slippage, value(amAsPmt).amount, value(amAsPmt).assetId, value(prAsPmt).amount, value(prAsPmt).assetId, caller, false, emitLp, isOneAsset, | |
426 | + | func cp (caller,txId,amAsPmt,prAsPmt,slippage,emitLp,isOneAsset,pmtAmt,pmtId) = { | |
427 | + | let r = epo(txId, slippage, value(amAsPmt).amount, value(amAsPmt).assetId, value(prAsPmt).amount, value(prAsPmt).assetId, caller, false, emitLp, isOneAsset, pmtAmt, pmtId) | |
433 | 428 | let sts = parseIntValue(r._8) | |
434 | 429 | if (if (if (igs()) | |
435 | 430 | then true | |
436 | 431 | else (sts == PoolPutDis)) | |
437 | 432 | then true | |
438 | 433 | else (sts == PoolShutdown)) | |
439 | 434 | then throw(("Blocked:" + toString(sts))) | |
440 | 435 | else r | |
441 | 436 | } | |
442 | 437 | ||
443 | 438 | ||
444 | - | func estimatePutOneTknV2 (pmtAmt,pmtAssetId,userAddress,txId) = { | |
445 | - | let poolConfig = gpc() | |
446 | - | let amId = poolConfig[idxAmAsId] | |
447 | - | let prId = poolConfig[idxPrAsId] | |
448 | - | let amBalance = getAccBalance(amId) | |
449 | - | let prBalance = getAccBalance(prId) | |
450 | - | let $t02075121200 = if ((txId == "")) | |
451 | - | then $Tuple2(amBalance, prBalance) | |
452 | - | else if ((pmtAssetId == amId)) | |
453 | - | then if ((pmtAmt > amBalance)) | |
454 | - | then throw("invalid payment amount") | |
455 | - | else $Tuple2((amBalance - pmtAmt), prBalance) | |
456 | - | else if ((pmtAssetId == prId)) | |
457 | - | then if ((pmtAmt > prBalance)) | |
458 | - | then throw("invalid payment amount") | |
459 | - | else $Tuple2(amBalance, (prBalance - pmtAmt)) | |
460 | - | else throw("wrong pmtAssetId") | |
461 | - | let amBalanceNow = $t02075121200._1 | |
462 | - | let prBalanceNow = $t02075121200._2 | |
463 | - | let $t02120421338 = if ((pmtAssetId == amId)) | |
464 | - | then $Tuple2(amBalanceNow, prBalanceNow) | |
465 | - | else $Tuple2(prBalanceNow, amBalanceNow) | |
466 | - | let amBalanceForCalc = $t02120421338._1 | |
467 | - | let prBalanceForCalc = $t02120421338._2 | |
468 | - | let xPrecision = 1 | |
469 | - | let result = { | |
470 | - | let @ = invoke(gwxContract, "calcPutXOnly", [toString(pmtAmt), toString(amBalanceForCalc), toString(prBalanceForCalc), "", A, Amult, toString(xPrecision), Dconv], nil) | |
471 | - | if ($isInstanceOf(@, "(Int, Int)")) | |
472 | - | then @ | |
473 | - | else throw(($getType(invoke(gwxContract, "calcPutXOnly", [toString(pmtAmt), toString(amBalanceForCalc), toString(prBalanceForCalc), "", A, Amult, toString(xPrecision), Dconv], nil)) + " couldn't be cast to (Int, Int)")) | |
474 | - | } | |
475 | - | let $t02180721903 = if ((pmtAssetId == amId)) | |
476 | - | then result | |
477 | - | else $Tuple2(result._2, result._1) | |
478 | - | let amAssetPart = $t02180721903._1 | |
479 | - | let prAssetPart = $t02180721903._2 | |
480 | - | let estPut = cp(userAddress, txId, AttachedPayment(fromBase58String(amId), amAssetPart), AttachedPayment(fromBase58String(prId), prAssetPart), 0, true, true, false, pmtAmt, pmtAssetId) | |
481 | - | let estimLP = estPut._2 | |
482 | - | let lpAssetId = estPut._7 | |
483 | - | let state = estPut._9 | |
484 | - | let amDiff = estPut._10 | |
485 | - | let prDiff = estPut._11 | |
486 | - | $Tuple5(estimLP, lpAssetId, state, amDiff, prDiff) | |
439 | + | func takeFee (amount) = { | |
440 | + | let fee = fraction(amount, feePermille, thousand) | |
441 | + | $Tuple2((amount - fee), fee) | |
487 | 442 | } | |
488 | 443 | ||
489 | 444 | ||
490 | 445 | func m () = match getString(mpk()) { | |
491 | 446 | case s: String => | |
492 | 447 | fromBase58String(s) | |
493 | 448 | case _: Unit => | |
494 | 449 | unit | |
495 | 450 | case _ => | |
496 | 451 | throw("Match error") | |
497 | 452 | } | |
498 | 453 | ||
499 | 454 | ||
500 | 455 | func pm () = match getString(pmpk()) { | |
501 | 456 | case s: String => | |
502 | 457 | fromBase58String(s) | |
503 | 458 | case _: Unit => | |
504 | 459 | unit | |
505 | 460 | case _ => | |
506 | 461 | throw("Match error") | |
507 | 462 | } | |
508 | 463 | ||
509 | 464 | ||
510 | 465 | let pd = throw("Permission denied") | |
511 | 466 | ||
512 | 467 | func mm (i) = match m() { | |
513 | 468 | case pk: ByteVector => | |
514 | 469 | if ((i.callerPublicKey == pk)) | |
515 | 470 | then true | |
516 | 471 | else pd | |
517 | 472 | case _: Unit => | |
518 | 473 | if ((i.caller == this)) | |
519 | 474 | then true | |
520 | 475 | else pd | |
521 | 476 | case _ => | |
522 | 477 | throw("Match error") | |
523 | 478 | } | |
524 | 479 | ||
525 | 480 | ||
526 | 481 | @Callable(i) | |
527 | 482 | func constructor (fc) = { | |
528 | 483 | let c = mm(i) | |
529 | 484 | if ((c == c)) | |
530 | 485 | then [StringEntry(fc(), fc)] | |
531 | 486 | else throw("Strict value is not equal to itself.") | |
532 | 487 | } | |
533 | 488 | ||
534 | 489 | ||
535 | 490 | ||
536 | 491 | @Callable(i) | |
537 | 492 | func setManager (pendingManagerPublicKey) = { | |
538 | 493 | let c = mm(i) | |
539 | 494 | if ((c == c)) | |
540 | 495 | then { | |
541 | 496 | let cm = fromBase58String(pendingManagerPublicKey) | |
542 | 497 | if ((cm == cm)) | |
543 | 498 | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
544 | 499 | else throw("Strict value is not equal to itself.") | |
545 | 500 | } | |
546 | 501 | else throw("Strict value is not equal to itself.") | |
547 | 502 | } | |
548 | 503 | ||
549 | 504 | ||
550 | 505 | ||
551 | 506 | @Callable(i) | |
552 | 507 | func confirmManager () = { | |
553 | 508 | let p = pm() | |
554 | 509 | let hpm = if (isDefined(p)) | |
555 | 510 | then true | |
556 | 511 | else throw("No pending manager") | |
557 | 512 | if ((hpm == hpm)) | |
558 | 513 | then { | |
559 | 514 | let cpm = if ((i.callerPublicKey == value(p))) | |
560 | 515 | then true | |
561 | 516 | else throw("You are not pending manager") | |
562 | 517 | if ((cpm == cpm)) | |
563 | 518 | then [StringEntry(mpk(), toBase58String(value(p))), DeleteEntry(pmpk())] | |
564 | 519 | else throw("Strict value is not equal to itself.") | |
565 | 520 | } | |
566 | 521 | else throw("Strict value is not equal to itself.") | |
567 | 522 | } | |
568 | 523 | ||
569 | 524 | ||
570 | 525 | ||
571 | 526 | @Callable(i) | |
572 | 527 | func put (slip,autoStake) = { | |
573 | 528 | let factCfg = gfc() | |
574 | 529 | let stakingCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactStakCntr]), "Wr st addr") | |
575 | 530 | let slipCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactSlippCntr]), "Wr sl addr") | |
576 | 531 | if ((0 > slip)) | |
577 | 532 | then throw("Wrong slippage") | |
578 | 533 | else if ((size(i.payments) != 2)) | |
579 | 534 | then throw("2 pmnts expd") | |
580 | 535 | else { | |
581 | - | let e = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], slip, true, false, | |
536 | + | let e = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], slip, true, false, 0, "") | |
582 | 537 | let emitLpAmt = e._2 | |
583 | 538 | let lpAssetId = e._7 | |
584 | 539 | let state = e._9 | |
585 | 540 | let amDiff = e._10 | |
586 | 541 | let prDiff = e._11 | |
587 | 542 | let amId = e._12 | |
588 | 543 | let prId = e._13 | |
589 | 544 | let r = invoke(fca, "emit", [emitLpAmt], nil) | |
590 | 545 | if ((r == r)) | |
591 | 546 | then { | |
592 | 547 | let el = match r { | |
593 | 548 | case legacy: Address => | |
594 | 549 | invoke(legacy, "emit", [emitLpAmt], nil) | |
595 | 550 | case _ => | |
596 | 551 | unit | |
597 | 552 | } | |
598 | 553 | if ((el == el)) | |
599 | 554 | then { | |
600 | 555 | let sa = if ((amDiff > 0)) | |
601 | 556 | then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)]) | |
602 | 557 | else nil | |
603 | 558 | if ((sa == sa)) | |
604 | 559 | then { | |
605 | 560 | let sp = if ((prDiff > 0)) | |
606 | 561 | then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)]) | |
607 | 562 | else nil | |
608 | 563 | if ((sp == sp)) | |
609 | 564 | then { | |
610 | 565 | let lpTrnsfr = if (autoStake) | |
611 | 566 | then { | |
612 | 567 | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
613 | 568 | if ((ss == ss)) | |
614 | 569 | then nil | |
615 | 570 | else throw("Strict value is not equal to itself.") | |
616 | 571 | } | |
617 | 572 | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
618 | 573 | (state ++ lpTrnsfr) | |
619 | 574 | } | |
620 | 575 | else throw("Strict value is not equal to itself.") | |
621 | 576 | } | |
622 | 577 | else throw("Strict value is not equal to itself.") | |
623 | 578 | } | |
624 | 579 | else throw("Strict value is not equal to itself.") | |
625 | 580 | } | |
626 | 581 | else throw("Strict value is not equal to itself.") | |
627 | 582 | } | |
628 | 583 | } | |
629 | 584 | ||
630 | 585 | ||
631 | 586 | ||
632 | 587 | @Callable(i) | |
633 | 588 | func putOneTkn (amAssetPart,prAssetPart,outLp,slippage,autoStake) = { | |
634 | 589 | let cfg = gfc() | |
635 | 590 | let stakingCntr = valueOrErrorMessage(addressFromString(cfg[idxFactStakCntr]), "Wr st addr") | |
636 | 591 | let slipCntr = valueOrErrorMessage(addressFromString(cfg[idxFactSlippCntr]), "Wr sl addr") | |
637 | 592 | let gwxCntr = valueOrErrorMessage(addressFromString(cfg[idxFactGwxRewCntr]), "Wr gwx addr") | |
638 | 593 | let poolCfg = gpc() | |
639 | 594 | let amId = poolCfg[idxAmAsId] | |
640 | 595 | let prId = poolCfg[idxPrAsId] | |
641 | 596 | let amDcm = parseIntValue(poolCfg[idxAmtAsDcm]) | |
642 | 597 | let prDcm = parseIntValue(poolCfg[idxPriceAsDcm]) | |
643 | 598 | let addon = valueOrElse(getString(this, ada()), "") | |
644 | 599 | let userAddress = if ((addon == toString(i.caller))) | |
645 | 600 | then i.originCaller | |
646 | 601 | else i.caller | |
647 | - | let addonContract = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(ada()), "no addons")), "addon address in not valid") | |
648 | - | let check = reentrantInvoke(addonContract, "ensureCanPutOneTkn", [toString(userAddress)], nil) | |
649 | - | if ((check == check)) | |
650 | - | then if (if (if (if ((0 >= slippage)) | |
651 | - | then true | |
652 | - | else (0 >= amAssetPart)) | |
653 | - | then true | |
654 | - | else (0 >= prAssetPart)) | |
655 | - | then true | |
656 | - | else (0 >= outLp)) | |
657 | - | then throw("Wrong params") | |
658 | - | else if ((size(i.payments) != 1)) | |
659 | - | then throw("1 pmnt expd") | |
660 | - | else { | |
661 | - | let pmt = value(i.payments[0]) | |
662 | - | let pmtAssetId = toBase58String(value(pmt.assetId)) | |
663 | - | let pmtAmt = pmt.amount | |
664 | - | if ((10000000 > pmtAmt)) | |
665 | - | then throw("Wrong pmt amt") | |
666 | - | else { | |
667 | - | let amBalance = getAccBalance(amId) | |
668 | - | let prBalance = getAccBalance(prId) | |
669 | - | let $t02731327889 = if ((pmtAssetId == amId)) | |
670 | - | then if (if ((pmtAmt > amBalance)) | |
602 | + | if (if (if (if ((0 >= slippage)) | |
603 | + | then true | |
604 | + | else (0 >= amAssetPart)) | |
605 | + | then true | |
606 | + | else (0 >= prAssetPart)) | |
607 | + | then true | |
608 | + | else (0 >= outLp)) | |
609 | + | then throw("Wrong params") | |
610 | + | else if ((size(i.payments) != 1)) | |
611 | + | then throw("1 pmnt expd") | |
612 | + | else { | |
613 | + | let pmt = value(i.payments[0]) | |
614 | + | let pmtAssetId = toBase58String(value(pmt.assetId)) | |
615 | + | let paymentAmountRaw = pmt.amount | |
616 | + | let $t02464424696 = takeFee(paymentAmountRaw) | |
617 | + | let pmtAmt = $t02464424696._1 | |
618 | + | let feeAmount = $t02464424696._2 | |
619 | + | if ((10000000 > paymentAmountRaw)) | |
620 | + | then throw("Wrong pmt amt") | |
621 | + | else { | |
622 | + | let amBalance = getAccBalance(amId) | |
623 | + | let prBalance = getAccBalance(prId) | |
624 | + | let $t02485625472 = if ((pmtAssetId == amId)) | |
625 | + | then if (if ((paymentAmountRaw > amBalance)) | |
626 | + | then true | |
627 | + | else (amAssetPart > pmtAmt)) | |
628 | + | then throw("invalid payment amount") | |
629 | + | else $Tuple6((amBalance - paymentAmountRaw), prBalance, (pmtAmt - amAssetPart), prAssetPart, 0, 0) | |
630 | + | else if ((pmtAssetId == prId)) | |
631 | + | then if (if ((paymentAmountRaw > prBalance)) | |
671 | 632 | then true | |
672 | - | else ( | |
633 | + | else (prAssetPart > pmtAmt)) | |
673 | 634 | then throw("invalid payment amount") | |
674 | - | else $Tuple6((amBalance - pmtAmt), prBalance, (pmtAmt - amAssetPart), prAssetPart, 0, 0) | |
675 | - | else if ((pmtAssetId == prId)) | |
676 | - | then if (if ((pmtAmt > prBalance)) | |
677 | - | then true | |
678 | - | else (prAssetPart > pmtAmt)) | |
679 | - | then throw("invalid payment amount") | |
680 | - | else $Tuple6(amBalance, (prBalance - pmtAmt), 0, 0, (pmtAmt - prAssetPart), amAssetPart) | |
681 | - | else throw("wrong pmtAssetId") | |
682 | - | let amBalanceNow = $t02731327889._1 | |
683 | - | let prBalanceNow = $t02731327889._2 | |
684 | - | let virtSwapInAm = $t02731327889._3 | |
685 | - | let virtSwapOutPr = $t02731327889._4 | |
686 | - | let virtSwapInPr = $t02731327889._5 | |
687 | - | let virtSwapOutAm = $t02731327889._6 | |
688 | - | let D0 = invoke(gwxCntr, "calcD", [toString(amBalanceNow), toString(prBalanceNow), A, Amult, Dconv], nil) | |
689 | - | let D1 = invoke(gwxCntr, "calcD", [toString(toBigInt(((amBalanceNow + virtSwapInAm) - virtSwapOutAm))), toString(toBigInt(((prBalanceNow + virtSwapInPr) - virtSwapOutPr))), A, Amult, Dconv], nil) | |
690 | - | let D0vsD1 = vd(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D) | |
691 | - | if ((D0vsD1 == D0vsD1)) | |
692 | - | then { | |
693 | - | let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(fromBase58String(amId), amAssetPart), AttachedPayment(fromBase58String(prId), prAssetPart), slippage, true, true, true, pmtAmt, pmtAssetId) | |
694 | - | let estimLP = estPut._2 | |
695 | - | let lpAssetId = estPut._7 | |
696 | - | let state = estPut._9 | |
697 | - | let amDiff = estPut._10 | |
698 | - | let prDiff = estPut._11 | |
699 | - | let lpCalcRes = vad(toBigInt(estimLP), toBigInt(outLp), toBigInt(slippage)) | |
700 | - | let emitLpAmt = toInt(lpCalcRes._2) | |
701 | - | let e = invoke(fca, "emit", [emitLpAmt], nil) | |
702 | - | if ((e == e)) | |
703 | - | then { | |
704 | - | let el = match e { | |
705 | - | case legacy: Address => | |
706 | - | invoke(legacy, "emit", [emitLpAmt], nil) | |
707 | - | case _ => | |
708 | - | unit | |
709 | - | } | |
710 | - | if ((el == el)) | |
711 | - | then { | |
712 | - | let sa = if ((amDiff > 0)) | |
713 | - | then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(amId), amDiff)]) | |
714 | - | else nil | |
715 | - | if ((sa == sa)) | |
716 | - | then { | |
717 | - | let sp = if ((prDiff > 0)) | |
718 | - | then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(prId), prDiff)]) | |
719 | - | else nil | |
720 | - | if ((sp == sp)) | |
721 | - | then { | |
722 | - | let lpTrnsfr = if (autoStake) | |
723 | - | then { | |
724 | - | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
725 | - | if ((ss == ss)) | |
726 | - | then nil | |
727 | - | else throw("Strict value is not equal to itself.") | |
728 | - | } | |
729 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
730 | - | (state ++ lpTrnsfr) | |
731 | - | } | |
732 | - | else throw("Strict value is not equal to itself.") | |
733 | - | } | |
734 | - | else throw("Strict value is not equal to itself.") | |
735 | - | } | |
736 | - | else throw("Strict value is not equal to itself.") | |
737 | - | } | |
738 | - | else throw("Strict value is not equal to itself.") | |
739 | - | } | |
740 | - | else throw("Strict value is not equal to itself.") | |
741 | - | } | |
742 | - | } | |
743 | - | else throw("Strict value is not equal to itself.") | |
744 | - | } | |
745 | - | ||
746 | - | ||
747 | - | ||
748 | - | @Callable(i) | |
749 | - | func putOneTknV2 (minOutAmount,autoStake) = if ((size(i.payments) != 1)) | |
750 | - | then throw("1 pmnt expd") | |
751 | - | else { | |
752 | - | let poolConfig = gpc() | |
753 | - | let amId = poolConfig[idxAmAsId] | |
754 | - | let prId = poolConfig[idxPrAsId] | |
755 | - | let amDecimals = parseIntValue(poolConfig[idxAmtAsDcm]) | |
756 | - | let prDecimals = parseIntValue(poolConfig[idxPriceAsDcm]) | |
757 | - | let userAddress = if ((i.caller == this)) | |
758 | - | then i.originCaller | |
759 | - | else i.caller | |
760 | - | let pmt = value(i.payments[0]) | |
761 | - | let pmtAssetId = toBase58String(value(pmt.assetId)) | |
762 | - | let pmtAmt = pmt.amount | |
763 | - | if ((10000000 > pmtAmt)) | |
764 | - | then throw("Wrong pmt amt") | |
765 | - | else { | |
766 | - | let $t03059830745 = estimatePutOneTknV2(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId)) | |
767 | - | let estimLP = $t03059830745._1 | |
768 | - | let lpAssetId = $t03059830745._2 | |
769 | - | let state = $t03059830745._3 | |
770 | - | let amDiff = $t03059830745._4 | |
771 | - | let prDiff = $t03059830745._5 | |
772 | - | let emitLpAmt = if (if ((minOutAmount > 0)) | |
773 | - | then (minOutAmount > estimLP) | |
774 | - | else false) | |
775 | - | then throw(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
776 | - | else estimLP | |
777 | - | let e = invoke(fca, "emit", [emitLpAmt], nil) | |
778 | - | if ((e == e)) | |
779 | - | then { | |
780 | - | let el = match e { | |
781 | - | case legacy: Address => | |
782 | - | invoke(legacy, "emit", [emitLpAmt], nil) | |
783 | - | case _ => | |
784 | - | unit | |
785 | - | } | |
786 | - | if ((el == el)) | |
635 | + | else $Tuple6(amBalance, (prBalance - paymentAmountRaw), 0, 0, (pmtAmt - prAssetPart), amAssetPart) | |
636 | + | else throw("wrong pmtAssetId") | |
637 | + | let amBalanceNow = $t02485625472._1 | |
638 | + | let prBalanceNow = $t02485625472._2 | |
639 | + | let virtSwapInAm = $t02485625472._3 | |
640 | + | let virtSwapOutPr = $t02485625472._4 | |
641 | + | let virtSwapInPr = $t02485625472._5 | |
642 | + | let virtSwapOutAm = $t02485625472._6 | |
643 | + | let D0 = invoke(gwxCntr, "calcD", [toString(amBalanceNow), toString(prBalanceNow), A, Amult, Dconv], nil) | |
644 | + | let D1 = invoke(gwxCntr, "calcD", [toString(toBigInt(((amBalanceNow + virtSwapInAm) - virtSwapOutAm))), toString(toBigInt(((prBalanceNow + virtSwapInPr) - virtSwapOutPr))), A, Amult, Dconv], nil) | |
645 | + | let D0vsD1 = vd(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D) | |
646 | + | if ((D0vsD1 == D0vsD1)) | |
787 | 647 | then { | |
788 | - | let sa = if ((amDiff > 0)) | |
789 | - | then invoke(slipageContract, "put", nil, [AttachedPayment(fromBase58String(amId), amDiff)]) | |
790 | - | else nil | |
791 | - | if ((sa == sa)) | |
648 | + | let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(fromBase58String(amId), amAssetPart), AttachedPayment(fromBase58String(prId), prAssetPart), slippage, true, true, pmtAmt, pmtAssetId) | |
649 | + | let estimLP = estPut._2 | |
650 | + | let lpAssetId = estPut._7 | |
651 | + | let state = estPut._9 | |
652 | + | let amDiff = estPut._10 | |
653 | + | let prDiff = estPut._11 | |
654 | + | let lpCalcRes = vad(toBigInt(estimLP), toBigInt(outLp), toBigInt(slippage)) | |
655 | + | let emitLpAmt = toInt(lpCalcRes._2) | |
656 | + | let e = invoke(fca, "emit", [emitLpAmt], nil) | |
657 | + | if ((e == e)) | |
792 | 658 | then { | |
793 | - | let sp = if ((prDiff > 0)) | |
794 | - | then invoke(slipageContract, "put", nil, [AttachedPayment(fromBase58String(prId), prDiff)]) | |
795 | - | else nil | |
796 | - | if ((sp == sp)) | |
659 | + | let el = match e { | |
660 | + | case legacy: Address => | |
661 | + | invoke(legacy, "emit", [emitLpAmt], nil) | |
662 | + | case _ => | |
663 | + | unit | |
664 | + | } | |
665 | + | if ((el == el)) | |
797 | 666 | then { | |
798 | - | let lpTrnsfr = if (autoStake) | |
667 | + | let sa = if ((amDiff > 0)) | |
668 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(amId), amDiff)]) | |
669 | + | else nil | |
670 | + | if ((sa == sa)) | |
799 | 671 | then { | |
800 | - | let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
801 | - | if ((ss == ss)) | |
802 | - | then nil | |
672 | + | let sp = if ((prDiff > 0)) | |
673 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(prId), prDiff)]) | |
674 | + | else nil | |
675 | + | if ((sp == sp)) | |
676 | + | then { | |
677 | + | let lpTrnsfr = if (autoStake) | |
678 | + | then { | |
679 | + | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
680 | + | if ((ss == ss)) | |
681 | + | then nil | |
682 | + | else throw("Strict value is not equal to itself.") | |
683 | + | } | |
684 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
685 | + | let sendFeeToMatcher = if ((feeAmount > 0)) | |
686 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))] | |
687 | + | else nil | |
688 | + | ((state ++ lpTrnsfr) ++ sendFeeToMatcher) | |
689 | + | } | |
803 | 690 | else throw("Strict value is not equal to itself.") | |
804 | 691 | } | |
805 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
806 | - | $Tuple2((state ++ lpTrnsfr), emitLpAmt) | |
692 | + | else throw("Strict value is not equal to itself.") | |
807 | 693 | } | |
808 | 694 | else throw("Strict value is not equal to itself.") | |
809 | 695 | } | |
810 | 696 | else throw("Strict value is not equal to itself.") | |
811 | 697 | } | |
812 | 698 | else throw("Strict value is not equal to itself.") | |
813 | 699 | } | |
814 | - | else throw("Strict value is not equal to itself.") | |
815 | 700 | } | |
816 | - | } | |
817 | - | ||
818 | - | ||
819 | - | ||
820 | - | @Callable(i) | |
821 | - | func putOneTknV2READONLY (paymentAmount,paymentAssetId) = { | |
822 | - | let $t03183031938 = estimatePutOneTknV2(paymentAmount, paymentAssetId, "", "") | |
823 | - | let estimLP = $t03183031938._1 | |
824 | - | let lpAssetId = $t03183031938._2 | |
825 | - | let state = $t03183031938._3 | |
826 | - | let amDiff = $t03183031938._4 | |
827 | - | let prDiff = $t03183031938._5 | |
828 | - | $Tuple2(nil, estimLP) | |
829 | 701 | } | |
830 | 702 | ||
831 | 703 | ||
832 | 704 | ||
833 | 705 | @Callable(i) | |
834 | 706 | func putForFree (maxSlpg) = if ((0 > maxSlpg)) | |
835 | 707 | then throw("Wrong slpg") | |
836 | 708 | else if ((size(i.payments) != 2)) | |
837 | 709 | then throw("2 pmnts expd") | |
838 | 710 | else { | |
839 | - | let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], maxSlpg, false, false, | |
711 | + | let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], maxSlpg, false, false, 0, "") | |
840 | 712 | estPut._9 | |
841 | 713 | } | |
842 | 714 | ||
843 | 715 | ||
844 | 716 | ||
845 | 717 | @Callable(i) | |
846 | 718 | func get () = { | |
847 | 719 | let r = cg(i) | |
848 | 720 | let outAmtAmt = r._1 | |
849 | 721 | let outPrAmt = r._2 | |
850 | 722 | let pmtAmt = r._3 | |
851 | 723 | let pmtAssetId = r._4 | |
852 | 724 | let state = r._5 | |
853 | 725 | let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
854 | 726 | if ((b == b)) | |
855 | 727 | then state | |
856 | 728 | else throw("Strict value is not equal to itself.") | |
857 | 729 | } | |
858 | 730 | ||
859 | 731 | ||
860 | 732 | ||
861 | 733 | @Callable(i) | |
862 | 734 | func getOneTkn (exchResult,notUsed,outAmount,outAssetId,slippage) = if ((size(i.payments) != 1)) | |
863 | 735 | then throw("1 pmnt expd") | |
864 | 736 | else { | |
865 | 737 | let cfg = gpc() | |
866 | 738 | let lpId = cfg[idxLPAsId] | |
867 | 739 | let amId = cfg[idxAmAsId] | |
868 | 740 | let prId = cfg[idxPrAsId] | |
869 | 741 | let amDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
870 | 742 | let prDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
871 | 743 | let sts = cfg[idxPoolSt] | |
872 | 744 | let factCfg = gfc() | |
873 | 745 | let gwxCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactGwxRewCntr]), "Wr sl addr") | |
874 | 746 | let pmt = value(i.payments[0]) | |
875 | 747 | let addon = valueOrElse(getString(this, ada()), "") | |
876 | 748 | let userAddress = if ((addon == toString(i.caller))) | |
877 | 749 | then i.originCaller | |
878 | 750 | else i.caller | |
879 | 751 | let txId58 = toBase58String(i.transactionId) | |
880 | 752 | let pmtAssetId = value(pmt.assetId) | |
881 | 753 | let pmtAmt = pmt.amount | |
882 | - | let addonContract = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(ada()), "no addons")), "addon address in not valid") | |
883 | - | let check = reentrantInvoke(addonContract, "ensureCanGetOneTkn", [toString(userAddress)], nil) | |
884 | - | if ((check == check)) | |
885 | - | then if ((1000000000 > pmtAmt)) | |
886 | - | then throw("Min pmt 10 LP") | |
887 | - | else if (if (if ((0 > slippage)) | |
888 | - | then true | |
889 | - | else (0 > exchResult)) | |
890 | - | then true | |
891 | - | else (0 > outAmount)) | |
892 | - | then throw("Wrong params") | |
893 | - | else if ((lpId != toBase58String(pmtAssetId))) | |
894 | - | then throw("Wrong LP") | |
895 | - | else { | |
896 | - | let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
897 | - | let estimAmAmt = r._1 | |
898 | - | let estimPrAmt = r._2 | |
899 | - | let amBalance = getAccBalance(amId) | |
900 | - | let prBalance = getAccBalance(prId) | |
901 | - | let $t03497635433 = if ((outAssetId == amId)) | |
902 | - | then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), exchResult, estimPrAmt, 0, 0, (estimAmAmt + exchResult)) | |
903 | - | else if ((outAssetId == prId)) | |
904 | - | then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), 0, 0, exchResult, estimAmAmt, (estimPrAmt + exchResult)) | |
905 | - | else throw("wrong outAssetId") | |
906 | - | let amBalanceNow = $t03497635433._1 | |
907 | - | let prBalanceNow = $t03497635433._2 | |
908 | - | let virtSwapInAm = $t03497635433._3 | |
909 | - | let virtSwapOutPr = $t03497635433._4 | |
910 | - | let virtSwapInPr = $t03497635433._5 | |
911 | - | let virtSwapOutAm = $t03497635433._6 | |
912 | - | let totalGet = $t03497635433._7 | |
913 | - | if (if ((0 > virtSwapInAm)) | |
914 | - | then true | |
915 | - | else (0 > virtSwapInPr)) | |
916 | - | then throw("Wrong calc") | |
917 | - | else { | |
918 | - | let D0 = invoke(gwxCntr, "calcD", [toString(amBalanceNow), toString(prBalanceNow), A, Amult, Dconv], nil) | |
919 | - | let D1 = invoke(gwxCntr, "calcD", [toString(((amBalanceNow - virtSwapInAm) + virtSwapOutAm)), toString(((prBalanceNow + virtSwapOutPr) - virtSwapInPr)), A, Amult, Dconv], nil) | |
920 | - | let D0vsD1 = vd(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D) | |
921 | - | if ((D0vsD1 == D0vsD1)) | |
922 | - | then { | |
923 | - | let finalRes = vad(toBigInt(totalGet), toBigInt(outAmount), toBigInt(slippage)) | |
924 | - | if ((finalRes == finalRes)) | |
925 | - | then { | |
926 | - | let $t03613836242 = if ((outAssetId == amId)) | |
927 | - | then $Tuple2(toInt(finalRes._2), 0) | |
928 | - | else $Tuple2(0, toInt(finalRes._2)) | |
929 | - | let outAm = $t03613836242._1 | |
930 | - | let outPr = $t03613836242._2 | |
931 | - | let curPrX18 = cpbi(t1(prBalance, prDcm), t1(amBalance, amDcm)) | |
932 | - | let curPr = f1(curPrX18, scale8) | |
933 | - | let state = [ScriptTransfer(userAddress, (outAm + outPr), if ((outAssetId == "WAVES")) | |
934 | - | then unit | |
935 | - | else fromBase58String(outAssetId)), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, pmtAmt, curPr, height, lastBlock.timestamp)), IntegerEntry(pl(), curPr), IntegerEntry(ph(height, lastBlock.timestamp), curPr)] | |
936 | - | if ((state == state)) | |
937 | - | then { | |
938 | - | let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
939 | - | if ((burn == burn)) | |
940 | - | then state | |
941 | - | else throw("Strict value is not equal to itself.") | |
942 | - | } | |
943 | - | else throw("Strict value is not equal to itself.") | |
944 | - | } | |
945 | - | else throw("Strict value is not equal to itself.") | |
946 | - | } | |
947 | - | else throw("Strict value is not equal to itself.") | |
948 | - | } | |
949 | - | } | |
950 | - | else throw("Strict value is not equal to itself.") | |
951 | - | } | |
952 | - | ||
953 | - | ||
954 | - | ||
955 | - | @Callable(i) | |
956 | - | func getOneTknV2 (outAssetId,minOutAmount) = if ((size(i.payments) != 1)) | |
957 | - | then throw("1 pmnt expd") | |
958 | - | else { | |
959 | - | let poolConfig = gpc() | |
960 | - | let lpId = poolConfig[idxLPAsId] | |
961 | - | let amId = poolConfig[idxAmAsId] | |
962 | - | let prId = poolConfig[idxPrAsId] | |
963 | - | let amDecimals = parseIntValue(poolConfig[idxAmtAsDcm]) | |
964 | - | let prDecimals = parseIntValue(poolConfig[idxPriceAsDcm]) | |
965 | - | let poolStatus = poolConfig[idxPoolSt] | |
966 | - | let userAddress = if ((i.caller == this)) | |
967 | - | then i.originCaller | |
968 | - | else i.caller | |
969 | - | let pmt = value(i.payments[0]) | |
970 | - | let pmtAssetId = value(pmt.assetId) | |
971 | - | let pmtAmt = pmt.amount | |
972 | 754 | if ((1000000000 > pmtAmt)) | |
973 | 755 | then throw("Min pmt 10 LP") | |
974 | - | else { | |
975 | - | let txId58 = toBase58String(i.transactionId) | |
976 | - | if ((lpId != toBase58String(pmtAssetId))) | |
756 | + | else if (if (if ((0 > slippage)) | |
757 | + | then true | |
758 | + | else (0 > exchResult)) | |
759 | + | then true | |
760 | + | else (0 > outAmount)) | |
761 | + | then throw("Wrong params") | |
762 | + | else if ((lpId != toBase58String(pmtAssetId))) | |
977 | 763 | then throw("Wrong LP") | |
978 | 764 | else { | |
979 | - | let r = ego( | |
765 | + | let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
980 | 766 | let estimAmAmt = r._1 | |
981 | 767 | let estimPrAmt = r._2 | |
982 | 768 | let amBalance = getAccBalance(amId) | |
983 | 769 | let prBalance = getAccBalance(prId) | |
984 | - | let totalGet = { | |
985 | - | let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil) | |
986 | - | if ($isInstanceOf(@, "Int")) | |
987 | - | then @ | |
988 | - | else throw(($getType(invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil)) + " couldn't be cast to Int")) | |
989 | - | } | |
990 | - | let totalAmount = if (if ((minOutAmount > 0)) | |
991 | - | then (minOutAmount > totalGet) | |
992 | - | else false) | |
993 | - | then throw(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
994 | - | else totalGet | |
995 | - | let $t03819038277 = if ((outAssetId == amId)) | |
996 | - | then $Tuple2(totalAmount, 0) | |
997 | - | else $Tuple2(0, totalAmount) | |
998 | - | let outAm = $t03819038277._1 | |
999 | - | let outPr = $t03819038277._2 | |
1000 | - | let curPrX18 = cpbi(t1(prBalance, prDecimals), t1(amBalance, amDecimals)) | |
1001 | - | let curPr = f1(curPrX18, scale8) | |
1002 | - | let state = [ScriptTransfer(userAddress, totalAmount, if ((outAssetId == "WAVES")) | |
1003 | - | then unit | |
1004 | - | else fromBase58String(outAssetId)), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, pmtAmt, curPr, height, lastBlock.timestamp)), IntegerEntry(pl(), curPr), IntegerEntry(ph(height, lastBlock.timestamp), curPr)] | |
1005 | - | if ((state == state)) | |
1006 | - | then { | |
1007 | - | let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1008 | - | if ((burn == burn)) | |
1009 | - | then $Tuple2(state, totalAmount) | |
770 | + | let $t03041530875 = if ((outAssetId == amId)) | |
771 | + | then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), exchResult, estimPrAmt, 0, 0, (estimAmAmt + exchResult)) | |
772 | + | else if ((outAssetId == prId)) | |
773 | + | then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), 0, 0, exchResult, estimAmAmt, (estimPrAmt + exchResult)) | |
774 | + | else throw("wrong outAssetId") | |
775 | + | let amBalanceNow = $t03041530875._1 | |
776 | + | let prBalanceNow = $t03041530875._2 | |
777 | + | let virtSwapInAm = $t03041530875._3 | |
778 | + | let virtSwapOutPr = $t03041530875._4 | |
779 | + | let virtSwapInPr = $t03041530875._5 | |
780 | + | let virtSwapOutAm = $t03041530875._6 | |
781 | + | let totalGetRaw = $t03041530875._7 | |
782 | + | if (if ((0 > virtSwapInAm)) | |
783 | + | then true | |
784 | + | else (0 > virtSwapInPr)) | |
785 | + | then throw("Wrong calc") | |
786 | + | else { | |
787 | + | let D0 = invoke(gwxCntr, "calcD", [toString(amBalanceNow), toString(prBalanceNow), A, Amult, Dconv], nil) | |
788 | + | let D1 = invoke(gwxCntr, "calcD", [toString(((amBalanceNow - virtSwapInAm) + virtSwapOutAm)), toString(((prBalanceNow + virtSwapOutPr) - virtSwapInPr)), A, Amult, Dconv], nil) | |
789 | + | let D0vsD1 = vd(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D) | |
790 | + | if ((D0vsD1 == D0vsD1)) | |
791 | + | then { | |
792 | + | let totalGet = takeFee(totalGetRaw)._1 | |
793 | + | let finalRes = vad(toBigInt(totalGet), toBigInt(outAmount), toBigInt(slippage)) | |
794 | + | if ((finalRes == finalRes)) | |
795 | + | then { | |
796 | + | let $t03162231726 = if ((outAssetId == amId)) | |
797 | + | then $Tuple2(toInt(finalRes._2), 0) | |
798 | + | else $Tuple2(0, toInt(finalRes._2)) | |
799 | + | let outAm = $t03162231726._1 | |
800 | + | let outPr = $t03162231726._2 | |
801 | + | let totalAmount = (outAm + outPr) | |
802 | + | let feeAmount = (totalGetRaw - totalGet) | |
803 | + | let outAssetIdOrWaves = if ((outAssetId == "WAVES")) | |
804 | + | then unit | |
805 | + | else fromBase58String(outAssetId) | |
806 | + | let sendFeeToMatcher = if ((feeAmount > 0)) | |
807 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)] | |
808 | + | else nil | |
809 | + | let curPrX18 = cpbi(t1(prBalance, prDcm), t1(amBalance, amDcm)) | |
810 | + | let curPr = f1(curPrX18, scale8) | |
811 | + | let state = [ScriptTransfer(userAddress, totalAmount, outAssetIdOrWaves), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, pmtAmt, curPr, height, lastBlock.timestamp)), IntegerEntry(pl(), curPr), IntegerEntry(ph(height, lastBlock.timestamp), curPr)] | |
812 | + | if ((state == state)) | |
813 | + | then { | |
814 | + | let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
815 | + | if ((burn == burn)) | |
816 | + | then (state ++ sendFeeToMatcher) | |
817 | + | else throw("Strict value is not equal to itself.") | |
818 | + | } | |
819 | + | else throw("Strict value is not equal to itself.") | |
820 | + | } | |
821 | + | else throw("Strict value is not equal to itself.") | |
822 | + | } | |
1010 | 823 | else throw("Strict value is not equal to itself.") | |
1011 | 824 | } | |
1012 | - | else throw("Strict value is not equal to itself.") | |
1013 | 825 | } | |
1014 | - | } | |
1015 | 826 | } | |
1016 | - | ||
1017 | - | ||
1018 | - | ||
1019 | - | @Callable(i) | |
1020 | - | func getOneTknV2READONLY (outAssetId,lpAssetAmount) = { | |
1021 | - | let poolConfig = gpc() | |
1022 | - | let lpId = poolConfig[idxLPAsId] | |
1023 | - | let amId = poolConfig[idxAmAsId] | |
1024 | - | let prId = poolConfig[idxPrAsId] | |
1025 | - | let r = ego("", lpId, lpAssetAmount, this) | |
1026 | - | let estimAmAmt = r._1 | |
1027 | - | let estimPrAmt = r._2 | |
1028 | - | let amBalance = getAccBalance(amId) | |
1029 | - | let prBalance = getAccBalance(prId) | |
1030 | - | let amBalanceNow = (amBalance - estimAmAmt) | |
1031 | - | let prBalanceNow = (prBalance - estimPrAmt) | |
1032 | - | let $t03937139642 = if ((outAssetId == amId)) | |
1033 | - | then $Tuple3(prBalanceNow, amBalanceNow, estimPrAmt) | |
1034 | - | else if ((outAssetId == prId)) | |
1035 | - | then $Tuple3(amBalanceNow, prBalanceNow, estimAmAmt) | |
1036 | - | else throw("wrong outAssetId") | |
1037 | - | let amountBalanceForSwap = $t03937139642._1 | |
1038 | - | let priceBalanceForSwap = $t03937139642._2 | |
1039 | - | let amountToSwap = $t03937139642._3 | |
1040 | - | let yPrecision = 1 | |
1041 | - | let exchResult = { | |
1042 | - | let @ = invoke(gwxContract, "calcSwapXToY", [toString(amountToSwap), toString(amountBalanceForSwap), toString(priceBalanceForSwap), "", A, Amult, toString(yPrecision), Dconv], nil) | |
1043 | - | if ($isInstanceOf(@, "Int")) | |
1044 | - | then @ | |
1045 | - | else throw(($getType(invoke(gwxContract, "calcSwapXToY", [toString(amountToSwap), toString(amountBalanceForSwap), toString(priceBalanceForSwap), "", A, Amult, toString(yPrecision), Dconv], nil)) + " couldn't be cast to Int")) | |
1046 | - | } | |
1047 | - | let totalGet = (exchResult + (if ((outAssetId == amId)) | |
1048 | - | then estimAmAmt | |
1049 | - | else estimPrAmt)) | |
1050 | - | $Tuple2(nil, totalGet) | |
1051 | - | } | |
1052 | 827 | ||
1053 | 828 | ||
1054 | 829 | ||
1055 | 830 | @Callable(i) | |
1056 | 831 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
1057 | 832 | let r = cg(i) | |
1058 | 833 | let outAmAmt = r._1 | |
1059 | 834 | let outPrAmt = r._2 | |
1060 | 835 | let pmtAmt = r._3 | |
1061 | 836 | let pmtAssetId = r._4 | |
1062 | 837 | let state = r._5 | |
1063 | 838 | if ((noLessThenAmtAsset > outAmAmt)) | |
1064 | 839 | then throw(((("Failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
1065 | 840 | else if ((noLessThenPriceAsset > outPrAmt)) | |
1066 | 841 | then throw(((("Failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
1067 | 842 | else { | |
1068 | 843 | let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1069 | 844 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1070 | 845 | then state | |
1071 | 846 | else throw("Strict value is not equal to itself.") | |
1072 | 847 | } | |
1073 | 848 | } | |
1074 | 849 | ||
1075 | 850 | ||
1076 | 851 | ||
1077 | 852 | @Callable(i) | |
1078 | 853 | func unstakeAndGet (amount) = { | |
1079 | 854 | let checkPayments = if ((size(i.payments) != 0)) | |
1080 | 855 | then throw("No pmnts expd") | |
1081 | 856 | else true | |
1082 | 857 | if ((checkPayments == checkPayments)) | |
1083 | 858 | then { | |
1084 | 859 | let cfg = gpc() | |
1085 | 860 | let factoryCfg = gfc() | |
1086 | 861 | let lpAssetId = fromBase58String(cfg[idxLPAsId]) | |
1087 | 862 | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr") | |
1088 | 863 | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1089 | 864 | if ((unstakeInv == unstakeInv)) | |
1090 | 865 | then { | |
1091 | 866 | let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1092 | 867 | let sts = parseIntValue(r._9) | |
1093 | 868 | let state = r._10 | |
1094 | 869 | let v = if (if (igs()) | |
1095 | 870 | then true | |
1096 | 871 | else (sts == PoolShutdown)) | |
1097 | 872 | then throw(("Blocked: " + toString(sts))) | |
1098 | 873 | else true | |
1099 | 874 | if ((v == v)) | |
1100 | 875 | then { | |
1101 | 876 | let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1102 | 877 | if ((burnA == burnA)) | |
1103 | 878 | then state | |
1104 | 879 | else throw("Strict value is not equal to itself.") | |
1105 | 880 | } | |
1106 | 881 | else throw("Strict value is not equal to itself.") | |
1107 | 882 | } | |
1108 | 883 | else throw("Strict value is not equal to itself.") | |
1109 | 884 | } | |
1110 | 885 | else throw("Strict value is not equal to itself.") | |
1111 | 886 | } | |
1112 | 887 | ||
1113 | 888 | ||
1114 | 889 | ||
1115 | 890 | @Callable(i) | |
1116 | - | func unstakeAndGetOneTkn (amount,outAmount,outAssetId,slippage) = { | |
1117 | - | let checkPayments = if ((size(i.payments) != 0)) | |
1118 | - | then throw("No pmnts expd") | |
1119 | - | else true | |
1120 | - | if ((checkPayments == checkPayments)) | |
1121 | - | then { | |
1122 | - | let cfg = gpc() | |
1123 | - | let factoryCfg = gfc() | |
1124 | - | let lpAssetId = fromBase58String(cfg[idxLPAsId]) | |
1125 | - | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr") | |
1126 | - | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1127 | - | if ((unstakeInv == unstakeInv)) | |
1128 | - | then { | |
1129 | - | let outAmountResult = { | |
1130 | - | let @ = invoke(this, "getOneTknV2", [outAmount, outAssetId, slippage], [AttachedPayment(lpAssetId, amount)]) | |
1131 | - | if ($isInstanceOf(@, "Int")) | |
1132 | - | then @ | |
1133 | - | else unit | |
1134 | - | } | |
1135 | - | if ((outAmountResult == outAmountResult)) | |
1136 | - | then $Tuple2(nil, outAmountResult) | |
1137 | - | else throw("Strict value is not equal to itself.") | |
1138 | - | } | |
1139 | - | else throw("Strict value is not equal to itself.") | |
1140 | - | } | |
1141 | - | else throw("Strict value is not equal to itself.") | |
1142 | - | } | |
1143 | - | ||
1144 | - | ||
1145 | - | ||
1146 | - | @Callable(i) | |
1147 | 891 | func activate (amtAsStr,prAsStr) = if ((toString(i.caller) != toString(fca))) | |
1148 | 892 | then throw("denied") | |
1149 | 893 | else $Tuple2([StringEntry(aa(), amtAsStr), StringEntry(pa(), prAsStr)], "success") | |
1150 | 894 | ||
1151 | 895 | ||
1152 | 896 | ||
1153 | 897 | @Callable(i) | |
1154 | 898 | func setS (k,v) = if ((toString(i.caller) != strf(this, ada()))) | |
1155 | 899 | then pd | |
1156 | 900 | else [StringEntry(k, v)] | |
1157 | 901 | ||
1158 | 902 | ||
1159 | 903 | ||
1160 | 904 | @Callable(i) | |
1161 | 905 | func setI (k,v) = if ((toString(i.caller) != strf(this, ada()))) | |
1162 | 906 | then pd | |
1163 | 907 | else [IntegerEntry(k, v)] | |
1164 | 908 | ||
1165 | 909 | ||
1166 | 910 | ||
1167 | 911 | @Callable(i) | |
1168 | 912 | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, gpc()) | |
1169 | 913 | ||
1170 | 914 | ||
1171 | 915 | ||
1172 | 916 | @Callable(i) | |
1173 | 917 | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
1174 | 918 | ||
1175 | 919 | ||
1176 | 920 | ||
1177 | 921 | @Callable(i) | |
1178 | 922 | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
1179 | 923 | let pr = calcPrices(amAmt, prAmt, lpAmt) | |
1180 | 924 | $Tuple2(nil, [toString(pr[0]), toString(pr[1]), toString(pr[2])]) | |
1181 | 925 | } | |
1182 | 926 | ||
1183 | 927 | ||
1184 | 928 | ||
1185 | 929 | @Callable(i) | |
1186 | 930 | func fromX18WrapperREADONLY (val,resScaleMult) = $Tuple2(nil, f1(parseBigIntValue(val), resScaleMult)) | |
1187 | 931 | ||
1188 | 932 | ||
1189 | 933 | ||
1190 | 934 | @Callable(i) | |
1191 | 935 | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(t1(origVal, origScaleMult))) | |
1192 | 936 | ||
1193 | 937 | ||
1194 | 938 | ||
1195 | 939 | @Callable(i) | |
1196 | 940 | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(cpbi(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
1197 | 941 | ||
1198 | 942 | ||
1199 | 943 | ||
1200 | 944 | @Callable(i) | |
1201 | - | func estimatePutOperationWrapperREADONLY (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,usrAddr,isEval,emitLp) = $Tuple2(nil, epo(txId58, slippage, inAmAmt, inAmId, inPrAmt, inPrId, usrAddr, isEval, emitLp, | |
945 | + | func estimatePutOperationWrapperREADONLY (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,usrAddr,isEval,emitLp) = $Tuple2(nil, epo(txId58, slippage, inAmAmt, inAmId, inPrAmt, inPrId, usrAddr, isEval, emitLp, false, 0, "")) | |
1202 | 946 | ||
1203 | 947 | ||
1204 | 948 | ||
1205 | 949 | @Callable(i) | |
1206 | 950 | func estimateGetOperationWrapperREADONLY (txId58,pmtAsId,pmtLpAmt,usrAddr) = { | |
1207 | 951 | let r = ego(txId58, pmtAsId, pmtLpAmt, addressFromStringValue(usrAddr)) | |
1208 | 952 | $Tuple2(nil, $Tuple10(r._1, r._2, r._3, r._4, r._5, r._6, r._7, toString(r._8), r._9, r._10)) | |
1209 | 953 | } | |
1210 | 954 | ||
1211 | 955 | ||
1212 | 956 | @Verifier(tx) | |
1213 | 957 | func verify () = { | |
1214 | 958 | let targetPublicKey = match m() { | |
1215 | 959 | case pk: ByteVector => | |
1216 | 960 | pk | |
1217 | 961 | case _: Unit => | |
1218 | 962 | tx.senderPublicKey | |
1219 | 963 | case _ => | |
1220 | 964 | throw("Match error") | |
1221 | 965 | } | |
1222 | 966 | match tx { | |
1223 | 967 | case order: Order => | |
1224 | 968 | let matcherPub = mp() | |
1225 | 969 | let orderValid = moa(order) | |
1226 | 970 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1227 | 971 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1228 | 972 | if (if (if (orderValid) | |
1229 | 973 | then senderValid | |
1230 | 974 | else false) | |
1231 | 975 | then matcherValid | |
1232 | 976 | else false) | |
1233 | 977 | then true | |
1234 | 978 | else toe(orderValid, senderValid, matcherValid) | |
1235 | 979 | case s: SetScriptTransaction => | |
1236 | 980 | let newHash = blake2b256(value(s.script)) | |
1237 | 981 | let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash()))) | |
1238 | 982 | let currentHash = scriptHash(this) | |
1239 | 983 | if (if ((allowedHash == newHash)) | |
1240 | 984 | then (currentHash != newHash) | |
1241 | 985 | else false) | |
1242 | 986 | then true | |
1243 | 987 | else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1244 | 988 | case _ => | |
1245 | 989 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1246 | 990 | } | |
1247 | 991 | } | |
1248 | 992 |
github/deemru/w8io/026f985 117.61 ms ◑