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