tx · G6t7Kp8ZqGR27kre9Vtvq83NXicH2cNZwba145JdmU6D

3N1qXc8SizCcasbC4E68twgv1UiWRPdSoGT:  -0.03600000 Waves

2023.01.19 18:15 [2411977] smart account 3N1qXc8SizCcasbC4E68twgv1UiWRPdSoGT > SELF 0.00000000 Waves

{ "type": 13, "id": "G6t7Kp8ZqGR27kre9Vtvq83NXicH2cNZwba145JdmU6D", "fee": 3600000, "feeAssetId": null, "timestamp": 1674141334836, "version": 1, "sender": "3N1qXc8SizCcasbC4E68twgv1UiWRPdSoGT", "senderPublicKey": "3gBPsWafK5yQ4fHf18MkK7VWgr5ziYBv8YkEjnRJCiAw", "proofs": [ "nATXX79GxbrEpQW7Dx1J5dqM5tUYTeYLwhe75VAWiwp3bhvdE8epKEJrEPma4VGAHiCGrMo9M4nRFkXRTTJRqMo" ], "script": "base64:BgLcLQgCEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgQKAggBEgQKAggBEgQKAggBEgUKAwEIARIAEgQKAgEBEgMKAQESBQoDAQEBEgQKAggIEgASABIDCgEIEgUKAwEBARIECgIBARIECgIIARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCBIAEgMKAQESAwoBARIECgIIASIKbFBkZWNpbWFscyIGc2NhbGU4IgxzY2FsZThCaWdJbnQiB3NjYWxlMTgiCnplcm9CaWdJbnQiBGJpZzAiBGJpZzEiBGJpZzIiC3dhdmVzU3RyaW5nIgNTRVAiClBvb2xBY3RpdmUiD1Bvb2xQdXREaXNhYmxlZCITUG9vbE1hdGNoZXJEaXNhYmxlZCIMUG9vbFNodXRkb3duIg5pZHhQb29sQWRkcmVzcyINaWR4UG9vbFN0YXR1cyIQaWR4UG9vbExQQXNzZXRJZCINaWR4QW10QXNzZXRJZCIPaWR4UHJpY2VBc3NldElkIg5pZHhBbXRBc3NldERjbSIQaWR4UHJpY2VBc3NldERjbSIOaWR4SUFtdEFzc2V0SWQiEGlkeElQcmljZUFzc2V0SWQiDWlkeExQQXNzZXREY20iEm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NsCQDMCAIJAKQDAQUCY2kJAMwIAgkApgMBBQJjbwkAzAgCCQCkAwEFAmNoBQNuaWwFAWoBAmdHAQJnSAAEAmdJBAJkVAkBAmVXAAMJAAECBQJkVAIKQnl0ZVZlY3RvcgQCZmEFAmRUBQJmYQMJAAECBQJkVAIEVW5pdAgFAmdHD3NlbmRlclB1YmxpY0tleQkAAgECC01hdGNoIGVycm9yBAJkVAUCZ0cDCQABAgUCZFQCBU9yZGVyBAJkeQUCZFQEAmdKCQECYVMABAJhQwkBAmR4AQUCZHkEAmFECQD0AwMIBQJkeQlib2R5Qnl0ZXMJAJEDAggFAmR5BnByb29mcwAACAUCZHkPc2VuZGVyUHVibGljS2V5BAJhRQkA9AMDCAUCZHkJYm9keUJ5dGVzCQCRAwIIBQJkeQZwcm9vZnMAAQUCZ0oDAwMFAmFDBQJhRAcFAmFFBwYJAQJhQgMFAmFDBQJhRAUCYUUDCQABAgUCZFQCFFNldFNjcmlwdFRyYW5zYWN0aW9uBAJlWAUCZFQEAmdLCQD2AwEJAQV2YWx1ZQEIBQJlWAZzY3JpcHQEAmdMCQDbBAEJAQV2YWx1ZQEJAJ0IAgUCYU0JAQJhegAEAmdNCQDxBwEFBHRoaXMDAwkAAAIFAmdMBQJnSwkBAiE9AgUCZ00FAmdLBwYJAPQDAwgFAmdHCWJvZHlCeXRlcwkAkQMCCAUCZ0cGcHJvb2ZzAAAFAmdJCQD0AwMIBQJnRwlib2R5Qnl0ZXMJAJEDAggFAmdHBnByb29mcwAABQJnSYeWoQs=", "chainId": 84, "height": 2411977, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 89NQ7AYhUZcEZaNHSZJaCUCT59AxHp8g8HqP1ybBRqmR Next: none Diff:
OldNewDifferences
6262 func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult))
6363
6464
65+func toX18BigInt (origVal,origScaleMult) = fraction(origVal, scale18, origScaleMult)
66+
67+
6568 func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18))
69+
70+
71+func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round))
6672
6773
6874 func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale)
105111 func pa () = "%s__priceAsset"
106112
107113
114+let keyFee = "%s__fee"
115+
116+let feeDefault = fraction(10, scale8, 10000)
117+
118+let fee = valueOrElse(getInteger(this, keyFee), feeDefault)
119+
120+let keyKLp = makeString(["%s", "kLp"], SEP)
121+
122+let keyKLpRefreshedHeight = makeString(["%s", "kLpRefreshedHeight"], SEP)
123+
124+let keyKLpRefreshDelay = makeString(["%s", "refreshKLpDelay"], SEP)
125+
126+let kLpRefreshDelayDefault = 30
127+
128+let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault)
129+
108130 func keyFactoryConfig () = "%s__factoryConfig"
109131
110132
141163
142164
143165 func throwErr (msg) = throw(makeString(["lp.ride:", msg], " "))
166+
167+
168+func fmtErr (msg) = makeString(["lp.ride:", msg], " ")
144169
145170
146171 let factoryContract = addressFromStringValue(getStringOrFail(this, fc()))
191216
192217 let poolConfigParsed = parsePoolConfig(getPoolConfig())
193218
194-let $t076017767 = poolConfigParsed
219+let $t083448510 = poolConfigParsed
195220
196-let cfgPoolAddress = $t076017767._1
221+let cfgPoolAddress = $t083448510._1
197222
198-let cfgPoolStatus = $t076017767._2
223+let cfgPoolStatus = $t083448510._2
199224
200-let cfgLpAssetId = $t076017767._3
225+let cfgLpAssetId = $t083448510._3
201226
202-let cfgAmountAssetId = $t076017767._4
227+let cfgAmountAssetId = $t083448510._4
203228
204-let cfgPriceAssetId = $t076017767._5
229+let cfgPriceAssetId = $t083448510._5
205230
206-let cfgAmountAssetDecimals = $t076017767._6
231+let cfgAmountAssetDecimals = $t083448510._6
207232
208-let cfgPriceAssetDecimals = $t076017767._7
233+let cfgPriceAssetDecimals = $t083448510._7
209234
210235 func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
211236
226251
227252
228253 func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
254+
255+
256+func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
229257
230258
231259 func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
277305 let lpEmissionX18 = toX18(lpEmission, scale8)
278306 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18)
279307 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18)
280- let outAmAmt = fromX18(outAmAmtX18, amAssetDcm)
281- let outPrAmt = fromX18(outPrAmtX18, prAssetDcm)
308+ let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR)
309+ let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR)
282310 let state = if ((txId58 == ""))
283311 then nil
284312 else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES"))
337365 then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18)))
338366 else {
339367 let lpEmissionX18 = toX18(lpEmission, scale8)
340- let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
341- let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
368+ let prViaAmX18 = fraction(inAmAssetAmtX18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING)
369+ let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, FLOOR), CEILING)
342370 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
343371 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
344372 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
345373 let expAmtAssetAmtX18 = expectedAmts._1
346374 let expPriceAssetAmtX18 = expectedAmts._2
347- let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
348- $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18)
375+ let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR)
376+ $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtAssetDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceAssetDcm, CEILING), curPriceX18, slippageX18)
349377 }
350378 }
351379 let calcLpAmt = res._1
368396 }
369397
370398
399+func calcKLp (amountBalance,priceBalance,lpEmission) = {
400+ let amountBalanceX18 = toX18BigInt(amountBalance, toBigInt(cfgAmountAssetDecimals))
401+ let priceBalanceX18 = toX18BigInt(priceBalance, toBigInt(cfgPriceAssetDecimals))
402+ let updatedKLp = fraction(pow((amountBalanceX18 * priceBalanceX18), 0, toBigInt(5), 1, 18, DOWN), big1, lpEmission)
403+ if ((lpEmission == big0))
404+ then big0
405+ else updatedKLp
406+ }
407+
408+
409+func calcCurrentKLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = {
410+ let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta)
411+ let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta)
412+ let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta)
413+ let currentKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpAssetEmission)
414+ currentKLp
415+ }
416+
417+
418+func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = {
419+ let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta)
420+ let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta)
421+ let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta)
422+ let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission))
423+ let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))]
424+ $Tuple2(actions, updatedKLp)
425+ }
426+
427+
428+func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp))
429+ then true
430+ else throwErr(makeString(["updated KLp lower than current KLp", toString(oldKLp), toString(updatedKLp)], " "))
431+
432+
371433 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)
434+ let amountAssetAmount = order.amount
435+ let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR)
436+ let $t02126221474 = if ((order.orderType == Buy))
437+ then $Tuple2(amountAssetAmount, -(priceAssetAmount))
438+ else $Tuple2(-(amountAssetAmount), priceAssetAmount)
439+ let amountAssetBalanceDelta = $t02126221474._1
440+ let priceAssetBalanceDelta = $t02126221474._2
384441 if (if (if (isGlobalShutdown())
385442 then true
386- else (poolStatus == PoolMatcherDisabled))
443+ else (cfgPoolStatus == PoolMatcherDisabled))
387444 then true
388- else (poolStatus == PoolShutdown))
445+ else (cfgPoolStatus == PoolShutdown))
389446 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- }
447+ else if (if ((order.assetPair.amountAsset != cfgAmountAssetId))
448+ then true
449+ else (order.assetPair.priceAsset != cfgPriceAssetId))
450+ then throw("Wrong order assets.")
451+ else {
452+ let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp"))
453+ let $t02194522045 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
454+ let unusedActions = $t02194522045._1
455+ let kLpNew = $t02194522045._2
456+ let isOrderValid = (kLpNew >= kLp)
457+ isOrderValid
458+ }
413459 }
414460
415461
484530 else if ((paymentAssetId == cfgPriceAssetId))
485531 then false
486532 else throwErr("invalid asset")
487- let $t02266422957 = if (isEval)
533+ let $t02476625059 = if (isEval)
488534 then $Tuple2(amountBalanceRaw, priceBalanceRaw)
489535 else if (paymentInAmountAsset)
490536 then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw)
491537 else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw))
492- let amountBalanceOld = $t02266422957._1
493- let priceBalanceOld = $t02266422957._2
494- let $t02296123110 = if (paymentInAmountAsset)
538+ let amountBalanceOld = $t02476625059._1
539+ let priceBalanceOld = $t02476625059._2
540+ let $t02506325212 = if (paymentInAmountAsset)
495541 then $Tuple2(paymentAmountRaw, 0)
496542 else $Tuple2(0, paymentAmountRaw)
497- let amountAssetAmountRaw = $t02296123110._1
498- let priceAssetAmountRaw = $t02296123110._2
543+ let amountAssetAmountRaw = $t02506325212._1
544+ let priceAssetAmountRaw = $t02506325212._2
499545 let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1
500546 let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1
501- let $t02324223306 = takeFee(paymentAmountRaw, inFee)
502- let paymentAmount = $t02324223306._1
503- let feeAmount = $t02324223306._2
547+ let $t02534425408 = takeFee(paymentAmountRaw, inFee)
548+ let paymentAmount = $t02534425408._1
549+ let feeAmount = $t02534425408._2
504550 let amountBalanceNew = (amountBalanceOld + amountAssetAmount)
505551 let priceBalanceNew = (priceBalanceOld + priceAssetAmount)
506552 let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals))
523569 let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals))
524570 let priceOld = fromX18(priceOldX18, scale8)
525571 let loss = {
526- let $t02478324950 = if (paymentInAmountAsset)
572+ let $t02708927256 = if (paymentInAmountAsset)
527573 then $Tuple2(amountAssetAmountRaw, amountBalanceOld)
528574 else $Tuple2(priceAssetAmountRaw, priceBalanceOld)
529- let amount = $t02478324950._1
530- let balance = $t02478324950._2
575+ let amount = $t02708927256._1
576+ let balance = $t02708927256._2
531577 let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance)))
532578 fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth)
533579 }
534- $Tuple4(issueAmount, commonState, feeAmount, loss)
580+ $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset)
535581 }
536582 else throw("Strict value is not equal to itself.")
537583 }
539585
540586 func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = {
541587 let isEval = (txId == unit)
588+ let cfg = getPoolConfig()
589+ let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
590+ let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
542591 let checks = [if ((paymentAssetId == cfgLpAssetId))
543592 then true
544593 else throwErr("invalid lp asset")]
552601 let balanceBigInt = if (outInAmountAsset)
553602 then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId)))
554603 else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId)))
604+ let outInAmountAssetDecimals = if (outInAmountAsset)
605+ then amtAssetDcm
606+ else priceAssetDcm
555607 let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId))
556608 let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId))
557609 let outBalance = if (outInAmountAsset)
561613 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
562614 let redeemedBigInt = toBigInt(paymentAmount)
563615 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)
616+ let $t02933429390 = takeFee(amountRaw, outFee)
617+ let totalAmount = $t02933429390._1
618+ let feeAmount = $t02933429390._2
619+ let $t02939429620 = if (outInAmountAsset)
568620 then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
569621 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
622+ let outAmAmount = $t02939429620._1
623+ let outPrAmount = $t02939429620._2
624+ let amBalanceNew = $t02939429620._3
625+ let prBalanceNew = $t02939429620._4
574626 let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
575627 let priceNew = fromX18(priceNewX18, scale8)
576628 let commonState = if (isEval)
582634 let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2)
583635 fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset)
584636 }
585- $Tuple4(totalAmount, commonState, feeAmount, loss)
637+ $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset)
586638 }
587639 else throw("Strict value is not equal to itself.")
588640 }
682734 let prDiff = estPut._11
683735 let amId = estPut._12
684736 let prId = estPut._13
685- let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
686- if ((emitInv == emitInv))
737+ let amAssetPmt = toBigInt(value(i.payments[0]).amount)
738+ let prAssetPmt = toBigInt(value(i.payments[1]).amount)
739+ let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
740+ if ((currentKLp == currentKLp))
687741 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))
742+ let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
743+ if ((emitInv == emitInv))
695744 then {
696- let slippageAInv = if ((amDiff > 0))
697- then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
698- else nil
699- if ((slippageAInv == slippageAInv))
745+ let emitInvLegacy = match emitInv {
746+ case legacyFactoryContract: Address =>
747+ invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
748+ case _ =>
749+ unit
750+ }
751+ if ((emitInvLegacy == emitInvLegacy))
700752 then {
701- let slippagePInv = if ((prDiff > 0))
702- then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
753+ let slippageAInv = if ((amDiff > 0))
754+ then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
703755 else nil
704- if ((slippagePInv == slippagePInv))
756+ if ((slippageAInv == slippageAInv))
705757 then {
706- let lpTransfer = if (shouldAutoStake)
758+ let slippagePInv = if ((prDiff > 0))
759+ then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
760+ else nil
761+ if ((slippagePInv == slippagePInv))
707762 then {
708- let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
709- if ((slpStakeInv == slpStakeInv))
710- then nil
763+ let lpTransfer = if (shouldAutoStake)
764+ then {
765+ let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
766+ if ((slpStakeInv == slpStakeInv))
767+ then nil
768+ else throw("Strict value is not equal to itself.")
769+ }
770+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
771+ let $t03414834610 = refreshKLpInternal(0, 0, 0)
772+ if (($t03414834610 == $t03414834610))
773+ then {
774+ let updatedKLp = $t03414834610._2
775+ let refreshKLpActions = $t03414834610._1
776+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
777+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
778+ then ((state ++ lpTransfer) ++ refreshKLpActions)
779+ else throw("Strict value is not equal to itself.")
780+ }
711781 else throw("Strict value is not equal to itself.")
712782 }
713- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
714- (state ++ lpTransfer)
783+ else throw("Strict value is not equal to itself.")
715784 }
716785 else throw("Strict value is not equal to itself.")
717786 }
729798 then throw("Invalid value passed")
730799 else {
731800 let estPut = commonPut(i, maxSlippage, false)
732- estPut._9
801+ let state = estPut._9
802+ let amAssetPmt = toBigInt(value(i.payments[0]).amount)
803+ let prAssetPmt = toBigInt(value(i.payments[1]).amount)
804+ let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
805+ if ((currentKLp == currentKLp))
806+ then {
807+ let $t03517235237 = refreshKLpInternal(0, 0, 0)
808+ let refreshKLpActions = $t03517235237._1
809+ let updatedKLp = $t03517235237._2
810+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
811+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
812+ then (state ++ refreshKLpActions)
813+ else throw("Strict value is not equal to itself.")
814+ }
815+ else throw("Strict value is not equal to itself.")
733816 }
734817
735818
761844 let payment = i.payments[0]
762845 let paymentAssetId = payment.assetId
763846 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))
847+ let currentKLp = if ((paymentAssetId == cfgAmountAssetId))
848+ then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0))
849+ else if ((paymentAssetId == cfgPriceAssetId))
850+ then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0))
851+ else throwErr("payment asset is not supported")
852+ if ((currentKLp == currentKLp))
768853 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))
854+ let userAddress = i.caller
855+ let txId = i.transactionId
856+ let $t03642536577 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
857+ if (($t03642536577 == $t03642536577))
780858 then {
781- let lpTransfer = if (autoStake)
859+ let paymentInAmountAsset = $t03642536577._5
860+ let bonus = $t03642536577._4
861+ let feeAmount = $t03642536577._3
862+ let commonState = $t03642536577._2
863+ let emitAmountEstimated = $t03642536577._1
864+ let emitAmount = if (if ((minOutAmount > 0))
865+ then (minOutAmount > emitAmountEstimated)
866+ else false)
867+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
868+ else emitAmountEstimated
869+ let emitInv = emit(emitAmount)
870+ if ((emitInv == emitInv))
782871 then {
783- let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
784- if ((stakeInv == stakeInv))
785- then nil
872+ let lpTransfer = if (autoStake)
873+ then {
874+ let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
875+ if ((stakeInv == stakeInv))
876+ then nil
877+ else throw("Strict value is not equal to itself.")
878+ }
879+ else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
880+ let sendFee = if ((feeAmount > 0))
881+ then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
882+ else nil
883+ let $t03716337360 = if ((this == feeCollectorAddress))
884+ then $Tuple2(0, 0)
885+ else if (paymentInAmountAsset)
886+ then $Tuple2(-(feeAmount), 0)
887+ else $Tuple2(0, -(feeAmount))
888+ let amountAssetBalanceDelta = $t03716337360._1
889+ let priceAssetBalanceDelta = $t03716337360._2
890+ let $t03736337471 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
891+ let refreshKLpActions = $t03736337471._1
892+ let updatedKLp = $t03736337471._2
893+ let kLp = value(getString(keyKLp))
894+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
895+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
896+ then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
786897 else throw("Strict value is not equal to itself.")
787898 }
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)
899+ else throw("Strict value is not equal to itself.")
793900 }
794901 else throw("Strict value is not equal to itself.")
795902 }
802909
803910 @Callable(i)
804911 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
912+ let $t03777737934 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
913+ let emitAmountEstimated = $t03777737934._1
914+ let commonState = $t03777737934._2
915+ let feeAmount = $t03777737934._3
916+ let bonus = $t03777737934._4
917+ let paymentInAmountAsset = $t03777737934._5
810918 $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
811919 }
812920
838946 let payment = i.payments[0]
839947 let paymentAssetId = payment.assetId
840948 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))
949+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
950+ if ((currentKLp == currentKLp))
845951 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))
952+ let userAddress = i.caller
953+ let txId = i.transactionId
954+ let $t03881938972 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
955+ if (($t03881938972 == $t03881938972))
857956 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)
957+ let outInAmountAsset = $t03881938972._5
958+ let bonus = $t03881938972._4
959+ let feeAmount = $t03881938972._3
960+ let commonState = $t03881938972._2
961+ let amountEstimated = $t03881938972._1
962+ let amount = if (if ((minOutAmount > 0))
963+ then (minOutAmount > amountEstimated)
964+ else false)
965+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
966+ else amountEstimated
967+ let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
968+ if ((burnInv == burnInv))
969+ then {
970+ let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
971+ let sendFee = if ((feeAmount > 0))
972+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
973+ else nil
974+ let $t03947239719 = {
975+ let feeAmountForCalc = if ((this == feeCollectorAddress))
976+ then 0
977+ else feeAmount
978+ if (outInAmountAsset)
979+ then $Tuple2(-((amount + feeAmountForCalc)), 0)
980+ else $Tuple2(0, -((amount + feeAmountForCalc)))
981+ }
982+ let amountAssetBalanceDelta = $t03947239719._1
983+ let priceAssetBalanceDelta = $t03947239719._2
984+ let $t03972239830 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
985+ let refreshKLpActions = $t03972239830._1
986+ let updatedKLp = $t03972239830._2
987+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
988+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
989+ then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
990+ else throw("Strict value is not equal to itself.")
991+ }
992+ else throw("Strict value is not equal to itself.")
863993 }
864994 else throw("Strict value is not equal to itself.")
865995 }
8721002
8731003 @Callable(i)
8741004 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
1005+ let $t04008740243 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
1006+ let amountEstimated = $t04008740243._1
1007+ let commonState = $t04008740243._2
1008+ let feeAmount = $t04008740243._3
1009+ let bonus = $t04008740243._4
1010+ let outInAmountAsset = $t04008740243._5
8801011 $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
8811012 }
8821013
9071038 let outAssetId = parseAssetId(outAssetIdStr)
9081039 let userAddress = i.caller
9091040 let txId = i.transactionId
910- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
911- if ((unstakeInv == unstakeInv))
1041+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1042+ if ((currentKLp == currentKLp))
9121043 then {
913- let $t03525535388 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
914- if (($t03525535388 == $t03525535388))
1044+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1045+ if ((unstakeInv == unstakeInv))
9151046 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))
1047+ let $t04114841299 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
1048+ if (($t04114841299 == $t04114841299))
9271049 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)
1050+ let outInAmountAsset = $t04114841299._5
1051+ let bonus = $t04114841299._4
1052+ let feeAmount = $t04114841299._3
1053+ let commonState = $t04114841299._2
1054+ let amountEstimated = $t04114841299._1
1055+ let amount = if (if ((minOutAmount > 0))
1056+ then (minOutAmount > amountEstimated)
1057+ else false)
1058+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1059+ else amountEstimated
1060+ let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1061+ if ((burnInv == burnInv))
1062+ then {
1063+ let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
1064+ let sendFee = if ((feeAmount > 0))
1065+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
1066+ else nil
1067+ let $t04179442041 = {
1068+ let feeAmountForCalc = if ((this == feeCollectorAddress))
1069+ then 0
1070+ else feeAmount
1071+ if (outInAmountAsset)
1072+ then $Tuple2(-((amount + feeAmountForCalc)), 0)
1073+ else $Tuple2(0, -((amount + feeAmountForCalc)))
1074+ }
1075+ let amountAssetBalanceDelta = $t04179442041._1
1076+ let priceAssetBalanceDelta = $t04179442041._2
1077+ let $t04204442152 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1078+ let refreshKLpActions = $t04204442152._1
1079+ let updatedKLp = $t04204442152._2
1080+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1081+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1082+ then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1083+ else throw("Strict value is not equal to itself.")
1084+ }
1085+ else throw("Strict value is not equal to itself.")
9331086 }
9341087 else throw("Strict value is not equal to itself.")
9351088 }
9501103 let pmtAmt = res._3
9511104 let pmtAssetId = res._4
9521105 let state = res._5
953- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
954- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
955- then state
1106+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1107+ if ((currentKLp == currentKLp))
1108+ then {
1109+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1110+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1111+ then {
1112+ let $t04309843180 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1113+ let refreshKLpActions = $t04309843180._1
1114+ let updatedKLp = $t04309843180._2
1115+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1116+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1117+ then (state ++ refreshKLpActions)
1118+ else throw("Strict value is not equal to itself.")
1119+ }
1120+ else throw("Strict value is not equal to itself.")
1121+ }
9561122 else throw("Strict value is not equal to itself.")
9571123 }
9581124
9711137 else if ((noLessThenPriceAsset > outPrAmt))
9721138 then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
9731139 else {
974- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
975- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
976- then state
1140+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1141+ if ((currentKLp == currentKLp))
1142+ then {
1143+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1144+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1145+ then {
1146+ let $t04412944210 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1147+ let refreshKLpActions = $t04412944210._1
1148+ let updatedKLp = $t04412944210._2
1149+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1150+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1151+ then (state ++ refreshKLpActions)
1152+ else throw("Strict value is not equal to itself.")
1153+ }
1154+ else throw("Strict value is not equal to itself.")
1155+ }
9771156 else throw("Strict value is not equal to itself.")
9781157 }
9791158 }
9891168 then {
9901169 let cfg = getPoolConfig()
9911170 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
992- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
993- if ((unstakeInv == unstakeInv))
1171+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1172+ if ((currentKLp == currentKLp))
9941173 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))
1174+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
1175+ if ((unstakeInv == unstakeInv))
10041176 then {
1005- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1006- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1007- then state
1177+ let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1178+ let outAmAmt = res._1
1179+ let outPrAmt = res._2
1180+ let poolStatus = parseIntValue(res._9)
1181+ let state = res._10
1182+ let checkPoolStatus = if (if (isGlobalShutdown())
1183+ then true
1184+ else (poolStatus == PoolShutdown))
1185+ then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
1186+ else true
1187+ if ((checkPoolStatus == checkPoolStatus))
1188+ then {
1189+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1190+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1191+ then {
1192+ let $t04533645417 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1193+ let refreshKLpActions = $t04533645417._1
1194+ let updatedKLp = $t04533645417._2
1195+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1196+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1197+ then (state ++ refreshKLpActions)
1198+ else throw("Strict value is not equal to itself.")
1199+ }
1200+ else throw("Strict value is not equal to itself.")
1201+ }
10081202 else throw("Strict value is not equal to itself.")
10091203 }
10101204 else throw("Strict value is not equal to itself.")
10281222 else throw("no payments are expected")]
10291223 if ((checks == checks))
10301224 then {
1031- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1032- if ((unstakeInv == unstakeInv))
1225+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1226+ if ((currentKLp == currentKLp))
10331227 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))
1228+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1229+ if ((unstakeInv == unstakeInv))
10441230 then {
1045- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1046- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1047- then state
1231+ let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1232+ let outAmAmt = res._1
1233+ let outPrAmt = res._2
1234+ let state = res._10
1235+ let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1236+ then true
1237+ else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1238+ then true
1239+ else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1240+ if ((checkAmounts == checkAmounts))
1241+ then {
1242+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1243+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1244+ then {
1245+ let $t04671246793 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1246+ let refreshKLpActions = $t04671246793._1
1247+ let updatedKLp = $t04671246793._2
1248+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1249+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1250+ then (state ++ refreshKLpActions)
1251+ else throw("Strict value is not equal to itself.")
1252+ }
1253+ else throw("Strict value is not equal to itself.")
1254+ }
10481255 else throw("Strict value is not equal to itself.")
10491256 }
10501257 else throw("Strict value is not equal to itself.")
10601267 func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
10611268 then throw("permissions denied")
10621269 else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success")
1270+
1271+
1272+
1273+@Callable(i)
1274+func refreshKLp () = {
1275+ let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0)
1276+ let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay))
1277+ then unit
1278+ else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1279+ if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1280+ then {
1281+ let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp"))
1282+ let $t04798048044 = refreshKLpInternal(0, 0, 0)
1283+ let kLpUpdateActions = $t04798048044._1
1284+ let updatedKLp = $t04798048044._2
1285+ let actions = if ((kLp != updatedKLp))
1286+ then kLpUpdateActions
1287+ else throwErr("nothing to refresh")
1288+ $Tuple2(actions, toString(updatedKLp))
1289+ }
1290+ else throw("Strict value is not equal to itself.")
1291+ }
10631292
10641293
10651294
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let lPdecimals = 8
55
66 let scale8 = 100000000
77
88 let scale8BigInt = toBigInt(100000000)
99
1010 let scale18 = toBigInt(1000000000000000000)
1111
1212 let zeroBigInt = toBigInt(0)
1313
1414 let big0 = toBigInt(0)
1515
1616 let big1 = toBigInt(1)
1717
1818 let big2 = toBigInt(2)
1919
2020 let wavesString = "WAVES"
2121
2222 let SEP = "__"
2323
2424 let PoolActive = 1
2525
2626 let PoolPutDisabled = 2
2727
2828 let PoolMatcherDisabled = 3
2929
3030 let PoolShutdown = 4
3131
3232 let idxPoolAddress = 1
3333
3434 let idxPoolStatus = 2
3535
3636 let idxPoolLPAssetId = 3
3737
3838 let idxAmtAssetId = 4
3939
4040 let idxPriceAssetId = 5
4141
4242 let idxAmtAssetDcm = 6
4343
4444 let idxPriceAssetDcm = 7
4545
4646 let idxIAmtAssetId = 8
4747
4848 let idxIPriceAssetId = 9
4949
5050 let idxLPAssetDcm = 10
5151
5252 let idxPoolAmtAssetAmt = 1
5353
5454 let idxPoolPriceAssetAmt = 2
5555
5656 let idxPoolLPAssetAmt = 3
5757
5858 let idxFactoryStakingContract = 1
5959
6060 let idxFactorySlippageContract = 7
6161
6262 func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult))
6363
6464
65+func toX18BigInt (origVal,origScaleMult) = fraction(origVal, scale18, origScaleMult)
66+
67+
6568 func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18))
69+
70+
71+func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round))
6672
6773
6874 func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale)
6975
7076
7177 func abs (val) = if ((0 > val))
7278 then -(val)
7379 else val
7480
7581
7682 func absBigInt (val) = if ((zeroBigInt > val))
7783 then -(val)
7884 else val
7985
8086
8187 func fc () = "%s__factoryContract"
8288
8389
8490 func mpk () = "%s__managerPublicKey"
8591
8692
8793 func pmpk () = "%s__pendingManagerPublicKey"
8894
8995
9096 func pl () = "%s%s__price__last"
9197
9298
9399 func ph (h,timestamp) = makeString(["%s%s%d%d__price__history", toString(h), toString(timestamp)], SEP)
94100
95101
96102 func pau (userAddress,txId) = ((("%s%s%s__P__" + userAddress) + "__") + txId)
97103
98104
99105 func gau (userAddress,txId) = ((("%s%s%s__G__" + userAddress) + "__") + txId)
100106
101107
102108 func aa () = "%s__amountAsset"
103109
104110
105111 func pa () = "%s__priceAsset"
106112
107113
114+let keyFee = "%s__fee"
115+
116+let feeDefault = fraction(10, scale8, 10000)
117+
118+let fee = valueOrElse(getInteger(this, keyFee), feeDefault)
119+
120+let keyKLp = makeString(["%s", "kLp"], SEP)
121+
122+let keyKLpRefreshedHeight = makeString(["%s", "kLpRefreshedHeight"], SEP)
123+
124+let keyKLpRefreshDelay = makeString(["%s", "refreshKLpDelay"], SEP)
125+
126+let kLpRefreshDelayDefault = 30
127+
128+let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault)
129+
108130 func keyFactoryConfig () = "%s__factoryConfig"
109131
110132
111133 func keyMatcherPub () = "%s%s__matcher__publicKey"
112134
113135
114136 func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset")
115137
116138
117139 func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config")
118140
119141
120142 func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr)
121143
122144
123145 func keyAllPoolsShutdown () = "%s__shutdown"
124146
125147
126148 func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress)
127149
128150
129151 func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash"
130152
131153
132154 let keyFeeCollectorAddress = "%s__feeCollectorAddress"
133155
134156 func throwOrderError (orderValid,senderValid,matcherValid) = throw(((((("order validation failed: orderValid=" + toString(orderValid)) + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid)))
135157
136158
137159 func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
138160
139161
140162 func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
141163
142164
143165 func throwErr (msg) = throw(makeString(["lp.ride:", msg], " "))
166+
167+
168+func fmtErr (msg) = makeString(["lp.ride:", msg], " ")
144169
145170
146171 let factoryContract = addressFromStringValue(getStringOrFail(this, fc()))
147172
148173 let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress))
149174
150175 let inFee = {
151176 let @ = invoke(factoryContract, "getInFeeREADONLY", [toString(this)], nil)
152177 if ($isInstanceOf(@, "Int"))
153178 then @
154179 else throw(($getType(@) + " couldn't be cast to Int"))
155180 }
156181
157182 let outFee = {
158183 let @ = invoke(factoryContract, "getOutFeeREADONLY", [toString(this)], nil)
159184 if ($isInstanceOf(@, "Int"))
160185 then @
161186 else throw(($getType(@) + " couldn't be cast to Int"))
162187 }
163188
164189 func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false)
165190
166191
167192 func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub()))
168193
169194
170195 func getPoolConfig () = {
171196 let amtAsset = getStringOrFail(this, aa())
172197 let priceAsset = getStringOrFail(this, pa())
173198 let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset))
174199 let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset))
175200 split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP)
176201 }
177202
178203
179204 func parseAssetId (input) = if ((input == wavesString))
180205 then unit
181206 else fromBase58String(input)
182207
183208
184209 func assetIdToString (input) = if ((input == unit))
185210 then wavesString
186211 else toBase58String(value(input))
187212
188213
189214 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]))
190215
191216
192217 let poolConfigParsed = parsePoolConfig(getPoolConfig())
193218
194-let $t076017767 = poolConfigParsed
219+let $t083448510 = poolConfigParsed
195220
196-let cfgPoolAddress = $t076017767._1
221+let cfgPoolAddress = $t083448510._1
197222
198-let cfgPoolStatus = $t076017767._2
223+let cfgPoolStatus = $t083448510._2
199224
200-let cfgLpAssetId = $t076017767._3
225+let cfgLpAssetId = $t083448510._3
201226
202-let cfgAmountAssetId = $t076017767._4
227+let cfgAmountAssetId = $t083448510._4
203228
204-let cfgPriceAssetId = $t076017767._5
229+let cfgPriceAssetId = $t083448510._5
205230
206-let cfgAmountAssetDecimals = $t076017767._6
231+let cfgAmountAssetDecimals = $t083448510._6
207232
208-let cfgPriceAssetDecimals = $t076017767._7
233+let cfgPriceAssetDecimals = $t083448510._7
209234
210235 func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
211236
212237
213238 let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address")
214239
215240 let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address")
216241
217242 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)
218243
219244
220245 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)
221246
222247
223248 func getAccBalance (assetId) = if ((assetId == "WAVES"))
224249 then wavesBalance(this).available
225250 else assetBalance(this, fromBase58String(assetId))
226251
227252
228253 func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
254+
255+
256+func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
229257
230258
231259 func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
232260 let amtAssetAmtX18 = toX18(amAmt, amAssetDcm)
233261 let priceAssetAmtX18 = toX18(prAmt, prAssetDcm)
234262 calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18)
235263 }
236264
237265
238266 func calcPrices (amAmt,prAmt,lpAmt) = {
239267 let cfg = getPoolConfig()
240268 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
241269 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
242270 let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt)
243271 let amAmtX18 = toX18(amAmt, amtAssetDcm)
244272 let prAmtX18 = toX18(prAmt, priceAssetDcm)
245273 let lpAmtX18 = toX18(lpAmt, scale8)
246274 let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18)
247275 let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18)
248276 [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18]
249277 }
250278
251279
252280 func calculatePrices (amAmt,prAmt,lpAmt) = {
253281 let prices = calcPrices(amAmt, prAmt, lpAmt)
254282 [fromX18(prices[0], scale8), fromX18(prices[1], scale8), fromX18(prices[2], scale8)]
255283 }
256284
257285
258286 func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
259287 let cfg = getPoolConfig()
260288 let lpAssetId = cfg[idxPoolLPAssetId]
261289 let amAssetId = cfg[idxAmtAssetId]
262290 let prAssetId = cfg[idxPriceAssetId]
263291 let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
264292 let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
265293 let poolStatus = cfg[idxPoolStatus]
266294 let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity
267295 if ((lpAssetId != pmtAssetId))
268296 then throw("Invalid asset passed.")
269297 else {
270298 let amBalance = getAccBalance(amAssetId)
271299 let amBalanceX18 = toX18(amBalance, amAssetDcm)
272300 let prBalance = getAccBalance(prAssetId)
273301 let prBalanceX18 = toX18(prBalance, prAssetDcm)
274302 let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18)
275303 let curPrice = fromX18(curPriceX18, scale8)
276304 let pmtLpAmtX18 = toX18(pmtLpAmt, scale8)
277305 let lpEmissionX18 = toX18(lpEmission, scale8)
278306 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18)
279307 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18)
280- let outAmAmt = fromX18(outAmAmtX18, amAssetDcm)
281- let outPrAmt = fromX18(outPrAmtX18, prAssetDcm)
308+ let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR)
309+ let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR)
282310 let state = if ((txId58 == ""))
283311 then nil
284312 else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES"))
285313 then unit
286314 else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES"))
287315 then unit
288316 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)]
289317 $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state)
290318 }
291319 }
292320
293321
294322 func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = {
295323 let cfg = getPoolConfig()
296324 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
297325 let amAssetIdStr = cfg[idxAmtAssetId]
298326 let prAssetIdStr = cfg[idxPriceAssetId]
299327 let iAmtAssetId = cfg[idxIAmtAssetId]
300328 let iPriceAssetId = cfg[idxIPriceAssetId]
301329 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
302330 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
303331 let poolStatus = cfg[idxPoolStatus]
304332 let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
305333 let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES")))
306334 let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES")))
307335 if (if ((amAssetIdStr != inAmAssetIdStr))
308336 then true
309337 else (prAssetIdStr != inPrAssetIdStr))
310338 then throw("Invalid amt or price asset passed.")
311339 else {
312340 let amBalance = if (isEvaluate)
313341 then getAccBalance(amAssetIdStr)
314342 else (getAccBalance(amAssetIdStr) - inAmAssetAmt)
315343 let prBalance = if (isEvaluate)
316344 then getAccBalance(prAssetIdStr)
317345 else (getAccBalance(prAssetIdStr) - inPrAssetAmt)
318346 let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm)
319347 let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm)
320348 let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18)
321349 let amBalanceX18 = toX18(amBalance, amtAssetDcm)
322350 let prBalanceX18 = toX18(prBalance, priceAssetDcm)
323351 let res = if ((lpEmission == 0))
324352 then {
325353 let curPriceX18 = zeroBigInt
326354 let slippageX18 = zeroBigInt
327355 let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN)
328356 $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
329357 }
330358 else {
331359 let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18)
332360 let slippageX18 = fraction(absBigInt((curPriceX18 - userPriceX18)), scale18, curPriceX18)
333361 let slippageToleranceX18 = toX18(slippageTolerance, scale8)
334362 if (if ((curPriceX18 != zeroBigInt))
335363 then (slippageX18 > slippageToleranceX18)
336364 else false)
337365 then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18)))
338366 else {
339367 let lpEmissionX18 = toX18(lpEmission, scale8)
340- let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
341- let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
368+ let prViaAmX18 = fraction(inAmAssetAmtX18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING)
369+ let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, FLOOR), CEILING)
342370 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
343371 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
344372 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
345373 let expAmtAssetAmtX18 = expectedAmts._1
346374 let expPriceAssetAmtX18 = expectedAmts._2
347- let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
348- $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18)
375+ let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR)
376+ $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtAssetDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceAssetDcm, CEILING), curPriceX18, slippageX18)
349377 }
350378 }
351379 let calcLpAmt = res._1
352380 let calcAmAssetPmt = res._2
353381 let calcPrAssetPmt = res._3
354382 let curPrice = fromX18(res._4, scale8)
355383 let slippageCalc = fromX18(res._5, scale8)
356384 if ((0 >= calcLpAmt))
357385 then throw("Invalid calculations. LP calculated is less than zero.")
358386 else {
359387 let emitLpAmt = if (!(emitLp))
360388 then 0
361389 else calcLpAmt
362390 let amDiff = (inAmAssetAmt - calcAmAssetPmt)
363391 let prDiff = (inPrAssetAmt - calcPrAssetPmt)
364392 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))]
365393 $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId)
366394 }
367395 }
368396 }
369397
370398
399+func calcKLp (amountBalance,priceBalance,lpEmission) = {
400+ let amountBalanceX18 = toX18BigInt(amountBalance, toBigInt(cfgAmountAssetDecimals))
401+ let priceBalanceX18 = toX18BigInt(priceBalance, toBigInt(cfgPriceAssetDecimals))
402+ let updatedKLp = fraction(pow((amountBalanceX18 * priceBalanceX18), 0, toBigInt(5), 1, 18, DOWN), big1, lpEmission)
403+ if ((lpEmission == big0))
404+ then big0
405+ else updatedKLp
406+ }
407+
408+
409+func calcCurrentKLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = {
410+ let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta)
411+ let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta)
412+ let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta)
413+ let currentKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpAssetEmission)
414+ currentKLp
415+ }
416+
417+
418+func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = {
419+ let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta)
420+ let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta)
421+ let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta)
422+ let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission))
423+ let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))]
424+ $Tuple2(actions, updatedKLp)
425+ }
426+
427+
428+func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp))
429+ then true
430+ else throwErr(makeString(["updated KLp lower than current KLp", toString(oldKLp), toString(updatedKLp)], " "))
431+
432+
371433 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)
434+ let amountAssetAmount = order.amount
435+ let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR)
436+ let $t02126221474 = if ((order.orderType == Buy))
437+ then $Tuple2(amountAssetAmount, -(priceAssetAmount))
438+ else $Tuple2(-(amountAssetAmount), priceAssetAmount)
439+ let amountAssetBalanceDelta = $t02126221474._1
440+ let priceAssetBalanceDelta = $t02126221474._2
384441 if (if (if (isGlobalShutdown())
385442 then true
386- else (poolStatus == PoolMatcherDisabled))
443+ else (cfgPoolStatus == PoolMatcherDisabled))
387444 then true
388- else (poolStatus == PoolShutdown))
445+ else (cfgPoolStatus == PoolShutdown))
389446 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- }
447+ else if (if ((order.assetPair.amountAsset != cfgAmountAssetId))
448+ then true
449+ else (order.assetPair.priceAsset != cfgPriceAssetId))
450+ then throw("Wrong order assets.")
451+ else {
452+ let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp"))
453+ let $t02194522045 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
454+ let unusedActions = $t02194522045._1
455+ let kLpNew = $t02194522045._2
456+ let isOrderValid = (kLpNew >= kLp)
457+ isOrderValid
458+ }
413459 }
414460
415461
416462 func commonGet (i) = if ((size(i.payments) != 1))
417463 then throw("exactly 1 payment is expected")
418464 else {
419465 let pmt = value(i.payments[0])
420466 let pmtAssetId = value(pmt.assetId)
421467 let pmtAmt = pmt.amount
422468 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller)
423469 let outAmAmt = res._1
424470 let outPrAmt = res._2
425471 let poolStatus = parseIntValue(res._9)
426472 let state = res._10
427473 if (if (isGlobalShutdown())
428474 then true
429475 else (poolStatus == PoolShutdown))
430476 then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
431477 else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state)
432478 }
433479
434480
435481 func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2))
436482 then throw("exactly 2 payments are expected")
437483 else {
438484 let amAssetPmt = value(i.payments[0])
439485 let prAssetPmt = value(i.payments[1])
440486 let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp)
441487 let poolStatus = parseIntValue(estPut._8)
442488 if (if (if (isGlobalShutdown())
443489 then true
444490 else (poolStatus == PoolPutDisabled))
445491 then true
446492 else (poolStatus == PoolShutdown))
447493 then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus)))
448494 else estPut
449495 }
450496
451497
452498 func emit (amount) = {
453499 let emitInv = invoke(factoryContract, "emit", [amount], nil)
454500 if ((emitInv == emitInv))
455501 then {
456502 let emitInvLegacy = match emitInv {
457503 case legacyFactoryContract: Address =>
458504 invoke(legacyFactoryContract, "emit", [amount], nil)
459505 case _ =>
460506 unit
461507 }
462508 if ((emitInvLegacy == emitInvLegacy))
463509 then amount
464510 else throw("Strict value is not equal to itself.")
465511 }
466512 else throw("Strict value is not equal to itself.")
467513 }
468514
469515
470516 func takeFee (amount,fee) = {
471517 let feeAmount = if ((fee == 0))
472518 then 0
473519 else fraction(amount, fee, scale8)
474520 $Tuple2((amount - feeAmount), feeAmount)
475521 }
476522
477523
478524 func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = {
479525 let isEval = (txId == unit)
480526 let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId))
481527 let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId))
482528 let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId))
483529 then true
484530 else if ((paymentAssetId == cfgPriceAssetId))
485531 then false
486532 else throwErr("invalid asset")
487- let $t02266422957 = if (isEval)
533+ let $t02476625059 = if (isEval)
488534 then $Tuple2(amountBalanceRaw, priceBalanceRaw)
489535 else if (paymentInAmountAsset)
490536 then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw)
491537 else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw))
492- let amountBalanceOld = $t02266422957._1
493- let priceBalanceOld = $t02266422957._2
494- let $t02296123110 = if (paymentInAmountAsset)
538+ let amountBalanceOld = $t02476625059._1
539+ let priceBalanceOld = $t02476625059._2
540+ let $t02506325212 = if (paymentInAmountAsset)
495541 then $Tuple2(paymentAmountRaw, 0)
496542 else $Tuple2(0, paymentAmountRaw)
497- let amountAssetAmountRaw = $t02296123110._1
498- let priceAssetAmountRaw = $t02296123110._2
543+ let amountAssetAmountRaw = $t02506325212._1
544+ let priceAssetAmountRaw = $t02506325212._2
499545 let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1
500546 let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1
501- let $t02324223306 = takeFee(paymentAmountRaw, inFee)
502- let paymentAmount = $t02324223306._1
503- let feeAmount = $t02324223306._2
547+ let $t02534425408 = takeFee(paymentAmountRaw, inFee)
548+ let paymentAmount = $t02534425408._1
549+ let feeAmount = $t02534425408._2
504550 let amountBalanceNew = (amountBalanceOld + amountAssetAmount)
505551 let priceBalanceNew = (priceBalanceOld + priceAssetAmount)
506552 let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals))
507553 let priceNew = fromX18(priceNewX18, scale8)
508554 let paymentBalance = if (paymentInAmountAsset)
509555 then amountBalanceOld
510556 else priceBalanceOld
511557 let paymentBalanceBigInt = toBigInt(paymentBalance)
512558 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
513559 let chechSupply = if ((supplyBigInt > big0))
514560 then true
515561 else throwErr("initial deposit requires all coins")
516562 if ((chechSupply == chechSupply))
517563 then {
518564 let depositBigInt = toBigInt(paymentAmount)
519565 let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))])
520566 let commonState = if (isEval)
521567 then nil
522568 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))]
523569 let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals))
524570 let priceOld = fromX18(priceOldX18, scale8)
525571 let loss = {
526- let $t02478324950 = if (paymentInAmountAsset)
572+ let $t02708927256 = if (paymentInAmountAsset)
527573 then $Tuple2(amountAssetAmountRaw, amountBalanceOld)
528574 else $Tuple2(priceAssetAmountRaw, priceBalanceOld)
529- let amount = $t02478324950._1
530- let balance = $t02478324950._2
575+ let amount = $t02708927256._1
576+ let balance = $t02708927256._2
531577 let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance)))
532578 fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth)
533579 }
534- $Tuple4(issueAmount, commonState, feeAmount, loss)
580+ $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset)
535581 }
536582 else throw("Strict value is not equal to itself.")
537583 }
538584
539585
540586 func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = {
541587 let isEval = (txId == unit)
588+ let cfg = getPoolConfig()
589+ let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
590+ let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
542591 let checks = [if ((paymentAssetId == cfgLpAssetId))
543592 then true
544593 else throwErr("invalid lp asset")]
545594 if ((checks == checks))
546595 then {
547596 let outInAmountAsset = if ((outAssetId == cfgAmountAssetId))
548597 then true
549598 else if ((outAssetId == cfgPriceAssetId))
550599 then false
551600 else throwErr("invalid asset")
552601 let balanceBigInt = if (outInAmountAsset)
553602 then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId)))
554603 else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId)))
604+ let outInAmountAssetDecimals = if (outInAmountAsset)
605+ then amtAssetDcm
606+ else priceAssetDcm
555607 let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId))
556608 let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId))
557609 let outBalance = if (outInAmountAsset)
558610 then amBalanceOld
559611 else prBalanceOld
560612 let outBalanceBigInt = toBigInt(outBalance)
561613 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
562614 let redeemedBigInt = toBigInt(paymentAmount)
563615 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)
616+ let $t02933429390 = takeFee(amountRaw, outFee)
617+ let totalAmount = $t02933429390._1
618+ let feeAmount = $t02933429390._2
619+ let $t02939429620 = if (outInAmountAsset)
568620 then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
569621 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
622+ let outAmAmount = $t02939429620._1
623+ let outPrAmount = $t02939429620._2
624+ let amBalanceNew = $t02939429620._3
625+ let prBalanceNew = $t02939429620._4
574626 let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
575627 let priceNew = fromX18(priceNewX18, scale8)
576628 let commonState = if (isEval)
577629 then nil
578630 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)]
579631 let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals))
580632 let priceOld = fromX18(priceOldX18, scale8)
581633 let loss = {
582634 let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2)
583635 fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset)
584636 }
585- $Tuple4(totalAmount, commonState, feeAmount, loss)
637+ $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset)
586638 }
587639 else throw("Strict value is not equal to itself.")
588640 }
589641
590642
591643 func managerPublicKeyOrUnit () = match getString(mpk()) {
592644 case s: String =>
593645 fromBase58String(s)
594646 case _: Unit =>
595647 unit
596648 case _ =>
597649 throw("Match error")
598650 }
599651
600652
601653 func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) {
602654 case s: String =>
603655 fromBase58String(s)
604656 case _: Unit =>
605657 unit
606658 case _ =>
607659 throw("Match error")
608660 }
609661
610662
611663 func isManager (i) = match managerPublicKeyOrUnit() {
612664 case pk: ByteVector =>
613665 (i.callerPublicKey == pk)
614666 case _: Unit =>
615667 (i.caller == this)
616668 case _ =>
617669 throw("Match error")
618670 }
619671
620672
621673 func mustManager (i) = {
622674 let pd = throw("Permission denied")
623675 match managerPublicKeyOrUnit() {
624676 case pk: ByteVector =>
625677 if ((i.callerPublicKey == pk))
626678 then true
627679 else pd
628680 case _: Unit =>
629681 if ((i.caller == this))
630682 then true
631683 else pd
632684 case _ =>
633685 throw("Match error")
634686 }
635687 }
636688
637689
638690 @Callable(i)
639691 func setManager (pendingManagerPublicKey) = {
640692 let checkCaller = mustManager(i)
641693 if ((checkCaller == checkCaller))
642694 then {
643695 let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
644696 if ((checkManagerPublicKey == checkManagerPublicKey))
645697 then [StringEntry(pmpk(), pendingManagerPublicKey)]
646698 else throw("Strict value is not equal to itself.")
647699 }
648700 else throw("Strict value is not equal to itself.")
649701 }
650702
651703
652704
653705 @Callable(i)
654706 func confirmManager () = {
655707 let pm = pendingManagerPublicKeyOrUnit()
656708 let hasPM = if (isDefined(pm))
657709 then true
658710 else throw("No pending manager")
659711 if ((hasPM == hasPM))
660712 then {
661713 let checkPM = if ((i.callerPublicKey == value(pm)))
662714 then true
663715 else throw("You are not pending manager")
664716 if ((checkPM == checkPM))
665717 then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())]
666718 else throw("Strict value is not equal to itself.")
667719 }
668720 else throw("Strict value is not equal to itself.")
669721 }
670722
671723
672724
673725 @Callable(i)
674726 func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance))
675727 then throw("Invalid slippageTolerance passed")
676728 else {
677729 let estPut = commonPut(i, slippageTolerance, true)
678730 let emitLpAmt = estPut._2
679731 let lpAssetId = estPut._7
680732 let state = estPut._9
681733 let amDiff = estPut._10
682734 let prDiff = estPut._11
683735 let amId = estPut._12
684736 let prId = estPut._13
685- let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
686- if ((emitInv == emitInv))
737+ let amAssetPmt = toBigInt(value(i.payments[0]).amount)
738+ let prAssetPmt = toBigInt(value(i.payments[1]).amount)
739+ let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
740+ if ((currentKLp == currentKLp))
687741 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))
742+ let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
743+ if ((emitInv == emitInv))
695744 then {
696- let slippageAInv = if ((amDiff > 0))
697- then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
698- else nil
699- if ((slippageAInv == slippageAInv))
745+ let emitInvLegacy = match emitInv {
746+ case legacyFactoryContract: Address =>
747+ invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
748+ case _ =>
749+ unit
750+ }
751+ if ((emitInvLegacy == emitInvLegacy))
700752 then {
701- let slippagePInv = if ((prDiff > 0))
702- then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
753+ let slippageAInv = if ((amDiff > 0))
754+ then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
703755 else nil
704- if ((slippagePInv == slippagePInv))
756+ if ((slippageAInv == slippageAInv))
705757 then {
706- let lpTransfer = if (shouldAutoStake)
758+ let slippagePInv = if ((prDiff > 0))
759+ then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
760+ else nil
761+ if ((slippagePInv == slippagePInv))
707762 then {
708- let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
709- if ((slpStakeInv == slpStakeInv))
710- then nil
763+ let lpTransfer = if (shouldAutoStake)
764+ then {
765+ let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
766+ if ((slpStakeInv == slpStakeInv))
767+ then nil
768+ else throw("Strict value is not equal to itself.")
769+ }
770+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
771+ let $t03414834610 = refreshKLpInternal(0, 0, 0)
772+ if (($t03414834610 == $t03414834610))
773+ then {
774+ let updatedKLp = $t03414834610._2
775+ let refreshKLpActions = $t03414834610._1
776+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
777+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
778+ then ((state ++ lpTransfer) ++ refreshKLpActions)
779+ else throw("Strict value is not equal to itself.")
780+ }
711781 else throw("Strict value is not equal to itself.")
712782 }
713- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
714- (state ++ lpTransfer)
783+ else throw("Strict value is not equal to itself.")
715784 }
716785 else throw("Strict value is not equal to itself.")
717786 }
718787 else throw("Strict value is not equal to itself.")
719788 }
720789 else throw("Strict value is not equal to itself.")
721790 }
722791 else throw("Strict value is not equal to itself.")
723792 }
724793
725794
726795
727796 @Callable(i)
728797 func putForFree (maxSlippage) = if ((0 > maxSlippage))
729798 then throw("Invalid value passed")
730799 else {
731800 let estPut = commonPut(i, maxSlippage, false)
732- estPut._9
801+ let state = estPut._9
802+ let amAssetPmt = toBigInt(value(i.payments[0]).amount)
803+ let prAssetPmt = toBigInt(value(i.payments[1]).amount)
804+ let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
805+ if ((currentKLp == currentKLp))
806+ then {
807+ let $t03517235237 = refreshKLpInternal(0, 0, 0)
808+ let refreshKLpActions = $t03517235237._1
809+ let updatedKLp = $t03517235237._2
810+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
811+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
812+ then (state ++ refreshKLpActions)
813+ else throw("Strict value is not equal to itself.")
814+ }
815+ else throw("Strict value is not equal to itself.")
733816 }
734817
735818
736819
737820 @Callable(i)
738821 func putOneTkn (minOutAmount,autoStake) = {
739822 let isPoolOneTokenOperationsDisabled = {
740823 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
741824 if ($isInstanceOf(@, "Boolean"))
742825 then @
743826 else throw(($getType(@) + " couldn't be cast to Boolean"))
744827 }
745828 let isPutDisabled = if (if (if (isGlobalShutdown())
746829 then true
747830 else (cfgPoolStatus == PoolPutDisabled))
748831 then true
749832 else (cfgPoolStatus == PoolShutdown))
750833 then true
751834 else isPoolOneTokenOperationsDisabled
752835 let checks = [if (if (!(isPutDisabled))
753836 then true
754837 else isManager(i))
755838 then true
756839 else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1))
757840 then true
758841 else throwErr("exactly 1 payment are expected")]
759842 if ((checks == checks))
760843 then {
761844 let payment = i.payments[0]
762845 let paymentAssetId = payment.assetId
763846 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))
847+ let currentKLp = if ((paymentAssetId == cfgAmountAssetId))
848+ then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0))
849+ else if ((paymentAssetId == cfgPriceAssetId))
850+ then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0))
851+ else throwErr("payment asset is not supported")
852+ if ((currentKLp == currentKLp))
768853 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))
854+ let userAddress = i.caller
855+ let txId = i.transactionId
856+ let $t03642536577 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
857+ if (($t03642536577 == $t03642536577))
780858 then {
781- let lpTransfer = if (autoStake)
859+ let paymentInAmountAsset = $t03642536577._5
860+ let bonus = $t03642536577._4
861+ let feeAmount = $t03642536577._3
862+ let commonState = $t03642536577._2
863+ let emitAmountEstimated = $t03642536577._1
864+ let emitAmount = if (if ((minOutAmount > 0))
865+ then (minOutAmount > emitAmountEstimated)
866+ else false)
867+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
868+ else emitAmountEstimated
869+ let emitInv = emit(emitAmount)
870+ if ((emitInv == emitInv))
782871 then {
783- let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
784- if ((stakeInv == stakeInv))
785- then nil
872+ let lpTransfer = if (autoStake)
873+ then {
874+ let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
875+ if ((stakeInv == stakeInv))
876+ then nil
877+ else throw("Strict value is not equal to itself.")
878+ }
879+ else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
880+ let sendFee = if ((feeAmount > 0))
881+ then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
882+ else nil
883+ let $t03716337360 = if ((this == feeCollectorAddress))
884+ then $Tuple2(0, 0)
885+ else if (paymentInAmountAsset)
886+ then $Tuple2(-(feeAmount), 0)
887+ else $Tuple2(0, -(feeAmount))
888+ let amountAssetBalanceDelta = $t03716337360._1
889+ let priceAssetBalanceDelta = $t03716337360._2
890+ let $t03736337471 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
891+ let refreshKLpActions = $t03736337471._1
892+ let updatedKLp = $t03736337471._2
893+ let kLp = value(getString(keyKLp))
894+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
895+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
896+ then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
786897 else throw("Strict value is not equal to itself.")
787898 }
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)
899+ else throw("Strict value is not equal to itself.")
793900 }
794901 else throw("Strict value is not equal to itself.")
795902 }
796903 else throw("Strict value is not equal to itself.")
797904 }
798905 else throw("Strict value is not equal to itself.")
799906 }
800907
801908
802909
803910 @Callable(i)
804911 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
912+ let $t03777737934 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
913+ let emitAmountEstimated = $t03777737934._1
914+ let commonState = $t03777737934._2
915+ let feeAmount = $t03777737934._3
916+ let bonus = $t03777737934._4
917+ let paymentInAmountAsset = $t03777737934._5
810918 $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
811919 }
812920
813921
814922
815923 @Callable(i)
816924 func getOneTkn (outAssetIdStr,minOutAmount) = {
817925 let isPoolOneTokenOperationsDisabled = {
818926 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
819927 if ($isInstanceOf(@, "Boolean"))
820928 then @
821929 else throw(($getType(@) + " couldn't be cast to Boolean"))
822930 }
823931 let isGetDisabled = if (if (isGlobalShutdown())
824932 then true
825933 else (cfgPoolStatus == PoolShutdown))
826934 then true
827935 else isPoolOneTokenOperationsDisabled
828936 let checks = [if (if (!(isGetDisabled))
829937 then true
830938 else isManager(i))
831939 then true
832940 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1))
833941 then true
834942 else throwErr("exactly 1 payment are expected")]
835943 if ((checks == checks))
836944 then {
837945 let outAssetId = parseAssetId(outAssetIdStr)
838946 let payment = i.payments[0]
839947 let paymentAssetId = payment.assetId
840948 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))
949+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
950+ if ((currentKLp == currentKLp))
845951 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))
952+ let userAddress = i.caller
953+ let txId = i.transactionId
954+ let $t03881938972 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
955+ if (($t03881938972 == $t03881938972))
857956 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)
957+ let outInAmountAsset = $t03881938972._5
958+ let bonus = $t03881938972._4
959+ let feeAmount = $t03881938972._3
960+ let commonState = $t03881938972._2
961+ let amountEstimated = $t03881938972._1
962+ let amount = if (if ((minOutAmount > 0))
963+ then (minOutAmount > amountEstimated)
964+ else false)
965+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
966+ else amountEstimated
967+ let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
968+ if ((burnInv == burnInv))
969+ then {
970+ let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
971+ let sendFee = if ((feeAmount > 0))
972+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
973+ else nil
974+ let $t03947239719 = {
975+ let feeAmountForCalc = if ((this == feeCollectorAddress))
976+ then 0
977+ else feeAmount
978+ if (outInAmountAsset)
979+ then $Tuple2(-((amount + feeAmountForCalc)), 0)
980+ else $Tuple2(0, -((amount + feeAmountForCalc)))
981+ }
982+ let amountAssetBalanceDelta = $t03947239719._1
983+ let priceAssetBalanceDelta = $t03947239719._2
984+ let $t03972239830 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
985+ let refreshKLpActions = $t03972239830._1
986+ let updatedKLp = $t03972239830._2
987+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
988+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
989+ then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
990+ else throw("Strict value is not equal to itself.")
991+ }
992+ else throw("Strict value is not equal to itself.")
863993 }
864994 else throw("Strict value is not equal to itself.")
865995 }
866996 else throw("Strict value is not equal to itself.")
867997 }
868998 else throw("Strict value is not equal to itself.")
869999 }
8701000
8711001
8721002
8731003 @Callable(i)
8741004 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
1005+ let $t04008740243 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
1006+ let amountEstimated = $t04008740243._1
1007+ let commonState = $t04008740243._2
1008+ let feeAmount = $t04008740243._3
1009+ let bonus = $t04008740243._4
1010+ let outInAmountAsset = $t04008740243._5
8801011 $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
8811012 }
8821013
8831014
8841015
8851016 @Callable(i)
8861017 func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = {
8871018 let isPoolOneTokenOperationsDisabled = {
8881019 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
8891020 if ($isInstanceOf(@, "Boolean"))
8901021 then @
8911022 else throw(($getType(@) + " couldn't be cast to Boolean"))
8921023 }
8931024 let isGetDisabled = if (if (isGlobalShutdown())
8941025 then true
8951026 else (cfgPoolStatus == PoolShutdown))
8961027 then true
8971028 else isPoolOneTokenOperationsDisabled
8981029 let checks = [if (if (!(isGetDisabled))
8991030 then true
9001031 else isManager(i))
9011032 then true
9021033 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0))
9031034 then true
9041035 else throwErr("no payments are expected")]
9051036 if ((checks == checks))
9061037 then {
9071038 let outAssetId = parseAssetId(outAssetIdStr)
9081039 let userAddress = i.caller
9091040 let txId = i.transactionId
910- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
911- if ((unstakeInv == unstakeInv))
1041+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1042+ if ((currentKLp == currentKLp))
9121043 then {
913- let $t03525535388 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
914- if (($t03525535388 == $t03525535388))
1044+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1045+ if ((unstakeInv == unstakeInv))
9151046 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))
1047+ let $t04114841299 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
1048+ if (($t04114841299 == $t04114841299))
9271049 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)
1050+ let outInAmountAsset = $t04114841299._5
1051+ let bonus = $t04114841299._4
1052+ let feeAmount = $t04114841299._3
1053+ let commonState = $t04114841299._2
1054+ let amountEstimated = $t04114841299._1
1055+ let amount = if (if ((minOutAmount > 0))
1056+ then (minOutAmount > amountEstimated)
1057+ else false)
1058+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1059+ else amountEstimated
1060+ let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1061+ if ((burnInv == burnInv))
1062+ then {
1063+ let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
1064+ let sendFee = if ((feeAmount > 0))
1065+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
1066+ else nil
1067+ let $t04179442041 = {
1068+ let feeAmountForCalc = if ((this == feeCollectorAddress))
1069+ then 0
1070+ else feeAmount
1071+ if (outInAmountAsset)
1072+ then $Tuple2(-((amount + feeAmountForCalc)), 0)
1073+ else $Tuple2(0, -((amount + feeAmountForCalc)))
1074+ }
1075+ let amountAssetBalanceDelta = $t04179442041._1
1076+ let priceAssetBalanceDelta = $t04179442041._2
1077+ let $t04204442152 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1078+ let refreshKLpActions = $t04204442152._1
1079+ let updatedKLp = $t04204442152._2
1080+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1081+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1082+ then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1083+ else throw("Strict value is not equal to itself.")
1084+ }
1085+ else throw("Strict value is not equal to itself.")
9331086 }
9341087 else throw("Strict value is not equal to itself.")
9351088 }
9361089 else throw("Strict value is not equal to itself.")
9371090 }
9381091 else throw("Strict value is not equal to itself.")
9391092 }
9401093 else throw("Strict value is not equal to itself.")
9411094 }
9421095
9431096
9441097
9451098 @Callable(i)
9461099 func get () = {
9471100 let res = commonGet(i)
9481101 let outAmtAmt = res._1
9491102 let outPrAmt = res._2
9501103 let pmtAmt = res._3
9511104 let pmtAssetId = res._4
9521105 let state = res._5
953- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
954- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
955- then state
1106+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1107+ if ((currentKLp == currentKLp))
1108+ then {
1109+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1110+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1111+ then {
1112+ let $t04309843180 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1113+ let refreshKLpActions = $t04309843180._1
1114+ let updatedKLp = $t04309843180._2
1115+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1116+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1117+ then (state ++ refreshKLpActions)
1118+ else throw("Strict value is not equal to itself.")
1119+ }
1120+ else throw("Strict value is not equal to itself.")
1121+ }
9561122 else throw("Strict value is not equal to itself.")
9571123 }
9581124
9591125
9601126
9611127 @Callable(i)
9621128 func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = {
9631129 let res = commonGet(i)
9641130 let outAmAmt = res._1
9651131 let outPrAmt = res._2
9661132 let pmtAmt = res._3
9671133 let pmtAssetId = res._4
9681134 let state = res._5
9691135 if ((noLessThenAmtAsset > outAmAmt))
9701136 then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset)))
9711137 else if ((noLessThenPriceAsset > outPrAmt))
9721138 then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
9731139 else {
974- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
975- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
976- then state
1140+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1141+ if ((currentKLp == currentKLp))
1142+ then {
1143+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1144+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1145+ then {
1146+ let $t04412944210 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1147+ let refreshKLpActions = $t04412944210._1
1148+ let updatedKLp = $t04412944210._2
1149+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1150+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1151+ then (state ++ refreshKLpActions)
1152+ else throw("Strict value is not equal to itself.")
1153+ }
1154+ else throw("Strict value is not equal to itself.")
1155+ }
9771156 else throw("Strict value is not equal to itself.")
9781157 }
9791158 }
9801159
9811160
9821161
9831162 @Callable(i)
9841163 func unstakeAndGet (amount) = {
9851164 let checkPayments = if ((size(i.payments) != 0))
9861165 then throw("No payments are expected")
9871166 else true
9881167 if ((checkPayments == checkPayments))
9891168 then {
9901169 let cfg = getPoolConfig()
9911170 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
992- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
993- if ((unstakeInv == unstakeInv))
1171+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1172+ if ((currentKLp == currentKLp))
9941173 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))
1174+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
1175+ if ((unstakeInv == unstakeInv))
10041176 then {
1005- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1006- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1007- then state
1177+ let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1178+ let outAmAmt = res._1
1179+ let outPrAmt = res._2
1180+ let poolStatus = parseIntValue(res._9)
1181+ let state = res._10
1182+ let checkPoolStatus = if (if (isGlobalShutdown())
1183+ then true
1184+ else (poolStatus == PoolShutdown))
1185+ then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
1186+ else true
1187+ if ((checkPoolStatus == checkPoolStatus))
1188+ then {
1189+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1190+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1191+ then {
1192+ let $t04533645417 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1193+ let refreshKLpActions = $t04533645417._1
1194+ let updatedKLp = $t04533645417._2
1195+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1196+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1197+ then (state ++ refreshKLpActions)
1198+ else throw("Strict value is not equal to itself.")
1199+ }
1200+ else throw("Strict value is not equal to itself.")
1201+ }
10081202 else throw("Strict value is not equal to itself.")
10091203 }
10101204 else throw("Strict value is not equal to itself.")
10111205 }
10121206 else throw("Strict value is not equal to itself.")
10131207 }
10141208 else throw("Strict value is not equal to itself.")
10151209 }
10161210
10171211
10181212
10191213 @Callable(i)
10201214 func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = {
10211215 let isGetDisabled = if (isGlobalShutdown())
10221216 then true
10231217 else (cfgPoolStatus == PoolShutdown)
10241218 let checks = [if (!(isGetDisabled))
10251219 then true
10261220 else throw("get operation is blocked by admin"), if ((size(i.payments) == 0))
10271221 then true
10281222 else throw("no payments are expected")]
10291223 if ((checks == checks))
10301224 then {
1031- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1032- if ((unstakeInv == unstakeInv))
1225+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1226+ if ((currentKLp == currentKLp))
10331227 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))
1228+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1229+ if ((unstakeInv == unstakeInv))
10441230 then {
1045- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1046- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1047- then state
1231+ let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1232+ let outAmAmt = res._1
1233+ let outPrAmt = res._2
1234+ let state = res._10
1235+ let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1236+ then true
1237+ else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1238+ then true
1239+ else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1240+ if ((checkAmounts == checkAmounts))
1241+ then {
1242+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1243+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1244+ then {
1245+ let $t04671246793 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1246+ let refreshKLpActions = $t04671246793._1
1247+ let updatedKLp = $t04671246793._2
1248+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1249+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1250+ then (state ++ refreshKLpActions)
1251+ else throw("Strict value is not equal to itself.")
1252+ }
1253+ else throw("Strict value is not equal to itself.")
1254+ }
10481255 else throw("Strict value is not equal to itself.")
10491256 }
10501257 else throw("Strict value is not equal to itself.")
10511258 }
10521259 else throw("Strict value is not equal to itself.")
10531260 }
10541261 else throw("Strict value is not equal to itself.")
10551262 }
10561263
10571264
10581265
10591266 @Callable(i)
10601267 func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
10611268 then throw("permissions denied")
10621269 else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success")
1270+
1271+
1272+
1273+@Callable(i)
1274+func refreshKLp () = {
1275+ let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0)
1276+ let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay))
1277+ then unit
1278+ else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1279+ if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1280+ then {
1281+ let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp"))
1282+ let $t04798048044 = refreshKLpInternal(0, 0, 0)
1283+ let kLpUpdateActions = $t04798048044._1
1284+ let updatedKLp = $t04798048044._2
1285+ let actions = if ((kLp != updatedKLp))
1286+ then kLpUpdateActions
1287+ else throwErr("nothing to refresh")
1288+ $Tuple2(actions, toString(updatedKLp))
1289+ }
1290+ else throw("Strict value is not equal to itself.")
1291+ }
10631292
10641293
10651294
10661295 @Callable(i)
10671296 func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig())
10681297
10691298
10701299
10711300 @Callable(i)
10721301 func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId))
10731302
10741303
10751304
10761305 @Callable(i)
10771306 func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = {
10781307 let prices = calcPrices(amAmt, prAmt, lpAmt)
10791308 $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])])
10801309 }
10811310
10821311
10831312
10841313 @Callable(i)
10851314 func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult)))
10861315
10871316
10881317
10891318 @Callable(i)
10901319 func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult))
10911320
10921321
10931322
10941323 @Callable(i)
10951324 func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18))))
10961325
10971326
10981327
10991328 @Callable(i)
11001329 func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp))
11011330
11021331
11031332
11041333 @Callable(i)
11051334 func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
11061335 let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress))
11071336 $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10))
11081337 }
11091338
11101339
11111340
11121341 @Callable(i)
11131342 func statsREADONLY () = {
11141343 let cfg = getPoolConfig()
11151344 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
11161345 let amtAssetId = cfg[idxAmtAssetId]
11171346 let priceAssetId = cfg[idxPriceAssetId]
11181347 let iAmtAssetId = cfg[idxIAmtAssetId]
11191348 let iPriceAssetId = cfg[idxIPriceAssetId]
11201349 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
11211350 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
11221351 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
11231352 let accAmtAssetBalance = getAccBalance(amtAssetId)
11241353 let accPriceAssetBalance = getAccBalance(priceAssetId)
11251354 let pricesList = if ((poolLPBalance == 0))
11261355 then [zeroBigInt, zeroBigInt, zeroBigInt]
11271356 else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance)
11281357 let curPrice = 0
11291358 let lpAmtAssetShare = fromX18(pricesList[1], scale8)
11301359 let lpPriceAssetShare = fromX18(pricesList[2], scale8)
11311360 let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this))))
11321361 $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))
11331362 }
11341363
11351364
11361365
11371366 @Callable(i)
11381367 func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = {
11391368 let cfg = getPoolConfig()
11401369 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
11411370 let amAssetIdStr = cfg[idxAmtAssetId]
11421371 let amAssetId = fromBase58String(amAssetIdStr)
11431372 let prAssetIdStr = cfg[idxPriceAssetId]
11441373 let prAssetId = fromBase58String(prAssetIdStr)
11451374 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
11461375 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
11471376 let poolStatus = cfg[idxPoolStatus]
11481377 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
11491378 let accAmtAssetBalance = getAccBalance(amAssetIdStr)
11501379 let accPriceAssetBalance = getAccBalance(prAssetIdStr)
11511380 let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm)
11521381 let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm)
11531382 let curPriceX18 = if ((poolLPBalance == 0))
11541383 then zeroBigInt
11551384 else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18)
11561385 let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm)
11571386 let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
11581387 let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm)
11591388 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
11601389 let calcLpAmt = estPut._1
11611390 let curPriceCalc = estPut._3
11621391 let amBalance = estPut._4
11631392 let prBalance = estPut._5
11641393 let lpEmission = estPut._6
11651394 $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))
11661395 }
11671396
11681397
11691398
11701399 @Callable(i)
11711400 func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = {
11721401 let cfg = getPoolConfig()
11731402 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
11741403 let amAssetIdStr = cfg[idxAmtAssetId]
11751404 let amAssetId = fromBase58String(amAssetIdStr)
11761405 let prAssetIdStr = cfg[idxPriceAssetId]
11771406 let prAssetId = fromBase58String(prAssetIdStr)
11781407 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
11791408 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
11801409 let poolStatus = cfg[idxPoolStatus]
11811410 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
11821411 let amBalanceRaw = getAccBalance(amAssetIdStr)
11831412 let prBalanceRaw = getAccBalance(prAssetIdStr)
11841413 let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm)
11851414 let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm)
11861415 let curPriceX18 = if ((poolLPBalance == 0))
11871416 then zeroBigInt
11881417 else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18)
11891418 let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm)
11901419 let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
11911420 let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm)
11921421 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
11931422 let calcLpAmt = estPut._1
11941423 let curPriceCalc = estPut._3
11951424 let amBalance = estPut._4
11961425 let prBalance = estPut._5
11971426 let lpEmission = estPut._6
11981427 $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))
11991428 }
12001429
12011430
12021431
12031432 @Callable(i)
12041433 func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = {
12051434 let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this)
12061435 let outAmAmt = res._1
12071436 let outPrAmt = res._2
12081437 let amBalance = res._5
12091438 let prBalance = res._6
12101439 let lpEmission = res._7
12111440 let curPrice = res._8
12121441 let poolStatus = parseIntValue(res._9)
12131442 $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))
12141443 }
12151444
12161445
12171446 @Verifier(tx)
12181447 func verify () = {
12191448 let targetPublicKey = match managerPublicKeyOrUnit() {
12201449 case pk: ByteVector =>
12211450 pk
12221451 case _: Unit =>
12231452 tx.senderPublicKey
12241453 case _ =>
12251454 throw("Match error")
12261455 }
12271456 match tx {
12281457 case order: Order =>
12291458 let matcherPub = getMatcherPubOrFail()
12301459 let orderValid = validateMatcherOrderAllowed(order)
12311460 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
12321461 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
12331462 if (if (if (orderValid)
12341463 then senderValid
12351464 else false)
12361465 then matcherValid
12371466 else false)
12381467 then true
12391468 else throwOrderError(orderValid, senderValid, matcherValid)
12401469 case s: SetScriptTransaction =>
12411470 let newHash = blake2b256(value(s.script))
12421471 let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash())))
12431472 let currentHash = scriptHash(this)
12441473 if (if ((allowedHash == newHash))
12451474 then (currentHash != newHash)
12461475 else false)
12471476 then true
12481477 else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
12491478 case _ =>
12501479 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
12511480 }
12521481 }
12531482

github/deemru/w8io/169f3d6 
190.01 ms