tx · GNXBfNAvPrvRYhgiqRb58gCivjk7jEwvTXk9ZcT43Sp4

3N8xhCqhby2FuAxqMfNmJcoVYrkkJiVE1Jr:  -0.03600000 Waves

2023.01.19 12:41 [2411642] smart account 3N8xhCqhby2FuAxqMfNmJcoVYrkkJiVE1Jr > SELF 0.00000000 Waves

{ "type": 13, "id": "GNXBfNAvPrvRYhgiqRb58gCivjk7jEwvTXk9ZcT43Sp4", "fee": 3600000, "feeAssetId": null, "timestamp": 1674121364344, "version": 1, "sender": "3N8xhCqhby2FuAxqMfNmJcoVYrkkJiVE1Jr", "senderPublicKey": "5tCEcjM69HsRh7dRpSZ51WjznVLspnZVwPFARKC33MkF", "proofs": [ "4b534xphvki7xWMbUKx7zmSTDA4Qp5ysPbS1ZCUk1cfmVP64zdiB1cRQ44fF7DFyYc9bTqFQcUYeQz4vsM6LnKd1" ], "script": "base64:BgKsLQgCEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgQKAggBEgQKAggBEgQKAggBEgUKAwEIARIAEgQKAgEBEgMKAQESBQoDAQEBEgQKAggIEgASABIDCgEIEgUKAwEBARIECgIBARIECgIIARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCBIAEgMKAQESAwoBARIECgIIASIKbFBkZWNpbWFscyIGc2NhbGU4IgxzY2FsZThCaWdJbnQiB3NjYWxlMTgiCnplcm9CaWdJbnQiBGJpZzAiBGJpZzEiBGJpZzIiC3dhdmVzU3RyaW5nIgNTRVAiClBvb2xBY3RpdmUiD1Bvb2xQdXREaXNhYmxlZCITUG9vbE1hdGNoZXJEaXNhYmxlZCIMUG9vbFNodXRkb3duIg5pZHhQb29sQWRkcmVzcyINaWR4UG9vbFN0YXR1cyIQaWR4UG9vbExQQXNzZXRJZCINaWR4QW10QXNzZXRJZCIPaWR4UHJpY2VBc3NldElkIg5pZHhBbXRBc3NldERjbSIQaWR4UHJpY2VBc3NldERjbSIOaWR4SUFtdEFzc2V0SWQiEGlkeElQcmljZUFzc2V0SWQiDWl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Pc2VuZGVyUHVibGljS2V5CQACAQILTWF0Y2ggZXJyb3IEAmRRBQJnRAMJAAECBQJkUQIFT3JkZXIEAmR2BQJkUQQCZ0cJAQJhUgAEAmFCCQECZHUBBQJkdgQCYUMJAPQDAwgFAmR2CWJvZHlCeXRlcwkAkQMCCAUCZHYGcHJvb2ZzAAAIBQJkdg9zZW5kZXJQdWJsaWNLZXkEAmFECQD0AwMIBQJkdglib2R5Qnl0ZXMJAJEDAggFAmR2BnByb29mcwABBQJnRwMDAwUCYUIFAmFDBwUCYUQHBgkBAmFBAwUCYUIFAmFDBQJhRAMJAAECBQJkUQIUU2V0U2NyaXB0VHJhbnNhY3Rpb24EAmVVBQJkUQQCZ0gJAPYDAQkBBXZhbHVlAQgFAmVVBnNjcmlwdAQCZ0kJANsEAQkBBXZhbHVlAQkAnQgCBQJhTAkBAmF5AAQCZ0oJAPEHAQUEdGhpcwMDCQAAAgUCZ0kFAmdICQECIT0CBQJnSgUCZ0gHBgkA9AMDCAUCZ0QJYm9keUJ5dGVzCQCRAwIIBQJnRAZwcm9vZnMAAAUCZ0YJAPQDAwgFAmdECWJvZHlCeXRlcwkAkQMCCAUCZ0QGcHJvb2ZzAAAFAmdGigMyEw==", "chainId": 84, "height": 2411642, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FP7DvWxmwurfFQp3EXxx44KPpm7niUDRn8oWzMhdcrWT Next: HTXWoqbb6U8JX3tcR924y6bryzXeaeywDPRjRPFUtwMm Diff:
OldNewDifferences
6565 func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18))
6666
6767
68+func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round))
69+
70+
6871 func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale)
6972
7073
105108 func pa () = "%s__priceAsset"
106109
107110
111+let keyFee = "%s__fee"
112+
113+let feeDefault = fraction(10, scale8, 10000)
114+
115+let fee = valueOrElse(getInteger(this, keyFee), feeDefault)
116+
117+let keyKLp = makeString(["%s", "kLp"], SEP)
118+
119+let keyKLpRefreshedHeight = makeString(["%s", "kLpRefreshedHeight"], SEP)
120+
121+let keyKLpRefreshDelay = makeString(["%s", "refreshKLpDelay"], SEP)
122+
123+let kLpRefreshDelayDefault = 30
124+
125+let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault)
126+
108127 func keyFactoryConfig () = "%s__factoryConfig"
109128
110129
141160
142161
143162 func throwErr (msg) = throw(makeString(["lp.ride:", msg], " "))
163+
164+
165+func fmtErr (msg) = makeString(["lp.ride:", msg], " ")
144166
145167
146168 let factoryContract = addressFromStringValue(getStringOrFail(this, fc()))
191213
192214 let poolConfigParsed = parsePoolConfig(getPoolConfig())
193215
194-let $t076017767 = poolConfigParsed
216+let $t082438409 = poolConfigParsed
195217
196-let cfgPoolAddress = $t076017767._1
218+let cfgPoolAddress = $t082438409._1
197219
198-let cfgPoolStatus = $t076017767._2
220+let cfgPoolStatus = $t082438409._2
199221
200-let cfgLpAssetId = $t076017767._3
222+let cfgLpAssetId = $t082438409._3
201223
202-let cfgAmountAssetId = $t076017767._4
224+let cfgAmountAssetId = $t082438409._4
203225
204-let cfgPriceAssetId = $t076017767._5
226+let cfgPriceAssetId = $t082438409._5
205227
206-let cfgAmountAssetDecimals = $t076017767._6
228+let cfgAmountAssetDecimals = $t082438409._6
207229
208-let cfgPriceAssetDecimals = $t076017767._7
230+let cfgPriceAssetDecimals = $t082438409._7
209231
210232 func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
211233
226248
227249
228250 func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
251+
252+
253+func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
229254
230255
231256 func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
277302 let lpEmissionX18 = toX18(lpEmission, scale8)
278303 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18)
279304 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18)
280- let outAmAmt = fromX18(outAmAmtX18, amAssetDcm)
281- let outPrAmt = fromX18(outPrAmtX18, prAssetDcm)
305+ let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR)
306+ let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR)
282307 let state = if ((txId58 == ""))
283308 then nil
284309 else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES"))
337362 then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18)))
338363 else {
339364 let lpEmissionX18 = toX18(lpEmission, scale8)
340- let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
341- let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
365+ let prViaAmX18 = fraction(inAmAssetAmtX18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING)
366+ let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, FLOOR), CEILING)
342367 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
343368 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
344369 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
345370 let expAmtAssetAmtX18 = expectedAmts._1
346371 let expPriceAssetAmtX18 = expectedAmts._2
347- let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
348- $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18)
372+ let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR)
373+ $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtAssetDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceAssetDcm, CEILING), curPriceX18, slippageX18)
349374 }
350375 }
351376 let calcLpAmt = res._1
368393 }
369394
370395
396+func calcKLp (amountBalance,priceBalance,lpEmission) = {
397+ let updatedKLp = fraction(pow((amountBalance * priceBalance), 0, toBigInt(5), 1, 18, DOWN), big1, lpEmission)
398+ if ((lpEmission == big0))
399+ then big0
400+ else updatedKLp
401+ }
402+
403+
404+func calcCurrentKLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = {
405+ let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta)
406+ let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta)
407+ let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta)
408+ let currentKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpAssetEmission)
409+ currentKLp
410+ }
411+
412+
413+func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = {
414+ let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta)
415+ let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta)
416+ let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta)
417+ let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission))
418+ let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))]
419+ $Tuple2(actions, updatedKLp)
420+ }
421+
422+
423+func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp))
424+ then true
425+ else throwErr(makeString(["updated KLp lower than current KLp", toString(oldKLp), toString(updatedKLp)], " "))
426+
427+
371428 func validateMatcherOrderAllowed (order) = {
372- let cfg = getPoolConfig()
373- let amtAssetId = cfg[idxAmtAssetId]
374- let priceAssetId = cfg[idxPriceAssetId]
375- let poolStatus = parseIntValue(cfg[idxPoolStatus])
376- let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
377- let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
378- let accAmtAssetBalance = getAccBalance(amtAssetId)
379- let accPriceAssetBalance = getAccBalance(priceAssetId)
380- let curPriceX18 = if ((order.orderType == Buy))
381- then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance)
382- else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance)
383- let curPrice = fromX18(curPriceX18, scale8)
429+ let amountAssetAmount = order.amount
430+ let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR)
431+ let $t02098621198 = if ((order.orderType == Buy))
432+ then $Tuple2(amountAssetAmount, -(priceAssetAmount))
433+ else $Tuple2(-(amountAssetAmount), priceAssetAmount)
434+ let amountAssetBalanceDelta = $t02098621198._1
435+ let priceAssetBalanceDelta = $t02098621198._2
384436 if (if (if (isGlobalShutdown())
385437 then true
386- else (poolStatus == PoolMatcherDisabled))
438+ else (cfgPoolStatus == PoolMatcherDisabled))
387439 then true
388- else (poolStatus == PoolShutdown))
440+ else (cfgPoolStatus == PoolShutdown))
389441 then throw("Exchange operations disabled")
390- else {
391- let orderAmtAsset = order.assetPair.amountAsset
392- let orderAmtAssetStr = if ((orderAmtAsset == unit))
393- then "WAVES"
394- else toBase58String(value(orderAmtAsset))
395- let orderPriceAsset = order.assetPair.priceAsset
396- let orderPriceAssetStr = if ((orderPriceAsset == unit))
397- then "WAVES"
398- else toBase58String(value(orderPriceAsset))
399- if (if ((orderAmtAssetStr != amtAssetId))
400- then true
401- else (orderPriceAssetStr != priceAssetId))
402- then throw("Wrong order assets.")
403- else {
404- let orderPrice = order.price
405- let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm)
406- let castedOrderPrice = toScale(orderPrice, scale8, priceDcm)
407- let isOrderPriceValid = if ((order.orderType == Buy))
408- then (curPrice >= castedOrderPrice)
409- else (castedOrderPrice >= curPrice)
410- true
411- }
412- }
442+ else if (if ((order.assetPair.amountAsset != cfgAmountAssetId))
443+ then true
444+ else (order.assetPair.priceAsset != cfgPriceAssetId))
445+ then throw("Wrong order assets.")
446+ else {
447+ let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp"))
448+ let $t02166921769 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
449+ let unusedActions = $t02166921769._1
450+ let kLpNew = $t02166921769._2
451+ let isOrderValid = (kLpNew >= kLp)
452+ isOrderValid
453+ }
413454 }
414455
415456
484525 else if ((paymentAssetId == cfgPriceAssetId))
485526 then false
486527 else throwErr("invalid asset")
487- let $t02266422957 = if (isEval)
528+ let $t02449024783 = if (isEval)
488529 then $Tuple2(amountBalanceRaw, priceBalanceRaw)
489530 else if (paymentInAmountAsset)
490531 then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw)
491532 else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw))
492- let amountBalanceOld = $t02266422957._1
493- let priceBalanceOld = $t02266422957._2
494- let $t02296123110 = if (paymentInAmountAsset)
533+ let amountBalanceOld = $t02449024783._1
534+ let priceBalanceOld = $t02449024783._2
535+ let $t02478724936 = if (paymentInAmountAsset)
495536 then $Tuple2(paymentAmountRaw, 0)
496537 else $Tuple2(0, paymentAmountRaw)
497- let amountAssetAmountRaw = $t02296123110._1
498- let priceAssetAmountRaw = $t02296123110._2
538+ let amountAssetAmountRaw = $t02478724936._1
539+ let priceAssetAmountRaw = $t02478724936._2
499540 let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1
500541 let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1
501- let $t02324223306 = takeFee(paymentAmountRaw, inFee)
502- let paymentAmount = $t02324223306._1
503- let feeAmount = $t02324223306._2
542+ let $t02506825132 = takeFee(paymentAmountRaw, inFee)
543+ let paymentAmount = $t02506825132._1
544+ let feeAmount = $t02506825132._2
504545 let amountBalanceNew = (amountBalanceOld + amountAssetAmount)
505546 let priceBalanceNew = (priceBalanceOld + priceAssetAmount)
506547 let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals))
523564 let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals))
524565 let priceOld = fromX18(priceOldX18, scale8)
525566 let loss = {
526- let $t02478324950 = if (paymentInAmountAsset)
567+ let $t02681326980 = if (paymentInAmountAsset)
527568 then $Tuple2(amountAssetAmountRaw, amountBalanceOld)
528569 else $Tuple2(priceAssetAmountRaw, priceBalanceOld)
529- let amount = $t02478324950._1
530- let balance = $t02478324950._2
570+ let amount = $t02681326980._1
571+ let balance = $t02681326980._2
531572 let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance)))
532573 fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth)
533574 }
534- $Tuple4(issueAmount, commonState, feeAmount, loss)
575+ $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset)
535576 }
536577 else throw("Strict value is not equal to itself.")
537578 }
539580
540581 func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = {
541582 let isEval = (txId == unit)
583+ let cfg = getPoolConfig()
584+ let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
585+ let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
542586 let checks = [if ((paymentAssetId == cfgLpAssetId))
543587 then true
544588 else throwErr("invalid lp asset")]
552596 let balanceBigInt = if (outInAmountAsset)
553597 then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId)))
554598 else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId)))
599+ let outInAmountAssetDecimals = if (outInAmountAsset)
600+ then amtAssetDcm
601+ else priceAssetDcm
555602 let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId))
556603 let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId))
557604 let outBalance = if (outInAmountAsset)
561608 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
562609 let redeemedBigInt = toBigInt(paymentAmount)
563610 let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))])
564- let $t02653026586 = takeFee(amountRaw, outFee)
565- let totalAmount = $t02653026586._1
566- let feeAmount = $t02653026586._2
567- let $t02659026816 = if (outInAmountAsset)
611+ let $t02905829114 = takeFee(amountRaw, outFee)
612+ let totalAmount = $t02905829114._1
613+ let feeAmount = $t02905829114._2
614+ let $t02911829344 = if (outInAmountAsset)
568615 then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
569616 else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw))
570- let outAmAmount = $t02659026816._1
571- let outPrAmount = $t02659026816._2
572- let amBalanceNew = $t02659026816._3
573- let prBalanceNew = $t02659026816._4
617+ let outAmAmount = $t02911829344._1
618+ let outPrAmount = $t02911829344._2
619+ let amBalanceNew = $t02911829344._3
620+ let prBalanceNew = $t02911829344._4
574621 let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
575622 let priceNew = fromX18(priceNewX18, scale8)
576623 let commonState = if (isEval)
582629 let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2)
583630 fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset)
584631 }
585- $Tuple4(totalAmount, commonState, feeAmount, loss)
632+ $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset)
586633 }
587634 else throw("Strict value is not equal to itself.")
588635 }
682729 let prDiff = estPut._11
683730 let amId = estPut._12
684731 let prId = estPut._13
685- let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
686- if ((emitInv == emitInv))
732+ let amAssetPmt = toBigInt(value(i.payments[0]).amount)
733+ let prAssetPmt = toBigInt(value(i.payments[1]).amount)
734+ let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
735+ if ((currentKLp == currentKLp))
687736 then {
688- let emitInvLegacy = match emitInv {
689- case legacyFactoryContract: Address =>
690- invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
691- case _ =>
692- unit
693- }
694- if ((emitInvLegacy == emitInvLegacy))
737+ let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
738+ if ((emitInv == emitInv))
695739 then {
696- let slippageAInv = if ((amDiff > 0))
697- then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
698- else nil
699- if ((slippageAInv == slippageAInv))
740+ let emitInvLegacy = match emitInv {
741+ case legacyFactoryContract: Address =>
742+ invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
743+ case _ =>
744+ unit
745+ }
746+ if ((emitInvLegacy == emitInvLegacy))
700747 then {
701- let slippagePInv = if ((prDiff > 0))
702- then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
748+ let slippageAInv = if ((amDiff > 0))
749+ then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
703750 else nil
704- if ((slippagePInv == slippagePInv))
751+ if ((slippageAInv == slippageAInv))
705752 then {
706- let lpTransfer = if (shouldAutoStake)
753+ let slippagePInv = if ((prDiff > 0))
754+ then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
755+ else nil
756+ if ((slippagePInv == slippagePInv))
707757 then {
708- let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
709- if ((slpStakeInv == slpStakeInv))
710- then nil
758+ let lpTransfer = if (shouldAutoStake)
759+ then {
760+ let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
761+ if ((slpStakeInv == slpStakeInv))
762+ then nil
763+ else throw("Strict value is not equal to itself.")
764+ }
765+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
766+ let $t03387234334 = refreshKLpInternal(0, 0, 0)
767+ if (($t03387234334 == $t03387234334))
768+ then {
769+ let updatedKLp = $t03387234334._2
770+ let refreshKLpActions = $t03387234334._1
771+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
772+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
773+ then ((state ++ lpTransfer) ++ refreshKLpActions)
774+ else throw("Strict value is not equal to itself.")
775+ }
711776 else throw("Strict value is not equal to itself.")
712777 }
713- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
714- (state ++ lpTransfer)
778+ else throw("Strict value is not equal to itself.")
715779 }
716780 else throw("Strict value is not equal to itself.")
717781 }
729793 then throw("Invalid value passed")
730794 else {
731795 let estPut = commonPut(i, maxSlippage, false)
732- estPut._9
796+ let state = estPut._9
797+ let amAssetPmt = toBigInt(value(i.payments[0]).amount)
798+ let prAssetPmt = toBigInt(value(i.payments[1]).amount)
799+ let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
800+ if ((currentKLp == currentKLp))
801+ then {
802+ let $t03489634961 = refreshKLpInternal(0, 0, 0)
803+ let refreshKLpActions = $t03489634961._1
804+ let updatedKLp = $t03489634961._2
805+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
806+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
807+ then (state ++ refreshKLpActions)
808+ else throw("Strict value is not equal to itself.")
809+ }
810+ else throw("Strict value is not equal to itself.")
733811 }
734812
735813
761839 let payment = i.payments[0]
762840 let paymentAssetId = payment.assetId
763841 let paymentAmountRaw = payment.amount
764- let userAddress = i.caller
765- let txId = i.transactionId
766- let $t03172331853 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
767- if (($t03172331853 == $t03172331853))
842+ let currentKLp = if ((paymentAssetId == cfgAmountAssetId))
843+ then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0))
844+ else if ((paymentAssetId == cfgPriceAssetId))
845+ then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0))
846+ else throwErr("payment asset is not supported")
847+ if ((currentKLp == currentKLp))
768848 then {
769- let bonus = $t03172331853._4
770- let feeAmount = $t03172331853._3
771- let commonState = $t03172331853._2
772- let emitAmountEstimated = $t03172331853._1
773- let emitAmount = if (if ((minOutAmount > 0))
774- then (minOutAmount > emitAmountEstimated)
775- else false)
776- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
777- else emitAmountEstimated
778- let emitInv = emit(emitAmount)
779- if ((emitInv == emitInv))
849+ let userAddress = i.caller
850+ let txId = i.transactionId
851+ let $t03614936301 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
852+ if (($t03614936301 == $t03614936301))
780853 then {
781- let lpTransfer = if (autoStake)
854+ let paymentInAmountAsset = $t03614936301._5
855+ let bonus = $t03614936301._4
856+ let feeAmount = $t03614936301._3
857+ let commonState = $t03614936301._2
858+ let emitAmountEstimated = $t03614936301._1
859+ let emitAmount = if (if ((minOutAmount > 0))
860+ then (minOutAmount > emitAmountEstimated)
861+ else false)
862+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
863+ else emitAmountEstimated
864+ let emitInv = emit(emitAmount)
865+ if ((emitInv == emitInv))
782866 then {
783- let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
784- if ((stakeInv == stakeInv))
785- then nil
867+ let lpTransfer = if (autoStake)
868+ then {
869+ let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
870+ if ((stakeInv == stakeInv))
871+ then nil
872+ else throw("Strict value is not equal to itself.")
873+ }
874+ else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
875+ let sendFee = if ((feeAmount > 0))
876+ then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
877+ else nil
878+ let $t03688737084 = if ((this == feeCollectorAddress))
879+ then $Tuple2(0, 0)
880+ else if (paymentInAmountAsset)
881+ then $Tuple2(-(feeAmount), 0)
882+ else $Tuple2(0, -(feeAmount))
883+ let amountAssetBalanceDelta = $t03688737084._1
884+ let priceAssetBalanceDelta = $t03688737084._2
885+ let $t03708737195 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
886+ let refreshKLpActions = $t03708737195._1
887+ let updatedKLp = $t03708737195._2
888+ let kLp = value(getString(keyKLp))
889+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
890+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
891+ then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
786892 else throw("Strict value is not equal to itself.")
787893 }
788- else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
789- let sendFee = if ((feeAmount > 0))
790- then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
791- else nil
792- $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount)
894+ else throw("Strict value is not equal to itself.")
793895 }
794896 else throw("Strict value is not equal to itself.")
795897 }
802904
803905 @Callable(i)
804906 func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = {
805- let $t03258232717 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
806- let emitAmountEstimated = $t03258232717._1
807- let commonState = $t03258232717._2
808- let feeAmount = $t03258232717._3
809- let bonus = $t03258232717._4
907+ let $t03750137658 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
908+ let emitAmountEstimated = $t03750137658._1
909+ let commonState = $t03750137658._2
910+ let feeAmount = $t03750137658._3
911+ let bonus = $t03750137658._4
912+ let paymentInAmountAsset = $t03750137658._5
810913 $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
811914 }
812915
838941 let payment = i.payments[0]
839942 let paymentAssetId = payment.assetId
840943 let paymentAmount = payment.amount
841- let userAddress = i.caller
842- let txId = i.transactionId
843- let $t03352233657 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
844- if (($t03352233657 == $t03352233657))
944+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
945+ if ((currentKLp == currentKLp))
845946 then {
846- let bonus = $t03352233657._4
847- let feeAmount = $t03352233657._3
848- let commonState = $t03352233657._2
849- let amountEstimated = $t03352233657._1
850- let amount = if (if ((minOutAmount > 0))
851- then (minOutAmount > amountEstimated)
852- else false)
853- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
854- else amountEstimated
855- let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
856- if ((burnInv == burnInv))
947+ let userAddress = i.caller
948+ let txId = i.transactionId
949+ let $t03854338696 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
950+ if (($t03854338696 == $t03854338696))
857951 then {
858- let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
859- let sendFee = if ((feeAmount > 0))
860- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
861- else nil
862- $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
952+ let outInAmountAsset = $t03854338696._5
953+ let bonus = $t03854338696._4
954+ let feeAmount = $t03854338696._3
955+ let commonState = $t03854338696._2
956+ let amountEstimated = $t03854338696._1
957+ let amount = if (if ((minOutAmount > 0))
958+ then (minOutAmount > amountEstimated)
959+ else false)
960+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
961+ else amountEstimated
962+ let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
963+ if ((burnInv == burnInv))
964+ then {
965+ let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
966+ let sendFee = if ((feeAmount > 0))
967+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
968+ else nil
969+ let $t03919639443 = {
970+ let feeAmountForCalc = if ((this == feeCollectorAddress))
971+ then 0
972+ else feeAmount
973+ if (outInAmountAsset)
974+ then $Tuple2(-((amount + feeAmountForCalc)), 0)
975+ else $Tuple2(0, -((amount + feeAmountForCalc)))
976+ }
977+ let amountAssetBalanceDelta = $t03919639443._1
978+ let priceAssetBalanceDelta = $t03919639443._2
979+ let $t03944639554 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
980+ let refreshKLpActions = $t03944639554._1
981+ let updatedKLp = $t03944639554._2
982+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
983+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
984+ then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
985+ else throw("Strict value is not equal to itself.")
986+ }
987+ else throw("Strict value is not equal to itself.")
863988 }
864989 else throw("Strict value is not equal to itself.")
865990 }
872997
873998 @Callable(i)
874999 func getOneTknREADONLY (outAssetId,paymentAmount) = {
875- let $t03429234430 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
876- let amountEstimated = $t03429234430._1
877- let commonState = $t03429234430._2
878- let feeAmount = $t03429234430._3
879- let bonus = $t03429234430._4
1000+ let $t03981139967 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
1001+ let amountEstimated = $t03981139967._1
1002+ let commonState = $t03981139967._2
1003+ let feeAmount = $t03981139967._3
1004+ let bonus = $t03981139967._4
1005+ let outInAmountAsset = $t03981139967._5
8801006 $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
8811007 }
8821008
9071033 let outAssetId = parseAssetId(outAssetIdStr)
9081034 let userAddress = i.caller
9091035 let txId = i.transactionId
910- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
911- if ((unstakeInv == unstakeInv))
1036+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1037+ if ((currentKLp == currentKLp))
9121038 then {
913- let $t03525535388 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
914- if (($t03525535388 == $t03525535388))
1039+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1040+ if ((unstakeInv == unstakeInv))
9151041 then {
916- let bonus = $t03525535388._4
917- let feeAmount = $t03525535388._3
918- let commonState = $t03525535388._2
919- let amountEstimated = $t03525535388._1
920- let amount = if (if ((minOutAmount > 0))
921- then (minOutAmount > amountEstimated)
922- else false)
923- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
924- else amountEstimated
925- let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
926- if ((burnInv == burnInv))
1042+ let $t04087241023 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
1043+ if (($t04087241023 == $t04087241023))
9271044 then {
928- let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
929- let sendFee = if ((feeAmount > 0))
930- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
931- else nil
932- $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
1045+ let outInAmountAsset = $t04087241023._5
1046+ let bonus = $t04087241023._4
1047+ let feeAmount = $t04087241023._3
1048+ let commonState = $t04087241023._2
1049+ let amountEstimated = $t04087241023._1
1050+ let amount = if (if ((minOutAmount > 0))
1051+ then (minOutAmount > amountEstimated)
1052+ else false)
1053+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1054+ else amountEstimated
1055+ let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1056+ if ((burnInv == burnInv))
1057+ then {
1058+ let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
1059+ let sendFee = if ((feeAmount > 0))
1060+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
1061+ else nil
1062+ let $t04151841765 = {
1063+ let feeAmountForCalc = if ((this == feeCollectorAddress))
1064+ then 0
1065+ else feeAmount
1066+ if (outInAmountAsset)
1067+ then $Tuple2(-((amount + feeAmountForCalc)), 0)
1068+ else $Tuple2(0, -((amount + feeAmountForCalc)))
1069+ }
1070+ let amountAssetBalanceDelta = $t04151841765._1
1071+ let priceAssetBalanceDelta = $t04151841765._2
1072+ let $t04176841876 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1073+ let refreshKLpActions = $t04176841876._1
1074+ let updatedKLp = $t04176841876._2
1075+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1076+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1077+ then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1078+ else throw("Strict value is not equal to itself.")
1079+ }
1080+ else throw("Strict value is not equal to itself.")
9331081 }
9341082 else throw("Strict value is not equal to itself.")
9351083 }
9501098 let pmtAmt = res._3
9511099 let pmtAssetId = res._4
9521100 let state = res._5
953- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
954- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
955- then state
1101+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1102+ if ((currentKLp == currentKLp))
1103+ then {
1104+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1105+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1106+ then {
1107+ let $t04282242904 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1108+ let refreshKLpActions = $t04282242904._1
1109+ let updatedKLp = $t04282242904._2
1110+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1111+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1112+ then (state ++ refreshKLpActions)
1113+ else throw("Strict value is not equal to itself.")
1114+ }
1115+ else throw("Strict value is not equal to itself.")
1116+ }
9561117 else throw("Strict value is not equal to itself.")
9571118 }
9581119
9711132 else if ((noLessThenPriceAsset > outPrAmt))
9721133 then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
9731134 else {
974- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
975- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
976- then state
1135+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1136+ if ((currentKLp == currentKLp))
1137+ then {
1138+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1139+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1140+ then {
1141+ let $t04385343934 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1142+ let refreshKLpActions = $t04385343934._1
1143+ let updatedKLp = $t04385343934._2
1144+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1145+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1146+ then (state ++ refreshKLpActions)
1147+ else throw("Strict value is not equal to itself.")
1148+ }
1149+ else throw("Strict value is not equal to itself.")
1150+ }
9771151 else throw("Strict value is not equal to itself.")
9781152 }
9791153 }
9891163 then {
9901164 let cfg = getPoolConfig()
9911165 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
992- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
993- if ((unstakeInv == unstakeInv))
1166+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1167+ if ((currentKLp == currentKLp))
9941168 then {
995- let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
996- let poolStatus = parseIntValue(res._9)
997- let state = res._10
998- let checkPoolStatus = if (if (isGlobalShutdown())
999- then true
1000- else (poolStatus == PoolShutdown))
1001- then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
1002- else true
1003- if ((checkPoolStatus == checkPoolStatus))
1169+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
1170+ if ((unstakeInv == unstakeInv))
10041171 then {
1005- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1006- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1007- then state
1172+ let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1173+ let outAmAmt = res._1
1174+ let outPrAmt = res._2
1175+ let poolStatus = parseIntValue(res._9)
1176+ let state = res._10
1177+ let checkPoolStatus = if (if (isGlobalShutdown())
1178+ then true
1179+ else (poolStatus == PoolShutdown))
1180+ then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
1181+ else true
1182+ if ((checkPoolStatus == checkPoolStatus))
1183+ then {
1184+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1185+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1186+ then {
1187+ let $t04506045141 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1188+ let refreshKLpActions = $t04506045141._1
1189+ let updatedKLp = $t04506045141._2
1190+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1191+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1192+ then (state ++ refreshKLpActions)
1193+ else throw("Strict value is not equal to itself.")
1194+ }
1195+ else throw("Strict value is not equal to itself.")
1196+ }
10081197 else throw("Strict value is not equal to itself.")
10091198 }
10101199 else throw("Strict value is not equal to itself.")
10281217 else throw("no payments are expected")]
10291218 if ((checks == checks))
10301219 then {
1031- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1032- if ((unstakeInv == unstakeInv))
1220+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1221+ if ((currentKLp == currentKLp))
10331222 then {
1034- let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1035- let outAmAmt = res._1
1036- let outPrAmt = res._2
1037- let state = res._10
1038- let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1039- then true
1040- else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1041- then true
1042- else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1043- if ((checkAmounts == checkAmounts))
1223+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1224+ if ((unstakeInv == unstakeInv))
10441225 then {
1045- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1046- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1047- then state
1226+ let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1227+ let outAmAmt = res._1
1228+ let outPrAmt = res._2
1229+ let state = res._10
1230+ let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1231+ then true
1232+ else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1233+ then true
1234+ else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1235+ if ((checkAmounts == checkAmounts))
1236+ then {
1237+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1238+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1239+ then {
1240+ let $t04643646517 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1241+ let refreshKLpActions = $t04643646517._1
1242+ let updatedKLp = $t04643646517._2
1243+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1244+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1245+ then (state ++ refreshKLpActions)
1246+ else throw("Strict value is not equal to itself.")
1247+ }
1248+ else throw("Strict value is not equal to itself.")
1249+ }
10481250 else throw("Strict value is not equal to itself.")
10491251 }
10501252 else throw("Strict value is not equal to itself.")
10601262 func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
10611263 then throw("permissions denied")
10621264 else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success")
1265+
1266+
1267+
1268+@Callable(i)
1269+func refreshKLp () = {
1270+ let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0)
1271+ let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay))
1272+ then unit
1273+ else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1274+ if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1275+ then {
1276+ let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp"))
1277+ let $t04770447768 = refreshKLpInternal(0, 0, 0)
1278+ let kLpUpdateActions = $t04770447768._1
1279+ let updatedKLp = $t04770447768._2
1280+ let actions = if ((kLp != updatedKLp))
1281+ then kLpUpdateActions
1282+ else throwErr("nothing to refresh")
1283+ $Tuple2(actions, toString(updatedKLp))
1284+ }
1285+ else throw("Strict value is not equal to itself.")
1286+ }
10631287
10641288
10651289
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 fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18))
6666
6767
68+func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round))
69+
70+
6871 func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale)
6972
7073
7174 func abs (val) = if ((0 > val))
7275 then -(val)
7376 else val
7477
7578
7679 func absBigInt (val) = if ((zeroBigInt > val))
7780 then -(val)
7881 else val
7982
8083
8184 func fc () = "%s__factoryContract"
8285
8386
8487 func mpk () = "%s__managerPublicKey"
8588
8689
8790 func pmpk () = "%s__pendingManagerPublicKey"
8891
8992
9093 func pl () = "%s%s__price__last"
9194
9295
9396 func ph (h,timestamp) = makeString(["%s%s%d%d__price__history", toString(h), toString(timestamp)], SEP)
9497
9598
9699 func pau (userAddress,txId) = ((("%s%s%s__P__" + userAddress) + "__") + txId)
97100
98101
99102 func gau (userAddress,txId) = ((("%s%s%s__G__" + userAddress) + "__") + txId)
100103
101104
102105 func aa () = "%s__amountAsset"
103106
104107
105108 func pa () = "%s__priceAsset"
106109
107110
111+let keyFee = "%s__fee"
112+
113+let feeDefault = fraction(10, scale8, 10000)
114+
115+let fee = valueOrElse(getInteger(this, keyFee), feeDefault)
116+
117+let keyKLp = makeString(["%s", "kLp"], SEP)
118+
119+let keyKLpRefreshedHeight = makeString(["%s", "kLpRefreshedHeight"], SEP)
120+
121+let keyKLpRefreshDelay = makeString(["%s", "refreshKLpDelay"], SEP)
122+
123+let kLpRefreshDelayDefault = 30
124+
125+let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault)
126+
108127 func keyFactoryConfig () = "%s__factoryConfig"
109128
110129
111130 func keyMatcherPub () = "%s%s__matcher__publicKey"
112131
113132
114133 func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset")
115134
116135
117136 func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config")
118137
119138
120139 func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr)
121140
122141
123142 func keyAllPoolsShutdown () = "%s__shutdown"
124143
125144
126145 func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress)
127146
128147
129148 func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash"
130149
131150
132151 let keyFeeCollectorAddress = "%s__feeCollectorAddress"
133152
134153 func throwOrderError (orderValid,senderValid,matcherValid) = throw(((((("order validation failed: orderValid=" + toString(orderValid)) + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid)))
135154
136155
137156 func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
138157
139158
140159 func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
141160
142161
143162 func throwErr (msg) = throw(makeString(["lp.ride:", msg], " "))
163+
164+
165+func fmtErr (msg) = makeString(["lp.ride:", msg], " ")
144166
145167
146168 let factoryContract = addressFromStringValue(getStringOrFail(this, fc()))
147169
148170 let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress))
149171
150172 let inFee = {
151173 let @ = invoke(factoryContract, "getInFeeREADONLY", [toString(this)], nil)
152174 if ($isInstanceOf(@, "Int"))
153175 then @
154176 else throw(($getType(@) + " couldn't be cast to Int"))
155177 }
156178
157179 let outFee = {
158180 let @ = invoke(factoryContract, "getOutFeeREADONLY", [toString(this)], nil)
159181 if ($isInstanceOf(@, "Int"))
160182 then @
161183 else throw(($getType(@) + " couldn't be cast to Int"))
162184 }
163185
164186 func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false)
165187
166188
167189 func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub()))
168190
169191
170192 func getPoolConfig () = {
171193 let amtAsset = getStringOrFail(this, aa())
172194 let priceAsset = getStringOrFail(this, pa())
173195 let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset))
174196 let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset))
175197 split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP)
176198 }
177199
178200
179201 func parseAssetId (input) = if ((input == wavesString))
180202 then unit
181203 else fromBase58String(input)
182204
183205
184206 func assetIdToString (input) = if ((input == unit))
185207 then wavesString
186208 else toBase58String(value(input))
187209
188210
189211 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]))
190212
191213
192214 let poolConfigParsed = parsePoolConfig(getPoolConfig())
193215
194-let $t076017767 = poolConfigParsed
216+let $t082438409 = poolConfigParsed
195217
196-let cfgPoolAddress = $t076017767._1
218+let cfgPoolAddress = $t082438409._1
197219
198-let cfgPoolStatus = $t076017767._2
220+let cfgPoolStatus = $t082438409._2
199221
200-let cfgLpAssetId = $t076017767._3
222+let cfgLpAssetId = $t082438409._3
201223
202-let cfgAmountAssetId = $t076017767._4
224+let cfgAmountAssetId = $t082438409._4
203225
204-let cfgPriceAssetId = $t076017767._5
226+let cfgPriceAssetId = $t082438409._5
205227
206-let cfgAmountAssetDecimals = $t076017767._6
228+let cfgAmountAssetDecimals = $t082438409._6
207229
208-let cfgPriceAssetDecimals = $t076017767._7
230+let cfgPriceAssetDecimals = $t082438409._7
209231
210232 func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
211233
212234
213235 let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address")
214236
215237 let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address")
216238
217239 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)
218240
219241
220242 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)
221243
222244
223245 func getAccBalance (assetId) = if ((assetId == "WAVES"))
224246 then wavesBalance(this).available
225247 else assetBalance(this, fromBase58String(assetId))
226248
227249
228250 func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
251+
252+
253+func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
229254
230255
231256 func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
232257 let amtAssetAmtX18 = toX18(amAmt, amAssetDcm)
233258 let priceAssetAmtX18 = toX18(prAmt, prAssetDcm)
234259 calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18)
235260 }
236261
237262
238263 func calcPrices (amAmt,prAmt,lpAmt) = {
239264 let cfg = getPoolConfig()
240265 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
241266 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
242267 let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt)
243268 let amAmtX18 = toX18(amAmt, amtAssetDcm)
244269 let prAmtX18 = toX18(prAmt, priceAssetDcm)
245270 let lpAmtX18 = toX18(lpAmt, scale8)
246271 let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18)
247272 let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18)
248273 [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18]
249274 }
250275
251276
252277 func calculatePrices (amAmt,prAmt,lpAmt) = {
253278 let prices = calcPrices(amAmt, prAmt, lpAmt)
254279 [fromX18(prices[0], scale8), fromX18(prices[1], scale8), fromX18(prices[2], scale8)]
255280 }
256281
257282
258283 func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
259284 let cfg = getPoolConfig()
260285 let lpAssetId = cfg[idxPoolLPAssetId]
261286 let amAssetId = cfg[idxAmtAssetId]
262287 let prAssetId = cfg[idxPriceAssetId]
263288 let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
264289 let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
265290 let poolStatus = cfg[idxPoolStatus]
266291 let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity
267292 if ((lpAssetId != pmtAssetId))
268293 then throw("Invalid asset passed.")
269294 else {
270295 let amBalance = getAccBalance(amAssetId)
271296 let amBalanceX18 = toX18(amBalance, amAssetDcm)
272297 let prBalance = getAccBalance(prAssetId)
273298 let prBalanceX18 = toX18(prBalance, prAssetDcm)
274299 let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18)
275300 let curPrice = fromX18(curPriceX18, scale8)
276301 let pmtLpAmtX18 = toX18(pmtLpAmt, scale8)
277302 let lpEmissionX18 = toX18(lpEmission, scale8)
278303 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18)
279304 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18)
280- let outAmAmt = fromX18(outAmAmtX18, amAssetDcm)
281- let outPrAmt = fromX18(outPrAmtX18, prAssetDcm)
305+ let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR)
306+ let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR)
282307 let state = if ((txId58 == ""))
283308 then nil
284309 else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES"))
285310 then unit
286311 else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES"))
287312 then unit
288313 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)]
289314 $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state)
290315 }
291316 }
292317
293318
294319 func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = {
295320 let cfg = getPoolConfig()
296321 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
297322 let amAssetIdStr = cfg[idxAmtAssetId]
298323 let prAssetIdStr = cfg[idxPriceAssetId]
299324 let iAmtAssetId = cfg[idxIAmtAssetId]
300325 let iPriceAssetId = cfg[idxIPriceAssetId]
301326 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
302327 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
303328 let poolStatus = cfg[idxPoolStatus]
304329 let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
305330 let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES")))
306331 let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES")))
307332 if (if ((amAssetIdStr != inAmAssetIdStr))
308333 then true
309334 else (prAssetIdStr != inPrAssetIdStr))
310335 then throw("Invalid amt or price asset passed.")
311336 else {
312337 let amBalance = if (isEvaluate)
313338 then getAccBalance(amAssetIdStr)
314339 else (getAccBalance(amAssetIdStr) - inAmAssetAmt)
315340 let prBalance = if (isEvaluate)
316341 then getAccBalance(prAssetIdStr)
317342 else (getAccBalance(prAssetIdStr) - inPrAssetAmt)
318343 let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm)
319344 let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm)
320345 let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18)
321346 let amBalanceX18 = toX18(amBalance, amtAssetDcm)
322347 let prBalanceX18 = toX18(prBalance, priceAssetDcm)
323348 let res = if ((lpEmission == 0))
324349 then {
325350 let curPriceX18 = zeroBigInt
326351 let slippageX18 = zeroBigInt
327352 let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN)
328353 $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
329354 }
330355 else {
331356 let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18)
332357 let slippageX18 = fraction(absBigInt((curPriceX18 - userPriceX18)), scale18, curPriceX18)
333358 let slippageToleranceX18 = toX18(slippageTolerance, scale8)
334359 if (if ((curPriceX18 != zeroBigInt))
335360 then (slippageX18 > slippageToleranceX18)
336361 else false)
337362 then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18)))
338363 else {
339364 let lpEmissionX18 = toX18(lpEmission, scale8)
340- let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
341- let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
365+ let prViaAmX18 = fraction(inAmAssetAmtX18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING)
366+ let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, FLOOR), CEILING)
342367 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
343368 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
344369 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
345370 let expAmtAssetAmtX18 = expectedAmts._1
346371 let expPriceAssetAmtX18 = expectedAmts._2
347- let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
348- $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18)
372+ let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR)
373+ $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtAssetDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceAssetDcm, CEILING), curPriceX18, slippageX18)
349374 }
350375 }
351376 let calcLpAmt = res._1
352377 let calcAmAssetPmt = res._2
353378 let calcPrAssetPmt = res._3
354379 let curPrice = fromX18(res._4, scale8)
355380 let slippageCalc = fromX18(res._5, scale8)
356381 if ((0 >= calcLpAmt))
357382 then throw("Invalid calculations. LP calculated is less than zero.")
358383 else {
359384 let emitLpAmt = if (!(emitLp))
360385 then 0
361386 else calcLpAmt
362387 let amDiff = (inAmAssetAmt - calcAmAssetPmt)
363388 let prDiff = (inPrAssetAmt - calcPrAssetPmt)
364389 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))]
365390 $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId)
366391 }
367392 }
368393 }
369394
370395
396+func calcKLp (amountBalance,priceBalance,lpEmission) = {
397+ let updatedKLp = fraction(pow((amountBalance * priceBalance), 0, toBigInt(5), 1, 18, DOWN), big1, lpEmission)
398+ if ((lpEmission == big0))
399+ then big0
400+ else updatedKLp
401+ }
402+
403+
404+func calcCurrentKLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = {
405+ let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta)
406+ let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta)
407+ let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta)
408+ let currentKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpAssetEmission)
409+ currentKLp
410+ }
411+
412+
413+func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = {
414+ let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta)
415+ let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta)
416+ let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta)
417+ let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission))
418+ let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))]
419+ $Tuple2(actions, updatedKLp)
420+ }
421+
422+
423+func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp))
424+ then true
425+ else throwErr(makeString(["updated KLp lower than current KLp", toString(oldKLp), toString(updatedKLp)], " "))
426+
427+
371428 func validateMatcherOrderAllowed (order) = {
372- let cfg = getPoolConfig()
373- let amtAssetId = cfg[idxAmtAssetId]
374- let priceAssetId = cfg[idxPriceAssetId]
375- let poolStatus = parseIntValue(cfg[idxPoolStatus])
376- let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
377- let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
378- let accAmtAssetBalance = getAccBalance(amtAssetId)
379- let accPriceAssetBalance = getAccBalance(priceAssetId)
380- let curPriceX18 = if ((order.orderType == Buy))
381- then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance)
382- else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance)
383- let curPrice = fromX18(curPriceX18, scale8)
429+ let amountAssetAmount = order.amount
430+ let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR)
431+ let $t02098621198 = if ((order.orderType == Buy))
432+ then $Tuple2(amountAssetAmount, -(priceAssetAmount))
433+ else $Tuple2(-(amountAssetAmount), priceAssetAmount)
434+ let amountAssetBalanceDelta = $t02098621198._1
435+ let priceAssetBalanceDelta = $t02098621198._2
384436 if (if (if (isGlobalShutdown())
385437 then true
386- else (poolStatus == PoolMatcherDisabled))
438+ else (cfgPoolStatus == PoolMatcherDisabled))
387439 then true
388- else (poolStatus == PoolShutdown))
440+ else (cfgPoolStatus == PoolShutdown))
389441 then throw("Exchange operations disabled")
390- else {
391- let orderAmtAsset = order.assetPair.amountAsset
392- let orderAmtAssetStr = if ((orderAmtAsset == unit))
393- then "WAVES"
394- else toBase58String(value(orderAmtAsset))
395- let orderPriceAsset = order.assetPair.priceAsset
396- let orderPriceAssetStr = if ((orderPriceAsset == unit))
397- then "WAVES"
398- else toBase58String(value(orderPriceAsset))
399- if (if ((orderAmtAssetStr != amtAssetId))
400- then true
401- else (orderPriceAssetStr != priceAssetId))
402- then throw("Wrong order assets.")
403- else {
404- let orderPrice = order.price
405- let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm)
406- let castedOrderPrice = toScale(orderPrice, scale8, priceDcm)
407- let isOrderPriceValid = if ((order.orderType == Buy))
408- then (curPrice >= castedOrderPrice)
409- else (castedOrderPrice >= curPrice)
410- true
411- }
412- }
442+ else if (if ((order.assetPair.amountAsset != cfgAmountAssetId))
443+ then true
444+ else (order.assetPair.priceAsset != cfgPriceAssetId))
445+ then throw("Wrong order assets.")
446+ else {
447+ let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp"))
448+ let $t02166921769 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
449+ let unusedActions = $t02166921769._1
450+ let kLpNew = $t02166921769._2
451+ let isOrderValid = (kLpNew >= kLp)
452+ isOrderValid
453+ }
413454 }
414455
415456
416457 func commonGet (i) = if ((size(i.payments) != 1))
417458 then throw("exactly 1 payment is expected")
418459 else {
419460 let pmt = value(i.payments[0])
420461 let pmtAssetId = value(pmt.assetId)
421462 let pmtAmt = pmt.amount
422463 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller)
423464 let outAmAmt = res._1
424465 let outPrAmt = res._2
425466 let poolStatus = parseIntValue(res._9)
426467 let state = res._10
427468 if (if (isGlobalShutdown())
428469 then true
429470 else (poolStatus == PoolShutdown))
430471 then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
431472 else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state)
432473 }
433474
434475
435476 func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2))
436477 then throw("exactly 2 payments are expected")
437478 else {
438479 let amAssetPmt = value(i.payments[0])
439480 let prAssetPmt = value(i.payments[1])
440481 let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp)
441482 let poolStatus = parseIntValue(estPut._8)
442483 if (if (if (isGlobalShutdown())
443484 then true
444485 else (poolStatus == PoolPutDisabled))
445486 then true
446487 else (poolStatus == PoolShutdown))
447488 then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus)))
448489 else estPut
449490 }
450491
451492
452493 func emit (amount) = {
453494 let emitInv = invoke(factoryContract, "emit", [amount], nil)
454495 if ((emitInv == emitInv))
455496 then {
456497 let emitInvLegacy = match emitInv {
457498 case legacyFactoryContract: Address =>
458499 invoke(legacyFactoryContract, "emit", [amount], nil)
459500 case _ =>
460501 unit
461502 }
462503 if ((emitInvLegacy == emitInvLegacy))
463504 then amount
464505 else throw("Strict value is not equal to itself.")
465506 }
466507 else throw("Strict value is not equal to itself.")
467508 }
468509
469510
470511 func takeFee (amount,fee) = {
471512 let feeAmount = if ((fee == 0))
472513 then 0
473514 else fraction(amount, fee, scale8)
474515 $Tuple2((amount - feeAmount), feeAmount)
475516 }
476517
477518
478519 func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = {
479520 let isEval = (txId == unit)
480521 let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId))
481522 let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId))
482523 let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId))
483524 then true
484525 else if ((paymentAssetId == cfgPriceAssetId))
485526 then false
486527 else throwErr("invalid asset")
487- let $t02266422957 = if (isEval)
528+ let $t02449024783 = if (isEval)
488529 then $Tuple2(amountBalanceRaw, priceBalanceRaw)
489530 else if (paymentInAmountAsset)
490531 then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw)
491532 else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw))
492- let amountBalanceOld = $t02266422957._1
493- let priceBalanceOld = $t02266422957._2
494- let $t02296123110 = if (paymentInAmountAsset)
533+ let amountBalanceOld = $t02449024783._1
534+ let priceBalanceOld = $t02449024783._2
535+ let $t02478724936 = if (paymentInAmountAsset)
495536 then $Tuple2(paymentAmountRaw, 0)
496537 else $Tuple2(0, paymentAmountRaw)
497- let amountAssetAmountRaw = $t02296123110._1
498- let priceAssetAmountRaw = $t02296123110._2
538+ let amountAssetAmountRaw = $t02478724936._1
539+ let priceAssetAmountRaw = $t02478724936._2
499540 let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1
500541 let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1
501- let $t02324223306 = takeFee(paymentAmountRaw, inFee)
502- let paymentAmount = $t02324223306._1
503- let feeAmount = $t02324223306._2
542+ let $t02506825132 = takeFee(paymentAmountRaw, inFee)
543+ let paymentAmount = $t02506825132._1
544+ let feeAmount = $t02506825132._2
504545 let amountBalanceNew = (amountBalanceOld + amountAssetAmount)
505546 let priceBalanceNew = (priceBalanceOld + priceAssetAmount)
506547 let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals))
507548 let priceNew = fromX18(priceNewX18, scale8)
508549 let paymentBalance = if (paymentInAmountAsset)
509550 then amountBalanceOld
510551 else priceBalanceOld
511552 let paymentBalanceBigInt = toBigInt(paymentBalance)
512553 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
513554 let chechSupply = if ((supplyBigInt > big0))
514555 then true
515556 else throwErr("initial deposit requires all coins")
516557 if ((chechSupply == chechSupply))
517558 then {
518559 let depositBigInt = toBigInt(paymentAmount)
519560 let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))])
520561 let commonState = if (isEval)
521562 then nil
522563 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))]
523564 let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals))
524565 let priceOld = fromX18(priceOldX18, scale8)
525566 let loss = {
526- let $t02478324950 = if (paymentInAmountAsset)
567+ let $t02681326980 = if (paymentInAmountAsset)
527568 then $Tuple2(amountAssetAmountRaw, amountBalanceOld)
528569 else $Tuple2(priceAssetAmountRaw, priceBalanceOld)
529- let amount = $t02478324950._1
530- let balance = $t02478324950._2
570+ let amount = $t02681326980._1
571+ let balance = $t02681326980._2
531572 let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance)))
532573 fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth)
533574 }
534- $Tuple4(issueAmount, commonState, feeAmount, loss)
575+ $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset)
535576 }
536577 else throw("Strict value is not equal to itself.")
537578 }
538579
539580
540581 func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = {
541582 let isEval = (txId == unit)
583+ let cfg = getPoolConfig()
584+ let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
585+ let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
542586 let checks = [if ((paymentAssetId == cfgLpAssetId))
543587 then true
544588 else throwErr("invalid lp asset")]
545589 if ((checks == checks))
546590 then {
547591 let outInAmountAsset = if ((outAssetId == cfgAmountAssetId))
548592 then true
549593 else if ((outAssetId == cfgPriceAssetId))
550594 then false
551595 else throwErr("invalid asset")
552596 let balanceBigInt = if (outInAmountAsset)
553597 then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId)))
554598 else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId)))
599+ let outInAmountAssetDecimals = if (outInAmountAsset)
600+ then amtAssetDcm
601+ else priceAssetDcm
555602 let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId))
556603 let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId))
557604 let outBalance = if (outInAmountAsset)
558605 then amBalanceOld
559606 else prBalanceOld
560607 let outBalanceBigInt = toBigInt(outBalance)
561608 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
562609 let redeemedBigInt = toBigInt(paymentAmount)
563610 let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))])
564- let $t02653026586 = takeFee(amountRaw, outFee)
565- let totalAmount = $t02653026586._1
566- let feeAmount = $t02653026586._2
567- let $t02659026816 = if (outInAmountAsset)
611+ let $t02905829114 = takeFee(amountRaw, outFee)
612+ let totalAmount = $t02905829114._1
613+ let feeAmount = $t02905829114._2
614+ let $t02911829344 = if (outInAmountAsset)
568615 then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
569616 else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw))
570- let outAmAmount = $t02659026816._1
571- let outPrAmount = $t02659026816._2
572- let amBalanceNew = $t02659026816._3
573- let prBalanceNew = $t02659026816._4
617+ let outAmAmount = $t02911829344._1
618+ let outPrAmount = $t02911829344._2
619+ let amBalanceNew = $t02911829344._3
620+ let prBalanceNew = $t02911829344._4
574621 let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
575622 let priceNew = fromX18(priceNewX18, scale8)
576623 let commonState = if (isEval)
577624 then nil
578625 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)]
579626 let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals))
580627 let priceOld = fromX18(priceOldX18, scale8)
581628 let loss = {
582629 let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2)
583630 fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset)
584631 }
585- $Tuple4(totalAmount, commonState, feeAmount, loss)
632+ $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset)
586633 }
587634 else throw("Strict value is not equal to itself.")
588635 }
589636
590637
591638 func managerPublicKeyOrUnit () = match getString(mpk()) {
592639 case s: String =>
593640 fromBase58String(s)
594641 case _: Unit =>
595642 unit
596643 case _ =>
597644 throw("Match error")
598645 }
599646
600647
601648 func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) {
602649 case s: String =>
603650 fromBase58String(s)
604651 case _: Unit =>
605652 unit
606653 case _ =>
607654 throw("Match error")
608655 }
609656
610657
611658 func isManager (i) = match managerPublicKeyOrUnit() {
612659 case pk: ByteVector =>
613660 (i.callerPublicKey == pk)
614661 case _: Unit =>
615662 (i.caller == this)
616663 case _ =>
617664 throw("Match error")
618665 }
619666
620667
621668 func mustManager (i) = {
622669 let pd = throw("Permission denied")
623670 match managerPublicKeyOrUnit() {
624671 case pk: ByteVector =>
625672 if ((i.callerPublicKey == pk))
626673 then true
627674 else pd
628675 case _: Unit =>
629676 if ((i.caller == this))
630677 then true
631678 else pd
632679 case _ =>
633680 throw("Match error")
634681 }
635682 }
636683
637684
638685 @Callable(i)
639686 func setManager (pendingManagerPublicKey) = {
640687 let checkCaller = mustManager(i)
641688 if ((checkCaller == checkCaller))
642689 then {
643690 let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
644691 if ((checkManagerPublicKey == checkManagerPublicKey))
645692 then [StringEntry(pmpk(), pendingManagerPublicKey)]
646693 else throw("Strict value is not equal to itself.")
647694 }
648695 else throw("Strict value is not equal to itself.")
649696 }
650697
651698
652699
653700 @Callable(i)
654701 func confirmManager () = {
655702 let pm = pendingManagerPublicKeyOrUnit()
656703 let hasPM = if (isDefined(pm))
657704 then true
658705 else throw("No pending manager")
659706 if ((hasPM == hasPM))
660707 then {
661708 let checkPM = if ((i.callerPublicKey == value(pm)))
662709 then true
663710 else throw("You are not pending manager")
664711 if ((checkPM == checkPM))
665712 then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())]
666713 else throw("Strict value is not equal to itself.")
667714 }
668715 else throw("Strict value is not equal to itself.")
669716 }
670717
671718
672719
673720 @Callable(i)
674721 func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance))
675722 then throw("Invalid slippageTolerance passed")
676723 else {
677724 let estPut = commonPut(i, slippageTolerance, true)
678725 let emitLpAmt = estPut._2
679726 let lpAssetId = estPut._7
680727 let state = estPut._9
681728 let amDiff = estPut._10
682729 let prDiff = estPut._11
683730 let amId = estPut._12
684731 let prId = estPut._13
685- let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
686- if ((emitInv == emitInv))
732+ let amAssetPmt = toBigInt(value(i.payments[0]).amount)
733+ let prAssetPmt = toBigInt(value(i.payments[1]).amount)
734+ let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
735+ if ((currentKLp == currentKLp))
687736 then {
688- let emitInvLegacy = match emitInv {
689- case legacyFactoryContract: Address =>
690- invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
691- case _ =>
692- unit
693- }
694- if ((emitInvLegacy == emitInvLegacy))
737+ let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
738+ if ((emitInv == emitInv))
695739 then {
696- let slippageAInv = if ((amDiff > 0))
697- then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
698- else nil
699- if ((slippageAInv == slippageAInv))
740+ let emitInvLegacy = match emitInv {
741+ case legacyFactoryContract: Address =>
742+ invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
743+ case _ =>
744+ unit
745+ }
746+ if ((emitInvLegacy == emitInvLegacy))
700747 then {
701- let slippagePInv = if ((prDiff > 0))
702- then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
748+ let slippageAInv = if ((amDiff > 0))
749+ then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
703750 else nil
704- if ((slippagePInv == slippagePInv))
751+ if ((slippageAInv == slippageAInv))
705752 then {
706- let lpTransfer = if (shouldAutoStake)
753+ let slippagePInv = if ((prDiff > 0))
754+ then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
755+ else nil
756+ if ((slippagePInv == slippagePInv))
707757 then {
708- let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
709- if ((slpStakeInv == slpStakeInv))
710- then nil
758+ let lpTransfer = if (shouldAutoStake)
759+ then {
760+ let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
761+ if ((slpStakeInv == slpStakeInv))
762+ then nil
763+ else throw("Strict value is not equal to itself.")
764+ }
765+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
766+ let $t03387234334 = refreshKLpInternal(0, 0, 0)
767+ if (($t03387234334 == $t03387234334))
768+ then {
769+ let updatedKLp = $t03387234334._2
770+ let refreshKLpActions = $t03387234334._1
771+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
772+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
773+ then ((state ++ lpTransfer) ++ refreshKLpActions)
774+ else throw("Strict value is not equal to itself.")
775+ }
711776 else throw("Strict value is not equal to itself.")
712777 }
713- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
714- (state ++ lpTransfer)
778+ else throw("Strict value is not equal to itself.")
715779 }
716780 else throw("Strict value is not equal to itself.")
717781 }
718782 else throw("Strict value is not equal to itself.")
719783 }
720784 else throw("Strict value is not equal to itself.")
721785 }
722786 else throw("Strict value is not equal to itself.")
723787 }
724788
725789
726790
727791 @Callable(i)
728792 func putForFree (maxSlippage) = if ((0 > maxSlippage))
729793 then throw("Invalid value passed")
730794 else {
731795 let estPut = commonPut(i, maxSlippage, false)
732- estPut._9
796+ let state = estPut._9
797+ let amAssetPmt = toBigInt(value(i.payments[0]).amount)
798+ let prAssetPmt = toBigInt(value(i.payments[1]).amount)
799+ let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
800+ if ((currentKLp == currentKLp))
801+ then {
802+ let $t03489634961 = refreshKLpInternal(0, 0, 0)
803+ let refreshKLpActions = $t03489634961._1
804+ let updatedKLp = $t03489634961._2
805+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
806+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
807+ then (state ++ refreshKLpActions)
808+ else throw("Strict value is not equal to itself.")
809+ }
810+ else throw("Strict value is not equal to itself.")
733811 }
734812
735813
736814
737815 @Callable(i)
738816 func putOneTkn (minOutAmount,autoStake) = {
739817 let isPoolOneTokenOperationsDisabled = {
740818 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
741819 if ($isInstanceOf(@, "Boolean"))
742820 then @
743821 else throw(($getType(@) + " couldn't be cast to Boolean"))
744822 }
745823 let isPutDisabled = if (if (if (isGlobalShutdown())
746824 then true
747825 else (cfgPoolStatus == PoolPutDisabled))
748826 then true
749827 else (cfgPoolStatus == PoolShutdown))
750828 then true
751829 else isPoolOneTokenOperationsDisabled
752830 let checks = [if (if (!(isPutDisabled))
753831 then true
754832 else isManager(i))
755833 then true
756834 else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1))
757835 then true
758836 else throwErr("exactly 1 payment are expected")]
759837 if ((checks == checks))
760838 then {
761839 let payment = i.payments[0]
762840 let paymentAssetId = payment.assetId
763841 let paymentAmountRaw = payment.amount
764- let userAddress = i.caller
765- let txId = i.transactionId
766- let $t03172331853 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
767- if (($t03172331853 == $t03172331853))
842+ let currentKLp = if ((paymentAssetId == cfgAmountAssetId))
843+ then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0))
844+ else if ((paymentAssetId == cfgPriceAssetId))
845+ then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0))
846+ else throwErr("payment asset is not supported")
847+ if ((currentKLp == currentKLp))
768848 then {
769- let bonus = $t03172331853._4
770- let feeAmount = $t03172331853._3
771- let commonState = $t03172331853._2
772- let emitAmountEstimated = $t03172331853._1
773- let emitAmount = if (if ((minOutAmount > 0))
774- then (minOutAmount > emitAmountEstimated)
775- else false)
776- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
777- else emitAmountEstimated
778- let emitInv = emit(emitAmount)
779- if ((emitInv == emitInv))
849+ let userAddress = i.caller
850+ let txId = i.transactionId
851+ let $t03614936301 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
852+ if (($t03614936301 == $t03614936301))
780853 then {
781- let lpTransfer = if (autoStake)
854+ let paymentInAmountAsset = $t03614936301._5
855+ let bonus = $t03614936301._4
856+ let feeAmount = $t03614936301._3
857+ let commonState = $t03614936301._2
858+ let emitAmountEstimated = $t03614936301._1
859+ let emitAmount = if (if ((minOutAmount > 0))
860+ then (minOutAmount > emitAmountEstimated)
861+ else false)
862+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
863+ else emitAmountEstimated
864+ let emitInv = emit(emitAmount)
865+ if ((emitInv == emitInv))
782866 then {
783- let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
784- if ((stakeInv == stakeInv))
785- then nil
867+ let lpTransfer = if (autoStake)
868+ then {
869+ let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
870+ if ((stakeInv == stakeInv))
871+ then nil
872+ else throw("Strict value is not equal to itself.")
873+ }
874+ else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
875+ let sendFee = if ((feeAmount > 0))
876+ then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
877+ else nil
878+ let $t03688737084 = if ((this == feeCollectorAddress))
879+ then $Tuple2(0, 0)
880+ else if (paymentInAmountAsset)
881+ then $Tuple2(-(feeAmount), 0)
882+ else $Tuple2(0, -(feeAmount))
883+ let amountAssetBalanceDelta = $t03688737084._1
884+ let priceAssetBalanceDelta = $t03688737084._2
885+ let $t03708737195 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
886+ let refreshKLpActions = $t03708737195._1
887+ let updatedKLp = $t03708737195._2
888+ let kLp = value(getString(keyKLp))
889+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
890+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
891+ then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
786892 else throw("Strict value is not equal to itself.")
787893 }
788- else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
789- let sendFee = if ((feeAmount > 0))
790- then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
791- else nil
792- $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount)
894+ else throw("Strict value is not equal to itself.")
793895 }
794896 else throw("Strict value is not equal to itself.")
795897 }
796898 else throw("Strict value is not equal to itself.")
797899 }
798900 else throw("Strict value is not equal to itself.")
799901 }
800902
801903
802904
803905 @Callable(i)
804906 func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = {
805- let $t03258232717 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
806- let emitAmountEstimated = $t03258232717._1
807- let commonState = $t03258232717._2
808- let feeAmount = $t03258232717._3
809- let bonus = $t03258232717._4
907+ let $t03750137658 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
908+ let emitAmountEstimated = $t03750137658._1
909+ let commonState = $t03750137658._2
910+ let feeAmount = $t03750137658._3
911+ let bonus = $t03750137658._4
912+ let paymentInAmountAsset = $t03750137658._5
810913 $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
811914 }
812915
813916
814917
815918 @Callable(i)
816919 func getOneTkn (outAssetIdStr,minOutAmount) = {
817920 let isPoolOneTokenOperationsDisabled = {
818921 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
819922 if ($isInstanceOf(@, "Boolean"))
820923 then @
821924 else throw(($getType(@) + " couldn't be cast to Boolean"))
822925 }
823926 let isGetDisabled = if (if (isGlobalShutdown())
824927 then true
825928 else (cfgPoolStatus == PoolShutdown))
826929 then true
827930 else isPoolOneTokenOperationsDisabled
828931 let checks = [if (if (!(isGetDisabled))
829932 then true
830933 else isManager(i))
831934 then true
832935 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1))
833936 then true
834937 else throwErr("exactly 1 payment are expected")]
835938 if ((checks == checks))
836939 then {
837940 let outAssetId = parseAssetId(outAssetIdStr)
838941 let payment = i.payments[0]
839942 let paymentAssetId = payment.assetId
840943 let paymentAmount = payment.amount
841- let userAddress = i.caller
842- let txId = i.transactionId
843- let $t03352233657 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
844- if (($t03352233657 == $t03352233657))
944+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
945+ if ((currentKLp == currentKLp))
845946 then {
846- let bonus = $t03352233657._4
847- let feeAmount = $t03352233657._3
848- let commonState = $t03352233657._2
849- let amountEstimated = $t03352233657._1
850- let amount = if (if ((minOutAmount > 0))
851- then (minOutAmount > amountEstimated)
852- else false)
853- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
854- else amountEstimated
855- let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
856- if ((burnInv == burnInv))
947+ let userAddress = i.caller
948+ let txId = i.transactionId
949+ let $t03854338696 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
950+ if (($t03854338696 == $t03854338696))
857951 then {
858- let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
859- let sendFee = if ((feeAmount > 0))
860- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
861- else nil
862- $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
952+ let outInAmountAsset = $t03854338696._5
953+ let bonus = $t03854338696._4
954+ let feeAmount = $t03854338696._3
955+ let commonState = $t03854338696._2
956+ let amountEstimated = $t03854338696._1
957+ let amount = if (if ((minOutAmount > 0))
958+ then (minOutAmount > amountEstimated)
959+ else false)
960+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
961+ else amountEstimated
962+ let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
963+ if ((burnInv == burnInv))
964+ then {
965+ let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
966+ let sendFee = if ((feeAmount > 0))
967+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
968+ else nil
969+ let $t03919639443 = {
970+ let feeAmountForCalc = if ((this == feeCollectorAddress))
971+ then 0
972+ else feeAmount
973+ if (outInAmountAsset)
974+ then $Tuple2(-((amount + feeAmountForCalc)), 0)
975+ else $Tuple2(0, -((amount + feeAmountForCalc)))
976+ }
977+ let amountAssetBalanceDelta = $t03919639443._1
978+ let priceAssetBalanceDelta = $t03919639443._2
979+ let $t03944639554 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
980+ let refreshKLpActions = $t03944639554._1
981+ let updatedKLp = $t03944639554._2
982+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
983+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
984+ then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
985+ else throw("Strict value is not equal to itself.")
986+ }
987+ else throw("Strict value is not equal to itself.")
863988 }
864989 else throw("Strict value is not equal to itself.")
865990 }
866991 else throw("Strict value is not equal to itself.")
867992 }
868993 else throw("Strict value is not equal to itself.")
869994 }
870995
871996
872997
873998 @Callable(i)
874999 func getOneTknREADONLY (outAssetId,paymentAmount) = {
875- let $t03429234430 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
876- let amountEstimated = $t03429234430._1
877- let commonState = $t03429234430._2
878- let feeAmount = $t03429234430._3
879- let bonus = $t03429234430._4
1000+ let $t03981139967 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
1001+ let amountEstimated = $t03981139967._1
1002+ let commonState = $t03981139967._2
1003+ let feeAmount = $t03981139967._3
1004+ let bonus = $t03981139967._4
1005+ let outInAmountAsset = $t03981139967._5
8801006 $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
8811007 }
8821008
8831009
8841010
8851011 @Callable(i)
8861012 func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = {
8871013 let isPoolOneTokenOperationsDisabled = {
8881014 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
8891015 if ($isInstanceOf(@, "Boolean"))
8901016 then @
8911017 else throw(($getType(@) + " couldn't be cast to Boolean"))
8921018 }
8931019 let isGetDisabled = if (if (isGlobalShutdown())
8941020 then true
8951021 else (cfgPoolStatus == PoolShutdown))
8961022 then true
8971023 else isPoolOneTokenOperationsDisabled
8981024 let checks = [if (if (!(isGetDisabled))
8991025 then true
9001026 else isManager(i))
9011027 then true
9021028 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0))
9031029 then true
9041030 else throwErr("no payments are expected")]
9051031 if ((checks == checks))
9061032 then {
9071033 let outAssetId = parseAssetId(outAssetIdStr)
9081034 let userAddress = i.caller
9091035 let txId = i.transactionId
910- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
911- if ((unstakeInv == unstakeInv))
1036+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1037+ if ((currentKLp == currentKLp))
9121038 then {
913- let $t03525535388 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
914- if (($t03525535388 == $t03525535388))
1039+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1040+ if ((unstakeInv == unstakeInv))
9151041 then {
916- let bonus = $t03525535388._4
917- let feeAmount = $t03525535388._3
918- let commonState = $t03525535388._2
919- let amountEstimated = $t03525535388._1
920- let amount = if (if ((minOutAmount > 0))
921- then (minOutAmount > amountEstimated)
922- else false)
923- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
924- else amountEstimated
925- let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
926- if ((burnInv == burnInv))
1042+ let $t04087241023 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
1043+ if (($t04087241023 == $t04087241023))
9271044 then {
928- let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
929- let sendFee = if ((feeAmount > 0))
930- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
931- else nil
932- $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
1045+ let outInAmountAsset = $t04087241023._5
1046+ let bonus = $t04087241023._4
1047+ let feeAmount = $t04087241023._3
1048+ let commonState = $t04087241023._2
1049+ let amountEstimated = $t04087241023._1
1050+ let amount = if (if ((minOutAmount > 0))
1051+ then (minOutAmount > amountEstimated)
1052+ else false)
1053+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1054+ else amountEstimated
1055+ let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1056+ if ((burnInv == burnInv))
1057+ then {
1058+ let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
1059+ let sendFee = if ((feeAmount > 0))
1060+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
1061+ else nil
1062+ let $t04151841765 = {
1063+ let feeAmountForCalc = if ((this == feeCollectorAddress))
1064+ then 0
1065+ else feeAmount
1066+ if (outInAmountAsset)
1067+ then $Tuple2(-((amount + feeAmountForCalc)), 0)
1068+ else $Tuple2(0, -((amount + feeAmountForCalc)))
1069+ }
1070+ let amountAssetBalanceDelta = $t04151841765._1
1071+ let priceAssetBalanceDelta = $t04151841765._2
1072+ let $t04176841876 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1073+ let refreshKLpActions = $t04176841876._1
1074+ let updatedKLp = $t04176841876._2
1075+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1076+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1077+ then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1078+ else throw("Strict value is not equal to itself.")
1079+ }
1080+ else throw("Strict value is not equal to itself.")
9331081 }
9341082 else throw("Strict value is not equal to itself.")
9351083 }
9361084 else throw("Strict value is not equal to itself.")
9371085 }
9381086 else throw("Strict value is not equal to itself.")
9391087 }
9401088 else throw("Strict value is not equal to itself.")
9411089 }
9421090
9431091
9441092
9451093 @Callable(i)
9461094 func get () = {
9471095 let res = commonGet(i)
9481096 let outAmtAmt = res._1
9491097 let outPrAmt = res._2
9501098 let pmtAmt = res._3
9511099 let pmtAssetId = res._4
9521100 let state = res._5
953- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
954- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
955- then state
1101+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1102+ if ((currentKLp == currentKLp))
1103+ then {
1104+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1105+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1106+ then {
1107+ let $t04282242904 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1108+ let refreshKLpActions = $t04282242904._1
1109+ let updatedKLp = $t04282242904._2
1110+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1111+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1112+ then (state ++ refreshKLpActions)
1113+ else throw("Strict value is not equal to itself.")
1114+ }
1115+ else throw("Strict value is not equal to itself.")
1116+ }
9561117 else throw("Strict value is not equal to itself.")
9571118 }
9581119
9591120
9601121
9611122 @Callable(i)
9621123 func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = {
9631124 let res = commonGet(i)
9641125 let outAmAmt = res._1
9651126 let outPrAmt = res._2
9661127 let pmtAmt = res._3
9671128 let pmtAssetId = res._4
9681129 let state = res._5
9691130 if ((noLessThenAmtAsset > outAmAmt))
9701131 then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset)))
9711132 else if ((noLessThenPriceAsset > outPrAmt))
9721133 then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
9731134 else {
974- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
975- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
976- then state
1135+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1136+ if ((currentKLp == currentKLp))
1137+ then {
1138+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1139+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1140+ then {
1141+ let $t04385343934 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1142+ let refreshKLpActions = $t04385343934._1
1143+ let updatedKLp = $t04385343934._2
1144+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1145+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1146+ then (state ++ refreshKLpActions)
1147+ else throw("Strict value is not equal to itself.")
1148+ }
1149+ else throw("Strict value is not equal to itself.")
1150+ }
9771151 else throw("Strict value is not equal to itself.")
9781152 }
9791153 }
9801154
9811155
9821156
9831157 @Callable(i)
9841158 func unstakeAndGet (amount) = {
9851159 let checkPayments = if ((size(i.payments) != 0))
9861160 then throw("No payments are expected")
9871161 else true
9881162 if ((checkPayments == checkPayments))
9891163 then {
9901164 let cfg = getPoolConfig()
9911165 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
992- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
993- if ((unstakeInv == unstakeInv))
1166+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1167+ if ((currentKLp == currentKLp))
9941168 then {
995- let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
996- let poolStatus = parseIntValue(res._9)
997- let state = res._10
998- let checkPoolStatus = if (if (isGlobalShutdown())
999- then true
1000- else (poolStatus == PoolShutdown))
1001- then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
1002- else true
1003- if ((checkPoolStatus == checkPoolStatus))
1169+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
1170+ if ((unstakeInv == unstakeInv))
10041171 then {
1005- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1006- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1007- then state
1172+ let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1173+ let outAmAmt = res._1
1174+ let outPrAmt = res._2
1175+ let poolStatus = parseIntValue(res._9)
1176+ let state = res._10
1177+ let checkPoolStatus = if (if (isGlobalShutdown())
1178+ then true
1179+ else (poolStatus == PoolShutdown))
1180+ then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
1181+ else true
1182+ if ((checkPoolStatus == checkPoolStatus))
1183+ then {
1184+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1185+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1186+ then {
1187+ let $t04506045141 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1188+ let refreshKLpActions = $t04506045141._1
1189+ let updatedKLp = $t04506045141._2
1190+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1191+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1192+ then (state ++ refreshKLpActions)
1193+ else throw("Strict value is not equal to itself.")
1194+ }
1195+ else throw("Strict value is not equal to itself.")
1196+ }
10081197 else throw("Strict value is not equal to itself.")
10091198 }
10101199 else throw("Strict value is not equal to itself.")
10111200 }
10121201 else throw("Strict value is not equal to itself.")
10131202 }
10141203 else throw("Strict value is not equal to itself.")
10151204 }
10161205
10171206
10181207
10191208 @Callable(i)
10201209 func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = {
10211210 let isGetDisabled = if (isGlobalShutdown())
10221211 then true
10231212 else (cfgPoolStatus == PoolShutdown)
10241213 let checks = [if (!(isGetDisabled))
10251214 then true
10261215 else throw("get operation is blocked by admin"), if ((size(i.payments) == 0))
10271216 then true
10281217 else throw("no payments are expected")]
10291218 if ((checks == checks))
10301219 then {
1031- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1032- if ((unstakeInv == unstakeInv))
1220+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1221+ if ((currentKLp == currentKLp))
10331222 then {
1034- let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1035- let outAmAmt = res._1
1036- let outPrAmt = res._2
1037- let state = res._10
1038- let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1039- then true
1040- else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1041- then true
1042- else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1043- if ((checkAmounts == checkAmounts))
1223+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1224+ if ((unstakeInv == unstakeInv))
10441225 then {
1045- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1046- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1047- then state
1226+ let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1227+ let outAmAmt = res._1
1228+ let outPrAmt = res._2
1229+ let state = res._10
1230+ let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1231+ then true
1232+ else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1233+ then true
1234+ else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1235+ if ((checkAmounts == checkAmounts))
1236+ then {
1237+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1238+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1239+ then {
1240+ let $t04643646517 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1241+ let refreshKLpActions = $t04643646517._1
1242+ let updatedKLp = $t04643646517._2
1243+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1244+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1245+ then (state ++ refreshKLpActions)
1246+ else throw("Strict value is not equal to itself.")
1247+ }
1248+ else throw("Strict value is not equal to itself.")
1249+ }
10481250 else throw("Strict value is not equal to itself.")
10491251 }
10501252 else throw("Strict value is not equal to itself.")
10511253 }
10521254 else throw("Strict value is not equal to itself.")
10531255 }
10541256 else throw("Strict value is not equal to itself.")
10551257 }
10561258
10571259
10581260
10591261 @Callable(i)
10601262 func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
10611263 then throw("permissions denied")
10621264 else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success")
1265+
1266+
1267+
1268+@Callable(i)
1269+func refreshKLp () = {
1270+ let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0)
1271+ let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay))
1272+ then unit
1273+ else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1274+ if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1275+ then {
1276+ let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp"))
1277+ let $t04770447768 = refreshKLpInternal(0, 0, 0)
1278+ let kLpUpdateActions = $t04770447768._1
1279+ let updatedKLp = $t04770447768._2
1280+ let actions = if ((kLp != updatedKLp))
1281+ then kLpUpdateActions
1282+ else throwErr("nothing to refresh")
1283+ $Tuple2(actions, toString(updatedKLp))
1284+ }
1285+ else throw("Strict value is not equal to itself.")
1286+ }
10631287
10641288
10651289
10661290 @Callable(i)
10671291 func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig())
10681292
10691293
10701294
10711295 @Callable(i)
10721296 func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId))
10731297
10741298
10751299
10761300 @Callable(i)
10771301 func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = {
10781302 let prices = calcPrices(amAmt, prAmt, lpAmt)
10791303 $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])])
10801304 }
10811305
10821306
10831307
10841308 @Callable(i)
10851309 func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult)))
10861310
10871311
10881312
10891313 @Callable(i)
10901314 func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult))
10911315
10921316
10931317
10941318 @Callable(i)
10951319 func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18))))
10961320
10971321
10981322
10991323 @Callable(i)
11001324 func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp))
11011325
11021326
11031327
11041328 @Callable(i)
11051329 func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
11061330 let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress))
11071331 $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10))
11081332 }
11091333
11101334
11111335
11121336 @Callable(i)
11131337 func statsREADONLY () = {
11141338 let cfg = getPoolConfig()
11151339 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
11161340 let amtAssetId = cfg[idxAmtAssetId]
11171341 let priceAssetId = cfg[idxPriceAssetId]
11181342 let iAmtAssetId = cfg[idxIAmtAssetId]
11191343 let iPriceAssetId = cfg[idxIPriceAssetId]
11201344 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
11211345 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
11221346 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
11231347 let accAmtAssetBalance = getAccBalance(amtAssetId)
11241348 let accPriceAssetBalance = getAccBalance(priceAssetId)
11251349 let pricesList = if ((poolLPBalance == 0))
11261350 then [zeroBigInt, zeroBigInt, zeroBigInt]
11271351 else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance)
11281352 let curPrice = 0
11291353 let lpAmtAssetShare = fromX18(pricesList[1], scale8)
11301354 let lpPriceAssetShare = fromX18(pricesList[2], scale8)
11311355 let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this))))
11321356 $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))
11331357 }
11341358
11351359
11361360
11371361 @Callable(i)
11381362 func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = {
11391363 let cfg = getPoolConfig()
11401364 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
11411365 let amAssetIdStr = cfg[idxAmtAssetId]
11421366 let amAssetId = fromBase58String(amAssetIdStr)
11431367 let prAssetIdStr = cfg[idxPriceAssetId]
11441368 let prAssetId = fromBase58String(prAssetIdStr)
11451369 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
11461370 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
11471371 let poolStatus = cfg[idxPoolStatus]
11481372 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
11491373 let accAmtAssetBalance = getAccBalance(amAssetIdStr)
11501374 let accPriceAssetBalance = getAccBalance(prAssetIdStr)
11511375 let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm)
11521376 let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm)
11531377 let curPriceX18 = if ((poolLPBalance == 0))
11541378 then zeroBigInt
11551379 else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18)
11561380 let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm)
11571381 let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
11581382 let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm)
11591383 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
11601384 let calcLpAmt = estPut._1
11611385 let curPriceCalc = estPut._3
11621386 let amBalance = estPut._4
11631387 let prBalance = estPut._5
11641388 let lpEmission = estPut._6
11651389 $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))
11661390 }
11671391
11681392
11691393
11701394 @Callable(i)
11711395 func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = {
11721396 let cfg = getPoolConfig()
11731397 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
11741398 let amAssetIdStr = cfg[idxAmtAssetId]
11751399 let amAssetId = fromBase58String(amAssetIdStr)
11761400 let prAssetIdStr = cfg[idxPriceAssetId]
11771401 let prAssetId = fromBase58String(prAssetIdStr)
11781402 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
11791403 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
11801404 let poolStatus = cfg[idxPoolStatus]
11811405 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
11821406 let amBalanceRaw = getAccBalance(amAssetIdStr)
11831407 let prBalanceRaw = getAccBalance(prAssetIdStr)
11841408 let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm)
11851409 let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm)
11861410 let curPriceX18 = if ((poolLPBalance == 0))
11871411 then zeroBigInt
11881412 else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18)
11891413 let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm)
11901414 let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
11911415 let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm)
11921416 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
11931417 let calcLpAmt = estPut._1
11941418 let curPriceCalc = estPut._3
11951419 let amBalance = estPut._4
11961420 let prBalance = estPut._5
11971421 let lpEmission = estPut._6
11981422 $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))
11991423 }
12001424
12011425
12021426
12031427 @Callable(i)
12041428 func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = {
12051429 let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this)
12061430 let outAmAmt = res._1
12071431 let outPrAmt = res._2
12081432 let amBalance = res._5
12091433 let prBalance = res._6
12101434 let lpEmission = res._7
12111435 let curPrice = res._8
12121436 let poolStatus = parseIntValue(res._9)
12131437 $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))
12141438 }
12151439
12161440
12171441 @Verifier(tx)
12181442 func verify () = {
12191443 let targetPublicKey = match managerPublicKeyOrUnit() {
12201444 case pk: ByteVector =>
12211445 pk
12221446 case _: Unit =>
12231447 tx.senderPublicKey
12241448 case _ =>
12251449 throw("Match error")
12261450 }
12271451 match tx {
12281452 case order: Order =>
12291453 let matcherPub = getMatcherPubOrFail()
12301454 let orderValid = validateMatcherOrderAllowed(order)
12311455 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
12321456 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
12331457 if (if (if (orderValid)
12341458 then senderValid
12351459 else false)
12361460 then matcherValid
12371461 else false)
12381462 then true
12391463 else throwOrderError(orderValid, senderValid, matcherValid)
12401464 case s: SetScriptTransaction =>
12411465 let newHash = blake2b256(value(s.script))
12421466 let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash())))
12431467 let currentHash = scriptHash(this)
12441468 if (if ((allowedHash == newHash))
12451469 then (currentHash != newHash)
12461470 else false)
12471471 then true
12481472 else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
12491473 case _ =>
12501474 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
12511475 }
12521476 }
12531477

github/deemru/w8io/026f985 
255.30 ms