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