tx · 23HB4bSR3CPyvw7dMasHNEejo5mZ3rdYXSh48LK82JHj

3N8iNNRC4UfDK4aJctSvHajiZ81fzSumCeP:  -0.03600000 Waves

2023.02.09 15:49 [2442107] smart account 3N8iNNRC4UfDK4aJctSvHajiZ81fzSumCeP > SELF 0.00000000 Waves

{ "type": 13, "id": "23HB4bSR3CPyvw7dMasHNEejo5mZ3rdYXSh48LK82JHj", "fee": 3600000, "feeAssetId": null, "timestamp": 1675946968257, "version": 1, "sender": "3N8iNNRC4UfDK4aJctSvHajiZ81fzSumCeP", "senderPublicKey": "F7NZd812aXMUyDcj1XaB3wgMJXJfUsq3RhPhrEZ9b6ND", "proofs": [ "5ASienzpGSBReJUY5QiPCRkgxxxgmhoz9MFxqbNjFR2eG7VP5dsJD67V586yp4p49NyzS4eqRJo1avU1LHXb1uFk" ], "script": "base64:BgKBLggCEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgQKAggBEgQKAggBEgQKAggBEgUKAwEIARIAEgQKAgEBEgMKAQESBQoDAQEBEgQKAggIEgASABIDCgEIEgUKAwEBARIECgIBARIECgIIARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCBIAEgMKAQESAwoBARIECgIIASIKbFBkZWNpbWFscyIGc2NhbGU4IgxzY2FsZThCaWdJbnQiB3NjYWxlMTgiCnplcm9CaWdJbnQiBGJpZzAiBGJpZzEiBGJpZzIiC3dhdmVzU3RyaW5nIgNTRVAiClBvb2xBY3RpdmUiD1Bvb2xQdXREaXNhYmxlZCITUG9vbE1hdGNoZXJEaXNhYmxlZCIMUG9vbFNodXRkb3duIg5pZHhQb29sQWRkcmVzcyINaWR4UG9vbFN0YXR1cyIQaWR4UG9vbExQQXNzZXRJZCINaWR4QW10QXNzZXRJZCIPaWR4UHJpY2VBc3NldElkIg5pZHhBbXRBc3NldERjbSIQaWR4UHJpY2VBc3NldERjbSIOaWR4SUFtdEFzc2V0SWQiEGlkeElQcmljZUFzc2V0SWQiDWlkeExQQXNzZXREY20iEm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YDCQD0AwMIBQJnSQlib2R5Qnl0ZXMJAJEDAggFAmdJBnByb29mcwAABQJnSwYEAmdOCQD2AwEJAQV2YWx1ZQEIBQJlWgZzY3JpcHQEAmdPCQDbBAEJAQV2YWx1ZQEJAJ0IAgUCYU4JAQJhegAEAmdQCQDxBwEFBHRoaXMDCQAAAgUCZ08FAmdOCQECIT0CBQJnUAUCZ04HCQD0AwMIBQJnSQlib2R5Qnl0ZXMJAJEDAggFAmdJBnByb29mcwAABQJnS0Hdfx8=", "chainId": 84, "height": 2442107, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: CJZHVX7YsVEwgzRG1XUWFNzB5pFEArttLYuW7nXLABVf Next: 5KZBESpdB1ndZa6iQt8mVoZy5iBoBqyPisyM87o7n4Zx Diff:
OldNewDifferences
8484 else val
8585
8686
87-func swapContract () = "%s__swapContract"
88-
89-
9087 func fc () = "%s__factoryContract"
9188
9289
114111 func pa () = "%s__priceAsset"
115112
116113
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+
117130 func keyFactoryConfig () = "%s__factoryConfig"
118131
119132
140153
141154 let keyFeeCollectorAddress = "%s__feeCollectorAddress"
142155
143-func throwOrderError (orderValid,senderValid,matcherValid) = throw(((((("order validation failed: orderValid=" + toString(orderValid)) + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid)))
156+func throwOrderError (orderValid,orderValidInfo,senderValid,matcherValid) = throw((((((((("order validation failed: orderValid=" + toString(orderValid)) + " (") + orderValidInfo) + ")") + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid)))
144157
145158
146159 func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
150163
151164
152165 func throwErr (msg) = throw(makeString(["lp.ride:", msg], " "))
166+
167+
168+func fmtErr (msg) = makeString(["lp.ride:", msg], " ")
153169
154170
155171 let factoryContract = addressFromStringValue(getStringOrFail(this, fc()))
200216
201217 let poolConfigParsed = parsePoolConfig(getPoolConfig())
202218
203-let $t079068072 = poolConfigParsed
219+let $t084088574 = poolConfigParsed
204220
205-let cfgPoolAddress = $t079068072._1
221+let cfgPoolAddress = $t084088574._1
206222
207-let cfgPoolStatus = $t079068072._2
223+let cfgPoolStatus = $t084088574._2
208224
209-let cfgLpAssetId = $t079068072._3
225+let cfgLpAssetId = $t084088574._3
210226
211-let cfgAmountAssetId = $t079068072._4
227+let cfgAmountAssetId = $t084088574._4
212228
213-let cfgPriceAssetId = $t079068072._5
229+let cfgPriceAssetId = $t084088574._5
214230
215-let cfgAmountAssetDecimals = $t079068072._6
231+let cfgAmountAssetDecimals = $t084088574._6
216232
217-let cfgPriceAssetDecimals = $t079068072._7
233+let cfgPriceAssetDecimals = $t084088574._7
218234
219235 func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
220236
235251
236252
237253 func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
254+
255+
256+func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
238257
239258
240259 func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
286305 let lpEmissionX18 = toX18(lpEmission, scale8)
287306 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18)
288307 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18)
289- let outAmAmt = fromX18(outAmAmtX18, amAssetDcm)
290- let outPrAmt = fromX18(outPrAmtX18, prAssetDcm)
308+ let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR)
309+ let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR)
291310 let state = if ((txId58 == ""))
292311 then nil
293312 else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES"))
346365 then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18)))
347366 else {
348367 let lpEmissionX18 = toX18(lpEmission, scale8)
349- let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
350- let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
368+ let prViaAmX18 = fraction(inAmAssetAmtX18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING)
369+ let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, FLOOR), CEILING)
351370 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
352371 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
353372 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
354373 let expAmtAssetAmtX18 = expectedAmts._1
355374 let expPriceAssetAmtX18 = expectedAmts._2
356- let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
357- $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18)
375+ let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR)
376+ $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtAssetDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceAssetDcm, CEILING), curPriceX18, slippageX18)
358377 }
359378 }
360379 let calcLpAmt = res._1
377396 }
378397
379398
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+
380433 func validateMatcherOrderAllowed (order) = {
381- let cfg = getPoolConfig()
382- let amtAssetId = cfg[idxAmtAssetId]
383- let priceAssetId = cfg[idxPriceAssetId]
384- let poolStatus = parseIntValue(cfg[idxPoolStatus])
385- let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
386- let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
387- let accAmtAssetBalance = getAccBalance(amtAssetId)
388- let accPriceAssetBalance = getAccBalance(priceAssetId)
389- let curPriceX18 = if ((order.orderType == Buy))
390- then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance)
391- else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance)
392- let curPrice = fromX18(curPriceX18, scale8)
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
393443 if (if (if (isGlobalShutdown())
394444 then true
395- else (poolStatus == PoolMatcherDisabled))
445+ else (cfgPoolStatus == PoolMatcherDisabled))
396446 then true
397- else (poolStatus == PoolShutdown))
447+ else (cfgPoolStatus == PoolShutdown))
398448 then throw("Exchange operations disabled")
399- else {
400- let orderAmtAsset = order.assetPair.amountAsset
401- let orderAmtAssetStr = if ((orderAmtAsset == unit))
402- then "WAVES"
403- else toBase58String(value(orderAmtAsset))
404- let orderPriceAsset = order.assetPair.priceAsset
405- let orderPriceAssetStr = if ((orderPriceAsset == unit))
406- then "WAVES"
407- else toBase58String(value(orderPriceAsset))
408- if (if ((orderAmtAssetStr != amtAssetId))
409- then true
410- else (orderPriceAssetStr != priceAssetId))
411- then throw("Wrong order assets.")
412- else {
413- let orderPrice = order.price
414- let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm)
415- let castedOrderPrice = toScale(orderPrice, scale8, priceDcm)
416- let isOrderPriceValid = if ((order.orderType == Buy))
417- then (curPrice >= castedOrderPrice)
418- else (castedOrderPrice >= curPrice)
419- true
420- }
421- }
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), " height=", toString(height)], "")
460+ $Tuple2(isOrderValid, info)
461+ }
422462 }
423463
424464
493533 else if ((paymentAssetId == cfgPriceAssetId))
494534 then false
495535 else throwErr("invalid asset")
496- let $t02296923262 = if (isEval)
536+ let $t02534525638 = if (isEval)
497537 then $Tuple2(amountBalanceRaw, priceBalanceRaw)
498538 else if (paymentInAmountAsset)
499539 then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw)
500540 else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw))
501- let amountBalanceOld = $t02296923262._1
502- let priceBalanceOld = $t02296923262._2
503- let $t02326623415 = if (paymentInAmountAsset)
541+ let amountBalanceOld = $t02534525638._1
542+ let priceBalanceOld = $t02534525638._2
543+ let $t02564225791 = if (paymentInAmountAsset)
504544 then $Tuple2(paymentAmountRaw, 0)
505545 else $Tuple2(0, paymentAmountRaw)
506- let amountAssetAmountRaw = $t02326623415._1
507- let priceAssetAmountRaw = $t02326623415._2
546+ let amountAssetAmountRaw = $t02564225791._1
547+ let priceAssetAmountRaw = $t02564225791._2
508548 let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1
509549 let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1
510- let $t02354723611 = takeFee(paymentAmountRaw, inFee)
511- let paymentAmount = $t02354723611._1
512- let feeAmount = $t02354723611._2
550+ let $t02592325987 = takeFee(paymentAmountRaw, inFee)
551+ let paymentAmount = $t02592325987._1
552+ let feeAmount = $t02592325987._2
513553 let amountBalanceNew = (amountBalanceOld + amountAssetAmount)
514554 let priceBalanceNew = (priceBalanceOld + priceAssetAmount)
515555 let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals))
532572 let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals))
533573 let priceOld = fromX18(priceOldX18, scale8)
534574 let loss = {
535- let $t02508825255 = if (paymentInAmountAsset)
575+ let $t02766827835 = if (paymentInAmountAsset)
536576 then $Tuple2(amountAssetAmountRaw, amountBalanceOld)
537577 else $Tuple2(priceAssetAmountRaw, priceBalanceOld)
538- let amount = $t02508825255._1
539- let balance = $t02508825255._2
578+ let amount = $t02766827835._1
579+ let balance = $t02766827835._2
540580 let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance)))
541581 fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth)
542582 }
543- $Tuple4(issueAmount, commonState, feeAmount, loss)
583+ $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset)
544584 }
545585 else throw("Strict value is not equal to itself.")
546586 }
548588
549589 func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = {
550590 let isEval = (txId == unit)
591+ let cfg = getPoolConfig()
592+ let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
593+ let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
551594 let checks = [if ((paymentAssetId == cfgLpAssetId))
552595 then true
553596 else throwErr("invalid lp asset")]
561604 let balanceBigInt = if (outInAmountAsset)
562605 then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId)))
563606 else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId)))
607+ let outInAmountAssetDecimals = if (outInAmountAsset)
608+ then amtAssetDcm
609+ else priceAssetDcm
564610 let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId))
565611 let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId))
566612 let outBalance = if (outInAmountAsset)
570616 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
571617 let redeemedBigInt = toBigInt(paymentAmount)
572618 let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))])
573- let $t02683526891 = takeFee(amountRaw, outFee)
574- let totalAmount = $t02683526891._1
575- let feeAmount = $t02683526891._2
576- let $t02689527121 = if (outInAmountAsset)
619+ let $t02991329969 = takeFee(amountRaw, outFee)
620+ let totalAmount = $t02991329969._1
621+ let feeAmount = $t02991329969._2
622+ let $t02997330199 = if (outInAmountAsset)
577623 then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
578624 else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw))
579- let outAmAmount = $t02689527121._1
580- let outPrAmount = $t02689527121._2
581- let amBalanceNew = $t02689527121._3
582- let prBalanceNew = $t02689527121._4
625+ let outAmAmount = $t02997330199._1
626+ let outPrAmount = $t02997330199._2
627+ let amBalanceNew = $t02997330199._3
628+ let prBalanceNew = $t02997330199._4
583629 let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
584630 let priceNew = fromX18(priceNewX18, scale8)
585631 let commonState = if (isEval)
591637 let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2)
592638 fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset)
593639 }
594- $Tuple4(totalAmount, commonState, feeAmount, loss)
640+ $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset)
595641 }
596642 else throw("Strict value is not equal to itself.")
597643 }
645691
646692
647693 @Callable(i)
648-func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse) = {
649- let $t02879829103 = if ((isReverse == false))
650- then {
651- let assetOut = getStringOrFail(this, pa())
652- let assetIn = getStringOrFail(this, aa())
653- $Tuple2(assetOut, assetIn)
654- }
655- else {
656- let assetOut = getStringOrFail(this, aa())
657- let assetIn = getStringOrFail(this, pa())
658- $Tuple2(assetOut, assetIn)
659- }
660- let assetOut = $t02879829103._1
661- let assetIn = $t02879829103._2
662- let poolAssetInBalance = getAccBalance(assetIn)
663- let poolAssetOutBalance = getAccBalance(assetOut)
664- let amountOut = fraction(poolAssetOutBalance, cleanAmountIn, (poolAssetInBalance + cleanAmountIn))
665- let oldK = (toBigInt(poolAssetInBalance) * toBigInt(poolAssetOutBalance))
666- let newK = ((toBigInt(getAccBalance(assetIn)) + toBigInt(cleanAmountIn)) * (toBigInt(getAccBalance(assetOut)) - toBigInt(amountOut)))
667- let checkK = if ((newK >= oldK))
668- then true
669- else throw("new K is fewer error")
670- if ((checkK == checkK))
671- then $Tuple2(nil, amountOut)
672- else throw("Strict value is not equal to itself.")
673- }
674-
675-
676-
677-@Callable(i)
678-func calculateAmountOutForSwapAndSendTokens (cleanAmountIn,isReverse,amountOutMin,addressTo) = {
679- let checks = [if ((value(i.payments[0]).amount >= cleanAmountIn))
680- then true
681- else throwErr("Wrong amount"), if ((i.caller == addressFromStringValue(getStringOrFail(this, swapContract()))))
682- then true
683- else throwErr("Permission denied")]
684- if ((checks == checks))
685- then {
686- let pmt = value(i.payments[0])
687- let assetIn = if ((pmt.assetId == unit))
688- then toBase58String(toBytes("WAVES"))
689- else toBase58String(value(pmt.assetId))
690- let assetOut = if ((isReverse == false))
691- then getStringOrFail(this, pa())
692- else getStringOrFail(this, aa())
693- let poolAssetInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount)
694- let poolAssetOutBalance = getAccBalance(assetOut)
695- let amountOut = ((poolAssetOutBalance * cleanAmountIn) / (poolAssetInBalance + cleanAmountIn))
696- let oldK = (poolAssetInBalance * poolAssetOutBalance)
697- let newK = (getAccBalance(assetIn) * (getAccBalance(assetOut) - amountOut))
698- let checkK = if ((newK >= oldK))
699- then true
700- else throw("new K is fewer error")
701- if ((checkK == checkK))
702- then {
703- let checkMin = if ((amountOut >= amountOutMin))
704- then true
705- else throw("Exchange result is fewer coins than expected")
706- if ((checkMin == checkMin))
707- then [ScriptTransfer(addressFromStringValue(addressTo), amountOut, if ((assetIn == "WAVES"))
708- then unit
709- else fromBase58String(assetOut))]
710- else throw("Strict value is not equal to itself.")
711- }
712- else throw("Strict value is not equal to itself.")
713- }
714- else throw("Strict value is not equal to itself.")
715- }
716-
717-
718-
719-@Callable(i)
720694 func setManager (pendingManagerPublicKey) = {
721695 let checkCaller = mustManager(i)
722696 if ((checkCaller == checkCaller))
763737 let prDiff = estPut._11
764738 let amId = estPut._12
765739 let prId = estPut._13
766- let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
767- if ((emitInv == emitInv))
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))
768744 then {
769- let emitInvLegacy = match emitInv {
770- case legacyFactoryContract: Address =>
771- invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
772- case _ =>
773- unit
774- }
775- if ((emitInvLegacy == emitInvLegacy))
745+ let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
746+ if ((emitInv == emitInv))
776747 then {
777- let slippageAInv = if ((amDiff > 0))
778- then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
779- else nil
780- if ((slippageAInv == slippageAInv))
748+ let emitInvLegacy = match emitInv {
749+ case legacyFactoryContract: Address =>
750+ invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
751+ case _ =>
752+ unit
753+ }
754+ if ((emitInvLegacy == emitInvLegacy))
781755 then {
782- let slippagePInv = if ((prDiff > 0))
783- then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
756+ let slippageAInv = if ((amDiff > 0))
757+ then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
784758 else nil
785- if ((slippagePInv == slippagePInv))
759+ if ((slippageAInv == slippageAInv))
786760 then {
787- let lpTransfer = if (shouldAutoStake)
761+ let slippagePInv = if ((prDiff > 0))
762+ then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
763+ else nil
764+ if ((slippagePInv == slippagePInv))
788765 then {
789- let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
790- if ((slpStakeInv == slpStakeInv))
791- then nil
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 $t03472735189 = refreshKLpInternal(0, 0, 0)
775+ if (($t03472735189 == $t03472735189))
776+ then {
777+ let updatedKLp = $t03472735189._2
778+ let refreshKLpActions = $t03472735189._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+ }
792784 else throw("Strict value is not equal to itself.")
793785 }
794- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
795- (state ++ lpTransfer)
786+ else throw("Strict value is not equal to itself.")
796787 }
797788 else throw("Strict value is not equal to itself.")
798789 }
810801 then throw("Invalid value passed")
811802 else {
812803 let estPut = commonPut(i, maxSlippage, false)
813- estPut._9
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 $t03575135816 = refreshKLpInternal(0, 0, 0)
811+ let refreshKLpActions = $t03575135816._1
812+ let updatedKLp = $t03575135816._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.")
814819 }
815820
816821
842847 let payment = i.payments[0]
843848 let paymentAssetId = payment.assetId
844849 let paymentAmountRaw = payment.amount
845- let userAddress = i.caller
846- let txId = i.transactionId
847- let $t03429434424 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
848- if (($t03429434424 == $t03429434424))
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))
849856 then {
850- let bonus = $t03429434424._4
851- let feeAmount = $t03429434424._3
852- let commonState = $t03429434424._2
853- let emitAmountEstimated = $t03429434424._1
854- let emitAmount = if (if ((minOutAmount > 0))
855- then (minOutAmount > emitAmountEstimated)
856- else false)
857- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
858- else emitAmountEstimated
859- let emitInv = emit(emitAmount)
860- if ((emitInv == emitInv))
857+ let userAddress = i.caller
858+ let txId = i.transactionId
859+ let $t03700437156 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
860+ if (($t03700437156 == $t03700437156))
861861 then {
862- let lpTransfer = if (autoStake)
862+ let paymentInAmountAsset = $t03700437156._5
863+ let bonus = $t03700437156._4
864+ let feeAmount = $t03700437156._3
865+ let commonState = $t03700437156._2
866+ let emitAmountEstimated = $t03700437156._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))
863874 then {
864- let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
865- if ((stakeInv == stakeInv))
866- then nil
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 $t03774237939 = 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 = $t03774237939._1
892+ let priceAssetBalanceDelta = $t03774237939._2
893+ let $t03794238050 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
894+ let refreshKLpActions = $t03794238050._1
895+ let updatedKLp = $t03794238050._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)
867900 else throw("Strict value is not equal to itself.")
868901 }
869- else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
870- let sendFee = if ((feeAmount > 0))
871- then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
872- else nil
873- $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount)
902+ else throw("Strict value is not equal to itself.")
874903 }
875904 else throw("Strict value is not equal to itself.")
876905 }
883912
884913 @Callable(i)
885914 func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = {
886- let $t03515335288 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
887- let emitAmountEstimated = $t03515335288._1
888- let commonState = $t03515335288._2
889- let feeAmount = $t03515335288._3
890- let bonus = $t03515335288._4
915+ let $t03835638513 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
916+ let emitAmountEstimated = $t03835638513._1
917+ let commonState = $t03835638513._2
918+ let feeAmount = $t03835638513._3
919+ let bonus = $t03835638513._4
920+ let paymentInAmountAsset = $t03835638513._5
891921 $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
892922 }
893923
919949 let payment = i.payments[0]
920950 let paymentAssetId = payment.assetId
921951 let paymentAmount = payment.amount
922- let userAddress = i.caller
923- let txId = i.transactionId
924- let $t03609336228 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
925- if (($t03609336228 == $t03609336228))
952+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
953+ if ((currentKLp == currentKLp))
926954 then {
927- let bonus = $t03609336228._4
928- let feeAmount = $t03609336228._3
929- let commonState = $t03609336228._2
930- let amountEstimated = $t03609336228._1
931- let amount = if (if ((minOutAmount > 0))
932- then (minOutAmount > amountEstimated)
933- else false)
934- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
935- else amountEstimated
936- let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
937- if ((burnInv == burnInv))
955+ let userAddress = i.caller
956+ let txId = i.transactionId
957+ let $t03939839551 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
958+ if (($t03939839551 == $t03939839551))
938959 then {
939- let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
940- let sendFee = if ((feeAmount > 0))
941- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
942- else nil
943- $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
960+ let outInAmountAsset = $t03939839551._5
961+ let bonus = $t03939839551._4
962+ let feeAmount = $t03939839551._3
963+ let commonState = $t03939839551._2
964+ let amountEstimated = $t03939839551._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 $t04005140298 = {
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 = $t04005140298._1
986+ let priceAssetBalanceDelta = $t04005140298._2
987+ let $t04030140409 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
988+ let refreshKLpActions = $t04030140409._1
989+ let updatedKLp = $t04030140409._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.")
944996 }
945997 else throw("Strict value is not equal to itself.")
946998 }
9531005
9541006 @Callable(i)
9551007 func getOneTknREADONLY (outAssetId,paymentAmount) = {
956- let $t03686337001 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
957- let amountEstimated = $t03686337001._1
958- let commonState = $t03686337001._2
959- let feeAmount = $t03686337001._3
960- let bonus = $t03686337001._4
1008+ let $t04066640822 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
1009+ let amountEstimated = $t04066640822._1
1010+ let commonState = $t04066640822._2
1011+ let feeAmount = $t04066640822._3
1012+ let bonus = $t04066640822._4
1013+ let outInAmountAsset = $t04066640822._5
9611014 $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
9621015 }
9631016
9881041 let outAssetId = parseAssetId(outAssetIdStr)
9891042 let userAddress = i.caller
9901043 let txId = i.transactionId
991- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
992- if ((unstakeInv == unstakeInv))
1044+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1045+ if ((currentKLp == currentKLp))
9931046 then {
994- let $t03782637959 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
995- if (($t03782637959 == $t03782637959))
1047+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1048+ if ((unstakeInv == unstakeInv))
9961049 then {
997- let bonus = $t03782637959._4
998- let feeAmount = $t03782637959._3
999- let commonState = $t03782637959._2
1000- let amountEstimated = $t03782637959._1
1001- let amount = if (if ((minOutAmount > 0))
1002- then (minOutAmount > amountEstimated)
1003- else false)
1004- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1005- else amountEstimated
1006- let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1007- if ((burnInv == burnInv))
1050+ let $t04172741878 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
1051+ if (($t04172741878 == $t04172741878))
10081052 then {
1009- let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
1010- let sendFee = if ((feeAmount > 0))
1011- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
1012- else nil
1013- $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
1053+ let outInAmountAsset = $t04172741878._5
1054+ let bonus = $t04172741878._4
1055+ let feeAmount = $t04172741878._3
1056+ let commonState = $t04172741878._2
1057+ let amountEstimated = $t04172741878._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 $t04237342620 = {
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 = $t04237342620._1
1079+ let priceAssetBalanceDelta = $t04237342620._2
1080+ let $t04262342731 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1081+ let refreshKLpActions = $t04262342731._1
1082+ let updatedKLp = $t04262342731._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.")
10141089 }
10151090 else throw("Strict value is not equal to itself.")
10161091 }
10311106 let pmtAmt = res._3
10321107 let pmtAssetId = res._4
10331108 let state = res._5
1034- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1035- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1036- then state
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 $t04367743759 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1116+ let refreshKLpActions = $t04367743759._1
1117+ let updatedKLp = $t04367743759._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+ }
10371125 else throw("Strict value is not equal to itself.")
10381126 }
10391127
10521140 else if ((noLessThenPriceAsset > outPrAmt))
10531141 then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
10541142 else {
1055- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1056- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1057- then state
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 $t04470844789 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1150+ let refreshKLpActions = $t04470844789._1
1151+ let updatedKLp = $t04470844789._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+ }
10581159 else throw("Strict value is not equal to itself.")
10591160 }
10601161 }
10701171 then {
10711172 let cfg = getPoolConfig()
10721173 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
1073- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
1074- if ((unstakeInv == unstakeInv))
1174+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1175+ if ((currentKLp == currentKLp))
10751176 then {
1076- let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1077- let poolStatus = parseIntValue(res._9)
1078- let state = res._10
1079- let checkPoolStatus = if (if (isGlobalShutdown())
1080- then true
1081- else (poolStatus == PoolShutdown))
1082- then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
1083- else true
1084- if ((checkPoolStatus == checkPoolStatus))
1177+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
1178+ if ((unstakeInv == unstakeInv))
10851179 then {
1086- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1087- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1088- then state
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 $t04591545996 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1196+ let refreshKLpActions = $t04591545996._1
1197+ let updatedKLp = $t04591545996._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+ }
10891205 else throw("Strict value is not equal to itself.")
10901206 }
10911207 else throw("Strict value is not equal to itself.")
11091225 else throw("no payments are expected")]
11101226 if ((checks == checks))
11111227 then {
1112- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1113- if ((unstakeInv == unstakeInv))
1228+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1229+ if ((currentKLp == currentKLp))
11141230 then {
1115- let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1116- let outAmAmt = res._1
1117- let outPrAmt = res._2
1118- let state = res._10
1119- let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1120- then true
1121- else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1122- then true
1123- else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1124- if ((checkAmounts == checkAmounts))
1231+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1232+ if ((unstakeInv == unstakeInv))
11251233 then {
1126- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1127- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1128- then state
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 $t04729147372 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1249+ let refreshKLpActions = $t04729147372._1
1250+ let updatedKLp = $t04729147372._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+ }
11291258 else throw("Strict value is not equal to itself.")
11301259 }
11311260 else throw("Strict value is not equal to itself.")
11411270 func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
11421271 then throw("permissions denied")
11431272 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 $t04855948623 = refreshKLpInternal(0, 0, 0)
1286+ let kLpUpdateActions = $t04855948623._1
1287+ let updatedKLp = $t04855948623._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+ }
11441295
11451296
11461297
13081459 match tx {
13091460 case order: Order =>
13101461 let matcherPub = getMatcherPubOrFail()
1311- let orderValid = validateMatcherOrderAllowed(order)
1462+ let $t05728557354 = validateMatcherOrderAllowed(order)
1463+ let orderValid = $t05728557354._1
1464+ let orderValidInfo = $t05728557354._2
13121465 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
13131466 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
13141467 if (if (if (orderValid)
13171470 then matcherValid
13181471 else false)
13191472 then true
1320- else throwOrderError(orderValid, senderValid, matcherValid)
1473+ else throwOrderError(orderValid, orderValidInfo, senderValid, matcherValid)
13211474 case s: SetScriptTransaction =>
1322- let newHash = blake2b256(value(s.script))
1323- let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash())))
1324- let currentHash = scriptHash(this)
1325- if (if ((allowedHash == newHash))
1326- then (currentHash != newHash)
1327- else false)
1475+ if (sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey))
13281476 then true
1329- else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
1477+ else {
1478+ let newHash = blake2b256(value(s.script))
1479+ let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash())))
1480+ let currentHash = scriptHash(this)
1481+ if ((allowedHash == newHash))
1482+ then (currentHash != newHash)
1483+ else false
1484+ }
13301485 case _ =>
13311486 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
13321487 }
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
6565 func toX18BigInt (origVal,origScaleMult) = fraction(origVal, scale18, origScaleMult)
6666
6767
6868 func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18))
6969
7070
7171 func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round))
7272
7373
7474 func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale)
7575
7676
7777 func abs (val) = if ((0 > val))
7878 then -(val)
7979 else val
8080
8181
8282 func absBigInt (val) = if ((zeroBigInt > val))
8383 then -(val)
8484 else val
8585
8686
87-func swapContract () = "%s__swapContract"
88-
89-
9087 func fc () = "%s__factoryContract"
9188
9289
9390 func mpk () = "%s__managerPublicKey"
9491
9592
9693 func pmpk () = "%s__pendingManagerPublicKey"
9794
9895
9996 func pl () = "%s%s__price__last"
10097
10198
10299 func ph (h,timestamp) = makeString(["%s%s%d%d__price__history", toString(h), toString(timestamp)], SEP)
103100
104101
105102 func pau (userAddress,txId) = ((("%s%s%s__P__" + userAddress) + "__") + txId)
106103
107104
108105 func gau (userAddress,txId) = ((("%s%s%s__G__" + userAddress) + "__") + txId)
109106
110107
111108 func aa () = "%s__amountAsset"
112109
113110
114111 func pa () = "%s__priceAsset"
115112
116113
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+
117130 func keyFactoryConfig () = "%s__factoryConfig"
118131
119132
120133 func keyMatcherPub () = "%s%s__matcher__publicKey"
121134
122135
123136 func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset")
124137
125138
126139 func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config")
127140
128141
129142 func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr)
130143
131144
132145 func keyAllPoolsShutdown () = "%s__shutdown"
133146
134147
135148 func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress)
136149
137150
138151 func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash"
139152
140153
141154 let keyFeeCollectorAddress = "%s__feeCollectorAddress"
142155
143-func throwOrderError (orderValid,senderValid,matcherValid) = throw(((((("order validation failed: orderValid=" + toString(orderValid)) + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid)))
156+func throwOrderError (orderValid,orderValidInfo,senderValid,matcherValid) = throw((((((((("order validation failed: orderValid=" + toString(orderValid)) + " (") + orderValidInfo) + ")") + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid)))
144157
145158
146159 func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
147160
148161
149162 func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
150163
151164
152165 func throwErr (msg) = throw(makeString(["lp.ride:", msg], " "))
166+
167+
168+func fmtErr (msg) = makeString(["lp.ride:", msg], " ")
153169
154170
155171 let factoryContract = addressFromStringValue(getStringOrFail(this, fc()))
156172
157173 let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress))
158174
159175 let inFee = {
160176 let @ = invoke(factoryContract, "getInFeeREADONLY", [toString(this)], nil)
161177 if ($isInstanceOf(@, "Int"))
162178 then @
163179 else throw(($getType(@) + " couldn't be cast to Int"))
164180 }
165181
166182 let outFee = {
167183 let @ = invoke(factoryContract, "getOutFeeREADONLY", [toString(this)], nil)
168184 if ($isInstanceOf(@, "Int"))
169185 then @
170186 else throw(($getType(@) + " couldn't be cast to Int"))
171187 }
172188
173189 func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false)
174190
175191
176192 func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub()))
177193
178194
179195 func getPoolConfig () = {
180196 let amtAsset = getStringOrFail(this, aa())
181197 let priceAsset = getStringOrFail(this, pa())
182198 let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset))
183199 let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset))
184200 split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP)
185201 }
186202
187203
188204 func parseAssetId (input) = if ((input == wavesString))
189205 then unit
190206 else fromBase58String(input)
191207
192208
193209 func assetIdToString (input) = if ((input == unit))
194210 then wavesString
195211 else toBase58String(value(input))
196212
197213
198214 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]))
199215
200216
201217 let poolConfigParsed = parsePoolConfig(getPoolConfig())
202218
203-let $t079068072 = poolConfigParsed
219+let $t084088574 = poolConfigParsed
204220
205-let cfgPoolAddress = $t079068072._1
221+let cfgPoolAddress = $t084088574._1
206222
207-let cfgPoolStatus = $t079068072._2
223+let cfgPoolStatus = $t084088574._2
208224
209-let cfgLpAssetId = $t079068072._3
225+let cfgLpAssetId = $t084088574._3
210226
211-let cfgAmountAssetId = $t079068072._4
227+let cfgAmountAssetId = $t084088574._4
212228
213-let cfgPriceAssetId = $t079068072._5
229+let cfgPriceAssetId = $t084088574._5
214230
215-let cfgAmountAssetDecimals = $t079068072._6
231+let cfgAmountAssetDecimals = $t084088574._6
216232
217-let cfgPriceAssetDecimals = $t079068072._7
233+let cfgPriceAssetDecimals = $t084088574._7
218234
219235 func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
220236
221237
222238 let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address")
223239
224240 let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address")
225241
226242 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)
227243
228244
229245 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)
230246
231247
232248 func getAccBalance (assetId) = if ((assetId == "WAVES"))
233249 then wavesBalance(this).available
234250 else assetBalance(this, fromBase58String(assetId))
235251
236252
237253 func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
254+
255+
256+func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
238257
239258
240259 func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
241260 let amtAssetAmtX18 = toX18(amAmt, amAssetDcm)
242261 let priceAssetAmtX18 = toX18(prAmt, prAssetDcm)
243262 calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18)
244263 }
245264
246265
247266 func calcPrices (amAmt,prAmt,lpAmt) = {
248267 let cfg = getPoolConfig()
249268 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
250269 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
251270 let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt)
252271 let amAmtX18 = toX18(amAmt, amtAssetDcm)
253272 let prAmtX18 = toX18(prAmt, priceAssetDcm)
254273 let lpAmtX18 = toX18(lpAmt, scale8)
255274 let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18)
256275 let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18)
257276 [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18]
258277 }
259278
260279
261280 func calculatePrices (amAmt,prAmt,lpAmt) = {
262281 let prices = calcPrices(amAmt, prAmt, lpAmt)
263282 [fromX18(prices[0], scale8), fromX18(prices[1], scale8), fromX18(prices[2], scale8)]
264283 }
265284
266285
267286 func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
268287 let cfg = getPoolConfig()
269288 let lpAssetId = cfg[idxPoolLPAssetId]
270289 let amAssetId = cfg[idxAmtAssetId]
271290 let prAssetId = cfg[idxPriceAssetId]
272291 let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
273292 let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
274293 let poolStatus = cfg[idxPoolStatus]
275294 let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity
276295 if ((lpAssetId != pmtAssetId))
277296 then throw("Invalid asset passed.")
278297 else {
279298 let amBalance = getAccBalance(amAssetId)
280299 let amBalanceX18 = toX18(amBalance, amAssetDcm)
281300 let prBalance = getAccBalance(prAssetId)
282301 let prBalanceX18 = toX18(prBalance, prAssetDcm)
283302 let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18)
284303 let curPrice = fromX18(curPriceX18, scale8)
285304 let pmtLpAmtX18 = toX18(pmtLpAmt, scale8)
286305 let lpEmissionX18 = toX18(lpEmission, scale8)
287306 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18)
288307 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18)
289- let outAmAmt = fromX18(outAmAmtX18, amAssetDcm)
290- let outPrAmt = fromX18(outPrAmtX18, prAssetDcm)
308+ let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR)
309+ let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR)
291310 let state = if ((txId58 == ""))
292311 then nil
293312 else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES"))
294313 then unit
295314 else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES"))
296315 then unit
297316 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)]
298317 $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state)
299318 }
300319 }
301320
302321
303322 func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = {
304323 let cfg = getPoolConfig()
305324 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
306325 let amAssetIdStr = cfg[idxAmtAssetId]
307326 let prAssetIdStr = cfg[idxPriceAssetId]
308327 let iAmtAssetId = cfg[idxIAmtAssetId]
309328 let iPriceAssetId = cfg[idxIPriceAssetId]
310329 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
311330 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
312331 let poolStatus = cfg[idxPoolStatus]
313332 let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
314333 let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES")))
315334 let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES")))
316335 if (if ((amAssetIdStr != inAmAssetIdStr))
317336 then true
318337 else (prAssetIdStr != inPrAssetIdStr))
319338 then throw("Invalid amt or price asset passed.")
320339 else {
321340 let amBalance = if (isEvaluate)
322341 then getAccBalance(amAssetIdStr)
323342 else (getAccBalance(amAssetIdStr) - inAmAssetAmt)
324343 let prBalance = if (isEvaluate)
325344 then getAccBalance(prAssetIdStr)
326345 else (getAccBalance(prAssetIdStr) - inPrAssetAmt)
327346 let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm)
328347 let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm)
329348 let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18)
330349 let amBalanceX18 = toX18(amBalance, amtAssetDcm)
331350 let prBalanceX18 = toX18(prBalance, priceAssetDcm)
332351 let res = if ((lpEmission == 0))
333352 then {
334353 let curPriceX18 = zeroBigInt
335354 let slippageX18 = zeroBigInt
336355 let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN)
337356 $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
338357 }
339358 else {
340359 let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18)
341360 let slippageX18 = fraction(absBigInt((curPriceX18 - userPriceX18)), scale18, curPriceX18)
342361 let slippageToleranceX18 = toX18(slippageTolerance, scale8)
343362 if (if ((curPriceX18 != zeroBigInt))
344363 then (slippageX18 > slippageToleranceX18)
345364 else false)
346365 then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18)))
347366 else {
348367 let lpEmissionX18 = toX18(lpEmission, scale8)
349- let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
350- let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
368+ let prViaAmX18 = fraction(inAmAssetAmtX18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING)
369+ let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, FLOOR), CEILING)
351370 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
352371 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
353372 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
354373 let expAmtAssetAmtX18 = expectedAmts._1
355374 let expPriceAssetAmtX18 = expectedAmts._2
356- let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
357- $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18)
375+ let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR)
376+ $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtAssetDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceAssetDcm, CEILING), curPriceX18, slippageX18)
358377 }
359378 }
360379 let calcLpAmt = res._1
361380 let calcAmAssetPmt = res._2
362381 let calcPrAssetPmt = res._3
363382 let curPrice = fromX18(res._4, scale8)
364383 let slippageCalc = fromX18(res._5, scale8)
365384 if ((0 >= calcLpAmt))
366385 then throw("Invalid calculations. LP calculated is less than zero.")
367386 else {
368387 let emitLpAmt = if (!(emitLp))
369388 then 0
370389 else calcLpAmt
371390 let amDiff = (inAmAssetAmt - calcAmAssetPmt)
372391 let prDiff = (inPrAssetAmt - calcPrAssetPmt)
373392 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))]
374393 $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId)
375394 }
376395 }
377396 }
378397
379398
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+
380433 func validateMatcherOrderAllowed (order) = {
381- let cfg = getPoolConfig()
382- let amtAssetId = cfg[idxAmtAssetId]
383- let priceAssetId = cfg[idxPriceAssetId]
384- let poolStatus = parseIntValue(cfg[idxPoolStatus])
385- let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
386- let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
387- let accAmtAssetBalance = getAccBalance(amtAssetId)
388- let accPriceAssetBalance = getAccBalance(priceAssetId)
389- let curPriceX18 = if ((order.orderType == Buy))
390- then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance)
391- else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance)
392- let curPrice = fromX18(curPriceX18, scale8)
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
393443 if (if (if (isGlobalShutdown())
394444 then true
395- else (poolStatus == PoolMatcherDisabled))
445+ else (cfgPoolStatus == PoolMatcherDisabled))
396446 then true
397- else (poolStatus == PoolShutdown))
447+ else (cfgPoolStatus == PoolShutdown))
398448 then throw("Exchange operations disabled")
399- else {
400- let orderAmtAsset = order.assetPair.amountAsset
401- let orderAmtAssetStr = if ((orderAmtAsset == unit))
402- then "WAVES"
403- else toBase58String(value(orderAmtAsset))
404- let orderPriceAsset = order.assetPair.priceAsset
405- let orderPriceAssetStr = if ((orderPriceAsset == unit))
406- then "WAVES"
407- else toBase58String(value(orderPriceAsset))
408- if (if ((orderAmtAssetStr != amtAssetId))
409- then true
410- else (orderPriceAssetStr != priceAssetId))
411- then throw("Wrong order assets.")
412- else {
413- let orderPrice = order.price
414- let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm)
415- let castedOrderPrice = toScale(orderPrice, scale8, priceDcm)
416- let isOrderPriceValid = if ((order.orderType == Buy))
417- then (curPrice >= castedOrderPrice)
418- else (castedOrderPrice >= curPrice)
419- true
420- }
421- }
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), " height=", toString(height)], "")
460+ $Tuple2(isOrderValid, info)
461+ }
422462 }
423463
424464
425465 func commonGet (i) = if ((size(i.payments) != 1))
426466 then throw("exactly 1 payment is expected")
427467 else {
428468 let pmt = value(i.payments[0])
429469 let pmtAssetId = value(pmt.assetId)
430470 let pmtAmt = pmt.amount
431471 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller)
432472 let outAmAmt = res._1
433473 let outPrAmt = res._2
434474 let poolStatus = parseIntValue(res._9)
435475 let state = res._10
436476 if (if (isGlobalShutdown())
437477 then true
438478 else (poolStatus == PoolShutdown))
439479 then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
440480 else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state)
441481 }
442482
443483
444484 func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2))
445485 then throw("exactly 2 payments are expected")
446486 else {
447487 let amAssetPmt = value(i.payments[0])
448488 let prAssetPmt = value(i.payments[1])
449489 let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp)
450490 let poolStatus = parseIntValue(estPut._8)
451491 if (if (if (isGlobalShutdown())
452492 then true
453493 else (poolStatus == PoolPutDisabled))
454494 then true
455495 else (poolStatus == PoolShutdown))
456496 then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus)))
457497 else estPut
458498 }
459499
460500
461501 func emit (amount) = {
462502 let emitInv = invoke(factoryContract, "emit", [amount], nil)
463503 if ((emitInv == emitInv))
464504 then {
465505 let emitInvLegacy = match emitInv {
466506 case legacyFactoryContract: Address =>
467507 invoke(legacyFactoryContract, "emit", [amount], nil)
468508 case _ =>
469509 unit
470510 }
471511 if ((emitInvLegacy == emitInvLegacy))
472512 then amount
473513 else throw("Strict value is not equal to itself.")
474514 }
475515 else throw("Strict value is not equal to itself.")
476516 }
477517
478518
479519 func takeFee (amount,fee) = {
480520 let feeAmount = if ((fee == 0))
481521 then 0
482522 else fraction(amount, fee, scale8)
483523 $Tuple2((amount - feeAmount), feeAmount)
484524 }
485525
486526
487527 func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = {
488528 let isEval = (txId == unit)
489529 let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId))
490530 let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId))
491531 let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId))
492532 then true
493533 else if ((paymentAssetId == cfgPriceAssetId))
494534 then false
495535 else throwErr("invalid asset")
496- let $t02296923262 = if (isEval)
536+ let $t02534525638 = if (isEval)
497537 then $Tuple2(amountBalanceRaw, priceBalanceRaw)
498538 else if (paymentInAmountAsset)
499539 then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw)
500540 else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw))
501- let amountBalanceOld = $t02296923262._1
502- let priceBalanceOld = $t02296923262._2
503- let $t02326623415 = if (paymentInAmountAsset)
541+ let amountBalanceOld = $t02534525638._1
542+ let priceBalanceOld = $t02534525638._2
543+ let $t02564225791 = if (paymentInAmountAsset)
504544 then $Tuple2(paymentAmountRaw, 0)
505545 else $Tuple2(0, paymentAmountRaw)
506- let amountAssetAmountRaw = $t02326623415._1
507- let priceAssetAmountRaw = $t02326623415._2
546+ let amountAssetAmountRaw = $t02564225791._1
547+ let priceAssetAmountRaw = $t02564225791._2
508548 let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1
509549 let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1
510- let $t02354723611 = takeFee(paymentAmountRaw, inFee)
511- let paymentAmount = $t02354723611._1
512- let feeAmount = $t02354723611._2
550+ let $t02592325987 = takeFee(paymentAmountRaw, inFee)
551+ let paymentAmount = $t02592325987._1
552+ let feeAmount = $t02592325987._2
513553 let amountBalanceNew = (amountBalanceOld + amountAssetAmount)
514554 let priceBalanceNew = (priceBalanceOld + priceAssetAmount)
515555 let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals))
516556 let priceNew = fromX18(priceNewX18, scale8)
517557 let paymentBalance = if (paymentInAmountAsset)
518558 then amountBalanceOld
519559 else priceBalanceOld
520560 let paymentBalanceBigInt = toBigInt(paymentBalance)
521561 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
522562 let chechSupply = if ((supplyBigInt > big0))
523563 then true
524564 else throwErr("initial deposit requires all coins")
525565 if ((chechSupply == chechSupply))
526566 then {
527567 let depositBigInt = toBigInt(paymentAmount)
528568 let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))])
529569 let commonState = if (isEval)
530570 then nil
531571 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))]
532572 let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals))
533573 let priceOld = fromX18(priceOldX18, scale8)
534574 let loss = {
535- let $t02508825255 = if (paymentInAmountAsset)
575+ let $t02766827835 = if (paymentInAmountAsset)
536576 then $Tuple2(amountAssetAmountRaw, amountBalanceOld)
537577 else $Tuple2(priceAssetAmountRaw, priceBalanceOld)
538- let amount = $t02508825255._1
539- let balance = $t02508825255._2
578+ let amount = $t02766827835._1
579+ let balance = $t02766827835._2
540580 let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance)))
541581 fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth)
542582 }
543- $Tuple4(issueAmount, commonState, feeAmount, loss)
583+ $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset)
544584 }
545585 else throw("Strict value is not equal to itself.")
546586 }
547587
548588
549589 func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = {
550590 let isEval = (txId == unit)
591+ let cfg = getPoolConfig()
592+ let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
593+ let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
551594 let checks = [if ((paymentAssetId == cfgLpAssetId))
552595 then true
553596 else throwErr("invalid lp asset")]
554597 if ((checks == checks))
555598 then {
556599 let outInAmountAsset = if ((outAssetId == cfgAmountAssetId))
557600 then true
558601 else if ((outAssetId == cfgPriceAssetId))
559602 then false
560603 else throwErr("invalid asset")
561604 let balanceBigInt = if (outInAmountAsset)
562605 then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId)))
563606 else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId)))
607+ let outInAmountAssetDecimals = if (outInAmountAsset)
608+ then amtAssetDcm
609+ else priceAssetDcm
564610 let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId))
565611 let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId))
566612 let outBalance = if (outInAmountAsset)
567613 then amBalanceOld
568614 else prBalanceOld
569615 let outBalanceBigInt = toBigInt(outBalance)
570616 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
571617 let redeemedBigInt = toBigInt(paymentAmount)
572618 let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))])
573- let $t02683526891 = takeFee(amountRaw, outFee)
574- let totalAmount = $t02683526891._1
575- let feeAmount = $t02683526891._2
576- let $t02689527121 = if (outInAmountAsset)
619+ let $t02991329969 = takeFee(amountRaw, outFee)
620+ let totalAmount = $t02991329969._1
621+ let feeAmount = $t02991329969._2
622+ let $t02997330199 = if (outInAmountAsset)
577623 then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
578624 else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw))
579- let outAmAmount = $t02689527121._1
580- let outPrAmount = $t02689527121._2
581- let amBalanceNew = $t02689527121._3
582- let prBalanceNew = $t02689527121._4
625+ let outAmAmount = $t02997330199._1
626+ let outPrAmount = $t02997330199._2
627+ let amBalanceNew = $t02997330199._3
628+ let prBalanceNew = $t02997330199._4
583629 let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
584630 let priceNew = fromX18(priceNewX18, scale8)
585631 let commonState = if (isEval)
586632 then nil
587633 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)]
588634 let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals))
589635 let priceOld = fromX18(priceOldX18, scale8)
590636 let loss = {
591637 let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2)
592638 fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset)
593639 }
594- $Tuple4(totalAmount, commonState, feeAmount, loss)
640+ $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset)
595641 }
596642 else throw("Strict value is not equal to itself.")
597643 }
598644
599645
600646 func managerPublicKeyOrUnit () = match getString(mpk()) {
601647 case s: String =>
602648 fromBase58String(s)
603649 case _: Unit =>
604650 unit
605651 case _ =>
606652 throw("Match error")
607653 }
608654
609655
610656 func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) {
611657 case s: String =>
612658 fromBase58String(s)
613659 case _: Unit =>
614660 unit
615661 case _ =>
616662 throw("Match error")
617663 }
618664
619665
620666 func isManager (i) = match managerPublicKeyOrUnit() {
621667 case pk: ByteVector =>
622668 (i.callerPublicKey == pk)
623669 case _: Unit =>
624670 (i.caller == this)
625671 case _ =>
626672 throw("Match error")
627673 }
628674
629675
630676 func mustManager (i) = {
631677 let pd = throw("Permission denied")
632678 match managerPublicKeyOrUnit() {
633679 case pk: ByteVector =>
634680 if ((i.callerPublicKey == pk))
635681 then true
636682 else pd
637683 case _: Unit =>
638684 if ((i.caller == this))
639685 then true
640686 else pd
641687 case _ =>
642688 throw("Match error")
643689 }
644690 }
645691
646692
647693 @Callable(i)
648-func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse) = {
649- let $t02879829103 = if ((isReverse == false))
650- then {
651- let assetOut = getStringOrFail(this, pa())
652- let assetIn = getStringOrFail(this, aa())
653- $Tuple2(assetOut, assetIn)
654- }
655- else {
656- let assetOut = getStringOrFail(this, aa())
657- let assetIn = getStringOrFail(this, pa())
658- $Tuple2(assetOut, assetIn)
659- }
660- let assetOut = $t02879829103._1
661- let assetIn = $t02879829103._2
662- let poolAssetInBalance = getAccBalance(assetIn)
663- let poolAssetOutBalance = getAccBalance(assetOut)
664- let amountOut = fraction(poolAssetOutBalance, cleanAmountIn, (poolAssetInBalance + cleanAmountIn))
665- let oldK = (toBigInt(poolAssetInBalance) * toBigInt(poolAssetOutBalance))
666- let newK = ((toBigInt(getAccBalance(assetIn)) + toBigInt(cleanAmountIn)) * (toBigInt(getAccBalance(assetOut)) - toBigInt(amountOut)))
667- let checkK = if ((newK >= oldK))
668- then true
669- else throw("new K is fewer error")
670- if ((checkK == checkK))
671- then $Tuple2(nil, amountOut)
672- else throw("Strict value is not equal to itself.")
673- }
674-
675-
676-
677-@Callable(i)
678-func calculateAmountOutForSwapAndSendTokens (cleanAmountIn,isReverse,amountOutMin,addressTo) = {
679- let checks = [if ((value(i.payments[0]).amount >= cleanAmountIn))
680- then true
681- else throwErr("Wrong amount"), if ((i.caller == addressFromStringValue(getStringOrFail(this, swapContract()))))
682- then true
683- else throwErr("Permission denied")]
684- if ((checks == checks))
685- then {
686- let pmt = value(i.payments[0])
687- let assetIn = if ((pmt.assetId == unit))
688- then toBase58String(toBytes("WAVES"))
689- else toBase58String(value(pmt.assetId))
690- let assetOut = if ((isReverse == false))
691- then getStringOrFail(this, pa())
692- else getStringOrFail(this, aa())
693- let poolAssetInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount)
694- let poolAssetOutBalance = getAccBalance(assetOut)
695- let amountOut = ((poolAssetOutBalance * cleanAmountIn) / (poolAssetInBalance + cleanAmountIn))
696- let oldK = (poolAssetInBalance * poolAssetOutBalance)
697- let newK = (getAccBalance(assetIn) * (getAccBalance(assetOut) - amountOut))
698- let checkK = if ((newK >= oldK))
699- then true
700- else throw("new K is fewer error")
701- if ((checkK == checkK))
702- then {
703- let checkMin = if ((amountOut >= amountOutMin))
704- then true
705- else throw("Exchange result is fewer coins than expected")
706- if ((checkMin == checkMin))
707- then [ScriptTransfer(addressFromStringValue(addressTo), amountOut, if ((assetIn == "WAVES"))
708- then unit
709- else fromBase58String(assetOut))]
710- else throw("Strict value is not equal to itself.")
711- }
712- else throw("Strict value is not equal to itself.")
713- }
714- else throw("Strict value is not equal to itself.")
715- }
716-
717-
718-
719-@Callable(i)
720694 func setManager (pendingManagerPublicKey) = {
721695 let checkCaller = mustManager(i)
722696 if ((checkCaller == checkCaller))
723697 then {
724698 let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
725699 if ((checkManagerPublicKey == checkManagerPublicKey))
726700 then [StringEntry(pmpk(), pendingManagerPublicKey)]
727701 else throw("Strict value is not equal to itself.")
728702 }
729703 else throw("Strict value is not equal to itself.")
730704 }
731705
732706
733707
734708 @Callable(i)
735709 func confirmManager () = {
736710 let pm = pendingManagerPublicKeyOrUnit()
737711 let hasPM = if (isDefined(pm))
738712 then true
739713 else throw("No pending manager")
740714 if ((hasPM == hasPM))
741715 then {
742716 let checkPM = if ((i.callerPublicKey == value(pm)))
743717 then true
744718 else throw("You are not pending manager")
745719 if ((checkPM == checkPM))
746720 then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())]
747721 else throw("Strict value is not equal to itself.")
748722 }
749723 else throw("Strict value is not equal to itself.")
750724 }
751725
752726
753727
754728 @Callable(i)
755729 func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance))
756730 then throw("Invalid slippageTolerance passed")
757731 else {
758732 let estPut = commonPut(i, slippageTolerance, true)
759733 let emitLpAmt = estPut._2
760734 let lpAssetId = estPut._7
761735 let state = estPut._9
762736 let amDiff = estPut._10
763737 let prDiff = estPut._11
764738 let amId = estPut._12
765739 let prId = estPut._13
766- let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
767- if ((emitInv == emitInv))
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))
768744 then {
769- let emitInvLegacy = match emitInv {
770- case legacyFactoryContract: Address =>
771- invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
772- case _ =>
773- unit
774- }
775- if ((emitInvLegacy == emitInvLegacy))
745+ let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
746+ if ((emitInv == emitInv))
776747 then {
777- let slippageAInv = if ((amDiff > 0))
778- then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
779- else nil
780- if ((slippageAInv == slippageAInv))
748+ let emitInvLegacy = match emitInv {
749+ case legacyFactoryContract: Address =>
750+ invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
751+ case _ =>
752+ unit
753+ }
754+ if ((emitInvLegacy == emitInvLegacy))
781755 then {
782- let slippagePInv = if ((prDiff > 0))
783- then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
756+ let slippageAInv = if ((amDiff > 0))
757+ then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
784758 else nil
785- if ((slippagePInv == slippagePInv))
759+ if ((slippageAInv == slippageAInv))
786760 then {
787- let lpTransfer = if (shouldAutoStake)
761+ let slippagePInv = if ((prDiff > 0))
762+ then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
763+ else nil
764+ if ((slippagePInv == slippagePInv))
788765 then {
789- let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
790- if ((slpStakeInv == slpStakeInv))
791- then nil
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 $t03472735189 = refreshKLpInternal(0, 0, 0)
775+ if (($t03472735189 == $t03472735189))
776+ then {
777+ let updatedKLp = $t03472735189._2
778+ let refreshKLpActions = $t03472735189._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+ }
792784 else throw("Strict value is not equal to itself.")
793785 }
794- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
795- (state ++ lpTransfer)
786+ else throw("Strict value is not equal to itself.")
796787 }
797788 else throw("Strict value is not equal to itself.")
798789 }
799790 else throw("Strict value is not equal to itself.")
800791 }
801792 else throw("Strict value is not equal to itself.")
802793 }
803794 else throw("Strict value is not equal to itself.")
804795 }
805796
806797
807798
808799 @Callable(i)
809800 func putForFree (maxSlippage) = if ((0 > maxSlippage))
810801 then throw("Invalid value passed")
811802 else {
812803 let estPut = commonPut(i, maxSlippage, false)
813- estPut._9
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 $t03575135816 = refreshKLpInternal(0, 0, 0)
811+ let refreshKLpActions = $t03575135816._1
812+ let updatedKLp = $t03575135816._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.")
814819 }
815820
816821
817822
818823 @Callable(i)
819824 func putOneTkn (minOutAmount,autoStake) = {
820825 let isPoolOneTokenOperationsDisabled = {
821826 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
822827 if ($isInstanceOf(@, "Boolean"))
823828 then @
824829 else throw(($getType(@) + " couldn't be cast to Boolean"))
825830 }
826831 let isPutDisabled = if (if (if (isGlobalShutdown())
827832 then true
828833 else (cfgPoolStatus == PoolPutDisabled))
829834 then true
830835 else (cfgPoolStatus == PoolShutdown))
831836 then true
832837 else isPoolOneTokenOperationsDisabled
833838 let checks = [if (if (!(isPutDisabled))
834839 then true
835840 else isManager(i))
836841 then true
837842 else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1))
838843 then true
839844 else throwErr("exactly 1 payment are expected")]
840845 if ((checks == checks))
841846 then {
842847 let payment = i.payments[0]
843848 let paymentAssetId = payment.assetId
844849 let paymentAmountRaw = payment.amount
845- let userAddress = i.caller
846- let txId = i.transactionId
847- let $t03429434424 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
848- if (($t03429434424 == $t03429434424))
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))
849856 then {
850- let bonus = $t03429434424._4
851- let feeAmount = $t03429434424._3
852- let commonState = $t03429434424._2
853- let emitAmountEstimated = $t03429434424._1
854- let emitAmount = if (if ((minOutAmount > 0))
855- then (minOutAmount > emitAmountEstimated)
856- else false)
857- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
858- else emitAmountEstimated
859- let emitInv = emit(emitAmount)
860- if ((emitInv == emitInv))
857+ let userAddress = i.caller
858+ let txId = i.transactionId
859+ let $t03700437156 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
860+ if (($t03700437156 == $t03700437156))
861861 then {
862- let lpTransfer = if (autoStake)
862+ let paymentInAmountAsset = $t03700437156._5
863+ let bonus = $t03700437156._4
864+ let feeAmount = $t03700437156._3
865+ let commonState = $t03700437156._2
866+ let emitAmountEstimated = $t03700437156._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))
863874 then {
864- let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
865- if ((stakeInv == stakeInv))
866- then nil
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 $t03774237939 = 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 = $t03774237939._1
892+ let priceAssetBalanceDelta = $t03774237939._2
893+ let $t03794238050 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
894+ let refreshKLpActions = $t03794238050._1
895+ let updatedKLp = $t03794238050._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)
867900 else throw("Strict value is not equal to itself.")
868901 }
869- else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
870- let sendFee = if ((feeAmount > 0))
871- then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
872- else nil
873- $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount)
902+ else throw("Strict value is not equal to itself.")
874903 }
875904 else throw("Strict value is not equal to itself.")
876905 }
877906 else throw("Strict value is not equal to itself.")
878907 }
879908 else throw("Strict value is not equal to itself.")
880909 }
881910
882911
883912
884913 @Callable(i)
885914 func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = {
886- let $t03515335288 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
887- let emitAmountEstimated = $t03515335288._1
888- let commonState = $t03515335288._2
889- let feeAmount = $t03515335288._3
890- let bonus = $t03515335288._4
915+ let $t03835638513 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
916+ let emitAmountEstimated = $t03835638513._1
917+ let commonState = $t03835638513._2
918+ let feeAmount = $t03835638513._3
919+ let bonus = $t03835638513._4
920+ let paymentInAmountAsset = $t03835638513._5
891921 $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
892922 }
893923
894924
895925
896926 @Callable(i)
897927 func getOneTkn (outAssetIdStr,minOutAmount) = {
898928 let isPoolOneTokenOperationsDisabled = {
899929 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
900930 if ($isInstanceOf(@, "Boolean"))
901931 then @
902932 else throw(($getType(@) + " couldn't be cast to Boolean"))
903933 }
904934 let isGetDisabled = if (if (isGlobalShutdown())
905935 then true
906936 else (cfgPoolStatus == PoolShutdown))
907937 then true
908938 else isPoolOneTokenOperationsDisabled
909939 let checks = [if (if (!(isGetDisabled))
910940 then true
911941 else isManager(i))
912942 then true
913943 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1))
914944 then true
915945 else throwErr("exactly 1 payment are expected")]
916946 if ((checks == checks))
917947 then {
918948 let outAssetId = parseAssetId(outAssetIdStr)
919949 let payment = i.payments[0]
920950 let paymentAssetId = payment.assetId
921951 let paymentAmount = payment.amount
922- let userAddress = i.caller
923- let txId = i.transactionId
924- let $t03609336228 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
925- if (($t03609336228 == $t03609336228))
952+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
953+ if ((currentKLp == currentKLp))
926954 then {
927- let bonus = $t03609336228._4
928- let feeAmount = $t03609336228._3
929- let commonState = $t03609336228._2
930- let amountEstimated = $t03609336228._1
931- let amount = if (if ((minOutAmount > 0))
932- then (minOutAmount > amountEstimated)
933- else false)
934- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
935- else amountEstimated
936- let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
937- if ((burnInv == burnInv))
955+ let userAddress = i.caller
956+ let txId = i.transactionId
957+ let $t03939839551 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
958+ if (($t03939839551 == $t03939839551))
938959 then {
939- let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
940- let sendFee = if ((feeAmount > 0))
941- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
942- else nil
943- $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
960+ let outInAmountAsset = $t03939839551._5
961+ let bonus = $t03939839551._4
962+ let feeAmount = $t03939839551._3
963+ let commonState = $t03939839551._2
964+ let amountEstimated = $t03939839551._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 $t04005140298 = {
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 = $t04005140298._1
986+ let priceAssetBalanceDelta = $t04005140298._2
987+ let $t04030140409 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
988+ let refreshKLpActions = $t04030140409._1
989+ let updatedKLp = $t04030140409._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.")
944996 }
945997 else throw("Strict value is not equal to itself.")
946998 }
947999 else throw("Strict value is not equal to itself.")
9481000 }
9491001 else throw("Strict value is not equal to itself.")
9501002 }
9511003
9521004
9531005
9541006 @Callable(i)
9551007 func getOneTknREADONLY (outAssetId,paymentAmount) = {
956- let $t03686337001 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
957- let amountEstimated = $t03686337001._1
958- let commonState = $t03686337001._2
959- let feeAmount = $t03686337001._3
960- let bonus = $t03686337001._4
1008+ let $t04066640822 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
1009+ let amountEstimated = $t04066640822._1
1010+ let commonState = $t04066640822._2
1011+ let feeAmount = $t04066640822._3
1012+ let bonus = $t04066640822._4
1013+ let outInAmountAsset = $t04066640822._5
9611014 $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
9621015 }
9631016
9641017
9651018
9661019 @Callable(i)
9671020 func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = {
9681021 let isPoolOneTokenOperationsDisabled = {
9691022 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
9701023 if ($isInstanceOf(@, "Boolean"))
9711024 then @
9721025 else throw(($getType(@) + " couldn't be cast to Boolean"))
9731026 }
9741027 let isGetDisabled = if (if (isGlobalShutdown())
9751028 then true
9761029 else (cfgPoolStatus == PoolShutdown))
9771030 then true
9781031 else isPoolOneTokenOperationsDisabled
9791032 let checks = [if (if (!(isGetDisabled))
9801033 then true
9811034 else isManager(i))
9821035 then true
9831036 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0))
9841037 then true
9851038 else throwErr("no payments are expected")]
9861039 if ((checks == checks))
9871040 then {
9881041 let outAssetId = parseAssetId(outAssetIdStr)
9891042 let userAddress = i.caller
9901043 let txId = i.transactionId
991- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
992- if ((unstakeInv == unstakeInv))
1044+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1045+ if ((currentKLp == currentKLp))
9931046 then {
994- let $t03782637959 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
995- if (($t03782637959 == $t03782637959))
1047+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1048+ if ((unstakeInv == unstakeInv))
9961049 then {
997- let bonus = $t03782637959._4
998- let feeAmount = $t03782637959._3
999- let commonState = $t03782637959._2
1000- let amountEstimated = $t03782637959._1
1001- let amount = if (if ((minOutAmount > 0))
1002- then (minOutAmount > amountEstimated)
1003- else false)
1004- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1005- else amountEstimated
1006- let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1007- if ((burnInv == burnInv))
1050+ let $t04172741878 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
1051+ if (($t04172741878 == $t04172741878))
10081052 then {
1009- let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
1010- let sendFee = if ((feeAmount > 0))
1011- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
1012- else nil
1013- $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
1053+ let outInAmountAsset = $t04172741878._5
1054+ let bonus = $t04172741878._4
1055+ let feeAmount = $t04172741878._3
1056+ let commonState = $t04172741878._2
1057+ let amountEstimated = $t04172741878._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 $t04237342620 = {
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 = $t04237342620._1
1079+ let priceAssetBalanceDelta = $t04237342620._2
1080+ let $t04262342731 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1081+ let refreshKLpActions = $t04262342731._1
1082+ let updatedKLp = $t04262342731._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.")
10141089 }
10151090 else throw("Strict value is not equal to itself.")
10161091 }
10171092 else throw("Strict value is not equal to itself.")
10181093 }
10191094 else throw("Strict value is not equal to itself.")
10201095 }
10211096 else throw("Strict value is not equal to itself.")
10221097 }
10231098
10241099
10251100
10261101 @Callable(i)
10271102 func get () = {
10281103 let res = commonGet(i)
10291104 let outAmtAmt = res._1
10301105 let outPrAmt = res._2
10311106 let pmtAmt = res._3
10321107 let pmtAssetId = res._4
10331108 let state = res._5
1034- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1035- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1036- then state
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 $t04367743759 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1116+ let refreshKLpActions = $t04367743759._1
1117+ let updatedKLp = $t04367743759._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+ }
10371125 else throw("Strict value is not equal to itself.")
10381126 }
10391127
10401128
10411129
10421130 @Callable(i)
10431131 func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = {
10441132 let res = commonGet(i)
10451133 let outAmAmt = res._1
10461134 let outPrAmt = res._2
10471135 let pmtAmt = res._3
10481136 let pmtAssetId = res._4
10491137 let state = res._5
10501138 if ((noLessThenAmtAsset > outAmAmt))
10511139 then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset)))
10521140 else if ((noLessThenPriceAsset > outPrAmt))
10531141 then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
10541142 else {
1055- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1056- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1057- then state
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 $t04470844789 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1150+ let refreshKLpActions = $t04470844789._1
1151+ let updatedKLp = $t04470844789._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+ }
10581159 else throw("Strict value is not equal to itself.")
10591160 }
10601161 }
10611162
10621163
10631164
10641165 @Callable(i)
10651166 func unstakeAndGet (amount) = {
10661167 let checkPayments = if ((size(i.payments) != 0))
10671168 then throw("No payments are expected")
10681169 else true
10691170 if ((checkPayments == checkPayments))
10701171 then {
10711172 let cfg = getPoolConfig()
10721173 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
1073- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
1074- if ((unstakeInv == unstakeInv))
1174+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1175+ if ((currentKLp == currentKLp))
10751176 then {
1076- let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1077- let poolStatus = parseIntValue(res._9)
1078- let state = res._10
1079- let checkPoolStatus = if (if (isGlobalShutdown())
1080- then true
1081- else (poolStatus == PoolShutdown))
1082- then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
1083- else true
1084- if ((checkPoolStatus == checkPoolStatus))
1177+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
1178+ if ((unstakeInv == unstakeInv))
10851179 then {
1086- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1087- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1088- then state
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 $t04591545996 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1196+ let refreshKLpActions = $t04591545996._1
1197+ let updatedKLp = $t04591545996._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+ }
10891205 else throw("Strict value is not equal to itself.")
10901206 }
10911207 else throw("Strict value is not equal to itself.")
10921208 }
10931209 else throw("Strict value is not equal to itself.")
10941210 }
10951211 else throw("Strict value is not equal to itself.")
10961212 }
10971213
10981214
10991215
11001216 @Callable(i)
11011217 func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = {
11021218 let isGetDisabled = if (isGlobalShutdown())
11031219 then true
11041220 else (cfgPoolStatus == PoolShutdown)
11051221 let checks = [if (!(isGetDisabled))
11061222 then true
11071223 else throw("get operation is blocked by admin"), if ((size(i.payments) == 0))
11081224 then true
11091225 else throw("no payments are expected")]
11101226 if ((checks == checks))
11111227 then {
1112- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1113- if ((unstakeInv == unstakeInv))
1228+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1229+ if ((currentKLp == currentKLp))
11141230 then {
1115- let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1116- let outAmAmt = res._1
1117- let outPrAmt = res._2
1118- let state = res._10
1119- let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1120- then true
1121- else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1122- then true
1123- else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1124- if ((checkAmounts == checkAmounts))
1231+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1232+ if ((unstakeInv == unstakeInv))
11251233 then {
1126- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1127- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1128- then state
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 $t04729147372 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1249+ let refreshKLpActions = $t04729147372._1
1250+ let updatedKLp = $t04729147372._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+ }
11291258 else throw("Strict value is not equal to itself.")
11301259 }
11311260 else throw("Strict value is not equal to itself.")
11321261 }
11331262 else throw("Strict value is not equal to itself.")
11341263 }
11351264 else throw("Strict value is not equal to itself.")
11361265 }
11371266
11381267
11391268
11401269 @Callable(i)
11411270 func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
11421271 then throw("permissions denied")
11431272 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 $t04855948623 = refreshKLpInternal(0, 0, 0)
1286+ let kLpUpdateActions = $t04855948623._1
1287+ let updatedKLp = $t04855948623._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+ }
11441295
11451296
11461297
11471298 @Callable(i)
11481299 func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig())
11491300
11501301
11511302
11521303 @Callable(i)
11531304 func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId))
11541305
11551306
11561307
11571308 @Callable(i)
11581309 func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = {
11591310 let prices = calcPrices(amAmt, prAmt, lpAmt)
11601311 $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])])
11611312 }
11621313
11631314
11641315
11651316 @Callable(i)
11661317 func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult)))
11671318
11681319
11691320
11701321 @Callable(i)
11711322 func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult))
11721323
11731324
11741325
11751326 @Callable(i)
11761327 func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18))))
11771328
11781329
11791330
11801331 @Callable(i)
11811332 func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp))
11821333
11831334
11841335
11851336 @Callable(i)
11861337 func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
11871338 let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress))
11881339 $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10))
11891340 }
11901341
11911342
11921343
11931344 @Callable(i)
11941345 func statsREADONLY () = {
11951346 let cfg = getPoolConfig()
11961347 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
11971348 let amtAssetId = cfg[idxAmtAssetId]
11981349 let priceAssetId = cfg[idxPriceAssetId]
11991350 let iAmtAssetId = cfg[idxIAmtAssetId]
12001351 let iPriceAssetId = cfg[idxIPriceAssetId]
12011352 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
12021353 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
12031354 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
12041355 let accAmtAssetBalance = getAccBalance(amtAssetId)
12051356 let accPriceAssetBalance = getAccBalance(priceAssetId)
12061357 let pricesList = if ((poolLPBalance == 0))
12071358 then [zeroBigInt, zeroBigInt, zeroBigInt]
12081359 else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance)
12091360 let curPrice = 0
12101361 let lpAmtAssetShare = fromX18(pricesList[1], scale8)
12111362 let lpPriceAssetShare = fromX18(pricesList[2], scale8)
12121363 let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this))))
12131364 $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))
12141365 }
12151366
12161367
12171368
12181369 @Callable(i)
12191370 func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = {
12201371 let cfg = getPoolConfig()
12211372 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
12221373 let amAssetIdStr = cfg[idxAmtAssetId]
12231374 let amAssetId = fromBase58String(amAssetIdStr)
12241375 let prAssetIdStr = cfg[idxPriceAssetId]
12251376 let prAssetId = fromBase58String(prAssetIdStr)
12261377 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
12271378 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
12281379 let poolStatus = cfg[idxPoolStatus]
12291380 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
12301381 let accAmtAssetBalance = getAccBalance(amAssetIdStr)
12311382 let accPriceAssetBalance = getAccBalance(prAssetIdStr)
12321383 let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm)
12331384 let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm)
12341385 let curPriceX18 = if ((poolLPBalance == 0))
12351386 then zeroBigInt
12361387 else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18)
12371388 let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm)
12381389 let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
12391390 let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm)
12401391 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
12411392 let calcLpAmt = estPut._1
12421393 let curPriceCalc = estPut._3
12431394 let amBalance = estPut._4
12441395 let prBalance = estPut._5
12451396 let lpEmission = estPut._6
12461397 $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))
12471398 }
12481399
12491400
12501401
12511402 @Callable(i)
12521403 func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = {
12531404 let cfg = getPoolConfig()
12541405 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
12551406 let amAssetIdStr = cfg[idxAmtAssetId]
12561407 let amAssetId = fromBase58String(amAssetIdStr)
12571408 let prAssetIdStr = cfg[idxPriceAssetId]
12581409 let prAssetId = fromBase58String(prAssetIdStr)
12591410 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
12601411 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
12611412 let poolStatus = cfg[idxPoolStatus]
12621413 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
12631414 let amBalanceRaw = getAccBalance(amAssetIdStr)
12641415 let prBalanceRaw = getAccBalance(prAssetIdStr)
12651416 let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm)
12661417 let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm)
12671418 let curPriceX18 = if ((poolLPBalance == 0))
12681419 then zeroBigInt
12691420 else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18)
12701421 let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm)
12711422 let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
12721423 let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm)
12731424 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
12741425 let calcLpAmt = estPut._1
12751426 let curPriceCalc = estPut._3
12761427 let amBalance = estPut._4
12771428 let prBalance = estPut._5
12781429 let lpEmission = estPut._6
12791430 $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))
12801431 }
12811432
12821433
12831434
12841435 @Callable(i)
12851436 func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = {
12861437 let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this)
12871438 let outAmAmt = res._1
12881439 let outPrAmt = res._2
12891440 let amBalance = res._5
12901441 let prBalance = res._6
12911442 let lpEmission = res._7
12921443 let curPrice = res._8
12931444 let poolStatus = parseIntValue(res._9)
12941445 $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))
12951446 }
12961447
12971448
12981449 @Verifier(tx)
12991450 func verify () = {
13001451 let targetPublicKey = match managerPublicKeyOrUnit() {
13011452 case pk: ByteVector =>
13021453 pk
13031454 case _: Unit =>
13041455 tx.senderPublicKey
13051456 case _ =>
13061457 throw("Match error")
13071458 }
13081459 match tx {
13091460 case order: Order =>
13101461 let matcherPub = getMatcherPubOrFail()
1311- let orderValid = validateMatcherOrderAllowed(order)
1462+ let $t05728557354 = validateMatcherOrderAllowed(order)
1463+ let orderValid = $t05728557354._1
1464+ let orderValidInfo = $t05728557354._2
13121465 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
13131466 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
13141467 if (if (if (orderValid)
13151468 then senderValid
13161469 else false)
13171470 then matcherValid
13181471 else false)
13191472 then true
1320- else throwOrderError(orderValid, senderValid, matcherValid)
1473+ else throwOrderError(orderValid, orderValidInfo, senderValid, matcherValid)
13211474 case s: SetScriptTransaction =>
1322- let newHash = blake2b256(value(s.script))
1323- let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash())))
1324- let currentHash = scriptHash(this)
1325- if (if ((allowedHash == newHash))
1326- then (currentHash != newHash)
1327- else false)
1475+ if (sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey))
13281476 then true
1329- else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
1477+ else {
1478+ let newHash = blake2b256(value(s.script))
1479+ let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash())))
1480+ let currentHash = scriptHash(this)
1481+ if ((allowedHash == newHash))
1482+ then (currentHash != newHash)
1483+ else false
1484+ }
13301485 case _ =>
13311486 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
13321487 }
13331488 }
13341489

github/deemru/w8io/026f985 
241.72 ms