tx · 6vWHKPrcDdxNyXNE7JYQG8PE21zdJ7Rc3cWnVz2ifVHL

3N6wAa7PMFZJu4Zrmp3avXmMnRTrRpMM9Lh:  -0.03200000 Waves

2023.01.26 14:16 [2421866] smart account 3N6wAa7PMFZJu4Zrmp3avXmMnRTrRpMM9Lh > SELF 0.00000000 Waves

{ "type": 13, "id": "6vWHKPrcDdxNyXNE7JYQG8PE21zdJ7Rc3cWnVz2ifVHL", "fee": 3200000, "feeAssetId": null, "timestamp": 1674731775812, "version": 1, "sender": "3N6wAa7PMFZJu4Zrmp3avXmMnRTrRpMM9Lh", "senderPublicKey": "Cr8D7eozSzJh7XHsYTjBinPpo3SS83BrCGiBAJsjGxBo", "proofs": [ "61wqGyiTKLUPiyskDHFYLtzEhNhXdXG8RRqouSAs64vfwu9JcqP9T7myuggGf8ocZtEAgoRmtvKuEojseC5U31Aw" ], "script": "base64:BgLmKAgCEgQKAgEEEgYKBAEEAQgSAwoBCBIAEgQKAgEEEgMKAQESBAoCAQQSBAoCCAESBAoCCAESBAoCCAESBQoDAQgBEgASBAoCAQESAwoBARIFCgMBAQESBAoCCAgSABIDCgEIEgUKAwEBARIECgIBARIECgIIARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCBIAEgMKAQESAwoBARIECgIIASIKbFBkZWNpbWFscyIGc2NhbGU4IgxzY2FsZThCaWdJbnQiB3NjYWxlMTgiCnplcm9CaWdJbnQiBGJpZzAiBGJpZzEiBGJpZzIiC3dhdmVzU3RyaW5nIgNTRVAiClBvb2xBY3RpdmUiD1Bvb2xQdXREaXNhYmxlZCITUG9vbE1hdGNoZXJEaXNhYmxlZCIMUG9vbFNodXRkb3duIg5pZHhQb29sQWRkcmVzcyINaWR4UG9vbFN0YXR1cyIQaWR4UG9vbExQQXNzZXRJZCINaWR4QW10QXNzZXRJZCIPaWR4UHJpY2VBc3NldElkIg5pZHhBbXRBc3NldERjbSIQaWR4UHJpY2VBc3NldERjbSIOaWR4SUFtdEFzc2V0SWQiEG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yNo0Q==", "chainId": 84, "height": 2421866, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3rfJiadgVTTpnsXW2tT1jRzRXJZo1qEci2rq3bYZrzDg Next: 7ZKiFqfDuHtwfHNjhvyrBicXyv778KcdsvKsbXTK2g23 Diff:
OldNewDifferences
6262 func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult))
6363
6464
65-func toX18BigInt (origVal,origScaleMult) = fraction(origVal, scale18, origScaleMult)
66-
67-
6865 func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18))
69-
70-
71-func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round))
7266
7367
7468 func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale)
8276 func absBigInt (val) = if ((zeroBigInt > val))
8377 then -(val)
8478 else val
79+
80+
81+func swapContract () = "%s__swapContract"
8582
8683
8784 func fc () = "%s__factoryContract"
111108 func pa () = "%s__priceAsset"
112109
113110
114-let keyFee = "%s__fee"
115-
116-let feeDefault = fraction(10, scale8, 10000)
117-
118-let fee = valueOrElse(getInteger(this, keyFee), feeDefault)
119-
120-let keyKLp = makeString(["%s", "kLp"], SEP)
121-
122-let keyKLpRefreshedHeight = makeString(["%s", "kLpRefreshedHeight"], SEP)
123-
124-let keyKLpRefreshDelay = makeString(["%s", "refreshKLpDelay"], SEP)
125-
126-let kLpRefreshDelayDefault = 30
127-
128-let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault)
129-
130111 func keyFactoryConfig () = "%s__factoryConfig"
131112
132113
153134
154135 let keyFeeCollectorAddress = "%s__feeCollectorAddress"
155136
156-func throwOrderError (orderValid,orderValidInfo,senderValid,matcherValid) = throw((((((((("order validation failed: orderValid=" + toString(orderValid)) + " (") + orderValidInfo) + ")") + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid)))
137+func throwOrderError (orderValid,senderValid,matcherValid) = throw(((((("order validation failed: orderValid=" + toString(orderValid)) + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid)))
157138
158139
159140 func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
163144
164145
165146 func throwErr (msg) = throw(makeString(["lp.ride:", msg], " "))
166-
167-
168-func fmtErr (msg) = makeString(["lp.ride:", msg], " ")
169147
170148
171149 let factoryContract = addressFromStringValue(getStringOrFail(this, fc()))
216194
217195 let poolConfigParsed = parsePoolConfig(getPoolConfig())
218196
219-let $t084088574 = poolConfigParsed
197+let $t076627828 = poolConfigParsed
220198
221-let cfgPoolAddress = $t084088574._1
199+let cfgPoolAddress = $t076627828._1
222200
223-let cfgPoolStatus = $t084088574._2
201+let cfgPoolStatus = $t076627828._2
224202
225-let cfgLpAssetId = $t084088574._3
203+let cfgLpAssetId = $t076627828._3
226204
227-let cfgAmountAssetId = $t084088574._4
205+let cfgAmountAssetId = $t076627828._4
228206
229-let cfgPriceAssetId = $t084088574._5
207+let cfgPriceAssetId = $t076627828._5
230208
231-let cfgAmountAssetDecimals = $t084088574._6
209+let cfgAmountAssetDecimals = $t076627828._6
232210
233-let cfgPriceAssetDecimals = $t084088574._7
211+let cfgPriceAssetDecimals = $t076627828._7
234212
235213 func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
236214
251229
252230
253231 func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
254-
255-
256-func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
257232
258233
259234 func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
305280 let lpEmissionX18 = toX18(lpEmission, scale8)
306281 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18)
307282 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18)
308- let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR)
309- let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR)
283+ let outAmAmt = fromX18(outAmAmtX18, amAssetDcm)
284+ let outPrAmt = fromX18(outPrAmtX18, prAssetDcm)
310285 let state = if ((txId58 == ""))
311286 then nil
312287 else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES"))
365340 then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18)))
366341 else {
367342 let lpEmissionX18 = toX18(lpEmission, scale8)
368- let prViaAmX18 = fraction(inAmAssetAmtX18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING)
369- let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, FLOOR), CEILING)
343+ let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
344+ let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
370345 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
371346 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
372347 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
373348 let expAmtAssetAmtX18 = expectedAmts._1
374349 let expPriceAssetAmtX18 = expectedAmts._2
375- let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR)
376- $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtAssetDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceAssetDcm, CEILING), curPriceX18, slippageX18)
350+ let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
351+ $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18)
377352 }
378353 }
379354 let calcLpAmt = res._1
396371 }
397372
398373
399-func calcKLp (amountBalance,priceBalance,lpEmission) = {
400- let amountBalanceX18 = toX18BigInt(amountBalance, toBigInt(cfgAmountAssetDecimals))
401- let priceBalanceX18 = toX18BigInt(priceBalance, toBigInt(cfgPriceAssetDecimals))
402- let updatedKLp = fraction(pow((amountBalanceX18 * priceBalanceX18), 0, toBigInt(5), 1, 18, DOWN), big1, lpEmission)
403- if ((lpEmission == big0))
404- then big0
405- else updatedKLp
406- }
407-
408-
409-func calcCurrentKLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = {
410- let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta)
411- let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta)
412- let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta)
413- let currentKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpAssetEmission)
414- currentKLp
415- }
416-
417-
418-func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = {
419- let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta)
420- let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta)
421- let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta)
422- let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission))
423- let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))]
424- $Tuple2(actions, updatedKLp)
425- }
426-
427-
428-func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp))
429- then true
430- else throwErr(makeString(["updated KLp lower than current KLp", toString(oldKLp), toString(updatedKLp)], " "))
431-
432-
433374 func validateMatcherOrderAllowed (order) = {
434- let amountAssetBalance = getAccBalance(assetIdToString(cfgAmountAssetId))
435- let priceAssetBalance = getAccBalance(assetIdToString(cfgPriceAssetId))
436- let amountAssetAmount = order.amount
437- let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR)
438- let $t02148021692 = if ((order.orderType == Buy))
439- then $Tuple2(amountAssetAmount, -(priceAssetAmount))
440- else $Tuple2(-(amountAssetAmount), priceAssetAmount)
441- let amountAssetBalanceDelta = $t02148021692._1
442- let priceAssetBalanceDelta = $t02148021692._2
375+ let cfg = getPoolConfig()
376+ let amtAssetId = cfg[idxAmtAssetId]
377+ let priceAssetId = cfg[idxPriceAssetId]
378+ let poolStatus = parseIntValue(cfg[idxPoolStatus])
379+ let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
380+ let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
381+ let accAmtAssetBalance = getAccBalance(amtAssetId)
382+ let accPriceAssetBalance = getAccBalance(priceAssetId)
383+ let curPriceX18 = if ((order.orderType == Buy))
384+ then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance)
385+ else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance)
386+ let curPrice = fromX18(curPriceX18, scale8)
443387 if (if (if (isGlobalShutdown())
444388 then true
445- else (cfgPoolStatus == PoolMatcherDisabled))
389+ else (poolStatus == PoolMatcherDisabled))
446390 then true
447- else (cfgPoolStatus == PoolShutdown))
391+ else (poolStatus == PoolShutdown))
448392 then throw("Exchange operations disabled")
449- else if (if ((order.assetPair.amountAsset != cfgAmountAssetId))
450- then true
451- else (order.assetPair.priceAsset != cfgPriceAssetId))
452- then throw("Wrong order assets.")
453- else {
454- let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp"))
455- let $t02213222232 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
456- let unusedActions = $t02213222232._1
457- let kLpNew = $t02213222232._2
458- let isOrderValid = (kLpNew >= kLp)
459- let info = makeString(["kLp=", toString(kLp), " kLpNew=", toString(kLpNew), " amountAssetBalance=", toString(amountAssetBalance), " priceAssetBalance=", toString(priceAssetBalance), " amountAssetBalanceDelta=", toString(amountAssetBalanceDelta), " priceAssetBalanceDelta=", toString(priceAssetBalanceDelta)], "")
460- $Tuple2(isOrderValid, info)
461- }
393+ else {
394+ let orderAmtAsset = order.assetPair.amountAsset
395+ let orderAmtAssetStr = if ((orderAmtAsset == unit))
396+ then "WAVES"
397+ else toBase58String(value(orderAmtAsset))
398+ let orderPriceAsset = order.assetPair.priceAsset
399+ let orderPriceAssetStr = if ((orderPriceAsset == unit))
400+ then "WAVES"
401+ else toBase58String(value(orderPriceAsset))
402+ if (if ((orderAmtAssetStr != amtAssetId))
403+ then true
404+ else (orderPriceAssetStr != priceAssetId))
405+ then throw("Wrong order assets.")
406+ else {
407+ let orderPrice = order.price
408+ let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm)
409+ let castedOrderPrice = toScale(orderPrice, scale8, priceDcm)
410+ let isOrderPriceValid = if ((order.orderType == Buy))
411+ then (curPrice >= castedOrderPrice)
412+ else (castedOrderPrice >= curPrice)
413+ true
414+ }
415+ }
462416 }
463417
464418
533487 else if ((paymentAssetId == cfgPriceAssetId))
534488 then false
535489 else throwErr("invalid asset")
536- let $t02531025603 = if (isEval)
490+ let $t02272523018 = if (isEval)
537491 then $Tuple2(amountBalanceRaw, priceBalanceRaw)
538492 else if (paymentInAmountAsset)
539493 then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw)
540494 else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw))
541- let amountBalanceOld = $t02531025603._1
542- let priceBalanceOld = $t02531025603._2
543- let $t02560725756 = if (paymentInAmountAsset)
495+ let amountBalanceOld = $t02272523018._1
496+ let priceBalanceOld = $t02272523018._2
497+ let $t02302223171 = if (paymentInAmountAsset)
544498 then $Tuple2(paymentAmountRaw, 0)
545499 else $Tuple2(0, paymentAmountRaw)
546- let amountAssetAmountRaw = $t02560725756._1
547- let priceAssetAmountRaw = $t02560725756._2
500+ let amountAssetAmountRaw = $t02302223171._1
501+ let priceAssetAmountRaw = $t02302223171._2
548502 let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1
549503 let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1
550- let $t02588825952 = takeFee(paymentAmountRaw, inFee)
551- let paymentAmount = $t02588825952._1
552- let feeAmount = $t02588825952._2
504+ let $t02330323367 = takeFee(paymentAmountRaw, inFee)
505+ let paymentAmount = $t02330323367._1
506+ let feeAmount = $t02330323367._2
553507 let amountBalanceNew = (amountBalanceOld + amountAssetAmount)
554508 let priceBalanceNew = (priceBalanceOld + priceAssetAmount)
555509 let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals))
572526 let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals))
573527 let priceOld = fromX18(priceOldX18, scale8)
574528 let loss = {
575- let $t02763327800 = if (paymentInAmountAsset)
529+ let $t02484425011 = if (paymentInAmountAsset)
576530 then $Tuple2(amountAssetAmountRaw, amountBalanceOld)
577531 else $Tuple2(priceAssetAmountRaw, priceBalanceOld)
578- let amount = $t02763327800._1
579- let balance = $t02763327800._2
532+ let amount = $t02484425011._1
533+ let balance = $t02484425011._2
580534 let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance)))
581535 fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth)
582536 }
583- $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset)
537+ $Tuple4(issueAmount, commonState, feeAmount, loss)
584538 }
585539 else throw("Strict value is not equal to itself.")
586540 }
588542
589543 func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = {
590544 let isEval = (txId == unit)
591- let cfg = getPoolConfig()
592- let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
593- let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
594545 let checks = [if ((paymentAssetId == cfgLpAssetId))
595546 then true
596547 else throwErr("invalid lp asset")]
604555 let balanceBigInt = if (outInAmountAsset)
605556 then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId)))
606557 else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId)))
607- let outInAmountAssetDecimals = if (outInAmountAsset)
608- then amtAssetDcm
609- else priceAssetDcm
610558 let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId))
611559 let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId))
612560 let outBalance = if (outInAmountAsset)
616564 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
617565 let redeemedBigInt = toBigInt(paymentAmount)
618566 let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))])
619- let $t02987829934 = takeFee(amountRaw, outFee)
620- let totalAmount = $t02987829934._1
621- let feeAmount = $t02987829934._2
622- let $t02993830164 = if (outInAmountAsset)
567+ let $t02659126647 = takeFee(amountRaw, outFee)
568+ let totalAmount = $t02659126647._1
569+ let feeAmount = $t02659126647._2
570+ let $t02665126877 = if (outInAmountAsset)
623571 then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
624572 else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw))
625- let outAmAmount = $t02993830164._1
626- let outPrAmount = $t02993830164._2
627- let amBalanceNew = $t02993830164._3
628- let prBalanceNew = $t02993830164._4
573+ let outAmAmount = $t02665126877._1
574+ let outPrAmount = $t02665126877._2
575+ let amBalanceNew = $t02665126877._3
576+ let prBalanceNew = $t02665126877._4
629577 let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
630578 let priceNew = fromX18(priceNewX18, scale8)
631579 let commonState = if (isEval)
637585 let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2)
638586 fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset)
639587 }
640- $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset)
588+ $Tuple4(totalAmount, commonState, feeAmount, loss)
641589 }
642590 else throw("Strict value is not equal to itself.")
643591 }
691639
692640
693641 @Callable(i)
642+func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse) = {
643+ let $t02855428859 = if ((isReverse == false))
644+ then {
645+ let assetOut = getStringOrFail(this, pa())
646+ let assetIn = getStringOrFail(this, aa())
647+ $Tuple2(assetOut, assetIn)
648+ }
649+ else {
650+ let assetOut = getStringOrFail(this, aa())
651+ let assetIn = getStringOrFail(this, pa())
652+ $Tuple2(assetOut, assetIn)
653+ }
654+ let assetOut = $t02855428859._1
655+ let assetIn = $t02855428859._2
656+ let poolAssetInBalance = getAccBalance(assetIn)
657+ let poolAssetOutBalance = getAccBalance(assetOut)
658+ let amountOut = ((poolAssetOutBalance * cleanAmountIn) / (poolAssetInBalance + cleanAmountIn))
659+ $Tuple2(nil, amountOut)
660+ }
661+
662+
663+
664+@Callable(i)
665+func calculateAmountOutForSwapAndSendTokens (cleanAmountIn,isReverse,amountOutMin,addressTo) = {
666+ let checks = [if ((value(i.payments[0]).amount >= cleanAmountIn))
667+ then true
668+ else throwErr("Wrong amount"), if ((i.caller == addressFromStringValue(getStringOrFail(this, swapContract()))))
669+ then true
670+ else throwErr("Permission denied")]
671+ if ((checks == checks))
672+ then {
673+ let pmt = value(i.payments[0])
674+ let assetIn = if ((pmt.assetId == unit))
675+ then toBase58String(toBytes("WAVES"))
676+ else toBase58String(value(pmt.assetId))
677+ let assetOut = if ((isReverse == false))
678+ then getStringOrFail(this, pa())
679+ else getStringOrFail(this, aa())
680+ let poolAssetInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount)
681+ let poolAssetOutBalance = getAccBalance(assetOut)
682+ let amountOut = ((poolAssetOutBalance * cleanAmountIn) / (poolAssetInBalance + cleanAmountIn))
683+ let checkMin = if ((amountOut >= amountOutMin))
684+ then true
685+ else throw("Exchange result is fewer coins than expected")
686+ if ((checkMin == checkMin))
687+ then [ScriptTransfer(addressFromStringValue(addressTo), amountOut, if ((assetIn == "WAVES"))
688+ then unit
689+ else fromBase58String(assetOut))]
690+ else throw("Strict value is not equal to itself.")
691+ }
692+ else throw("Strict value is not equal to itself.")
693+ }
694+
695+
696+
697+@Callable(i)
694698 func setManager (pendingManagerPublicKey) = {
695699 let checkCaller = mustManager(i)
696700 if ((checkCaller == checkCaller))
737741 let prDiff = estPut._11
738742 let amId = estPut._12
739743 let prId = estPut._13
740- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
741- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
742- let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
743- if ((currentKLp == currentKLp))
744+ let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
745+ if ((emitInv == emitInv))
744746 then {
745- let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
746- if ((emitInv == emitInv))
747+ let emitInvLegacy = match emitInv {
748+ case legacyFactoryContract: Address =>
749+ invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
750+ case _ =>
751+ unit
752+ }
753+ if ((emitInvLegacy == emitInvLegacy))
747754 then {
748- let emitInvLegacy = match emitInv {
749- case legacyFactoryContract: Address =>
750- invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
751- case _ =>
752- unit
753- }
754- if ((emitInvLegacy == emitInvLegacy))
755+ let slippageAInv = if ((amDiff > 0))
756+ then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
757+ else nil
758+ if ((slippageAInv == slippageAInv))
755759 then {
756- let slippageAInv = if ((amDiff > 0))
757- then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
760+ let slippagePInv = if ((prDiff > 0))
761+ then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
758762 else nil
759- if ((slippageAInv == slippageAInv))
763+ if ((slippagePInv == slippagePInv))
760764 then {
761- let slippagePInv = if ((prDiff > 0))
762- then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
763- else nil
764- if ((slippagePInv == slippagePInv))
765+ let lpTransfer = if (shouldAutoStake)
765766 then {
766- let lpTransfer = if (shouldAutoStake)
767- then {
768- let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
769- if ((slpStakeInv == slpStakeInv))
770- then nil
771- else throw("Strict value is not equal to itself.")
772- }
773- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
774- let $t03469235154 = refreshKLpInternal(0, 0, 0)
775- if (($t03469235154 == $t03469235154))
776- then {
777- let updatedKLp = $t03469235154._2
778- let refreshKLpActions = $t03469235154._1
779- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
780- if ((isUpdatedKLpValid == isUpdatedKLpValid))
781- then ((state ++ lpTransfer) ++ refreshKLpActions)
782- else throw("Strict value is not equal to itself.")
783- }
767+ let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
768+ if ((slpStakeInv == slpStakeInv))
769+ then nil
784770 else throw("Strict value is not equal to itself.")
785771 }
786- else throw("Strict value is not equal to itself.")
772+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
773+ (state ++ lpTransfer)
787774 }
788775 else throw("Strict value is not equal to itself.")
789776 }
801788 then throw("Invalid value passed")
802789 else {
803790 let estPut = commonPut(i, maxSlippage, false)
804- let state = estPut._9
805- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
806- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
807- let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
808- if ((currentKLp == currentKLp))
809- then {
810- let $t03571635781 = refreshKLpInternal(0, 0, 0)
811- let refreshKLpActions = $t03571635781._1
812- let updatedKLp = $t03571635781._2
813- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
814- if ((isUpdatedKLpValid == isUpdatedKLpValid))
815- then (state ++ refreshKLpActions)
816- else throw("Strict value is not equal to itself.")
817- }
818- else throw("Strict value is not equal to itself.")
791+ estPut._9
819792 }
820793
821794
847820 let payment = i.payments[0]
848821 let paymentAssetId = payment.assetId
849822 let paymentAmountRaw = payment.amount
850- let currentKLp = if ((paymentAssetId == cfgAmountAssetId))
851- then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0))
852- else if ((paymentAssetId == cfgPriceAssetId))
853- then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0))
854- else throwErr("payment asset is not supported")
855- if ((currentKLp == currentKLp))
823+ let userAddress = i.caller
824+ let txId = i.transactionId
825+ let $t03366433794 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
826+ if (($t03366433794 == $t03366433794))
856827 then {
857- let userAddress = i.caller
858- let txId = i.transactionId
859- let $t03696937121 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
860- if (($t03696937121 == $t03696937121))
828+ let bonus = $t03366433794._4
829+ let feeAmount = $t03366433794._3
830+ let commonState = $t03366433794._2
831+ let emitAmountEstimated = $t03366433794._1
832+ let emitAmount = if (if ((minOutAmount > 0))
833+ then (minOutAmount > emitAmountEstimated)
834+ else false)
835+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
836+ else emitAmountEstimated
837+ let emitInv = emit(emitAmount)
838+ if ((emitInv == emitInv))
861839 then {
862- let paymentInAmountAsset = $t03696937121._5
863- let bonus = $t03696937121._4
864- let feeAmount = $t03696937121._3
865- let commonState = $t03696937121._2
866- let emitAmountEstimated = $t03696937121._1
867- let emitAmount = if (if ((minOutAmount > 0))
868- then (minOutAmount > emitAmountEstimated)
869- else false)
870- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
871- else emitAmountEstimated
872- let emitInv = emit(emitAmount)
873- if ((emitInv == emitInv))
840+ let lpTransfer = if (autoStake)
874841 then {
875- let lpTransfer = if (autoStake)
876- then {
877- let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
878- if ((stakeInv == stakeInv))
879- then nil
880- else throw("Strict value is not equal to itself.")
881- }
882- else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
883- let sendFee = if ((feeAmount > 0))
884- then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
885- else nil
886- let $t03770737904 = if ((this == feeCollectorAddress))
887- then $Tuple2(0, 0)
888- else if (paymentInAmountAsset)
889- then $Tuple2(-(feeAmount), 0)
890- else $Tuple2(0, -(feeAmount))
891- let amountAssetBalanceDelta = $t03770737904._1
892- let priceAssetBalanceDelta = $t03770737904._2
893- let $t03790738015 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
894- let refreshKLpActions = $t03790738015._1
895- let updatedKLp = $t03790738015._2
896- let kLp = value(getString(keyKLp))
897- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
898- if ((isUpdatedKLpValid == isUpdatedKLpValid))
899- then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
842+ let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
843+ if ((stakeInv == stakeInv))
844+ then nil
900845 else throw("Strict value is not equal to itself.")
901846 }
902- else throw("Strict value is not equal to itself.")
847+ else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
848+ let sendFee = if ((feeAmount > 0))
849+ then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
850+ else nil
851+ $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount)
903852 }
904853 else throw("Strict value is not equal to itself.")
905854 }
912861
913862 @Callable(i)
914863 func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = {
915- let $t03832138478 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
916- let emitAmountEstimated = $t03832138478._1
917- let commonState = $t03832138478._2
918- let feeAmount = $t03832138478._3
919- let bonus = $t03832138478._4
920- let paymentInAmountAsset = $t03832138478._5
864+ let $t03452334658 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
865+ let emitAmountEstimated = $t03452334658._1
866+ let commonState = $t03452334658._2
867+ let feeAmount = $t03452334658._3
868+ let bonus = $t03452334658._4
921869 $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
922870 }
923871
949897 let payment = i.payments[0]
950898 let paymentAssetId = payment.assetId
951899 let paymentAmount = payment.amount
952- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
953- if ((currentKLp == currentKLp))
900+ let userAddress = i.caller
901+ let txId = i.transactionId
902+ let $t03546335598 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
903+ if (($t03546335598 == $t03546335598))
954904 then {
955- let userAddress = i.caller
956- let txId = i.transactionId
957- let $t03936339516 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
958- if (($t03936339516 == $t03936339516))
905+ let bonus = $t03546335598._4
906+ let feeAmount = $t03546335598._3
907+ let commonState = $t03546335598._2
908+ let amountEstimated = $t03546335598._1
909+ let amount = if (if ((minOutAmount > 0))
910+ then (minOutAmount > amountEstimated)
911+ else false)
912+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
913+ else amountEstimated
914+ let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
915+ if ((burnInv == burnInv))
959916 then {
960- let outInAmountAsset = $t03936339516._5
961- let bonus = $t03936339516._4
962- let feeAmount = $t03936339516._3
963- let commonState = $t03936339516._2
964- let amountEstimated = $t03936339516._1
965- let amount = if (if ((minOutAmount > 0))
966- then (minOutAmount > amountEstimated)
967- else false)
968- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
969- else amountEstimated
970- let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
971- if ((burnInv == burnInv))
972- then {
973- let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
974- let sendFee = if ((feeAmount > 0))
975- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
976- else nil
977- let $t04001640263 = {
978- let feeAmountForCalc = if ((this == feeCollectorAddress))
979- then 0
980- else feeAmount
981- if (outInAmountAsset)
982- then $Tuple2(-((amount + feeAmountForCalc)), 0)
983- else $Tuple2(0, -((amount + feeAmountForCalc)))
984- }
985- let amountAssetBalanceDelta = $t04001640263._1
986- let priceAssetBalanceDelta = $t04001640263._2
987- let $t04026640374 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
988- let refreshKLpActions = $t04026640374._1
989- let updatedKLp = $t04026640374._2
990- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
991- if ((isUpdatedKLpValid == isUpdatedKLpValid))
992- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
993- else throw("Strict value is not equal to itself.")
994- }
995- else throw("Strict value is not equal to itself.")
917+ let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
918+ let sendFee = if ((feeAmount > 0))
919+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
920+ else nil
921+ $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
996922 }
997923 else throw("Strict value is not equal to itself.")
998924 }
1005931
1006932 @Callable(i)
1007933 func getOneTknREADONLY (outAssetId,paymentAmount) = {
1008- let $t04063140787 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
1009- let amountEstimated = $t04063140787._1
1010- let commonState = $t04063140787._2
1011- let feeAmount = $t04063140787._3
1012- let bonus = $t04063140787._4
1013- let outInAmountAsset = $t04063140787._5
934+ let $t03623336371 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
935+ let amountEstimated = $t03623336371._1
936+ let commonState = $t03623336371._2
937+ let feeAmount = $t03623336371._3
938+ let bonus = $t03623336371._4
1014939 $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
1015940 }
1016941
1041966 let outAssetId = parseAssetId(outAssetIdStr)
1042967 let userAddress = i.caller
1043968 let txId = i.transactionId
1044- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1045- if ((currentKLp == currentKLp))
969+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
970+ if ((unstakeInv == unstakeInv))
1046971 then {
1047- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1048- if ((unstakeInv == unstakeInv))
972+ let $t03719637329 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
973+ if (($t03719637329 == $t03719637329))
1049974 then {
1050- let $t04169241843 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
1051- if (($t04169241843 == $t04169241843))
975+ let bonus = $t03719637329._4
976+ let feeAmount = $t03719637329._3
977+ let commonState = $t03719637329._2
978+ let amountEstimated = $t03719637329._1
979+ let amount = if (if ((minOutAmount > 0))
980+ then (minOutAmount > amountEstimated)
981+ else false)
982+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
983+ else amountEstimated
984+ let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
985+ if ((burnInv == burnInv))
1052986 then {
1053- let outInAmountAsset = $t04169241843._5
1054- let bonus = $t04169241843._4
1055- let feeAmount = $t04169241843._3
1056- let commonState = $t04169241843._2
1057- let amountEstimated = $t04169241843._1
1058- let amount = if (if ((minOutAmount > 0))
1059- then (minOutAmount > amountEstimated)
1060- else false)
1061- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1062- else amountEstimated
1063- let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1064- if ((burnInv == burnInv))
1065- then {
1066- let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
1067- let sendFee = if ((feeAmount > 0))
1068- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
1069- else nil
1070- let $t04233842585 = {
1071- let feeAmountForCalc = if ((this == feeCollectorAddress))
1072- then 0
1073- else feeAmount
1074- if (outInAmountAsset)
1075- then $Tuple2(-((amount + feeAmountForCalc)), 0)
1076- else $Tuple2(0, -((amount + feeAmountForCalc)))
1077- }
1078- let amountAssetBalanceDelta = $t04233842585._1
1079- let priceAssetBalanceDelta = $t04233842585._2
1080- let $t04258842696 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1081- let refreshKLpActions = $t04258842696._1
1082- let updatedKLp = $t04258842696._2
1083- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1084- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1085- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1086- else throw("Strict value is not equal to itself.")
1087- }
1088- else throw("Strict value is not equal to itself.")
987+ let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
988+ let sendFee = if ((feeAmount > 0))
989+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
990+ else nil
991+ $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
1089992 }
1090993 else throw("Strict value is not equal to itself.")
1091994 }
11061009 let pmtAmt = res._3
11071010 let pmtAssetId = res._4
11081011 let state = res._5
1109- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1110- if ((currentKLp == currentKLp))
1111- then {
1112- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1113- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1114- then {
1115- let $t04364243724 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1116- let refreshKLpActions = $t04364243724._1
1117- let updatedKLp = $t04364243724._2
1118- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1119- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1120- then (state ++ refreshKLpActions)
1121- else throw("Strict value is not equal to itself.")
1122- }
1123- else throw("Strict value is not equal to itself.")
1124- }
1012+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1013+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1014+ then state
11251015 else throw("Strict value is not equal to itself.")
11261016 }
11271017
11401030 else if ((noLessThenPriceAsset > outPrAmt))
11411031 then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
11421032 else {
1143- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1144- if ((currentKLp == currentKLp))
1145- then {
1146- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1147- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1148- then {
1149- let $t04467344754 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1150- let refreshKLpActions = $t04467344754._1
1151- let updatedKLp = $t04467344754._2
1152- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1153- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1154- then (state ++ refreshKLpActions)
1155- else throw("Strict value is not equal to itself.")
1156- }
1157- else throw("Strict value is not equal to itself.")
1158- }
1033+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1034+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1035+ then state
11591036 else throw("Strict value is not equal to itself.")
11601037 }
11611038 }
11711048 then {
11721049 let cfg = getPoolConfig()
11731050 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
1174- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1175- if ((currentKLp == currentKLp))
1051+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
1052+ if ((unstakeInv == unstakeInv))
11761053 then {
1177- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
1178- if ((unstakeInv == unstakeInv))
1054+ let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1055+ let poolStatus = parseIntValue(res._9)
1056+ let state = res._10
1057+ let checkPoolStatus = if (if (isGlobalShutdown())
1058+ then true
1059+ else (poolStatus == PoolShutdown))
1060+ then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
1061+ else true
1062+ if ((checkPoolStatus == checkPoolStatus))
11791063 then {
1180- let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1181- let outAmAmt = res._1
1182- let outPrAmt = res._2
1183- let poolStatus = parseIntValue(res._9)
1184- let state = res._10
1185- let checkPoolStatus = if (if (isGlobalShutdown())
1186- then true
1187- else (poolStatus == PoolShutdown))
1188- then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
1189- else true
1190- if ((checkPoolStatus == checkPoolStatus))
1191- then {
1192- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1193- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1194- then {
1195- let $t04588045961 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1196- let refreshKLpActions = $t04588045961._1
1197- let updatedKLp = $t04588045961._2
1198- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1199- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1200- then (state ++ refreshKLpActions)
1201- else throw("Strict value is not equal to itself.")
1202- }
1203- else throw("Strict value is not equal to itself.")
1204- }
1064+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1065+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1066+ then state
12051067 else throw("Strict value is not equal to itself.")
12061068 }
12071069 else throw("Strict value is not equal to itself.")
12251087 else throw("no payments are expected")]
12261088 if ((checks == checks))
12271089 then {
1228- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1229- if ((currentKLp == currentKLp))
1090+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1091+ if ((unstakeInv == unstakeInv))
12301092 then {
1231- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1232- if ((unstakeInv == unstakeInv))
1093+ let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1094+ let outAmAmt = res._1
1095+ let outPrAmt = res._2
1096+ let state = res._10
1097+ let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1098+ then true
1099+ else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1100+ then true
1101+ else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1102+ if ((checkAmounts == checkAmounts))
12331103 then {
1234- let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1235- let outAmAmt = res._1
1236- let outPrAmt = res._2
1237- let state = res._10
1238- let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1239- then true
1240- else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1241- then true
1242- else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1243- if ((checkAmounts == checkAmounts))
1244- then {
1245- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1246- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1247- then {
1248- let $t04725647337 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1249- let refreshKLpActions = $t04725647337._1
1250- let updatedKLp = $t04725647337._2
1251- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1252- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1253- then (state ++ refreshKLpActions)
1254- else throw("Strict value is not equal to itself.")
1255- }
1256- else throw("Strict value is not equal to itself.")
1257- }
1104+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1105+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1106+ then state
12581107 else throw("Strict value is not equal to itself.")
12591108 }
12601109 else throw("Strict value is not equal to itself.")
12701119 func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
12711120 then throw("permissions denied")
12721121 else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success")
1273-
1274-
1275-
1276-@Callable(i)
1277-func refreshKLp () = {
1278- let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0)
1279- let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay))
1280- then unit
1281- else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1282- if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1283- then {
1284- let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp"))
1285- let $t04852448588 = refreshKLpInternal(0, 0, 0)
1286- let kLpUpdateActions = $t04852448588._1
1287- let updatedKLp = $t04852448588._2
1288- let actions = if ((kLp != updatedKLp))
1289- then kLpUpdateActions
1290- else throwErr("nothing to refresh")
1291- $Tuple2(actions, toString(updatedKLp))
1292- }
1293- else throw("Strict value is not equal to itself.")
1294- }
12951122
12961123
12971124
14591286 match tx {
14601287 case order: Order =>
14611288 let matcherPub = getMatcherPubOrFail()
1462- let $t05725057319 = validateMatcherOrderAllowed(order)
1463- let orderValid = $t05725057319._1
1464- let orderValidInfo = $t05725057319._2
1289+ let orderValid = validateMatcherOrderAllowed(order)
14651290 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
14661291 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
14671292 if (if (if (orderValid)
14701295 then matcherValid
14711296 else false)
14721297 then true
1473- else throwOrderError(orderValid, orderValidInfo, senderValid, matcherValid)
1298+ else throwOrderError(orderValid, senderValid, matcherValid)
14741299 case s: SetScriptTransaction =>
14751300 let newHash = blake2b256(value(s.script))
14761301 let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash())))
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let lPdecimals = 8
55
66 let scale8 = 100000000
77
88 let scale8BigInt = toBigInt(100000000)
99
1010 let scale18 = toBigInt(1000000000000000000)
1111
1212 let zeroBigInt = toBigInt(0)
1313
1414 let big0 = toBigInt(0)
1515
1616 let big1 = toBigInt(1)
1717
1818 let big2 = toBigInt(2)
1919
2020 let wavesString = "WAVES"
2121
2222 let SEP = "__"
2323
2424 let PoolActive = 1
2525
2626 let PoolPutDisabled = 2
2727
2828 let PoolMatcherDisabled = 3
2929
3030 let PoolShutdown = 4
3131
3232 let idxPoolAddress = 1
3333
3434 let idxPoolStatus = 2
3535
3636 let idxPoolLPAssetId = 3
3737
3838 let idxAmtAssetId = 4
3939
4040 let idxPriceAssetId = 5
4141
4242 let idxAmtAssetDcm = 6
4343
4444 let idxPriceAssetDcm = 7
4545
4646 let idxIAmtAssetId = 8
4747
4848 let idxIPriceAssetId = 9
4949
5050 let idxLPAssetDcm = 10
5151
5252 let idxPoolAmtAssetAmt = 1
5353
5454 let idxPoolPriceAssetAmt = 2
5555
5656 let idxPoolLPAssetAmt = 3
5757
5858 let idxFactoryStakingContract = 1
5959
6060 let idxFactorySlippageContract = 7
6161
6262 func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult))
6363
6464
65-func toX18BigInt (origVal,origScaleMult) = fraction(origVal, scale18, origScaleMult)
66-
67-
6865 func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18))
69-
70-
71-func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round))
7266
7367
7468 func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale)
7569
7670
7771 func abs (val) = if ((0 > val))
7872 then -(val)
7973 else val
8074
8175
8276 func absBigInt (val) = if ((zeroBigInt > val))
8377 then -(val)
8478 else val
79+
80+
81+func swapContract () = "%s__swapContract"
8582
8683
8784 func fc () = "%s__factoryContract"
8885
8986
9087 func mpk () = "%s__managerPublicKey"
9188
9289
9390 func pmpk () = "%s__pendingManagerPublicKey"
9491
9592
9693 func pl () = "%s%s__price__last"
9794
9895
9996 func ph (h,timestamp) = makeString(["%s%s%d%d__price__history", toString(h), toString(timestamp)], SEP)
10097
10198
10299 func pau (userAddress,txId) = ((("%s%s%s__P__" + userAddress) + "__") + txId)
103100
104101
105102 func gau (userAddress,txId) = ((("%s%s%s__G__" + userAddress) + "__") + txId)
106103
107104
108105 func aa () = "%s__amountAsset"
109106
110107
111108 func pa () = "%s__priceAsset"
112109
113110
114-let keyFee = "%s__fee"
115-
116-let feeDefault = fraction(10, scale8, 10000)
117-
118-let fee = valueOrElse(getInteger(this, keyFee), feeDefault)
119-
120-let keyKLp = makeString(["%s", "kLp"], SEP)
121-
122-let keyKLpRefreshedHeight = makeString(["%s", "kLpRefreshedHeight"], SEP)
123-
124-let keyKLpRefreshDelay = makeString(["%s", "refreshKLpDelay"], SEP)
125-
126-let kLpRefreshDelayDefault = 30
127-
128-let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault)
129-
130111 func keyFactoryConfig () = "%s__factoryConfig"
131112
132113
133114 func keyMatcherPub () = "%s%s__matcher__publicKey"
134115
135116
136117 func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset")
137118
138119
139120 func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config")
140121
141122
142123 func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr)
143124
144125
145126 func keyAllPoolsShutdown () = "%s__shutdown"
146127
147128
148129 func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress)
149130
150131
151132 func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash"
152133
153134
154135 let keyFeeCollectorAddress = "%s__feeCollectorAddress"
155136
156-func throwOrderError (orderValid,orderValidInfo,senderValid,matcherValid) = throw((((((((("order validation failed: orderValid=" + toString(orderValid)) + " (") + orderValidInfo) + ")") + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid)))
137+func throwOrderError (orderValid,senderValid,matcherValid) = throw(((((("order validation failed: orderValid=" + toString(orderValid)) + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid)))
157138
158139
159140 func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
160141
161142
162143 func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
163144
164145
165146 func throwErr (msg) = throw(makeString(["lp.ride:", msg], " "))
166-
167-
168-func fmtErr (msg) = makeString(["lp.ride:", msg], " ")
169147
170148
171149 let factoryContract = addressFromStringValue(getStringOrFail(this, fc()))
172150
173151 let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress))
174152
175153 let inFee = {
176154 let @ = invoke(factoryContract, "getInFeeREADONLY", [toString(this)], nil)
177155 if ($isInstanceOf(@, "Int"))
178156 then @
179157 else throw(($getType(@) + " couldn't be cast to Int"))
180158 }
181159
182160 let outFee = {
183161 let @ = invoke(factoryContract, "getOutFeeREADONLY", [toString(this)], nil)
184162 if ($isInstanceOf(@, "Int"))
185163 then @
186164 else throw(($getType(@) + " couldn't be cast to Int"))
187165 }
188166
189167 func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false)
190168
191169
192170 func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub()))
193171
194172
195173 func getPoolConfig () = {
196174 let amtAsset = getStringOrFail(this, aa())
197175 let priceAsset = getStringOrFail(this, pa())
198176 let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset))
199177 let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset))
200178 split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP)
201179 }
202180
203181
204182 func parseAssetId (input) = if ((input == wavesString))
205183 then unit
206184 else fromBase58String(input)
207185
208186
209187 func assetIdToString (input) = if ((input == unit))
210188 then wavesString
211189 else toBase58String(value(input))
212190
213191
214192 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]))
215193
216194
217195 let poolConfigParsed = parsePoolConfig(getPoolConfig())
218196
219-let $t084088574 = poolConfigParsed
197+let $t076627828 = poolConfigParsed
220198
221-let cfgPoolAddress = $t084088574._1
199+let cfgPoolAddress = $t076627828._1
222200
223-let cfgPoolStatus = $t084088574._2
201+let cfgPoolStatus = $t076627828._2
224202
225-let cfgLpAssetId = $t084088574._3
203+let cfgLpAssetId = $t076627828._3
226204
227-let cfgAmountAssetId = $t084088574._4
205+let cfgAmountAssetId = $t076627828._4
228206
229-let cfgPriceAssetId = $t084088574._5
207+let cfgPriceAssetId = $t076627828._5
230208
231-let cfgAmountAssetDecimals = $t084088574._6
209+let cfgAmountAssetDecimals = $t076627828._6
232210
233-let cfgPriceAssetDecimals = $t084088574._7
211+let cfgPriceAssetDecimals = $t076627828._7
234212
235213 func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
236214
237215
238216 let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address")
239217
240218 let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address")
241219
242220 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)
243221
244222
245223 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)
246224
247225
248226 func getAccBalance (assetId) = if ((assetId == "WAVES"))
249227 then wavesBalance(this).available
250228 else assetBalance(this, fromBase58String(assetId))
251229
252230
253231 func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
254-
255-
256-func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
257232
258233
259234 func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
260235 let amtAssetAmtX18 = toX18(amAmt, amAssetDcm)
261236 let priceAssetAmtX18 = toX18(prAmt, prAssetDcm)
262237 calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18)
263238 }
264239
265240
266241 func calcPrices (amAmt,prAmt,lpAmt) = {
267242 let cfg = getPoolConfig()
268243 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
269244 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
270245 let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt)
271246 let amAmtX18 = toX18(amAmt, amtAssetDcm)
272247 let prAmtX18 = toX18(prAmt, priceAssetDcm)
273248 let lpAmtX18 = toX18(lpAmt, scale8)
274249 let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18)
275250 let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18)
276251 [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18]
277252 }
278253
279254
280255 func calculatePrices (amAmt,prAmt,lpAmt) = {
281256 let prices = calcPrices(amAmt, prAmt, lpAmt)
282257 [fromX18(prices[0], scale8), fromX18(prices[1], scale8), fromX18(prices[2], scale8)]
283258 }
284259
285260
286261 func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
287262 let cfg = getPoolConfig()
288263 let lpAssetId = cfg[idxPoolLPAssetId]
289264 let amAssetId = cfg[idxAmtAssetId]
290265 let prAssetId = cfg[idxPriceAssetId]
291266 let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
292267 let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
293268 let poolStatus = cfg[idxPoolStatus]
294269 let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity
295270 if ((lpAssetId != pmtAssetId))
296271 then throw("Invalid asset passed.")
297272 else {
298273 let amBalance = getAccBalance(amAssetId)
299274 let amBalanceX18 = toX18(amBalance, amAssetDcm)
300275 let prBalance = getAccBalance(prAssetId)
301276 let prBalanceX18 = toX18(prBalance, prAssetDcm)
302277 let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18)
303278 let curPrice = fromX18(curPriceX18, scale8)
304279 let pmtLpAmtX18 = toX18(pmtLpAmt, scale8)
305280 let lpEmissionX18 = toX18(lpEmission, scale8)
306281 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18)
307282 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18)
308- let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR)
309- let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR)
283+ let outAmAmt = fromX18(outAmAmtX18, amAssetDcm)
284+ let outPrAmt = fromX18(outPrAmtX18, prAssetDcm)
310285 let state = if ((txId58 == ""))
311286 then nil
312287 else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES"))
313288 then unit
314289 else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES"))
315290 then unit
316291 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)]
317292 $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state)
318293 }
319294 }
320295
321296
322297 func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = {
323298 let cfg = getPoolConfig()
324299 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
325300 let amAssetIdStr = cfg[idxAmtAssetId]
326301 let prAssetIdStr = cfg[idxPriceAssetId]
327302 let iAmtAssetId = cfg[idxIAmtAssetId]
328303 let iPriceAssetId = cfg[idxIPriceAssetId]
329304 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
330305 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
331306 let poolStatus = cfg[idxPoolStatus]
332307 let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
333308 let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES")))
334309 let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES")))
335310 if (if ((amAssetIdStr != inAmAssetIdStr))
336311 then true
337312 else (prAssetIdStr != inPrAssetIdStr))
338313 then throw("Invalid amt or price asset passed.")
339314 else {
340315 let amBalance = if (isEvaluate)
341316 then getAccBalance(amAssetIdStr)
342317 else (getAccBalance(amAssetIdStr) - inAmAssetAmt)
343318 let prBalance = if (isEvaluate)
344319 then getAccBalance(prAssetIdStr)
345320 else (getAccBalance(prAssetIdStr) - inPrAssetAmt)
346321 let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm)
347322 let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm)
348323 let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18)
349324 let amBalanceX18 = toX18(amBalance, amtAssetDcm)
350325 let prBalanceX18 = toX18(prBalance, priceAssetDcm)
351326 let res = if ((lpEmission == 0))
352327 then {
353328 let curPriceX18 = zeroBigInt
354329 let slippageX18 = zeroBigInt
355330 let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN)
356331 $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
357332 }
358333 else {
359334 let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18)
360335 let slippageX18 = fraction(absBigInt((curPriceX18 - userPriceX18)), scale18, curPriceX18)
361336 let slippageToleranceX18 = toX18(slippageTolerance, scale8)
362337 if (if ((curPriceX18 != zeroBigInt))
363338 then (slippageX18 > slippageToleranceX18)
364339 else false)
365340 then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18)))
366341 else {
367342 let lpEmissionX18 = toX18(lpEmission, scale8)
368- let prViaAmX18 = fraction(inAmAssetAmtX18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING)
369- let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, FLOOR), CEILING)
343+ let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
344+ let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
370345 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
371346 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
372347 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
373348 let expAmtAssetAmtX18 = expectedAmts._1
374349 let expPriceAssetAmtX18 = expectedAmts._2
375- let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR)
376- $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtAssetDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceAssetDcm, CEILING), curPriceX18, slippageX18)
350+ let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
351+ $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18)
377352 }
378353 }
379354 let calcLpAmt = res._1
380355 let calcAmAssetPmt = res._2
381356 let calcPrAssetPmt = res._3
382357 let curPrice = fromX18(res._4, scale8)
383358 let slippageCalc = fromX18(res._5, scale8)
384359 if ((0 >= calcLpAmt))
385360 then throw("Invalid calculations. LP calculated is less than zero.")
386361 else {
387362 let emitLpAmt = if (!(emitLp))
388363 then 0
389364 else calcLpAmt
390365 let amDiff = (inAmAssetAmt - calcAmAssetPmt)
391366 let prDiff = (inPrAssetAmt - calcPrAssetPmt)
392367 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))]
393368 $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId)
394369 }
395370 }
396371 }
397372
398373
399-func calcKLp (amountBalance,priceBalance,lpEmission) = {
400- let amountBalanceX18 = toX18BigInt(amountBalance, toBigInt(cfgAmountAssetDecimals))
401- let priceBalanceX18 = toX18BigInt(priceBalance, toBigInt(cfgPriceAssetDecimals))
402- let updatedKLp = fraction(pow((amountBalanceX18 * priceBalanceX18), 0, toBigInt(5), 1, 18, DOWN), big1, lpEmission)
403- if ((lpEmission == big0))
404- then big0
405- else updatedKLp
406- }
407-
408-
409-func calcCurrentKLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = {
410- let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta)
411- let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta)
412- let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta)
413- let currentKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpAssetEmission)
414- currentKLp
415- }
416-
417-
418-func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = {
419- let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta)
420- let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta)
421- let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta)
422- let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission))
423- let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))]
424- $Tuple2(actions, updatedKLp)
425- }
426-
427-
428-func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp))
429- then true
430- else throwErr(makeString(["updated KLp lower than current KLp", toString(oldKLp), toString(updatedKLp)], " "))
431-
432-
433374 func validateMatcherOrderAllowed (order) = {
434- let amountAssetBalance = getAccBalance(assetIdToString(cfgAmountAssetId))
435- let priceAssetBalance = getAccBalance(assetIdToString(cfgPriceAssetId))
436- let amountAssetAmount = order.amount
437- let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR)
438- let $t02148021692 = if ((order.orderType == Buy))
439- then $Tuple2(amountAssetAmount, -(priceAssetAmount))
440- else $Tuple2(-(amountAssetAmount), priceAssetAmount)
441- let amountAssetBalanceDelta = $t02148021692._1
442- let priceAssetBalanceDelta = $t02148021692._2
375+ let cfg = getPoolConfig()
376+ let amtAssetId = cfg[idxAmtAssetId]
377+ let priceAssetId = cfg[idxPriceAssetId]
378+ let poolStatus = parseIntValue(cfg[idxPoolStatus])
379+ let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
380+ let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
381+ let accAmtAssetBalance = getAccBalance(amtAssetId)
382+ let accPriceAssetBalance = getAccBalance(priceAssetId)
383+ let curPriceX18 = if ((order.orderType == Buy))
384+ then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance)
385+ else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance)
386+ let curPrice = fromX18(curPriceX18, scale8)
443387 if (if (if (isGlobalShutdown())
444388 then true
445- else (cfgPoolStatus == PoolMatcherDisabled))
389+ else (poolStatus == PoolMatcherDisabled))
446390 then true
447- else (cfgPoolStatus == PoolShutdown))
391+ else (poolStatus == PoolShutdown))
448392 then throw("Exchange operations disabled")
449- else if (if ((order.assetPair.amountAsset != cfgAmountAssetId))
450- then true
451- else (order.assetPair.priceAsset != cfgPriceAssetId))
452- then throw("Wrong order assets.")
453- else {
454- let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp"))
455- let $t02213222232 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
456- let unusedActions = $t02213222232._1
457- let kLpNew = $t02213222232._2
458- let isOrderValid = (kLpNew >= kLp)
459- let info = makeString(["kLp=", toString(kLp), " kLpNew=", toString(kLpNew), " amountAssetBalance=", toString(amountAssetBalance), " priceAssetBalance=", toString(priceAssetBalance), " amountAssetBalanceDelta=", toString(amountAssetBalanceDelta), " priceAssetBalanceDelta=", toString(priceAssetBalanceDelta)], "")
460- $Tuple2(isOrderValid, info)
461- }
393+ else {
394+ let orderAmtAsset = order.assetPair.amountAsset
395+ let orderAmtAssetStr = if ((orderAmtAsset == unit))
396+ then "WAVES"
397+ else toBase58String(value(orderAmtAsset))
398+ let orderPriceAsset = order.assetPair.priceAsset
399+ let orderPriceAssetStr = if ((orderPriceAsset == unit))
400+ then "WAVES"
401+ else toBase58String(value(orderPriceAsset))
402+ if (if ((orderAmtAssetStr != amtAssetId))
403+ then true
404+ else (orderPriceAssetStr != priceAssetId))
405+ then throw("Wrong order assets.")
406+ else {
407+ let orderPrice = order.price
408+ let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm)
409+ let castedOrderPrice = toScale(orderPrice, scale8, priceDcm)
410+ let isOrderPriceValid = if ((order.orderType == Buy))
411+ then (curPrice >= castedOrderPrice)
412+ else (castedOrderPrice >= curPrice)
413+ true
414+ }
415+ }
462416 }
463417
464418
465419 func commonGet (i) = if ((size(i.payments) != 1))
466420 then throw("exactly 1 payment is expected")
467421 else {
468422 let pmt = value(i.payments[0])
469423 let pmtAssetId = value(pmt.assetId)
470424 let pmtAmt = pmt.amount
471425 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller)
472426 let outAmAmt = res._1
473427 let outPrAmt = res._2
474428 let poolStatus = parseIntValue(res._9)
475429 let state = res._10
476430 if (if (isGlobalShutdown())
477431 then true
478432 else (poolStatus == PoolShutdown))
479433 then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
480434 else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state)
481435 }
482436
483437
484438 func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2))
485439 then throw("exactly 2 payments are expected")
486440 else {
487441 let amAssetPmt = value(i.payments[0])
488442 let prAssetPmt = value(i.payments[1])
489443 let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp)
490444 let poolStatus = parseIntValue(estPut._8)
491445 if (if (if (isGlobalShutdown())
492446 then true
493447 else (poolStatus == PoolPutDisabled))
494448 then true
495449 else (poolStatus == PoolShutdown))
496450 then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus)))
497451 else estPut
498452 }
499453
500454
501455 func emit (amount) = {
502456 let emitInv = invoke(factoryContract, "emit", [amount], nil)
503457 if ((emitInv == emitInv))
504458 then {
505459 let emitInvLegacy = match emitInv {
506460 case legacyFactoryContract: Address =>
507461 invoke(legacyFactoryContract, "emit", [amount], nil)
508462 case _ =>
509463 unit
510464 }
511465 if ((emitInvLegacy == emitInvLegacy))
512466 then amount
513467 else throw("Strict value is not equal to itself.")
514468 }
515469 else throw("Strict value is not equal to itself.")
516470 }
517471
518472
519473 func takeFee (amount,fee) = {
520474 let feeAmount = if ((fee == 0))
521475 then 0
522476 else fraction(amount, fee, scale8)
523477 $Tuple2((amount - feeAmount), feeAmount)
524478 }
525479
526480
527481 func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = {
528482 let isEval = (txId == unit)
529483 let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId))
530484 let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId))
531485 let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId))
532486 then true
533487 else if ((paymentAssetId == cfgPriceAssetId))
534488 then false
535489 else throwErr("invalid asset")
536- let $t02531025603 = if (isEval)
490+ let $t02272523018 = if (isEval)
537491 then $Tuple2(amountBalanceRaw, priceBalanceRaw)
538492 else if (paymentInAmountAsset)
539493 then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw)
540494 else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw))
541- let amountBalanceOld = $t02531025603._1
542- let priceBalanceOld = $t02531025603._2
543- let $t02560725756 = if (paymentInAmountAsset)
495+ let amountBalanceOld = $t02272523018._1
496+ let priceBalanceOld = $t02272523018._2
497+ let $t02302223171 = if (paymentInAmountAsset)
544498 then $Tuple2(paymentAmountRaw, 0)
545499 else $Tuple2(0, paymentAmountRaw)
546- let amountAssetAmountRaw = $t02560725756._1
547- let priceAssetAmountRaw = $t02560725756._2
500+ let amountAssetAmountRaw = $t02302223171._1
501+ let priceAssetAmountRaw = $t02302223171._2
548502 let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1
549503 let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1
550- let $t02588825952 = takeFee(paymentAmountRaw, inFee)
551- let paymentAmount = $t02588825952._1
552- let feeAmount = $t02588825952._2
504+ let $t02330323367 = takeFee(paymentAmountRaw, inFee)
505+ let paymentAmount = $t02330323367._1
506+ let feeAmount = $t02330323367._2
553507 let amountBalanceNew = (amountBalanceOld + amountAssetAmount)
554508 let priceBalanceNew = (priceBalanceOld + priceAssetAmount)
555509 let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals))
556510 let priceNew = fromX18(priceNewX18, scale8)
557511 let paymentBalance = if (paymentInAmountAsset)
558512 then amountBalanceOld
559513 else priceBalanceOld
560514 let paymentBalanceBigInt = toBigInt(paymentBalance)
561515 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
562516 let chechSupply = if ((supplyBigInt > big0))
563517 then true
564518 else throwErr("initial deposit requires all coins")
565519 if ((chechSupply == chechSupply))
566520 then {
567521 let depositBigInt = toBigInt(paymentAmount)
568522 let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))])
569523 let commonState = if (isEval)
570524 then nil
571525 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))]
572526 let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals))
573527 let priceOld = fromX18(priceOldX18, scale8)
574528 let loss = {
575- let $t02763327800 = if (paymentInAmountAsset)
529+ let $t02484425011 = if (paymentInAmountAsset)
576530 then $Tuple2(amountAssetAmountRaw, amountBalanceOld)
577531 else $Tuple2(priceAssetAmountRaw, priceBalanceOld)
578- let amount = $t02763327800._1
579- let balance = $t02763327800._2
532+ let amount = $t02484425011._1
533+ let balance = $t02484425011._2
580534 let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance)))
581535 fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth)
582536 }
583- $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset)
537+ $Tuple4(issueAmount, commonState, feeAmount, loss)
584538 }
585539 else throw("Strict value is not equal to itself.")
586540 }
587541
588542
589543 func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = {
590544 let isEval = (txId == unit)
591- let cfg = getPoolConfig()
592- let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
593- let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
594545 let checks = [if ((paymentAssetId == cfgLpAssetId))
595546 then true
596547 else throwErr("invalid lp asset")]
597548 if ((checks == checks))
598549 then {
599550 let outInAmountAsset = if ((outAssetId == cfgAmountAssetId))
600551 then true
601552 else if ((outAssetId == cfgPriceAssetId))
602553 then false
603554 else throwErr("invalid asset")
604555 let balanceBigInt = if (outInAmountAsset)
605556 then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId)))
606557 else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId)))
607- let outInAmountAssetDecimals = if (outInAmountAsset)
608- then amtAssetDcm
609- else priceAssetDcm
610558 let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId))
611559 let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId))
612560 let outBalance = if (outInAmountAsset)
613561 then amBalanceOld
614562 else prBalanceOld
615563 let outBalanceBigInt = toBigInt(outBalance)
616564 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
617565 let redeemedBigInt = toBigInt(paymentAmount)
618566 let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))])
619- let $t02987829934 = takeFee(amountRaw, outFee)
620- let totalAmount = $t02987829934._1
621- let feeAmount = $t02987829934._2
622- let $t02993830164 = if (outInAmountAsset)
567+ let $t02659126647 = takeFee(amountRaw, outFee)
568+ let totalAmount = $t02659126647._1
569+ let feeAmount = $t02659126647._2
570+ let $t02665126877 = if (outInAmountAsset)
623571 then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
624572 else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw))
625- let outAmAmount = $t02993830164._1
626- let outPrAmount = $t02993830164._2
627- let amBalanceNew = $t02993830164._3
628- let prBalanceNew = $t02993830164._4
573+ let outAmAmount = $t02665126877._1
574+ let outPrAmount = $t02665126877._2
575+ let amBalanceNew = $t02665126877._3
576+ let prBalanceNew = $t02665126877._4
629577 let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
630578 let priceNew = fromX18(priceNewX18, scale8)
631579 let commonState = if (isEval)
632580 then nil
633581 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)]
634582 let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals))
635583 let priceOld = fromX18(priceOldX18, scale8)
636584 let loss = {
637585 let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2)
638586 fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset)
639587 }
640- $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset)
588+ $Tuple4(totalAmount, commonState, feeAmount, loss)
641589 }
642590 else throw("Strict value is not equal to itself.")
643591 }
644592
645593
646594 func managerPublicKeyOrUnit () = match getString(mpk()) {
647595 case s: String =>
648596 fromBase58String(s)
649597 case _: Unit =>
650598 unit
651599 case _ =>
652600 throw("Match error")
653601 }
654602
655603
656604 func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) {
657605 case s: String =>
658606 fromBase58String(s)
659607 case _: Unit =>
660608 unit
661609 case _ =>
662610 throw("Match error")
663611 }
664612
665613
666614 func isManager (i) = match managerPublicKeyOrUnit() {
667615 case pk: ByteVector =>
668616 (i.callerPublicKey == pk)
669617 case _: Unit =>
670618 (i.caller == this)
671619 case _ =>
672620 throw("Match error")
673621 }
674622
675623
676624 func mustManager (i) = {
677625 let pd = throw("Permission denied")
678626 match managerPublicKeyOrUnit() {
679627 case pk: ByteVector =>
680628 if ((i.callerPublicKey == pk))
681629 then true
682630 else pd
683631 case _: Unit =>
684632 if ((i.caller == this))
685633 then true
686634 else pd
687635 case _ =>
688636 throw("Match error")
689637 }
690638 }
691639
692640
693641 @Callable(i)
642+func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse) = {
643+ let $t02855428859 = if ((isReverse == false))
644+ then {
645+ let assetOut = getStringOrFail(this, pa())
646+ let assetIn = getStringOrFail(this, aa())
647+ $Tuple2(assetOut, assetIn)
648+ }
649+ else {
650+ let assetOut = getStringOrFail(this, aa())
651+ let assetIn = getStringOrFail(this, pa())
652+ $Tuple2(assetOut, assetIn)
653+ }
654+ let assetOut = $t02855428859._1
655+ let assetIn = $t02855428859._2
656+ let poolAssetInBalance = getAccBalance(assetIn)
657+ let poolAssetOutBalance = getAccBalance(assetOut)
658+ let amountOut = ((poolAssetOutBalance * cleanAmountIn) / (poolAssetInBalance + cleanAmountIn))
659+ $Tuple2(nil, amountOut)
660+ }
661+
662+
663+
664+@Callable(i)
665+func calculateAmountOutForSwapAndSendTokens (cleanAmountIn,isReverse,amountOutMin,addressTo) = {
666+ let checks = [if ((value(i.payments[0]).amount >= cleanAmountIn))
667+ then true
668+ else throwErr("Wrong amount"), if ((i.caller == addressFromStringValue(getStringOrFail(this, swapContract()))))
669+ then true
670+ else throwErr("Permission denied")]
671+ if ((checks == checks))
672+ then {
673+ let pmt = value(i.payments[0])
674+ let assetIn = if ((pmt.assetId == unit))
675+ then toBase58String(toBytes("WAVES"))
676+ else toBase58String(value(pmt.assetId))
677+ let assetOut = if ((isReverse == false))
678+ then getStringOrFail(this, pa())
679+ else getStringOrFail(this, aa())
680+ let poolAssetInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount)
681+ let poolAssetOutBalance = getAccBalance(assetOut)
682+ let amountOut = ((poolAssetOutBalance * cleanAmountIn) / (poolAssetInBalance + cleanAmountIn))
683+ let checkMin = if ((amountOut >= amountOutMin))
684+ then true
685+ else throw("Exchange result is fewer coins than expected")
686+ if ((checkMin == checkMin))
687+ then [ScriptTransfer(addressFromStringValue(addressTo), amountOut, if ((assetIn == "WAVES"))
688+ then unit
689+ else fromBase58String(assetOut))]
690+ else throw("Strict value is not equal to itself.")
691+ }
692+ else throw("Strict value is not equal to itself.")
693+ }
694+
695+
696+
697+@Callable(i)
694698 func setManager (pendingManagerPublicKey) = {
695699 let checkCaller = mustManager(i)
696700 if ((checkCaller == checkCaller))
697701 then {
698702 let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
699703 if ((checkManagerPublicKey == checkManagerPublicKey))
700704 then [StringEntry(pmpk(), pendingManagerPublicKey)]
701705 else throw("Strict value is not equal to itself.")
702706 }
703707 else throw("Strict value is not equal to itself.")
704708 }
705709
706710
707711
708712 @Callable(i)
709713 func confirmManager () = {
710714 let pm = pendingManagerPublicKeyOrUnit()
711715 let hasPM = if (isDefined(pm))
712716 then true
713717 else throw("No pending manager")
714718 if ((hasPM == hasPM))
715719 then {
716720 let checkPM = if ((i.callerPublicKey == value(pm)))
717721 then true
718722 else throw("You are not pending manager")
719723 if ((checkPM == checkPM))
720724 then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())]
721725 else throw("Strict value is not equal to itself.")
722726 }
723727 else throw("Strict value is not equal to itself.")
724728 }
725729
726730
727731
728732 @Callable(i)
729733 func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance))
730734 then throw("Invalid slippageTolerance passed")
731735 else {
732736 let estPut = commonPut(i, slippageTolerance, true)
733737 let emitLpAmt = estPut._2
734738 let lpAssetId = estPut._7
735739 let state = estPut._9
736740 let amDiff = estPut._10
737741 let prDiff = estPut._11
738742 let amId = estPut._12
739743 let prId = estPut._13
740- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
741- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
742- let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
743- if ((currentKLp == currentKLp))
744+ let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
745+ if ((emitInv == emitInv))
744746 then {
745- let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
746- if ((emitInv == emitInv))
747+ let emitInvLegacy = match emitInv {
748+ case legacyFactoryContract: Address =>
749+ invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
750+ case _ =>
751+ unit
752+ }
753+ if ((emitInvLegacy == emitInvLegacy))
747754 then {
748- let emitInvLegacy = match emitInv {
749- case legacyFactoryContract: Address =>
750- invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
751- case _ =>
752- unit
753- }
754- if ((emitInvLegacy == emitInvLegacy))
755+ let slippageAInv = if ((amDiff > 0))
756+ then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
757+ else nil
758+ if ((slippageAInv == slippageAInv))
755759 then {
756- let slippageAInv = if ((amDiff > 0))
757- then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
760+ let slippagePInv = if ((prDiff > 0))
761+ then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
758762 else nil
759- if ((slippageAInv == slippageAInv))
763+ if ((slippagePInv == slippagePInv))
760764 then {
761- let slippagePInv = if ((prDiff > 0))
762- then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
763- else nil
764- if ((slippagePInv == slippagePInv))
765+ let lpTransfer = if (shouldAutoStake)
765766 then {
766- let lpTransfer = if (shouldAutoStake)
767- then {
768- let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
769- if ((slpStakeInv == slpStakeInv))
770- then nil
771- else throw("Strict value is not equal to itself.")
772- }
773- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
774- let $t03469235154 = refreshKLpInternal(0, 0, 0)
775- if (($t03469235154 == $t03469235154))
776- then {
777- let updatedKLp = $t03469235154._2
778- let refreshKLpActions = $t03469235154._1
779- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
780- if ((isUpdatedKLpValid == isUpdatedKLpValid))
781- then ((state ++ lpTransfer) ++ refreshKLpActions)
782- else throw("Strict value is not equal to itself.")
783- }
767+ let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
768+ if ((slpStakeInv == slpStakeInv))
769+ then nil
784770 else throw("Strict value is not equal to itself.")
785771 }
786- else throw("Strict value is not equal to itself.")
772+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
773+ (state ++ lpTransfer)
787774 }
788775 else throw("Strict value is not equal to itself.")
789776 }
790777 else throw("Strict value is not equal to itself.")
791778 }
792779 else throw("Strict value is not equal to itself.")
793780 }
794781 else throw("Strict value is not equal to itself.")
795782 }
796783
797784
798785
799786 @Callable(i)
800787 func putForFree (maxSlippage) = if ((0 > maxSlippage))
801788 then throw("Invalid value passed")
802789 else {
803790 let estPut = commonPut(i, maxSlippage, false)
804- let state = estPut._9
805- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
806- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
807- let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
808- if ((currentKLp == currentKLp))
809- then {
810- let $t03571635781 = refreshKLpInternal(0, 0, 0)
811- let refreshKLpActions = $t03571635781._1
812- let updatedKLp = $t03571635781._2
813- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
814- if ((isUpdatedKLpValid == isUpdatedKLpValid))
815- then (state ++ refreshKLpActions)
816- else throw("Strict value is not equal to itself.")
817- }
818- else throw("Strict value is not equal to itself.")
791+ estPut._9
819792 }
820793
821794
822795
823796 @Callable(i)
824797 func putOneTkn (minOutAmount,autoStake) = {
825798 let isPoolOneTokenOperationsDisabled = {
826799 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
827800 if ($isInstanceOf(@, "Boolean"))
828801 then @
829802 else throw(($getType(@) + " couldn't be cast to Boolean"))
830803 }
831804 let isPutDisabled = if (if (if (isGlobalShutdown())
832805 then true
833806 else (cfgPoolStatus == PoolPutDisabled))
834807 then true
835808 else (cfgPoolStatus == PoolShutdown))
836809 then true
837810 else isPoolOneTokenOperationsDisabled
838811 let checks = [if (if (!(isPutDisabled))
839812 then true
840813 else isManager(i))
841814 then true
842815 else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1))
843816 then true
844817 else throwErr("exactly 1 payment are expected")]
845818 if ((checks == checks))
846819 then {
847820 let payment = i.payments[0]
848821 let paymentAssetId = payment.assetId
849822 let paymentAmountRaw = payment.amount
850- let currentKLp = if ((paymentAssetId == cfgAmountAssetId))
851- then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0))
852- else if ((paymentAssetId == cfgPriceAssetId))
853- then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0))
854- else throwErr("payment asset is not supported")
855- if ((currentKLp == currentKLp))
823+ let userAddress = i.caller
824+ let txId = i.transactionId
825+ let $t03366433794 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
826+ if (($t03366433794 == $t03366433794))
856827 then {
857- let userAddress = i.caller
858- let txId = i.transactionId
859- let $t03696937121 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
860- if (($t03696937121 == $t03696937121))
828+ let bonus = $t03366433794._4
829+ let feeAmount = $t03366433794._3
830+ let commonState = $t03366433794._2
831+ let emitAmountEstimated = $t03366433794._1
832+ let emitAmount = if (if ((minOutAmount > 0))
833+ then (minOutAmount > emitAmountEstimated)
834+ else false)
835+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
836+ else emitAmountEstimated
837+ let emitInv = emit(emitAmount)
838+ if ((emitInv == emitInv))
861839 then {
862- let paymentInAmountAsset = $t03696937121._5
863- let bonus = $t03696937121._4
864- let feeAmount = $t03696937121._3
865- let commonState = $t03696937121._2
866- let emitAmountEstimated = $t03696937121._1
867- let emitAmount = if (if ((minOutAmount > 0))
868- then (minOutAmount > emitAmountEstimated)
869- else false)
870- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
871- else emitAmountEstimated
872- let emitInv = emit(emitAmount)
873- if ((emitInv == emitInv))
840+ let lpTransfer = if (autoStake)
874841 then {
875- let lpTransfer = if (autoStake)
876- then {
877- let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
878- if ((stakeInv == stakeInv))
879- then nil
880- else throw("Strict value is not equal to itself.")
881- }
882- else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
883- let sendFee = if ((feeAmount > 0))
884- then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
885- else nil
886- let $t03770737904 = if ((this == feeCollectorAddress))
887- then $Tuple2(0, 0)
888- else if (paymentInAmountAsset)
889- then $Tuple2(-(feeAmount), 0)
890- else $Tuple2(0, -(feeAmount))
891- let amountAssetBalanceDelta = $t03770737904._1
892- let priceAssetBalanceDelta = $t03770737904._2
893- let $t03790738015 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
894- let refreshKLpActions = $t03790738015._1
895- let updatedKLp = $t03790738015._2
896- let kLp = value(getString(keyKLp))
897- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
898- if ((isUpdatedKLpValid == isUpdatedKLpValid))
899- then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
842+ let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
843+ if ((stakeInv == stakeInv))
844+ then nil
900845 else throw("Strict value is not equal to itself.")
901846 }
902- else throw("Strict value is not equal to itself.")
847+ else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
848+ let sendFee = if ((feeAmount > 0))
849+ then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
850+ else nil
851+ $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount)
903852 }
904853 else throw("Strict value is not equal to itself.")
905854 }
906855 else throw("Strict value is not equal to itself.")
907856 }
908857 else throw("Strict value is not equal to itself.")
909858 }
910859
911860
912861
913862 @Callable(i)
914863 func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = {
915- let $t03832138478 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
916- let emitAmountEstimated = $t03832138478._1
917- let commonState = $t03832138478._2
918- let feeAmount = $t03832138478._3
919- let bonus = $t03832138478._4
920- let paymentInAmountAsset = $t03832138478._5
864+ let $t03452334658 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
865+ let emitAmountEstimated = $t03452334658._1
866+ let commonState = $t03452334658._2
867+ let feeAmount = $t03452334658._3
868+ let bonus = $t03452334658._4
921869 $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
922870 }
923871
924872
925873
926874 @Callable(i)
927875 func getOneTkn (outAssetIdStr,minOutAmount) = {
928876 let isPoolOneTokenOperationsDisabled = {
929877 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
930878 if ($isInstanceOf(@, "Boolean"))
931879 then @
932880 else throw(($getType(@) + " couldn't be cast to Boolean"))
933881 }
934882 let isGetDisabled = if (if (isGlobalShutdown())
935883 then true
936884 else (cfgPoolStatus == PoolShutdown))
937885 then true
938886 else isPoolOneTokenOperationsDisabled
939887 let checks = [if (if (!(isGetDisabled))
940888 then true
941889 else isManager(i))
942890 then true
943891 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1))
944892 then true
945893 else throwErr("exactly 1 payment are expected")]
946894 if ((checks == checks))
947895 then {
948896 let outAssetId = parseAssetId(outAssetIdStr)
949897 let payment = i.payments[0]
950898 let paymentAssetId = payment.assetId
951899 let paymentAmount = payment.amount
952- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
953- if ((currentKLp == currentKLp))
900+ let userAddress = i.caller
901+ let txId = i.transactionId
902+ let $t03546335598 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
903+ if (($t03546335598 == $t03546335598))
954904 then {
955- let userAddress = i.caller
956- let txId = i.transactionId
957- let $t03936339516 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
958- if (($t03936339516 == $t03936339516))
905+ let bonus = $t03546335598._4
906+ let feeAmount = $t03546335598._3
907+ let commonState = $t03546335598._2
908+ let amountEstimated = $t03546335598._1
909+ let amount = if (if ((minOutAmount > 0))
910+ then (minOutAmount > amountEstimated)
911+ else false)
912+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
913+ else amountEstimated
914+ let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
915+ if ((burnInv == burnInv))
959916 then {
960- let outInAmountAsset = $t03936339516._5
961- let bonus = $t03936339516._4
962- let feeAmount = $t03936339516._3
963- let commonState = $t03936339516._2
964- let amountEstimated = $t03936339516._1
965- let amount = if (if ((minOutAmount > 0))
966- then (minOutAmount > amountEstimated)
967- else false)
968- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
969- else amountEstimated
970- let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
971- if ((burnInv == burnInv))
972- then {
973- let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
974- let sendFee = if ((feeAmount > 0))
975- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
976- else nil
977- let $t04001640263 = {
978- let feeAmountForCalc = if ((this == feeCollectorAddress))
979- then 0
980- else feeAmount
981- if (outInAmountAsset)
982- then $Tuple2(-((amount + feeAmountForCalc)), 0)
983- else $Tuple2(0, -((amount + feeAmountForCalc)))
984- }
985- let amountAssetBalanceDelta = $t04001640263._1
986- let priceAssetBalanceDelta = $t04001640263._2
987- let $t04026640374 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
988- let refreshKLpActions = $t04026640374._1
989- let updatedKLp = $t04026640374._2
990- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
991- if ((isUpdatedKLpValid == isUpdatedKLpValid))
992- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
993- else throw("Strict value is not equal to itself.")
994- }
995- else throw("Strict value is not equal to itself.")
917+ let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
918+ let sendFee = if ((feeAmount > 0))
919+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
920+ else nil
921+ $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
996922 }
997923 else throw("Strict value is not equal to itself.")
998924 }
999925 else throw("Strict value is not equal to itself.")
1000926 }
1001927 else throw("Strict value is not equal to itself.")
1002928 }
1003929
1004930
1005931
1006932 @Callable(i)
1007933 func getOneTknREADONLY (outAssetId,paymentAmount) = {
1008- let $t04063140787 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
1009- let amountEstimated = $t04063140787._1
1010- let commonState = $t04063140787._2
1011- let feeAmount = $t04063140787._3
1012- let bonus = $t04063140787._4
1013- let outInAmountAsset = $t04063140787._5
934+ let $t03623336371 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
935+ let amountEstimated = $t03623336371._1
936+ let commonState = $t03623336371._2
937+ let feeAmount = $t03623336371._3
938+ let bonus = $t03623336371._4
1014939 $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
1015940 }
1016941
1017942
1018943
1019944 @Callable(i)
1020945 func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = {
1021946 let isPoolOneTokenOperationsDisabled = {
1022947 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
1023948 if ($isInstanceOf(@, "Boolean"))
1024949 then @
1025950 else throw(($getType(@) + " couldn't be cast to Boolean"))
1026951 }
1027952 let isGetDisabled = if (if (isGlobalShutdown())
1028953 then true
1029954 else (cfgPoolStatus == PoolShutdown))
1030955 then true
1031956 else isPoolOneTokenOperationsDisabled
1032957 let checks = [if (if (!(isGetDisabled))
1033958 then true
1034959 else isManager(i))
1035960 then true
1036961 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0))
1037962 then true
1038963 else throwErr("no payments are expected")]
1039964 if ((checks == checks))
1040965 then {
1041966 let outAssetId = parseAssetId(outAssetIdStr)
1042967 let userAddress = i.caller
1043968 let txId = i.transactionId
1044- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1045- if ((currentKLp == currentKLp))
969+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
970+ if ((unstakeInv == unstakeInv))
1046971 then {
1047- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1048- if ((unstakeInv == unstakeInv))
972+ let $t03719637329 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
973+ if (($t03719637329 == $t03719637329))
1049974 then {
1050- let $t04169241843 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
1051- if (($t04169241843 == $t04169241843))
975+ let bonus = $t03719637329._4
976+ let feeAmount = $t03719637329._3
977+ let commonState = $t03719637329._2
978+ let amountEstimated = $t03719637329._1
979+ let amount = if (if ((minOutAmount > 0))
980+ then (minOutAmount > amountEstimated)
981+ else false)
982+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
983+ else amountEstimated
984+ let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
985+ if ((burnInv == burnInv))
1052986 then {
1053- let outInAmountAsset = $t04169241843._5
1054- let bonus = $t04169241843._4
1055- let feeAmount = $t04169241843._3
1056- let commonState = $t04169241843._2
1057- let amountEstimated = $t04169241843._1
1058- let amount = if (if ((minOutAmount > 0))
1059- then (minOutAmount > amountEstimated)
1060- else false)
1061- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1062- else amountEstimated
1063- let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1064- if ((burnInv == burnInv))
1065- then {
1066- let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
1067- let sendFee = if ((feeAmount > 0))
1068- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
1069- else nil
1070- let $t04233842585 = {
1071- let feeAmountForCalc = if ((this == feeCollectorAddress))
1072- then 0
1073- else feeAmount
1074- if (outInAmountAsset)
1075- then $Tuple2(-((amount + feeAmountForCalc)), 0)
1076- else $Tuple2(0, -((amount + feeAmountForCalc)))
1077- }
1078- let amountAssetBalanceDelta = $t04233842585._1
1079- let priceAssetBalanceDelta = $t04233842585._2
1080- let $t04258842696 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1081- let refreshKLpActions = $t04258842696._1
1082- let updatedKLp = $t04258842696._2
1083- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1084- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1085- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1086- else throw("Strict value is not equal to itself.")
1087- }
1088- else throw("Strict value is not equal to itself.")
987+ let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
988+ let sendFee = if ((feeAmount > 0))
989+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
990+ else nil
991+ $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
1089992 }
1090993 else throw("Strict value is not equal to itself.")
1091994 }
1092995 else throw("Strict value is not equal to itself.")
1093996 }
1094997 else throw("Strict value is not equal to itself.")
1095998 }
1096999 else throw("Strict value is not equal to itself.")
10971000 }
10981001
10991002
11001003
11011004 @Callable(i)
11021005 func get () = {
11031006 let res = commonGet(i)
11041007 let outAmtAmt = res._1
11051008 let outPrAmt = res._2
11061009 let pmtAmt = res._3
11071010 let pmtAssetId = res._4
11081011 let state = res._5
1109- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1110- if ((currentKLp == currentKLp))
1111- then {
1112- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1113- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1114- then {
1115- let $t04364243724 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1116- let refreshKLpActions = $t04364243724._1
1117- let updatedKLp = $t04364243724._2
1118- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1119- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1120- then (state ++ refreshKLpActions)
1121- else throw("Strict value is not equal to itself.")
1122- }
1123- else throw("Strict value is not equal to itself.")
1124- }
1012+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1013+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1014+ then state
11251015 else throw("Strict value is not equal to itself.")
11261016 }
11271017
11281018
11291019
11301020 @Callable(i)
11311021 func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = {
11321022 let res = commonGet(i)
11331023 let outAmAmt = res._1
11341024 let outPrAmt = res._2
11351025 let pmtAmt = res._3
11361026 let pmtAssetId = res._4
11371027 let state = res._5
11381028 if ((noLessThenAmtAsset > outAmAmt))
11391029 then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset)))
11401030 else if ((noLessThenPriceAsset > outPrAmt))
11411031 then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
11421032 else {
1143- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1144- if ((currentKLp == currentKLp))
1145- then {
1146- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1147- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1148- then {
1149- let $t04467344754 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1150- let refreshKLpActions = $t04467344754._1
1151- let updatedKLp = $t04467344754._2
1152- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1153- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1154- then (state ++ refreshKLpActions)
1155- else throw("Strict value is not equal to itself.")
1156- }
1157- else throw("Strict value is not equal to itself.")
1158- }
1033+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1034+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1035+ then state
11591036 else throw("Strict value is not equal to itself.")
11601037 }
11611038 }
11621039
11631040
11641041
11651042 @Callable(i)
11661043 func unstakeAndGet (amount) = {
11671044 let checkPayments = if ((size(i.payments) != 0))
11681045 then throw("No payments are expected")
11691046 else true
11701047 if ((checkPayments == checkPayments))
11711048 then {
11721049 let cfg = getPoolConfig()
11731050 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
1174- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1175- if ((currentKLp == currentKLp))
1051+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
1052+ if ((unstakeInv == unstakeInv))
11761053 then {
1177- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
1178- if ((unstakeInv == unstakeInv))
1054+ let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1055+ let poolStatus = parseIntValue(res._9)
1056+ let state = res._10
1057+ let checkPoolStatus = if (if (isGlobalShutdown())
1058+ then true
1059+ else (poolStatus == PoolShutdown))
1060+ then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
1061+ else true
1062+ if ((checkPoolStatus == checkPoolStatus))
11791063 then {
1180- let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1181- let outAmAmt = res._1
1182- let outPrAmt = res._2
1183- let poolStatus = parseIntValue(res._9)
1184- let state = res._10
1185- let checkPoolStatus = if (if (isGlobalShutdown())
1186- then true
1187- else (poolStatus == PoolShutdown))
1188- then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
1189- else true
1190- if ((checkPoolStatus == checkPoolStatus))
1191- then {
1192- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1193- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1194- then {
1195- let $t04588045961 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1196- let refreshKLpActions = $t04588045961._1
1197- let updatedKLp = $t04588045961._2
1198- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1199- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1200- then (state ++ refreshKLpActions)
1201- else throw("Strict value is not equal to itself.")
1202- }
1203- else throw("Strict value is not equal to itself.")
1204- }
1064+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1065+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1066+ then state
12051067 else throw("Strict value is not equal to itself.")
12061068 }
12071069 else throw("Strict value is not equal to itself.")
12081070 }
12091071 else throw("Strict value is not equal to itself.")
12101072 }
12111073 else throw("Strict value is not equal to itself.")
12121074 }
12131075
12141076
12151077
12161078 @Callable(i)
12171079 func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = {
12181080 let isGetDisabled = if (isGlobalShutdown())
12191081 then true
12201082 else (cfgPoolStatus == PoolShutdown)
12211083 let checks = [if (!(isGetDisabled))
12221084 then true
12231085 else throw("get operation is blocked by admin"), if ((size(i.payments) == 0))
12241086 then true
12251087 else throw("no payments are expected")]
12261088 if ((checks == checks))
12271089 then {
1228- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1229- if ((currentKLp == currentKLp))
1090+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1091+ if ((unstakeInv == unstakeInv))
12301092 then {
1231- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1232- if ((unstakeInv == unstakeInv))
1093+ let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1094+ let outAmAmt = res._1
1095+ let outPrAmt = res._2
1096+ let state = res._10
1097+ let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1098+ then true
1099+ else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1100+ then true
1101+ else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1102+ if ((checkAmounts == checkAmounts))
12331103 then {
1234- let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1235- let outAmAmt = res._1
1236- let outPrAmt = res._2
1237- let state = res._10
1238- let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1239- then true
1240- else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1241- then true
1242- else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1243- if ((checkAmounts == checkAmounts))
1244- then {
1245- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1246- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1247- then {
1248- let $t04725647337 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1249- let refreshKLpActions = $t04725647337._1
1250- let updatedKLp = $t04725647337._2
1251- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1252- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1253- then (state ++ refreshKLpActions)
1254- else throw("Strict value is not equal to itself.")
1255- }
1256- else throw("Strict value is not equal to itself.")
1257- }
1104+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1105+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1106+ then state
12581107 else throw("Strict value is not equal to itself.")
12591108 }
12601109 else throw("Strict value is not equal to itself.")
12611110 }
12621111 else throw("Strict value is not equal to itself.")
12631112 }
12641113 else throw("Strict value is not equal to itself.")
12651114 }
12661115
12671116
12681117
12691118 @Callable(i)
12701119 func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
12711120 then throw("permissions denied")
12721121 else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success")
1273-
1274-
1275-
1276-@Callable(i)
1277-func refreshKLp () = {
1278- let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0)
1279- let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay))
1280- then unit
1281- else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1282- if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1283- then {
1284- let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp"))
1285- let $t04852448588 = refreshKLpInternal(0, 0, 0)
1286- let kLpUpdateActions = $t04852448588._1
1287- let updatedKLp = $t04852448588._2
1288- let actions = if ((kLp != updatedKLp))
1289- then kLpUpdateActions
1290- else throwErr("nothing to refresh")
1291- $Tuple2(actions, toString(updatedKLp))
1292- }
1293- else throw("Strict value is not equal to itself.")
1294- }
12951122
12961123
12971124
12981125 @Callable(i)
12991126 func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig())
13001127
13011128
13021129
13031130 @Callable(i)
13041131 func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId))
13051132
13061133
13071134
13081135 @Callable(i)
13091136 func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = {
13101137 let prices = calcPrices(amAmt, prAmt, lpAmt)
13111138 $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])])
13121139 }
13131140
13141141
13151142
13161143 @Callable(i)
13171144 func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult)))
13181145
13191146
13201147
13211148 @Callable(i)
13221149 func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult))
13231150
13241151
13251152
13261153 @Callable(i)
13271154 func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18))))
13281155
13291156
13301157
13311158 @Callable(i)
13321159 func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp))
13331160
13341161
13351162
13361163 @Callable(i)
13371164 func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
13381165 let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress))
13391166 $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10))
13401167 }
13411168
13421169
13431170
13441171 @Callable(i)
13451172 func statsREADONLY () = {
13461173 let cfg = getPoolConfig()
13471174 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
13481175 let amtAssetId = cfg[idxAmtAssetId]
13491176 let priceAssetId = cfg[idxPriceAssetId]
13501177 let iAmtAssetId = cfg[idxIAmtAssetId]
13511178 let iPriceAssetId = cfg[idxIPriceAssetId]
13521179 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
13531180 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
13541181 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
13551182 let accAmtAssetBalance = getAccBalance(amtAssetId)
13561183 let accPriceAssetBalance = getAccBalance(priceAssetId)
13571184 let pricesList = if ((poolLPBalance == 0))
13581185 then [zeroBigInt, zeroBigInt, zeroBigInt]
13591186 else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance)
13601187 let curPrice = 0
13611188 let lpAmtAssetShare = fromX18(pricesList[1], scale8)
13621189 let lpPriceAssetShare = fromX18(pricesList[2], scale8)
13631190 let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this))))
13641191 $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))
13651192 }
13661193
13671194
13681195
13691196 @Callable(i)
13701197 func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = {
13711198 let cfg = getPoolConfig()
13721199 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
13731200 let amAssetIdStr = cfg[idxAmtAssetId]
13741201 let amAssetId = fromBase58String(amAssetIdStr)
13751202 let prAssetIdStr = cfg[idxPriceAssetId]
13761203 let prAssetId = fromBase58String(prAssetIdStr)
13771204 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
13781205 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
13791206 let poolStatus = cfg[idxPoolStatus]
13801207 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
13811208 let accAmtAssetBalance = getAccBalance(amAssetIdStr)
13821209 let accPriceAssetBalance = getAccBalance(prAssetIdStr)
13831210 let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm)
13841211 let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm)
13851212 let curPriceX18 = if ((poolLPBalance == 0))
13861213 then zeroBigInt
13871214 else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18)
13881215 let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm)
13891216 let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
13901217 let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm)
13911218 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
13921219 let calcLpAmt = estPut._1
13931220 let curPriceCalc = estPut._3
13941221 let amBalance = estPut._4
13951222 let prBalance = estPut._5
13961223 let lpEmission = estPut._6
13971224 $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))
13981225 }
13991226
14001227
14011228
14021229 @Callable(i)
14031230 func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = {
14041231 let cfg = getPoolConfig()
14051232 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
14061233 let amAssetIdStr = cfg[idxAmtAssetId]
14071234 let amAssetId = fromBase58String(amAssetIdStr)
14081235 let prAssetIdStr = cfg[idxPriceAssetId]
14091236 let prAssetId = fromBase58String(prAssetIdStr)
14101237 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
14111238 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
14121239 let poolStatus = cfg[idxPoolStatus]
14131240 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
14141241 let amBalanceRaw = getAccBalance(amAssetIdStr)
14151242 let prBalanceRaw = getAccBalance(prAssetIdStr)
14161243 let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm)
14171244 let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm)
14181245 let curPriceX18 = if ((poolLPBalance == 0))
14191246 then zeroBigInt
14201247 else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18)
14211248 let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm)
14221249 let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
14231250 let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm)
14241251 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
14251252 let calcLpAmt = estPut._1
14261253 let curPriceCalc = estPut._3
14271254 let amBalance = estPut._4
14281255 let prBalance = estPut._5
14291256 let lpEmission = estPut._6
14301257 $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))
14311258 }
14321259
14331260
14341261
14351262 @Callable(i)
14361263 func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = {
14371264 let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this)
14381265 let outAmAmt = res._1
14391266 let outPrAmt = res._2
14401267 let amBalance = res._5
14411268 let prBalance = res._6
14421269 let lpEmission = res._7
14431270 let curPrice = res._8
14441271 let poolStatus = parseIntValue(res._9)
14451272 $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))
14461273 }
14471274
14481275
14491276 @Verifier(tx)
14501277 func verify () = {
14511278 let targetPublicKey = match managerPublicKeyOrUnit() {
14521279 case pk: ByteVector =>
14531280 pk
14541281 case _: Unit =>
14551282 tx.senderPublicKey
14561283 case _ =>
14571284 throw("Match error")
14581285 }
14591286 match tx {
14601287 case order: Order =>
14611288 let matcherPub = getMatcherPubOrFail()
1462- let $t05725057319 = validateMatcherOrderAllowed(order)
1463- let orderValid = $t05725057319._1
1464- let orderValidInfo = $t05725057319._2
1289+ let orderValid = validateMatcherOrderAllowed(order)
14651290 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
14661291 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
14671292 if (if (if (orderValid)
14681293 then senderValid
14691294 else false)
14701295 then matcherValid
14711296 else false)
14721297 then true
1473- else throwOrderError(orderValid, orderValidInfo, senderValid, matcherValid)
1298+ else throwOrderError(orderValid, senderValid, matcherValid)
14741299 case s: SetScriptTransaction =>
14751300 let newHash = blake2b256(value(s.script))
14761301 let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash())))
14771302 let currentHash = scriptHash(this)
14781303 if (if ((allowedHash == newHash))
14791304 then (currentHash != newHash)
14801305 else false)
14811306 then true
14821307 else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
14831308 case _ =>
14841309 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
14851310 }
14861311 }
14871312

github/deemru/w8io/026f985 
184.88 ms