tx · 5gCUdNqJQU8GRpiae2f7s2UiZDKZ84GKZTGScAVf3Dti

3MzKSdTH2jFbypLsoNfrH7QgkzSbx3EYwCA:  -0.03200000 Waves

2022.12.20 12:50 [2368450] smart account 3MzKSdTH2jFbypLsoNfrH7QgkzSbx3EYwCA > SELF 0.00000000 Waves

{ "type": 13, "id": "5gCUdNqJQU8GRpiae2f7s2UiZDKZ84GKZTGScAVf3Dti", "fee": 3200000, "feeAssetId": null, "timestamp": 1671529739810, "version": 1, "sender": "3MzKSdTH2jFbypLsoNfrH7QgkzSbx3EYwCA", "senderPublicKey": "35yd3qw1gxKDxKwGAykHN9fANbXNWwseaUwbWDj24o3x", "proofs": [ "5eDmv4ciVtd18kGqXpcSru7nXkRdKGEFvxyL4jkWkD8pPxF8R5tK9LUvsMeFPgBLGWFBshmSUpAfE4KMSL56iQnX" ], "script": "base64:BgKmIggCEgMKAQgSAwoBCBIAEgQKAgEEEgQKAgEEEgMKAQESABIECgIIARIECgIIARIECgIIARIECgIBARIDCgEBEgUKAwEBARIFCgMBCAESBAoCAQgSBAoCAQgSBAoCCAgSBAoCCAgSBAoCCAESABIDCgEIEgUKAwEBARIECgIIARIECgIBARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCCIGc2NhbGU4IgxzY2FsZThCaWdJbnQiB3NjYWxlMTgiCnplcm9CaWdJbnQiBGJpZzAiBGJpZzEiBGJpZzIiCnNsaXBwYWdlNEQiC3dhdmVzU3RyaW5nIgVBbXVsdCIFRGNvbnYiA1NFUCIFRU1QVFkiClBvb2xBY3RpdmUiClBvb2xQdXREaXMiDlBvb2xNYXRjaGVyRGlzIgxQb29sU2h1dGRvd24iDmlkeFBvb2xBZGRyZXNzIglpZHhQb29sU3QiCWlkeExQQXNJZCIJaWR4QW1Bc0lkIglpZHhQckFzSWQiC2lkeEFtdEFzRGNtIg1pZHhQcmljZUFzRGNtIgtpZHhJQW10QXNJZCINaWR4SVByaWNlQXNJZCIPaWR4RmFjdFN0YWtDbnRy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JnTgMJAAECBQJhdgIFT3JkZXIEAmR6BQJhdgQCZ1EJAQJhSgAEAmdSCQECZHkBBQJkegQCZ1MJAPQDAwgFAmR6CWJvZHlCeXRlcwkAkQMCCAUCZHoGcHJvb2ZzAAAIBQJkeg9zZW5kZXJQdWJsaWNLZXkEAmdUCQD0AwMIBQJkeglib2R5Qnl0ZXMJAJEDAggFAmR6BnByb29mcwABBQJnUQMDAwUCZ1IFAmdTBwUCZ1QHBgkBAmFxAwUCZ1IFAmdTBQJnVAMJAAECBQJhdgIUU2V0U2NyaXB0VHJhbnNhY3Rpb24EAmRaBQJhdgQCZ1UJAPYDAQkBBXZhbHVlAQgFAmRaBnNjcmlwdAQCZ1YJANsEAQkBBXZhbHVlAQkAnQgCBQJhRAkBAmFvAAQCZ1cJAPEHAQUEdGhpcwMDCQAAAgUCZ1YFAmdVCQECIT0CBQJnVwUCZ1UHBgkA9AMDCAUCZ04JYm9keUJ5dGVzCQCRAwIIBQJnTgZwcm9vZnMAAAUCZ1AJAPQDAwgFAmdOCWJvZHlCeXRlcwkAkQMCCAUCZ04GcHJvb2ZzAAAFAmdQf6Cfrw==", "chainId": 84, "height": 2368450, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4fqMMhfmDYkLB5AgNKBfUefnLTX5cmRyGZJyGErAz2aF Next: H8Q5ZgeE5fD5wcECWXJKLgpkwF7twfzxQqBzwzAC6Zfh Diff:
OldNewDifferences
1414 let big1 = toBigInt(1)
1515
1616 let big2 = toBigInt(2)
17-
18-let big3 = toBigInt(3)
19-
20-let big4 = toBigInt(4)
2117
2218 let slippage4D = toBigInt((scale8 - ((scale8 * 1) / scale8)))
2319
7369 func f1 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18))
7470
7571
76-func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round))
77-
78-
7972 func ts (amt,resScale,curScale) = fraction(amt, resScale, curScale)
8073
8174
122115 func ada () = "%s__addonAddr"
123116
124117
125-let keyFee = "%s__fee"
126-
127-let fee = valueOrElse(getInteger(this, keyFee), feeDefault)
128-
129-let keyDLp = makeString(["%s", "dLp"], SEP)
130-
131-let keyDLpRefreshedHeight = makeString(["%s", "dLpRefreshedHeight"], SEP)
132-
133-let keyDLpRefreshDelay = makeString(["%s", "refreshDLpDelay"], SEP)
134-
135-let dLpRefreshDelayDefault = 1
136-
137-let dLpRefreshDelay = valueOrElse(getInteger(this, keyDLpRefreshDelay), dLpRefreshDelayDefault)
138-
139118 func fcfg () = "%s__factoryConfig"
140119
141120
177156 func throwErr (msg) = throw(makeString(["lp_stable.ride:", msg], " "))
178157
179158
180-func fmtErr (msg) = makeString(["lp_stable.ride:", msg], " ")
159+let fca = addressFromStringValue(strf(this, fc()))
181160
161+let inFee = {
162+ let @ = invoke(fca, "getInFeeREADONLY", [toString(this)], nil)
163+ if ($isInstanceOf(@, "Int"))
164+ then @
165+ else throw(($getType(@) + " couldn't be cast to Int"))
166+ }
182167
183-let fca = addressFromStringValue(strf(this, fc()))
168+let outFee = {
169+ let @ = invoke(fca, "getOutFeeREADONLY", [toString(this)], nil)
170+ if ($isInstanceOf(@, "Int"))
171+ then @
172+ else throw(($getType(@) + " couldn't be cast to Int"))
173+ }
184174
185175 let A = strf(this, amp())
186176
216206
217207 let poolConfigParsed = parsePoolConfig(gpc())
218208
219-let $t074067592 = poolConfigParsed
209+let $t069097095 = poolConfigParsed
220210
221-let cfgPoolAddress = $t074067592._1
211+let cfgPoolAddress = $t069097095._1
222212
223-let cfgPoolStatus = $t074067592._2
213+let cfgPoolStatus = $t069097095._2
224214
225-let cfgLpAssetId = $t074067592._3
215+let cfgLpAssetId = $t069097095._3
226216
227-let cfgAmountAssetId = $t074067592._4
217+let cfgAmountAssetId = $t069097095._4
228218
229-let cfgPriceAssetId = $t074067592._5
219+let cfgPriceAssetId = $t069097095._5
230220
231-let cfgAmountAssetDecimals = $t074067592._6
221+let cfgAmountAssetDecimals = $t069097095._6
232222
233-let cfgPriceAssetDecimals = $t074067592._7
223+let cfgPriceAssetDecimals = $t069097095._7
234224
235225 func gfc () = split(strf(fca, fcfg()), SEP)
236226
306296 }
307297
308298
309-func takeFee (amount) = {
310- let feeAmount = fraction(amount, fee, scale8)
299+func takeFee (amount,fee) = {
300+ let feeAmount = if ((fee == 0))
301+ then 0
302+ else fraction(amount, fee, scale8)
311303 $Tuple2((amount - feeAmount), feeAmount)
312304 }
313305
334326 let lpEmissX18 = t1(lpEmiss, scale8)
335327 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissX18)
336328 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissX18)
337- let outAmAmt = fromX18Round(outAmAmtX18, amDcm, FLOOR)
338- let outPrAmt = fromX18Round(outPrAmtX18, prDcm, FLOOR)
329+ let outAmAmt = f1(outAmAmtX18, amDcm)
330+ let outPrAmt = f1(outPrAmtX18, prDcm)
339331 let state = if ((txId58 == ""))
340332 then nil
341333 else [ScriptTransfer(userAddress, outAmAmt, if ((amId == "WAVES"))
409401 let expAmtAssetAmtX18 = expectedAmts._1
410402 let expPriceAssetAmtX18 = expectedAmts._2
411403 let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
412- $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceDcm, CEILING), curPriceX18, slippageX18)
404+ $Tuple5(f1(lpAmtX18, scale8), f1(expAmtAssetAmtX18, amtDcm), f1(expPriceAssetAmtX18, priceDcm), curPriceX18, slippageX18)
413405 }
414406 }
415407 let calcLpAmt = r._1
425417 else calcLpAmt
426418 let amDiff = (inAmAmt - calcAmAssetPmt)
427419 let prDiff = (inPrAmt - calcPrAssetPmt)
428- let $t01811218457 = if (if (isOneAsset)
420+ let $t01756217907 = if (if (isOneAsset)
429421 then (pmtId == amIdStr)
430422 else false)
431423 then $Tuple2(pmtAmt, 0)
434426 else false)
435427 then $Tuple2(0, pmtAmt)
436428 else $Tuple2(calcAmAssetPmt, calcPrAssetPmt)
437- let writeAmAmt = $t01811218457._1
438- let writePrAmt = $t01811218457._2
429+ let writeAmAmt = $t01756217907._1
430+ let writePrAmt = $t01756217907._2
439431 let commonState = [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(userAddress, txId58), dataPutActionInfo(writeAmAmt, writePrAmt, emitLpAmt, curPrice, slippage, slippageCalc, height, lastBlock.timestamp, amDiff, prDiff))]
440432 $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEm, lpId, sts, commonState, amDiff, prDiff, inAmId, inPrId)
441433 }
442434 }
443435
444436
445-func getD (xp) = {
446- let xp0 = xp[0]
447- let xp1 = xp[1]
448- let s = (xp0 + xp1)
449- if ((s == big0))
450- then big0
451- else {
452- let a = parseIntValue(A)
453- let ann = (a * 2)
454- let p = fraction(xp0, xp1, big1)
455- let xp0_xp1_n_n = fraction(p, big4, big1)
456- let ann_s = fraction(toBigInt(ann), s, big1)
457- let ann_1 = toBigInt((ann - 1))
458- func calcDNext (d) = {
459- let dd = fraction(d, d, big1)
460- let ddd = fraction(dd, d, big1)
461- let dp = fraction(ddd, big1, xp0_xp1_n_n)
462- fraction((ann_s + fraction(dp, big2, big1)), d, (fraction(ann_1, d, big1) + fraction(big3, dp, big1)), CEILING)
463- }
464-
465- func calc (acc,i) = if (acc._2)
466- then acc
467- else {
468- let d = acc._1
469- let dNext = calcDNext(d)
470- let dDiffRaw = toInt((dNext - value(d)))
471- let dDiff = if ((0 > dDiffRaw))
472- then -(dDiffRaw)
473- else dDiffRaw
474- if ((1 >= dDiff))
475- then $Tuple2(dNext, true)
476- else $Tuple2(dNext, false)
477- }
478-
479- let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
480- let $t02038520433 = {
481- let $l = arr
482- let $s = size($l)
483- let $acc0 = $Tuple2(s, false)
484- func $f0_1 ($a,$i) = if (($i >= $s))
485- then $a
486- else calc($a, $l[$i])
487-
488- func $f0_2 ($a,$i) = if (($i >= $s))
489- then $a
490- else throw("List size exceeds 15")
491-
492- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15)
493- }
494- let d = $t02038520433._1
495- let found = $t02038520433._2
496- if (found)
497- then d
498- else throw(("D calculation error, D = " + toString(d)))
499- }
500- }
501-
502-
503-func getDOld (xp) = {
504- let n = big2
505- let xp0 = xp[0]
506- let xp1 = xp[1]
507- let aPrecision = parseBigIntValue(Amult)
508- let a = (parseBigIntValue(A) * aPrecision)
509- let s = (xp0 + xp1)
510- if ((s == big0))
511- then big0
512- else {
513- let ann = (a * n)
514- let xp0_xp1_n_n = (((xp0 * xp1) * n) * n)
515- let ann_s_aPrecision = ((ann * s) / aPrecision)
516- let ann_aPrecision = (ann - aPrecision)
517- let n1 = (n + big1)
518- func calc (acc,cur) = {
519- let $t02106221082 = acc
520- let d = $t02106221082._1
521- let found = $t02106221082._2
522- if ((found != unit))
523- then acc
524- else {
525- let dp = (((d * d) * d) / xp0_xp1_n_n)
526- let dNext = (((ann_s_aPrecision + (dp * n)) * d) / (((ann_aPrecision * d) / aPrecision) + (n1 * dp)))
527- let dDiff = absBigInt((dNext - value(d)))
528- if ((big1 >= dDiff))
529- then $Tuple2(dNext, cur)
530- else $Tuple2(dNext, unit)
531- }
532- }
533-
534- let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
535- let $t02150321550 = {
536- let $l = arr
537- let $s = size($l)
538- let $acc0 = $Tuple2(s, unit)
539- func $f0_1 ($a,$i) = if (($i >= $s))
540- then $a
541- else calc($a, $l[$i])
542-
543- func $f0_2 ($a,$i) = if (($i >= $s))
544- then $a
545- else throw("List size exceeds 15")
546-
547- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15)
548- }
549- let d = $t02150321550._1
550- let found = $t02150321550._2
551- if ((found != unit))
552- then d
553- else throw(("D calculation error, D = " + toString(d)))
554- }
555- }
556-
557-
558-func getYD (xp,i,D) = {
559- let n = big2
560- let x = xp[if ((i == 0))
561- then 1
562- else 0]
563- let aPrecision = parseBigIntValue(Amult)
564- let a = (parseBigIntValue(A) * aPrecision)
565- let s = x
566- let ann = (a * n)
567- let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n))
568- let b = ((s + ((D * aPrecision) / ann)) - D)
569- func calc (acc,cur) = {
570- let $t02205022070 = acc
571- let y = $t02205022070._1
572- let found = $t02205022070._2
573- if ((found != unit))
574- then acc
575- else {
576- let yNext = (((y * y) + c) / ((big2 * y) + b))
577- let yDiff = absBigInt((yNext - value(y)))
578- if ((big1 >= yDiff))
579- then $Tuple2(yNext, cur)
580- else $Tuple2(yNext, unit)
581- }
582- }
583-
584- let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
585- let $t02237722424 = {
586- let $l = arr
587- let $s = size($l)
588- let $acc0 = $Tuple2(D, unit)
589- func $f0_1 ($a,$i) = if (($i >= $s))
590- then $a
591- else calc($a, $l[$i])
592-
593- func $f0_2 ($a,$i) = if (($i >= $s))
594- then $a
595- else throw("List size exceeds 15")
596-
597- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15)
598- }
599- let y = $t02237722424._1
600- let found = $t02237722424._2
601- if ((found != unit))
602- then y
603- else throw(("Y calculation error, Y = " + toString(y)))
604- }
605-
606-
607-func calcDLp (amountBalance,priceBalance,lpEmission) = {
608- let updatedDLp = fraction(getD([amountBalance, priceBalance]), scale18, lpEmission)
609- if ((lpEmission == big0))
610- then big0
611- else updatedDLp
612- }
613-
614-
615-func calcCurrentDLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = {
616- let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta)
617- let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta)
618- let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta)
619- let currentDLp = calcDLp(amountAssetBalance, priceAssetBalance, lpAssetEmission)
620- currentDLp
621- }
622-
623-
624-func refreshDLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = {
625- let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta)
626- let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta)
627- let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta)
628- let updatedDLp = calcDLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission))
629- let actions = [IntegerEntry(keyDLpRefreshedHeight, height), StringEntry(keyDLp, toString(updatedDLp))]
630- $Tuple2(actions, updatedDLp)
631- }
632-
633-
634-func validateUpdatedDLp (oldDLp,updatedDLp) = if ((updatedDLp >= oldDLp))
635- then true
636- else throwErr("updated DLp lower than current DLp")
637-
638-
639-func validateMatcherOrderAllowed (order) = {
640- let amountAssetAmount = order.amount
641- let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR)
642- let $t02436324575 = if ((order.orderType == Buy))
643- then $Tuple2(amountAssetAmount, -(priceAssetAmount))
644- else $Tuple2(-(amountAssetAmount), priceAssetAmount)
645- let amountAssetBalanceDelta = $t02436324575._1
646- let priceAssetBalanceDelta = $t02436324575._2
437+func moa (order) = {
438+ let cfg = gpc()
439+ let amtAsId = cfg[idxAmAsId]
440+ let prAsId = cfg[idxPrAsId]
441+ let sts = parseIntValue(cfg[idxPoolSt])
442+ let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm])
443+ let prAsDcm = parseIntValue(cfg[idxPriceAsDcm])
444+ let accAmtAsBalance = getAccBalance(amtAsId)
445+ let accPrAsBalance = getAccBalance(prAsId)
446+ let curPriceX18 = if ((order.orderType == Buy))
447+ then pcp(amtAsDcm, prAsDcm, (accAmtAsBalance + order.amount), accPrAsBalance)
448+ else pcp(amtAsDcm, prAsDcm, (accAmtAsBalance - order.amount), accPrAsBalance)
449+ let curPrice = f1(curPriceX18, scale8)
647450 if (if (if (igs())
648451 then true
649- else (cfgPoolStatus == PoolMatcherDis))
452+ else (sts == PoolMatcherDis))
650453 then true
651- else (cfgPoolStatus == PoolShutdown))
454+ else (sts == PoolShutdown))
652455 then throw("Admin blocked")
653- else if (if ((order.assetPair.amountAsset != cfgAmountAssetId))
654- then true
655- else (order.assetPair.priceAsset != cfgPriceAssetId))
656- then throw("Wr assets")
657- else {
658- let dLp = parseBigIntValue(getStringValue(this, keyDLp))
659- let $t02490525005 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
660- let unusedActions = $t02490525005._1
661- let dLpNew = $t02490525005._2
662- let isOrderValid = (dLpNew >= dLp)
663- isOrderValid
664- }
456+ else {
457+ let orAmtAsset = order.assetPair.amountAsset
458+ let orAmtAsStr = if ((orAmtAsset == unit))
459+ then "WAVES"
460+ else toBase58String(value(orAmtAsset))
461+ let orPrAsset = order.assetPair.priceAsset
462+ let orPrAsStr = if ((orPrAsset == unit))
463+ then "WAVES"
464+ else toBase58String(value(orPrAsset))
465+ if (if ((orAmtAsStr != amtAsId))
466+ then true
467+ else (orPrAsStr != prAsId))
468+ then throw("Wr assets")
469+ else {
470+ let orderPrice = order.price
471+ let priceDcm = fraction(scale8, prAsDcm, amtAsDcm)
472+ let castOrderPrice = ts(orderPrice, scale8, priceDcm)
473+ let isOrderPriceValid = if ((order.orderType == Buy))
474+ then (curPrice >= castOrderPrice)
475+ else (castOrderPrice >= curPrice)
476+ true
477+ }
478+ }
665479 }
666480
667481
697511 }
698512
699513
514+func getD (xp) = {
515+ let n = big2
516+ let xp0 = xp[0]
517+ let xp1 = xp[1]
518+ let aPrecision = parseBigIntValue(Amult)
519+ let a = (parseBigIntValue(A) * aPrecision)
520+ let s = (xp0 + xp1)
521+ if ((s == big0))
522+ then big0
523+ else {
524+ let ann = (a * n)
525+ let xp0_xp1_n_n = (((xp0 * xp1) * n) * n)
526+ let ann_s_aPrecision = ((ann * s) / aPrecision)
527+ let ann_aPrecision = (ann - aPrecision)
528+ let n1 = (n + big1)
529+ func calc (acc,cur) = {
530+ let $t02245922479 = acc
531+ let d = $t02245922479._1
532+ let found = $t02245922479._2
533+ if ((found != unit))
534+ then acc
535+ else {
536+ let dp = (((d * d) * d) / xp0_xp1_n_n)
537+ let dNext = (((ann_s_aPrecision + (dp * n)) * d) / (((ann_aPrecision * d) / aPrecision) + (n1 * dp)))
538+ let dDiff = absBigInt((dNext - value(d)))
539+ if ((big1 >= dDiff))
540+ then $Tuple2(dNext, cur)
541+ else $Tuple2(dNext, unit)
542+ }
543+ }
544+
545+ let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
546+ let $t02290022947 = {
547+ let $l = arr
548+ let $s = size($l)
549+ let $acc0 = $Tuple2(s, unit)
550+ func $f0_1 ($a,$i) = if (($i >= $s))
551+ then $a
552+ else calc($a, $l[$i])
553+
554+ func $f0_2 ($a,$i) = if (($i >= $s))
555+ then $a
556+ else throw("List size exceeds 15")
557+
558+ $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15)
559+ }
560+ let d = $t02290022947._1
561+ let found = $t02290022947._2
562+ if ((found != unit))
563+ then d
564+ else throw(("D calculation error, D = " + toString(d)))
565+ }
566+ }
567+
568+
569+func getYD (xp,i,D) = {
570+ let n = big2
571+ let x = xp[if ((i == 0))
572+ then 1
573+ else 0]
574+ let aPrecision = parseBigIntValue(Amult)
575+ let a = (parseBigIntValue(A) * aPrecision)
576+ let s = x
577+ let ann = (a * n)
578+ let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n))
579+ let b = ((s + ((D * aPrecision) / ann)) - D)
580+ func calc (acc,cur) = {
581+ let $t02344723467 = acc
582+ let y = $t02344723467._1
583+ let found = $t02344723467._2
584+ if ((found != unit))
585+ then acc
586+ else {
587+ let yNext = (((y * y) + c) / ((big2 * y) + b))
588+ let yDiff = absBigInt((yNext - value(y)))
589+ if ((big1 >= yDiff))
590+ then $Tuple2(yNext, cur)
591+ else $Tuple2(yNext, unit)
592+ }
593+ }
594+
595+ let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
596+ let $t02377423821 = {
597+ let $l = arr
598+ let $s = size($l)
599+ let $acc0 = $Tuple2(D, unit)
600+ func $f0_1 ($a,$i) = if (($i >= $s))
601+ then $a
602+ else calc($a, $l[$i])
603+
604+ func $f0_2 ($a,$i) = if (($i >= $s))
605+ then $a
606+ else throw("List size exceeds 15")
607+
608+ $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15)
609+ }
610+ let y = $t02377423821._1
611+ let found = $t02377423821._2
612+ if ((found != unit))
613+ then y
614+ else throw(("Y calculation error, Y = " + toString(y)))
615+ }
616+
617+
700618 func calcPutOneTkn (pmtAmtRaw,pmtAssetId,userAddress,txId,withTakeFee) = {
701619 let poolConfig = gpc()
702620 let amId = poolConfig[idxAmAsId]
712630 then {
713631 let amBalance = getAccBalance(amId)
714632 let prBalance = getAccBalance(prId)
715- let $t02732227784 = if ((txId == ""))
633+ let $t02460425066 = if ((txId == ""))
716634 then $Tuple2(amBalance, prBalance)
717635 else if ((pmtAssetId == amId))
718636 then if ((pmtAmtRaw > amBalance))
723641 then throw("invalid payment amount")
724642 else $Tuple2(amBalance, (prBalance - pmtAmtRaw))
725643 else throw("wrong pmtAssetId")
726- let amBalanceOld = $t02732227784._1
727- let prBalanceOld = $t02732227784._2
728- let $t02779027966 = if ((pmtAssetId == amId))
644+ let amBalanceOld = $t02460425066._1
645+ let prBalanceOld = $t02460425066._2
646+ let $t02507225248 = if ((pmtAssetId == amId))
729647 then $Tuple2(pmtAmtRaw, 0)
730648 else if ((pmtAssetId == prId))
731649 then $Tuple2(0, pmtAmtRaw)
732650 else throw("invalid payment")
733- let amAmountRaw = $t02779027966._1
734- let prAmountRaw = $t02779027966._2
735- let $t02797028209 = if (withTakeFee)
736- then $Tuple3(takeFee(amAmountRaw)._1, takeFee(prAmountRaw)._1, takeFee(pmtAmtRaw)._2)
651+ let amAmountRaw = $t02507225248._1
652+ let prAmountRaw = $t02507225248._2
653+ let $t02525225506 = if (withTakeFee)
654+ then $Tuple3(takeFee(amAmountRaw, inFee)._1, takeFee(prAmountRaw, inFee)._1, takeFee(pmtAmtRaw, inFee)._2)
737655 else $Tuple3(amAmountRaw, prAmountRaw, 0)
738- let amAmount = $t02797028209._1
739- let prAmount = $t02797028209._2
740- let feeAmount = $t02797028209._3
656+ let amAmount = $t02525225506._1
657+ let prAmount = $t02525225506._2
658+ let feeAmount = $t02525225506._3
741659 let amBalanceNew = (amBalanceOld + amAmount)
742660 let prBalanceNew = (prBalanceOld + prAmount)
743661 let D0 = getD([toBigInt(amBalanceOld), toBigInt(prBalanceOld)])
747665 else throw()
748666 if ((checkD == checkD))
749667 then {
750- let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0, FLOOR)
668+ let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0)
751669 let curPrice = f1(cpbi(t1(prBalanceNew, priceDcm), t1(amBalanceNew, amtDcm)), scale8)
752670 let commonState = [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(userAddress, txId), dataPutActionInfo(amAmountRaw, prAmountRaw, toInt(lpAmount), curPrice, 0, 0, height, lastBlock.timestamp, 0, 0))]
753671 let poolProportion = fraction(prBalanceOld, scale8, amBalanceOld)
777695 let pmt = value(payments[0])
778696 let pmtAssetId = value(pmt.assetId)
779697 let pmtAmt = pmt.amount
780- let currentDLp = calcCurrentDLp(big0, big0, big0)
781- if ((currentDLp == currentDLp))
782- then {
783- let txId58 = toBase58String(transactionId)
784- if ((lpId != toBase58String(pmtAssetId)))
785- then throw("Wrong LP")
786- else {
787- let amBalance = getAccBalance(amId)
788- let prBalance = getAccBalance(prId)
789- let $t03027430385 = {
790- let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil)
791- if ($isInstanceOf(@, "(Int, Int)"))
792- then @
793- else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
794- }
795- if (($t03027430385 == $t03027430385))
698+ let txId58 = toBase58String(transactionId)
699+ if ((lpId != toBase58String(pmtAssetId)))
700+ then throw("Wrong LP")
701+ else {
702+ let amBalance = getAccBalance(amId)
703+ let prBalance = getAccBalance(prId)
704+ let $t02750827619 = {
705+ let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil)
706+ if ($isInstanceOf(@, "(Int, Int)"))
707+ then @
708+ else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
709+ }
710+ if (($t02750827619 == $t02750827619))
711+ then {
712+ let feeAmount = $t02750827619._2
713+ let totalGet = $t02750827619._1
714+ let totalAmount = if (if ((minOutAmount > 0))
715+ then (minOutAmount > totalGet)
716+ else false)
717+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
718+ else totalGet
719+ let $t02780928116 = if ((outAssetId == amId))
720+ then $Tuple4(totalAmount, 0, ((amBalance - totalAmount) - feeAmount), prBalance)
721+ else if ((outAssetId == prId))
722+ then $Tuple4(0, totalAmount, amBalance, ((prBalance - totalAmount) - feeAmount))
723+ else throw("invalid out asset id")
724+ let outAm = $t02780928116._1
725+ let outPr = $t02780928116._2
726+ let amBalanceNew = $t02780928116._3
727+ let prBalanceNew = $t02780928116._4
728+ let curPrX18 = cpbi(t1(prBalanceNew, prDecimals), t1(amBalanceNew, amDecimals))
729+ let curPr = f1(curPrX18, scale8)
730+ let outAssetIdOrWaves = if ((outAssetId == "WAVES"))
731+ then unit
732+ else fromBase58String(outAssetId)
733+ let sendFeeToMatcher = if ((feeAmount > 0))
734+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)]
735+ else nil
736+ let state = ([ScriptTransfer(userAddress, totalAmount, outAssetIdOrWaves), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, pmtAmt, curPr, height, lastBlock.timestamp)), IntegerEntry(pl(), curPr), IntegerEntry(ph(height, lastBlock.timestamp), curPr)] ++ sendFeeToMatcher)
737+ if ((state == state))
796738 then {
797- let feeAmount = $t03027430385._2
798- let totalGet = $t03027430385._1
799- let totalAmount = if (if ((minOutAmount > 0))
800- then (minOutAmount > totalGet)
801- else false)
802- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
803- else totalGet
804- let $t03057530882 = if ((outAssetId == amId))
805- then $Tuple4(totalAmount, 0, ((amBalance - totalAmount) - feeAmount), prBalance)
806- else if ((outAssetId == prId))
807- then $Tuple4(0, totalAmount, amBalance, ((prBalance - totalAmount) - feeAmount))
808- else throw("invalid out asset id")
809- let outAm = $t03057530882._1
810- let outPr = $t03057530882._2
811- let amBalanceNew = $t03057530882._3
812- let prBalanceNew = $t03057530882._4
813- let curPrX18 = cpbi(t1(prBalanceNew, prDecimals), t1(amBalanceNew, amDecimals))
814- let curPr = f1(curPrX18, scale8)
815- let outAssetIdOrWaves = if ((outAssetId == "WAVES"))
816- then unit
817- else fromBase58String(outAssetId)
818- let sendFeeToMatcher = if ((feeAmount > 0))
819- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)]
820- else nil
821- let state = ([ScriptTransfer(userAddress, totalAmount, outAssetIdOrWaves), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, pmtAmt, curPr, height, lastBlock.timestamp)), IntegerEntry(pl(), curPr), IntegerEntry(ph(height, lastBlock.timestamp), curPr)] ++ sendFeeToMatcher)
822- if ((state == state))
823- then {
824- let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
825- if ((burn == burn))
826- then {
827- let $t03166732017 = {
828- let feeAmountForCalc = if ((this == feeCollectorAddress))
829- then 0
830- else feeAmount
831- let outInAmountAsset = if ((parseAssetId(outAssetId) == cfgAmountAssetId))
832- then true
833- else false
834- if (outInAmountAsset)
835- then $Tuple2(-((totalGet + feeAmountForCalc)), 0)
836- else $Tuple2(0, -((totalGet + feeAmountForCalc)))
837- }
838- let amountAssetBalanceDelta = $t03166732017._1
839- let priceAssetBalanceDelta = $t03166732017._2
840- let $t03202032128 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
841- let refreshDLpActions = $t03202032128._1
842- let updatedDLp = $t03202032128._2
843- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
844- if ((isUpdatedDLpValid == isUpdatedDLpValid))
845- then $Tuple2((state ++ refreshDLpActions), totalAmount)
846- else throw("Strict value is not equal to itself.")
847- }
848- else throw("Strict value is not equal to itself.")
849- }
739+ let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
740+ if ((burn == burn))
741+ then $Tuple2(state, totalAmount)
850742 else throw("Strict value is not equal to itself.")
851743 }
852744 else throw("Strict value is not equal to itself.")
853745 }
746+ else throw("Strict value is not equal to itself.")
854747 }
855- else throw("Strict value is not equal to itself.")
856748 }
857749
858750
957849 else if ((size(i.payments) != 2))
958850 then throw("2 pmnts expd")
959851 else {
960- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
961- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
962- let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amAssetPmt)
963- if ((amountAssetBalance == amountAssetBalance))
852+ let e = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], slip, true, false, true, 0, "")
853+ let emitLpAmt = e._2
854+ let lpAssetId = e._7
855+ let state = e._9
856+ let amDiff = e._10
857+ let prDiff = e._11
858+ let amId = e._12
859+ let prId = e._13
860+ let r = invoke(fca, "emit", [emitLpAmt], nil)
861+ if ((r == r))
964862 then {
965- let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - prAssetPmt)
966- if ((priceAssetBalance == priceAssetBalance))
863+ let el = match r {
864+ case legacy: Address =>
865+ invoke(legacy, "emit", [emitLpAmt], nil)
866+ case _ =>
867+ unit
868+ }
869+ if ((el == el))
967870 then {
968- let lpAssetEmission = toBigInt(value(assetInfo(cfgLpAssetId)).quantity)
969- if ((lpAssetEmission == lpAssetEmission))
871+ let sa = if ((amDiff > 0))
872+ then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)])
873+ else nil
874+ if ((sa == sa))
970875 then {
971- let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0))
972- if ((currentDLp == currentDLp))
876+ let sp = if ((prDiff > 0))
877+ then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)])
878+ else nil
879+ if ((sp == sp))
973880 then {
974- let e = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], slip, true, false, true, 0, "")
975- let emitLpAmt = e._2
976- let lpAssetId = e._7
977- let state = e._9
978- let amDiff = e._10
979- let prDiff = e._11
980- let amId = e._12
981- let prId = e._13
982- let r = invoke(fca, "emit", [emitLpAmt], nil)
983- if ((r == r))
881+ let lpTrnsfr = if (autoStake)
984882 then {
985- let el = match r {
986- case legacy: Address =>
987- invoke(legacy, "emit", [emitLpAmt], nil)
988- case _ =>
989- unit
990- }
991- if ((el == el))
992- then {
993- let sa = if ((amDiff > 0))
994- then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)])
995- else nil
996- if ((sa == sa))
997- then {
998- let sp = if ((prDiff > 0))
999- then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)])
1000- else nil
1001- if ((sp == sp))
1002- then {
1003- let lpTrnsfr = if (autoStake)
1004- then {
1005- let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
1006- if ((ss == ss))
1007- then nil
1008- else throw("Strict value is not equal to itself.")
1009- }
1010- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
1011- let $t03627736342 = refreshDLpInternal(0, 0, 0)
1012- let refreshDLpActions = $t03627736342._1
1013- let updatedDLp = $t03627736342._2
1014- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1015- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1016- then {
1017- let check = if ((updatedDLp >= currentDLp))
1018- then true
1019- else throwErr("updated DLp lower than current DLp")
1020- if ((check == check))
1021- then {
1022- let lpAssetEmissionAfter = value(assetInfo(cfgLpAssetId)).quantity
1023- if ((lpAssetEmissionAfter == lpAssetEmissionAfter))
1024- then ((state ++ lpTrnsfr) ++ refreshDLpActions)
1025- else throw("Strict value is not equal to itself.")
1026- }
1027- else throw("Strict value is not equal to itself.")
1028- }
1029- else throw("Strict value is not equal to itself.")
1030- }
1031- else throw("Strict value is not equal to itself.")
1032- }
1033- else throw("Strict value is not equal to itself.")
1034- }
883+ let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
884+ if ((ss == ss))
885+ then nil
1035886 else throw("Strict value is not equal to itself.")
1036887 }
1037- else throw("Strict value is not equal to itself.")
888+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
889+ (state ++ lpTrnsfr)
1038890 }
1039891 else throw("Strict value is not equal to itself.")
1040892 }
1084936 let pmt = value(i.payments[0])
1085937 let pmtAssetId = toBase58String(value(pmt.assetId))
1086938 let pmtAmt = pmt.amount
1087- let currentDLp = if ((pmt.assetId == cfgAmountAssetId))
1088- then calcCurrentDLp(toBigInt(pmtAmt), toBigInt(0), toBigInt(0))
1089- else calcCurrentDLp(toBigInt(0), toBigInt(pmtAmt), toBigInt(0))
1090- if ((currentDLp == currentDLp))
939+ let $t03347833636 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true)
940+ if (($t03347833636 == $t03347833636))
1091941 then {
1092- let $t03786438022 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true)
1093- if (($t03786438022 == $t03786438022))
942+ let feeAmount = $t03347833636._3
943+ let state = $t03347833636._2
944+ let estimLP = $t03347833636._1
945+ let emitLpAmt = if (if ((minOutAmount > 0))
946+ then (minOutAmount > estimLP)
947+ else false)
948+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
949+ else estimLP
950+ let e = invoke(fca, "emit", [emitLpAmt], nil)
951+ if ((e == e))
1094952 then {
1095- let feeAmount = $t03786438022._3
1096- let state = $t03786438022._2
1097- let estimLP = $t03786438022._1
1098- let emitLpAmt = if (if ((minOutAmount > 0))
1099- then (minOutAmount > estimLP)
1100- else false)
1101- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1102- else estimLP
1103- let e = invoke(fca, "emit", [emitLpAmt], nil)
1104- if ((e == e))
953+ let el = match e {
954+ case legacy: Address =>
955+ invoke(legacy, "emit", [emitLpAmt], nil)
956+ case _ =>
957+ unit
958+ }
959+ if ((el == el))
1105960 then {
1106- let el = match e {
1107- case legacy: Address =>
1108- invoke(legacy, "emit", [emitLpAmt], nil)
1109- case _ =>
1110- unit
1111- }
1112- if ((el == el))
961+ let lpTrnsfr = if (autoStake)
1113962 then {
1114- let lpTrnsfr = if (autoStake)
1115- then {
1116- let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)])
1117- if ((ss == ss))
1118- then nil
1119- else throw("Strict value is not equal to itself.")
1120- }
1121- else [ScriptTransfer(i.caller, emitLpAmt, lpId)]
1122- let sendFeeToMatcher = if ((feeAmount > 0))
1123- then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))]
1124- else nil
1125- let $t03883739186 = if ((this == feeCollectorAddress))
1126- then $Tuple2(0, 0)
1127- else {
1128- let paymentInAmountAsset = if ((pmt.assetId == cfgAmountAssetId))
1129- then true
1130- else false
1131- if (paymentInAmountAsset)
1132- then $Tuple2(-(feeAmount), 0)
1133- else $Tuple2(0, -(feeAmount))
1134- }
1135- let amountAssetBalanceDelta = $t03883739186._1
1136- let priceAssetBalanceDelta = $t03883739186._2
1137- let $t03918939297 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1138- let refreshDLpActions = $t03918939297._1
1139- let updatedDLp = $t03918939297._2
1140- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1141- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1142- then $Tuple2((((state ++ lpTrnsfr) ++ sendFeeToMatcher) ++ refreshDLpActions), emitLpAmt)
963+ let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)])
964+ if ((ss == ss))
965+ then nil
1143966 else throw("Strict value is not equal to itself.")
1144967 }
1145- else throw("Strict value is not equal to itself.")
968+ else [ScriptTransfer(i.caller, emitLpAmt, lpId)]
969+ let sendFeeToMatcher = if ((feeAmount > 0))
970+ then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))]
971+ else nil
972+ $Tuple2(((state ++ lpTrnsfr) ++ sendFeeToMatcher), emitLpAmt)
1146973 }
1147974 else throw("Strict value is not equal to itself.")
1148975 }
1156983
1157984
1158985 @Callable(i)
986+func putForFree (maxSlpg) = if ((0 > maxSlpg))
987+ then throw("Wrong slpg")
988+ else if ((size(i.payments) != 2))
989+ then throw("2 pmnts expd")
990+ else {
991+ let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], maxSlpg, false, false, true, 0, "")
992+ estPut._9
993+ }
994+
995+
996+
997+@Callable(i)
1159998 func get () = {
1160- let aab = toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId)))
1161- if ((aab == aab))
1162- then {
1163- let pab = toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId)))
1164- if ((pab == pab))
1165- then {
1166- let lae = toBigInt(value(assetInfo(cfgLpAssetId)).quantity)
1167- if ((lae == lae))
1168- then {
1169- let laea = (lae - toBigInt(value(i.payments[0]).amount))
1170- if ((laea == laea))
1171- then {
1172- let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1173- if ((currentDLp == currentDLp))
1174- then {
1175- let r = cg(i)
1176- let outAmtAmt = r._1
1177- let outPrAmt = r._2
1178- let pmtAmt = r._3
1179- let pmtAssetId = r._4
1180- let state = r._5
1181- let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1182- if ((b == b))
1183- then {
1184- let $t04159541752 = refreshDLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1185- let refreshDLpActions = $t04159541752._1
1186- let updatedDLp = $t04159541752._2
1187- let error = if ((updatedDLp >= currentDLp))
1188- then true
1189- else throwErr(makeString(["updated DLp lower than current DLp", toString(aab), toString(pab), toString(currentDLp), toString(updatedDLp), toString(lae), toString(laea)], " "))
1190- if ((error == error))
1191- then (state ++ refreshDLpActions)
1192- else throw("Strict value is not equal to itself.")
1193- }
1194- else throw("Strict value is not equal to itself.")
1195- }
1196- else throw("Strict value is not equal to itself.")
1197- }
1198- else throw("Strict value is not equal to itself.")
1199- }
1200- else throw("Strict value is not equal to itself.")
1201- }
1202- else throw("Strict value is not equal to itself.")
1203- }
999+ let r = cg(i)
1000+ let outAmtAmt = r._1
1001+ let outPrAmt = r._2
1002+ let pmtAmt = r._3
1003+ let pmtAssetId = r._4
1004+ let state = r._5
1005+ let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1006+ if ((b == b))
1007+ then state
12041008 else throw("Strict value is not equal to itself.")
12051009 }
12061010
12281032 else throwErr("exactly 1 payment are expected")]
12291033 if ((checks == checks))
12301034 then {
1231- let $t04255142706 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId)
1232- let state = $t04255142706._1
1233- let totalAmount = $t04255142706._2
1035+ let $t03625836413 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId)
1036+ let state = $t03625836413._1
1037+ let totalAmount = $t03625836413._2
12341038 $Tuple2(state, totalAmount)
1235- }
1236- else throw("Strict value is not equal to itself.")
1237- }
1238-
1239-
1240-
1241-@Callable(i)
1242-func refreshDLp () = {
1243- let lastRefreshedBlockHeight = valueOrElse(getInteger(keyDLpRefreshedHeight), 0)
1244- let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= dLpRefreshDelay))
1245- then unit
1246- else throwErr(makeString([toString(dLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1247- if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1248- then {
1249- let dLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyDLp), "0")), fmtErr("invalid dLp"))
1250- let $t04323043294 = refreshDLpInternal(0, 0, 0)
1251- let dLpUpdateActions = $t04323043294._1
1252- let updatedDLp = $t04323043294._2
1253- let actions = if ((dLp != updatedDLp))
1254- then dLpUpdateActions
1255- else throwErr("nothing to refresh")
1256- $Tuple2(actions, toString(updatedDLp))
12571039 }
12581040 else throw("Strict value is not equal to itself.")
12591041 }
12781060 let newY = getYD(xp, index, D1)
12791061 let dy = (xp[index] - newY)
12801062 let totalGetRaw = max([0, toInt((dy - big1))])
1281- let $t04419444243 = takeFee(totalGetRaw)
1282- let totalGet = $t04419444243._1
1283- let feeAmount = $t04419444243._2
1063+ let $t03720337258 = takeFee(totalGetRaw, outFee)
1064+ let totalGet = $t03720337258._1
1065+ let feeAmount = $t03720337258._2
12841066 $Tuple2(nil, $Tuple2(totalGet, feeAmount))
12851067 }
12861068
12941076 let lpId = poolConfig[idxLPAsId]
12951077 let amBalance = getAccBalance(amId)
12961078 let prBalance = getAccBalance(prId)
1297- let $t04458844703 = {
1079+ let $t03760337718 = {
12981080 let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, lpAssetAmount], nil)
12991081 if ($isInstanceOf(@, "(Int, Int)"))
13001082 then @
13011083 else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
13021084 }
1303- let totalGet = $t04458844703._1
1304- let feeAmount = $t04458844703._2
1085+ let totalGet = $t03760337718._1
1086+ let feeAmount = $t03760337718._2
13051087 let r = ego("", lpId, lpAssetAmount, this)
13061088 let outAmAmt = r._1
13071089 let outPrAmt = r._2
13291111 else if ((noLessThenPriceAsset > outPrAmt))
13301112 then throw(((("Failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
13311113 else {
1332- let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt))
13331114 let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
13341115 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1335- then {
1336- let $t04587145952 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1337- let refreshDLpActions = $t04587145952._1
1338- let updatedDLp = $t04587145952._2
1339- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1340- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1341- then (state ++ refreshDLpActions)
1342- else throw("Strict value is not equal to itself.")
1343- }
1116+ then state
13441117 else throw("Strict value is not equal to itself.")
13451118 }
13461119 }
13581131 let factoryCfg = gfc()
13591132 let lpAssetId = fromBase58String(cfg[idxLPAsId])
13601133 let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
1361- let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
13621134 let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil)
13631135 if ((unstakeInv == unstakeInv))
13641136 then {
13651137 let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1366- let outAmAmt = r._1
1367- let outPrAmt = r._2
13681138 let sts = parseIntValue(r._9)
13691139 let state = r._10
13701140 let v = if (if (igs())
13761146 then {
13771147 let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
13781148 if ((burnA == burnA))
1379- then {
1380- let $t04701547096 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1381- let refreshDLpActions = $t04701547096._1
1382- let updatedDLp = $t04701547096._2
1383- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1384- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1385- then (state ++ refreshDLpActions)
1386- else throw("Strict value is not equal to itself.")
1387- }
1149+ then state
13881150 else throw("Strict value is not equal to itself.")
13891151 }
13901152 else throw("Strict value is not equal to itself.")
14081170 else throw("no payments are expected")]
14091171 if ((checks == checks))
14101172 then {
1411- let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
14121173 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
14131174 if ((unstakeInv == unstakeInv))
14141175 then {
14251186 then {
14261187 let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
14271188 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1428- then {
1429- let $t04834448425 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1430- let refreshDLpActions = $t04834448425._1
1431- let updatedDLp = $t04834448425._2
1432- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1433- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1434- then (state ++ refreshDLpActions)
1435- else throw("Strict value is not equal to itself.")
1436- }
1189+ then state
14371190 else throw("Strict value is not equal to itself.")
14381191 }
14391192 else throw("Strict value is not equal to itself.")
14741227 let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), unstakeAmount], nil)
14751228 if ((unstakeInv == unstakeInv))
14761229 then {
1477- let $t04935949547 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId)
1478- let state = $t04935949547._1
1479- let totalAmount = $t04935949547._2
1230+ let $t04155641744 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId)
1231+ let state = $t04155641744._1
1232+ let totalAmount = $t04155641744._2
14801233 $Tuple2(state, totalAmount)
14811234 }
14821235 else throw("Strict value is not equal to itself.")
14921245 let amId = poolConfig[idxAmAsId]
14931246 let prId = poolConfig[idxPrAsId]
14941247 let lpId = poolConfig[idxLPAsId]
1495- let $t04980649909 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true)
1496- let lpAmount = $t04980649909._1
1497- let state = $t04980649909._2
1498- let feeAmount = $t04980649909._3
1499- let bonus = $t04980649909._4
1248+ let $t04200342106 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true)
1249+ let lpAmount = $t04200342106._1
1250+ let state = $t04200342106._2
1251+ let feeAmount = $t04200342106._3
1252+ let bonus = $t04200342106._4
15001253 $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus))
15011254 }
15021255
15081261 let amId = poolConfig[idxAmAsId]
15091262 let prId = poolConfig[idxPrAsId]
15101263 let lpId = poolConfig[idxLPAsId]
1511- let $t05018850292 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false)
1512- let lpAmount = $t05018850292._1
1513- let state = $t05018850292._2
1514- let feeAmount = $t05018850292._3
1515- let bonus = $t05018850292._4
1264+ let $t04238542489 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false)
1265+ let lpAmount = $t04238542489._1
1266+ let state = $t04238542489._2
1267+ let feeAmount = $t04238542489._3
1268+ let bonus = $t04238542489._4
15161269 $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus))
15171270 }
15181271
15841337 }
15851338
15861339
1587-
1588-@Callable(i)
1589-func getFeeREADONLY () = $Tuple2(nil, fee)
1590-
1591-
15921340 @Verifier(tx)
15931341 func verify () = {
15941342 let targetPublicKey = match m() {
16021350 match tx {
16031351 case order: Order =>
16041352 let matcherPub = mp()
1605- let orderValid = validateMatcherOrderAllowed(order)
1353+ let orderValid = moa(order)
16061354 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
16071355 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
16081356 if (if (if (orderValid)
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let scale8 = 100000000
55
66 let scale8BigInt = toBigInt(100000000)
77
88 let scale18 = toBigInt(1000000000000000000)
99
1010 let zeroBigInt = toBigInt(0)
1111
1212 let big0 = toBigInt(0)
1313
1414 let big1 = toBigInt(1)
1515
1616 let big2 = toBigInt(2)
17-
18-let big3 = toBigInt(3)
19-
20-let big4 = toBigInt(4)
2117
2218 let slippage4D = toBigInt((scale8 - ((scale8 * 1) / scale8)))
2319
2420 let wavesString = "WAVES"
2521
2622 let Amult = "100"
2723
2824 let Dconv = "1"
2925
3026 let SEP = "__"
3127
3228 let EMPTY = ""
3329
3430 let PoolActive = 1
3531
3632 let PoolPutDis = 2
3733
3834 let PoolMatcherDis = 3
3935
4036 let PoolShutdown = 4
4137
4238 let idxPoolAddress = 1
4339
4440 let idxPoolSt = 2
4541
4642 let idxLPAsId = 3
4743
4844 let idxAmAsId = 4
4945
5046 let idxPrAsId = 5
5147
5248 let idxAmtAsDcm = 6
5349
5450 let idxPriceAsDcm = 7
5551
5652 let idxIAmtAsId = 8
5753
5854 let idxIPriceAsId = 9
5955
6056 let idxFactStakCntr = 1
6157
6258 let idxFactoryRestCntr = 6
6359
6460 let idxFactSlippCntr = 7
6561
6662 let idxFactGwxRewCntr = 10
6763
6864 let feeDefault = fraction(10, scale8, 10000)
6965
7066 func t1 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult))
7167
7268
7369 func f1 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18))
7470
7571
76-func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round))
77-
78-
7972 func ts (amt,resScale,curScale) = fraction(amt, resScale, curScale)
8073
8174
8275 func abs (val) = if ((zeroBigInt > val))
8376 then -(val)
8477 else val
8578
8679
8780 func absBigInt (val) = if ((zeroBigInt > val))
8881 then -(val)
8982 else val
9083
9184
9285 func fc () = "%s__factoryContract"
9386
9487
9588 func mpk () = "%s__managerPublicKey"
9689
9790
9891 func pmpk () = "%s__pendingManagerPublicKey"
9992
10093
10194 func pl () = "%s%s__price__last"
10295
10396
10497 func ph (h,t) = makeString(["%s%s%d%d__price__history", toString(h), toString(t)], SEP)
10598
10699
107100 func pau (ua,txId) = ((("%s%s%s__P__" + ua) + "__") + txId)
108101
109102
110103 func gau (ua,txId) = ((("%s%s%s__G__" + ua) + "__") + txId)
111104
112105
113106 func aa () = "%s__amountAsset"
114107
115108
116109 func pa () = "%s__priceAsset"
117110
118111
119112 func amp () = "%s__amp"
120113
121114
122115 func ada () = "%s__addonAddr"
123116
124117
125-let keyFee = "%s__fee"
126-
127-let fee = valueOrElse(getInteger(this, keyFee), feeDefault)
128-
129-let keyDLp = makeString(["%s", "dLp"], SEP)
130-
131-let keyDLpRefreshedHeight = makeString(["%s", "dLpRefreshedHeight"], SEP)
132-
133-let keyDLpRefreshDelay = makeString(["%s", "refreshDLpDelay"], SEP)
134-
135-let dLpRefreshDelayDefault = 1
136-
137-let dLpRefreshDelay = valueOrElse(getInteger(this, keyDLpRefreshDelay), dLpRefreshDelayDefault)
138-
139118 func fcfg () = "%s__factoryConfig"
140119
141120
142121 func mtpk () = "%s%s__matcher__publicKey"
143122
144123
145124 func pc (iAmtAs,iPrAs) = (((("%d%d%s__" + iAmtAs) + "__") + iPrAs) + "__config")
146125
147126
148127 func mba (bAStr) = ("%s%s%s__mappings__baseAsset2internalId__" + bAStr)
149128
150129
151130 func aps () = "%s__shutdown"
152131
153132
154133 func keyAllowedLpStableScriptHash () = "%s__allowedLpStableScriptHash"
155134
156135
157136 func keyFeeCollectorAddress () = "%s__feeCollectorAddress"
158137
159138
160139 func toe (orV,sendrV,matchV) = throw(((((("Failed: ordValid=" + toString(orV)) + " sndrValid=") + toString(sendrV)) + " mtchrValid=") + toString(matchV)))
161140
162141
163142 func str (val) = match val {
164143 case valStr: String =>
165144 valStr
166145 case _ =>
167146 throw("fail cast to String")
168147 }
169148
170149
171150 func strf (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], ""))
172151
173152
174153 func intf (addr,key) = valueOrErrorMessage(getInteger(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], ""))
175154
176155
177156 func throwErr (msg) = throw(makeString(["lp_stable.ride:", msg], " "))
178157
179158
180-func fmtErr (msg) = makeString(["lp_stable.ride:", msg], " ")
159+let fca = addressFromStringValue(strf(this, fc()))
181160
161+let inFee = {
162+ let @ = invoke(fca, "getInFeeREADONLY", [toString(this)], nil)
163+ if ($isInstanceOf(@, "Int"))
164+ then @
165+ else throw(($getType(@) + " couldn't be cast to Int"))
166+ }
182167
183-let fca = addressFromStringValue(strf(this, fc()))
168+let outFee = {
169+ let @ = invoke(fca, "getOutFeeREADONLY", [toString(this)], nil)
170+ if ($isInstanceOf(@, "Int"))
171+ then @
172+ else throw(($getType(@) + " couldn't be cast to Int"))
173+ }
184174
185175 let A = strf(this, amp())
186176
187177 func igs () = valueOrElse(getBoolean(fca, aps()), false)
188178
189179
190180 func mp () = fromBase58String(strf(fca, mtpk()))
191181
192182
193183 let feeCollectorAddress = addressFromStringValue(strf(fca, keyFeeCollectorAddress()))
194184
195185 func gpc () = {
196186 let amtAs = strf(this, aa())
197187 let priceAs = strf(this, pa())
198188 let iPriceAs = intf(fca, mba(priceAs))
199189 let iAmtAs = intf(fca, mba(amtAs))
200190 split(strf(fca, pc(toString(iAmtAs), toString(iPriceAs))), SEP)
201191 }
202192
203193
204194 func parseAssetId (input) = if ((input == wavesString))
205195 then unit
206196 else fromBase58String(input)
207197
208198
209199 func assetIdToString (input) = if ((input == unit))
210200 then wavesString
211201 else toBase58String(value(input))
212202
213203
214204 func parsePoolConfig (poolConfig) = $Tuple7(addressFromStringValue(poolConfig[idxPoolAddress]), parseIntValue(poolConfig[idxPoolSt]), fromBase58String(poolConfig[idxLPAsId]), parseAssetId(poolConfig[idxAmAsId]), parseAssetId(poolConfig[idxPrAsId]), parseIntValue(poolConfig[idxAmtAsDcm]), parseIntValue(poolConfig[idxPriceAsDcm]))
215205
216206
217207 let poolConfigParsed = parsePoolConfig(gpc())
218208
219-let $t074067592 = poolConfigParsed
209+let $t069097095 = poolConfigParsed
220210
221-let cfgPoolAddress = $t074067592._1
211+let cfgPoolAddress = $t069097095._1
222212
223-let cfgPoolStatus = $t074067592._2
213+let cfgPoolStatus = $t069097095._2
224214
225-let cfgLpAssetId = $t074067592._3
215+let cfgLpAssetId = $t069097095._3
226216
227-let cfgAmountAssetId = $t074067592._4
217+let cfgAmountAssetId = $t069097095._4
228218
229-let cfgPriceAssetId = $t074067592._5
219+let cfgPriceAssetId = $t069097095._5
230220
231-let cfgAmountAssetDecimals = $t074067592._6
221+let cfgAmountAssetDecimals = $t069097095._6
232222
233-let cfgPriceAssetDecimals = $t074067592._7
223+let cfgPriceAssetDecimals = $t069097095._7
234224
235225 func gfc () = split(strf(fca, fcfg()), SEP)
236226
237227
238228 let factoryConfig = gfc()
239229
240230 let stakingContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactStakCntr]), "Invalid staking contract address")
241231
242232 let slipageContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactSlippCntr]), "Invalid slipage contract address")
243233
244234 let gwxContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactGwxRewCntr]), "Invalid gwx contract address")
245235
246236 let restContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactoryRestCntr]), "Invalid gwx contract address")
247237
248238 func dataPutActionInfo (inAmtAssetAmt,inPriceAssetAmt,outLpAmt,price,slipByUser,slippageReal,txHeight,txTimestamp,slipageAmAmt,slipagePrAmt) = makeString(["%d%d%d%d%d%d%d%d%d%d", toString(inAmtAssetAmt), toString(inPriceAssetAmt), toString(outLpAmt), toString(price), toString(slipByUser), toString(slippageReal), toString(txHeight), toString(txTimestamp), toString(slipageAmAmt), toString(slipagePrAmt)], SEP)
249239
250240
251241 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)
252242
253243
254244 func getAccBalance (assetId) = if ((assetId == "WAVES"))
255245 then wavesBalance(this).available
256246 else assetBalance(this, fromBase58String(assetId))
257247
258248
259249 func cpbi (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
260250
261251
262252 func vad (A1,A2,slippage) = {
263253 let diff = fraction((A1 - A2), scale8BigInt, A2)
264254 let pass = ((slippage - abs(diff)) > zeroBigInt)
265255 if (!(pass))
266256 then throw(("Big slpg: " + toString(diff)))
267257 else $Tuple2(pass, min([A1, A2]))
268258 }
269259
270260
271261 func vd (D1,D0,slpg) = {
272262 let diff = fraction(D0, scale8BigInt, D1)
273263 let fail = (slpg > diff)
274264 if (if (fail)
275265 then true
276266 else (D0 > D1))
277267 then throw(((((((toString(D0) + " ") + toString(D1)) + " ") + toString(diff)) + " ") + toString(slpg)))
278268 else fail
279269 }
280270
281271
282272 func pcp (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
283273 let amtAsAmtX18 = t1(amAmt, amAssetDcm)
284274 let prAsAmtX18 = t1(prAmt, prAssetDcm)
285275 cpbi(prAsAmtX18, amtAsAmtX18)
286276 }
287277
288278
289279 func calcPrices (amAmt,prAmt,lpAmt) = {
290280 let cfg = gpc()
291281 let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm])
292282 let prAsDcm = parseIntValue(cfg[idxPriceAsDcm])
293283 let priceX18 = pcp(amtAsDcm, prAsDcm, amAmt, prAmt)
294284 let amAmtX18 = t1(amAmt, amtAsDcm)
295285 let prAmtX18 = t1(prAmt, prAsDcm)
296286 let lpAmtX18 = t1(lpAmt, scale8)
297287 let lpPrInAmAsX18 = cpbi(amAmtX18, lpAmtX18)
298288 let lpPrInPrAsX18 = cpbi(prAmtX18, lpAmtX18)
299289 [priceX18, lpPrInAmAsX18, lpPrInPrAsX18]
300290 }
301291
302292
303293 func calculatePrices (amAmt,prAmt,lpAmt) = {
304294 let p = calcPrices(amAmt, prAmt, lpAmt)
305295 [f1(p[0], scale8), f1(p[1], scale8), f1(p[2], scale8)]
306296 }
307297
308298
309-func takeFee (amount) = {
310- let feeAmount = fraction(amount, fee, scale8)
299+func takeFee (amount,fee) = {
300+ let feeAmount = if ((fee == 0))
301+ then 0
302+ else fraction(amount, fee, scale8)
311303 $Tuple2((amount - feeAmount), feeAmount)
312304 }
313305
314306
315307 func ego (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
316308 let cfg = gpc()
317309 let lpId = cfg[idxLPAsId]
318310 let amId = cfg[idxAmAsId]
319311 let prId = cfg[idxPrAsId]
320312 let amDcm = parseIntValue(cfg[idxAmtAsDcm])
321313 let prDcm = parseIntValue(cfg[idxPriceAsDcm])
322314 let sts = cfg[idxPoolSt]
323315 let lpEmiss = valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "Wrong LP id").quantity
324316 if ((lpId != pmtAssetId))
325317 then throw("Wrong pmt asset")
326318 else {
327319 let amBalance = getAccBalance(amId)
328320 let amBalanceX18 = t1(amBalance, amDcm)
329321 let prBalance = getAccBalance(prId)
330322 let prBalanceX18 = t1(prBalance, prDcm)
331323 let curPriceX18 = cpbi(prBalanceX18, amBalanceX18)
332324 let curPrice = f1(curPriceX18, scale8)
333325 let pmtLpAmtX18 = t1(pmtLpAmt, scale8)
334326 let lpEmissX18 = t1(lpEmiss, scale8)
335327 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissX18)
336328 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissX18)
337- let outAmAmt = fromX18Round(outAmAmtX18, amDcm, FLOOR)
338- let outPrAmt = fromX18Round(outPrAmtX18, prDcm, FLOOR)
329+ let outAmAmt = f1(outAmAmtX18, amDcm)
330+ let outPrAmt = f1(outPrAmtX18, prDcm)
339331 let state = if ((txId58 == ""))
340332 then nil
341333 else [ScriptTransfer(userAddress, outAmAmt, if ((amId == "WAVES"))
342334 then unit
343335 else fromBase58String(amId)), ScriptTransfer(userAddress, outPrAmt, if ((prId == "WAVES"))
344336 then unit
345337 else fromBase58String(prId)), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAmAmt, outPrAmt, pmtLpAmt, curPrice, height, lastBlock.timestamp)), IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice)]
346338 $Tuple10(outAmAmt, outPrAmt, amId, prId, amBalance, prBalance, lpEmiss, curPriceX18, sts, state)
347339 }
348340 }
349341
350342
351343 func epo (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,userAddress,isEval,emitLp,isOneAsset,validateSlippage,pmtAmt,pmtId) = {
352344 let cfg = gpc()
353345 let lpId = fromBase58String(cfg[idxLPAsId])
354346 let amIdStr = cfg[idxAmAsId]
355347 let prIdStr = cfg[idxPrAsId]
356348 let inAmIdStr = cfg[idxIAmtAsId]
357349 let inPrIdStr = cfg[idxIPriceAsId]
358350 let amtDcm = parseIntValue(cfg[idxAmtAsDcm])
359351 let priceDcm = parseIntValue(cfg[idxPriceAsDcm])
360352 let sts = cfg[idxPoolSt]
361353 let lpEm = valueOrErrorMessage(assetInfo(lpId), "Wr lp as").quantity
362354 let amBalance = if (isEval)
363355 then getAccBalance(amIdStr)
364356 else if (if (isOneAsset)
365357 then (pmtId == amIdStr)
366358 else false)
367359 then (getAccBalance(amIdStr) - pmtAmt)
368360 else if (isOneAsset)
369361 then getAccBalance(amIdStr)
370362 else (getAccBalance(amIdStr) - inAmAmt)
371363 let prBalance = if (isEval)
372364 then getAccBalance(prIdStr)
373365 else if (if (isOneAsset)
374366 then (pmtId == prIdStr)
375367 else false)
376368 then (getAccBalance(prIdStr) - pmtAmt)
377369 else if (isOneAsset)
378370 then getAccBalance(prIdStr)
379371 else (getAccBalance(prIdStr) - inPrAmt)
380372 let inAmAssetAmtX18 = t1(inAmAmt, amtDcm)
381373 let inPrAssetAmtX18 = t1(inPrAmt, priceDcm)
382374 let userPriceX18 = cpbi(inPrAssetAmtX18, inAmAssetAmtX18)
383375 let amBalanceX18 = t1(amBalance, amtDcm)
384376 let prBalanceX18 = t1(prBalance, priceDcm)
385377 let r = if ((lpEm == 0))
386378 then {
387379 let curPriceX18 = zeroBigInt
388380 let slippageX18 = zeroBigInt
389381 let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN)
390382 $Tuple5(f1(lpAmtX18, scale8), f1(inAmAssetAmtX18, amtDcm), f1(inPrAssetAmtX18, priceDcm), cpbi((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
391383 }
392384 else {
393385 let curPriceX18 = cpbi(prBalanceX18, amBalanceX18)
394386 let slippageRealX18 = fraction(abs((curPriceX18 - userPriceX18)), scale18, curPriceX18)
395387 let slippageX18 = t1(slippage, scale8)
396388 if (if (if (validateSlippage)
397389 then (curPriceX18 != zeroBigInt)
398390 else false)
399391 then (slippageRealX18 > slippageX18)
400392 else false)
401393 then throw(((("Price slippage " + toString(slippageRealX18)) + " > ") + toString(slippageX18)))
402394 else {
403395 let lpEmissionX18 = t1(lpEm, scale8)
404396 let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
405397 let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
406398 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
407399 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
408400 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
409401 let expAmtAssetAmtX18 = expectedAmts._1
410402 let expPriceAssetAmtX18 = expectedAmts._2
411403 let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
412- $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceDcm, CEILING), curPriceX18, slippageX18)
404+ $Tuple5(f1(lpAmtX18, scale8), f1(expAmtAssetAmtX18, amtDcm), f1(expPriceAssetAmtX18, priceDcm), curPriceX18, slippageX18)
413405 }
414406 }
415407 let calcLpAmt = r._1
416408 let calcAmAssetPmt = r._2
417409 let calcPrAssetPmt = r._3
418410 let curPrice = f1(r._4, scale8)
419411 let slippageCalc = f1(r._5, scale8)
420412 if ((0 >= calcLpAmt))
421413 then throw("LP <= 0")
422414 else {
423415 let emitLpAmt = if (!(emitLp))
424416 then 0
425417 else calcLpAmt
426418 let amDiff = (inAmAmt - calcAmAssetPmt)
427419 let prDiff = (inPrAmt - calcPrAssetPmt)
428- let $t01811218457 = if (if (isOneAsset)
420+ let $t01756217907 = if (if (isOneAsset)
429421 then (pmtId == amIdStr)
430422 else false)
431423 then $Tuple2(pmtAmt, 0)
432424 else if (if (isOneAsset)
433425 then (pmtId == prIdStr)
434426 else false)
435427 then $Tuple2(0, pmtAmt)
436428 else $Tuple2(calcAmAssetPmt, calcPrAssetPmt)
437- let writeAmAmt = $t01811218457._1
438- let writePrAmt = $t01811218457._2
429+ let writeAmAmt = $t01756217907._1
430+ let writePrAmt = $t01756217907._2
439431 let commonState = [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(userAddress, txId58), dataPutActionInfo(writeAmAmt, writePrAmt, emitLpAmt, curPrice, slippage, slippageCalc, height, lastBlock.timestamp, amDiff, prDiff))]
440432 $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEm, lpId, sts, commonState, amDiff, prDiff, inAmId, inPrId)
441433 }
442434 }
443435
444436
445-func getD (xp) = {
446- let xp0 = xp[0]
447- let xp1 = xp[1]
448- let s = (xp0 + xp1)
449- if ((s == big0))
450- then big0
451- else {
452- let a = parseIntValue(A)
453- let ann = (a * 2)
454- let p = fraction(xp0, xp1, big1)
455- let xp0_xp1_n_n = fraction(p, big4, big1)
456- let ann_s = fraction(toBigInt(ann), s, big1)
457- let ann_1 = toBigInt((ann - 1))
458- func calcDNext (d) = {
459- let dd = fraction(d, d, big1)
460- let ddd = fraction(dd, d, big1)
461- let dp = fraction(ddd, big1, xp0_xp1_n_n)
462- fraction((ann_s + fraction(dp, big2, big1)), d, (fraction(ann_1, d, big1) + fraction(big3, dp, big1)), CEILING)
463- }
464-
465- func calc (acc,i) = if (acc._2)
466- then acc
467- else {
468- let d = acc._1
469- let dNext = calcDNext(d)
470- let dDiffRaw = toInt((dNext - value(d)))
471- let dDiff = if ((0 > dDiffRaw))
472- then -(dDiffRaw)
473- else dDiffRaw
474- if ((1 >= dDiff))
475- then $Tuple2(dNext, true)
476- else $Tuple2(dNext, false)
477- }
478-
479- let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
480- let $t02038520433 = {
481- let $l = arr
482- let $s = size($l)
483- let $acc0 = $Tuple2(s, false)
484- func $f0_1 ($a,$i) = if (($i >= $s))
485- then $a
486- else calc($a, $l[$i])
487-
488- func $f0_2 ($a,$i) = if (($i >= $s))
489- then $a
490- else throw("List size exceeds 15")
491-
492- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15)
493- }
494- let d = $t02038520433._1
495- let found = $t02038520433._2
496- if (found)
497- then d
498- else throw(("D calculation error, D = " + toString(d)))
499- }
500- }
501-
502-
503-func getDOld (xp) = {
504- let n = big2
505- let xp0 = xp[0]
506- let xp1 = xp[1]
507- let aPrecision = parseBigIntValue(Amult)
508- let a = (parseBigIntValue(A) * aPrecision)
509- let s = (xp0 + xp1)
510- if ((s == big0))
511- then big0
512- else {
513- let ann = (a * n)
514- let xp0_xp1_n_n = (((xp0 * xp1) * n) * n)
515- let ann_s_aPrecision = ((ann * s) / aPrecision)
516- let ann_aPrecision = (ann - aPrecision)
517- let n1 = (n + big1)
518- func calc (acc,cur) = {
519- let $t02106221082 = acc
520- let d = $t02106221082._1
521- let found = $t02106221082._2
522- if ((found != unit))
523- then acc
524- else {
525- let dp = (((d * d) * d) / xp0_xp1_n_n)
526- let dNext = (((ann_s_aPrecision + (dp * n)) * d) / (((ann_aPrecision * d) / aPrecision) + (n1 * dp)))
527- let dDiff = absBigInt((dNext - value(d)))
528- if ((big1 >= dDiff))
529- then $Tuple2(dNext, cur)
530- else $Tuple2(dNext, unit)
531- }
532- }
533-
534- let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
535- let $t02150321550 = {
536- let $l = arr
537- let $s = size($l)
538- let $acc0 = $Tuple2(s, unit)
539- func $f0_1 ($a,$i) = if (($i >= $s))
540- then $a
541- else calc($a, $l[$i])
542-
543- func $f0_2 ($a,$i) = if (($i >= $s))
544- then $a
545- else throw("List size exceeds 15")
546-
547- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15)
548- }
549- let d = $t02150321550._1
550- let found = $t02150321550._2
551- if ((found != unit))
552- then d
553- else throw(("D calculation error, D = " + toString(d)))
554- }
555- }
556-
557-
558-func getYD (xp,i,D) = {
559- let n = big2
560- let x = xp[if ((i == 0))
561- then 1
562- else 0]
563- let aPrecision = parseBigIntValue(Amult)
564- let a = (parseBigIntValue(A) * aPrecision)
565- let s = x
566- let ann = (a * n)
567- let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n))
568- let b = ((s + ((D * aPrecision) / ann)) - D)
569- func calc (acc,cur) = {
570- let $t02205022070 = acc
571- let y = $t02205022070._1
572- let found = $t02205022070._2
573- if ((found != unit))
574- then acc
575- else {
576- let yNext = (((y * y) + c) / ((big2 * y) + b))
577- let yDiff = absBigInt((yNext - value(y)))
578- if ((big1 >= yDiff))
579- then $Tuple2(yNext, cur)
580- else $Tuple2(yNext, unit)
581- }
582- }
583-
584- let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
585- let $t02237722424 = {
586- let $l = arr
587- let $s = size($l)
588- let $acc0 = $Tuple2(D, unit)
589- func $f0_1 ($a,$i) = if (($i >= $s))
590- then $a
591- else calc($a, $l[$i])
592-
593- func $f0_2 ($a,$i) = if (($i >= $s))
594- then $a
595- else throw("List size exceeds 15")
596-
597- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15)
598- }
599- let y = $t02237722424._1
600- let found = $t02237722424._2
601- if ((found != unit))
602- then y
603- else throw(("Y calculation error, Y = " + toString(y)))
604- }
605-
606-
607-func calcDLp (amountBalance,priceBalance,lpEmission) = {
608- let updatedDLp = fraction(getD([amountBalance, priceBalance]), scale18, lpEmission)
609- if ((lpEmission == big0))
610- then big0
611- else updatedDLp
612- }
613-
614-
615-func calcCurrentDLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = {
616- let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta)
617- let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta)
618- let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta)
619- let currentDLp = calcDLp(amountAssetBalance, priceAssetBalance, lpAssetEmission)
620- currentDLp
621- }
622-
623-
624-func refreshDLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = {
625- let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta)
626- let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta)
627- let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta)
628- let updatedDLp = calcDLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission))
629- let actions = [IntegerEntry(keyDLpRefreshedHeight, height), StringEntry(keyDLp, toString(updatedDLp))]
630- $Tuple2(actions, updatedDLp)
631- }
632-
633-
634-func validateUpdatedDLp (oldDLp,updatedDLp) = if ((updatedDLp >= oldDLp))
635- then true
636- else throwErr("updated DLp lower than current DLp")
637-
638-
639-func validateMatcherOrderAllowed (order) = {
640- let amountAssetAmount = order.amount
641- let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR)
642- let $t02436324575 = if ((order.orderType == Buy))
643- then $Tuple2(amountAssetAmount, -(priceAssetAmount))
644- else $Tuple2(-(amountAssetAmount), priceAssetAmount)
645- let amountAssetBalanceDelta = $t02436324575._1
646- let priceAssetBalanceDelta = $t02436324575._2
437+func moa (order) = {
438+ let cfg = gpc()
439+ let amtAsId = cfg[idxAmAsId]
440+ let prAsId = cfg[idxPrAsId]
441+ let sts = parseIntValue(cfg[idxPoolSt])
442+ let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm])
443+ let prAsDcm = parseIntValue(cfg[idxPriceAsDcm])
444+ let accAmtAsBalance = getAccBalance(amtAsId)
445+ let accPrAsBalance = getAccBalance(prAsId)
446+ let curPriceX18 = if ((order.orderType == Buy))
447+ then pcp(amtAsDcm, prAsDcm, (accAmtAsBalance + order.amount), accPrAsBalance)
448+ else pcp(amtAsDcm, prAsDcm, (accAmtAsBalance - order.amount), accPrAsBalance)
449+ let curPrice = f1(curPriceX18, scale8)
647450 if (if (if (igs())
648451 then true
649- else (cfgPoolStatus == PoolMatcherDis))
452+ else (sts == PoolMatcherDis))
650453 then true
651- else (cfgPoolStatus == PoolShutdown))
454+ else (sts == PoolShutdown))
652455 then throw("Admin blocked")
653- else if (if ((order.assetPair.amountAsset != cfgAmountAssetId))
654- then true
655- else (order.assetPair.priceAsset != cfgPriceAssetId))
656- then throw("Wr assets")
657- else {
658- let dLp = parseBigIntValue(getStringValue(this, keyDLp))
659- let $t02490525005 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
660- let unusedActions = $t02490525005._1
661- let dLpNew = $t02490525005._2
662- let isOrderValid = (dLpNew >= dLp)
663- isOrderValid
664- }
456+ else {
457+ let orAmtAsset = order.assetPair.amountAsset
458+ let orAmtAsStr = if ((orAmtAsset == unit))
459+ then "WAVES"
460+ else toBase58String(value(orAmtAsset))
461+ let orPrAsset = order.assetPair.priceAsset
462+ let orPrAsStr = if ((orPrAsset == unit))
463+ then "WAVES"
464+ else toBase58String(value(orPrAsset))
465+ if (if ((orAmtAsStr != amtAsId))
466+ then true
467+ else (orPrAsStr != prAsId))
468+ then throw("Wr assets")
469+ else {
470+ let orderPrice = order.price
471+ let priceDcm = fraction(scale8, prAsDcm, amtAsDcm)
472+ let castOrderPrice = ts(orderPrice, scale8, priceDcm)
473+ let isOrderPriceValid = if ((order.orderType == Buy))
474+ then (curPrice >= castOrderPrice)
475+ else (castOrderPrice >= curPrice)
476+ true
477+ }
478+ }
665479 }
666480
667481
668482 func cg (i) = if ((size(i.payments) != 1))
669483 then throw("1 pmnt exp")
670484 else {
671485 let pmt = value(i.payments[0])
672486 let pmtAssetId = value(pmt.assetId)
673487 let pmtAmt = pmt.amount
674488 let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller)
675489 let outAmAmt = r._1
676490 let outPrAmt = r._2
677491 let sts = parseIntValue(r._9)
678492 let state = r._10
679493 if (if (igs())
680494 then true
681495 else (sts == PoolShutdown))
682496 then throw(("Admin blocked: " + toString(sts)))
683497 else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state)
684498 }
685499
686500
687501 func cp (caller,txId,amAsPmt,prAsPmt,slippage,emitLp,isOneAsset,validateSlippage,pmtAmt,pmtId) = {
688502 let r = epo(txId, slippage, value(amAsPmt).amount, value(amAsPmt).assetId, value(prAsPmt).amount, value(prAsPmt).assetId, caller, (txId == ""), emitLp, isOneAsset, validateSlippage, pmtAmt, pmtId)
689503 let sts = parseIntValue(r._8)
690504 if (if (if (igs())
691505 then true
692506 else (sts == PoolPutDis))
693507 then true
694508 else (sts == PoolShutdown))
695509 then throw(("Blocked:" + toString(sts)))
696510 else r
697511 }
698512
699513
514+func getD (xp) = {
515+ let n = big2
516+ let xp0 = xp[0]
517+ let xp1 = xp[1]
518+ let aPrecision = parseBigIntValue(Amult)
519+ let a = (parseBigIntValue(A) * aPrecision)
520+ let s = (xp0 + xp1)
521+ if ((s == big0))
522+ then big0
523+ else {
524+ let ann = (a * n)
525+ let xp0_xp1_n_n = (((xp0 * xp1) * n) * n)
526+ let ann_s_aPrecision = ((ann * s) / aPrecision)
527+ let ann_aPrecision = (ann - aPrecision)
528+ let n1 = (n + big1)
529+ func calc (acc,cur) = {
530+ let $t02245922479 = acc
531+ let d = $t02245922479._1
532+ let found = $t02245922479._2
533+ if ((found != unit))
534+ then acc
535+ else {
536+ let dp = (((d * d) * d) / xp0_xp1_n_n)
537+ let dNext = (((ann_s_aPrecision + (dp * n)) * d) / (((ann_aPrecision * d) / aPrecision) + (n1 * dp)))
538+ let dDiff = absBigInt((dNext - value(d)))
539+ if ((big1 >= dDiff))
540+ then $Tuple2(dNext, cur)
541+ else $Tuple2(dNext, unit)
542+ }
543+ }
544+
545+ let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
546+ let $t02290022947 = {
547+ let $l = arr
548+ let $s = size($l)
549+ let $acc0 = $Tuple2(s, unit)
550+ func $f0_1 ($a,$i) = if (($i >= $s))
551+ then $a
552+ else calc($a, $l[$i])
553+
554+ func $f0_2 ($a,$i) = if (($i >= $s))
555+ then $a
556+ else throw("List size exceeds 15")
557+
558+ $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15)
559+ }
560+ let d = $t02290022947._1
561+ let found = $t02290022947._2
562+ if ((found != unit))
563+ then d
564+ else throw(("D calculation error, D = " + toString(d)))
565+ }
566+ }
567+
568+
569+func getYD (xp,i,D) = {
570+ let n = big2
571+ let x = xp[if ((i == 0))
572+ then 1
573+ else 0]
574+ let aPrecision = parseBigIntValue(Amult)
575+ let a = (parseBigIntValue(A) * aPrecision)
576+ let s = x
577+ let ann = (a * n)
578+ let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n))
579+ let b = ((s + ((D * aPrecision) / ann)) - D)
580+ func calc (acc,cur) = {
581+ let $t02344723467 = acc
582+ let y = $t02344723467._1
583+ let found = $t02344723467._2
584+ if ((found != unit))
585+ then acc
586+ else {
587+ let yNext = (((y * y) + c) / ((big2 * y) + b))
588+ let yDiff = absBigInt((yNext - value(y)))
589+ if ((big1 >= yDiff))
590+ then $Tuple2(yNext, cur)
591+ else $Tuple2(yNext, unit)
592+ }
593+ }
594+
595+ let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
596+ let $t02377423821 = {
597+ let $l = arr
598+ let $s = size($l)
599+ let $acc0 = $Tuple2(D, unit)
600+ func $f0_1 ($a,$i) = if (($i >= $s))
601+ then $a
602+ else calc($a, $l[$i])
603+
604+ func $f0_2 ($a,$i) = if (($i >= $s))
605+ then $a
606+ else throw("List size exceeds 15")
607+
608+ $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15)
609+ }
610+ let y = $t02377423821._1
611+ let found = $t02377423821._2
612+ if ((found != unit))
613+ then y
614+ else throw(("Y calculation error, Y = " + toString(y)))
615+ }
616+
617+
700618 func calcPutOneTkn (pmtAmtRaw,pmtAssetId,userAddress,txId,withTakeFee) = {
701619 let poolConfig = gpc()
702620 let amId = poolConfig[idxAmAsId]
703621 let prId = poolConfig[idxPrAsId]
704622 let lpId = poolConfig[idxLPAsId]
705623 let amtDcm = parseIntValue(poolConfig[idxAmtAsDcm])
706624 let priceDcm = parseIntValue(poolConfig[idxPriceAsDcm])
707625 let lpAssetEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity)
708626 let chechEmission = if ((lpAssetEmission > big0))
709627 then true
710628 else throw("initial deposit requires all coins")
711629 if ((chechEmission == chechEmission))
712630 then {
713631 let amBalance = getAccBalance(amId)
714632 let prBalance = getAccBalance(prId)
715- let $t02732227784 = if ((txId == ""))
633+ let $t02460425066 = if ((txId == ""))
716634 then $Tuple2(amBalance, prBalance)
717635 else if ((pmtAssetId == amId))
718636 then if ((pmtAmtRaw > amBalance))
719637 then throw("invalid payment amount")
720638 else $Tuple2((amBalance - pmtAmtRaw), prBalance)
721639 else if ((pmtAssetId == prId))
722640 then if ((pmtAmtRaw > prBalance))
723641 then throw("invalid payment amount")
724642 else $Tuple2(amBalance, (prBalance - pmtAmtRaw))
725643 else throw("wrong pmtAssetId")
726- let amBalanceOld = $t02732227784._1
727- let prBalanceOld = $t02732227784._2
728- let $t02779027966 = if ((pmtAssetId == amId))
644+ let amBalanceOld = $t02460425066._1
645+ let prBalanceOld = $t02460425066._2
646+ let $t02507225248 = if ((pmtAssetId == amId))
729647 then $Tuple2(pmtAmtRaw, 0)
730648 else if ((pmtAssetId == prId))
731649 then $Tuple2(0, pmtAmtRaw)
732650 else throw("invalid payment")
733- let amAmountRaw = $t02779027966._1
734- let prAmountRaw = $t02779027966._2
735- let $t02797028209 = if (withTakeFee)
736- then $Tuple3(takeFee(amAmountRaw)._1, takeFee(prAmountRaw)._1, takeFee(pmtAmtRaw)._2)
651+ let amAmountRaw = $t02507225248._1
652+ let prAmountRaw = $t02507225248._2
653+ let $t02525225506 = if (withTakeFee)
654+ then $Tuple3(takeFee(amAmountRaw, inFee)._1, takeFee(prAmountRaw, inFee)._1, takeFee(pmtAmtRaw, inFee)._2)
737655 else $Tuple3(amAmountRaw, prAmountRaw, 0)
738- let amAmount = $t02797028209._1
739- let prAmount = $t02797028209._2
740- let feeAmount = $t02797028209._3
656+ let amAmount = $t02525225506._1
657+ let prAmount = $t02525225506._2
658+ let feeAmount = $t02525225506._3
741659 let amBalanceNew = (amBalanceOld + amAmount)
742660 let prBalanceNew = (prBalanceOld + prAmount)
743661 let D0 = getD([toBigInt(amBalanceOld), toBigInt(prBalanceOld)])
744662 let D1 = getD([toBigInt(amBalanceNew), toBigInt(prBalanceNew)])
745663 let checkD = if ((D1 > D0))
746664 then true
747665 else throw()
748666 if ((checkD == checkD))
749667 then {
750- let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0, FLOOR)
668+ let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0)
751669 let curPrice = f1(cpbi(t1(prBalanceNew, priceDcm), t1(amBalanceNew, amtDcm)), scale8)
752670 let commonState = [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(userAddress, txId), dataPutActionInfo(amAmountRaw, prAmountRaw, toInt(lpAmount), curPrice, 0, 0, height, lastBlock.timestamp, 0, 0))]
753671 let poolProportion = fraction(prBalanceOld, scale8, amBalanceOld)
754672 let amountAssetPart = fraction(pmtAmtRaw, scale8, (poolProportion + scale8))
755673 let priceAssetPart = (pmtAmtRaw - amountAssetPart)
756674 let lpAmtBoth = fraction(lpAssetEmission, toBigInt(priceAssetPart), toBigInt(prBalanceOld))
757675 let bonus = toInt(fraction((lpAmount - lpAmtBoth), scale8BigInt, lpAmtBoth))
758676 $Tuple4(toInt(lpAmount), commonState, feeAmount, bonus)
759677 }
760678 else throw("Strict value is not equal to itself.")
761679 }
762680 else throw("Strict value is not equal to itself.")
763681 }
764682
765683
766684 func getOneTknV2Internal (outAssetId,minOutAmount,payments,caller,originCaller,transactionId) = {
767685 let poolConfig = gpc()
768686 let lpId = poolConfig[idxLPAsId]
769687 let amId = poolConfig[idxAmAsId]
770688 let prId = poolConfig[idxPrAsId]
771689 let amDecimals = parseIntValue(poolConfig[idxAmtAsDcm])
772690 let prDecimals = parseIntValue(poolConfig[idxPriceAsDcm])
773691 let poolStatus = poolConfig[idxPoolSt]
774692 let userAddress = if ((caller == restContract))
775693 then originCaller
776694 else caller
777695 let pmt = value(payments[0])
778696 let pmtAssetId = value(pmt.assetId)
779697 let pmtAmt = pmt.amount
780- let currentDLp = calcCurrentDLp(big0, big0, big0)
781- if ((currentDLp == currentDLp))
782- then {
783- let txId58 = toBase58String(transactionId)
784- if ((lpId != toBase58String(pmtAssetId)))
785- then throw("Wrong LP")
786- else {
787- let amBalance = getAccBalance(amId)
788- let prBalance = getAccBalance(prId)
789- let $t03027430385 = {
790- let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil)
791- if ($isInstanceOf(@, "(Int, Int)"))
792- then @
793- else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
794- }
795- if (($t03027430385 == $t03027430385))
698+ let txId58 = toBase58String(transactionId)
699+ if ((lpId != toBase58String(pmtAssetId)))
700+ then throw("Wrong LP")
701+ else {
702+ let amBalance = getAccBalance(amId)
703+ let prBalance = getAccBalance(prId)
704+ let $t02750827619 = {
705+ let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil)
706+ if ($isInstanceOf(@, "(Int, Int)"))
707+ then @
708+ else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
709+ }
710+ if (($t02750827619 == $t02750827619))
711+ then {
712+ let feeAmount = $t02750827619._2
713+ let totalGet = $t02750827619._1
714+ let totalAmount = if (if ((minOutAmount > 0))
715+ then (minOutAmount > totalGet)
716+ else false)
717+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
718+ else totalGet
719+ let $t02780928116 = if ((outAssetId == amId))
720+ then $Tuple4(totalAmount, 0, ((amBalance - totalAmount) - feeAmount), prBalance)
721+ else if ((outAssetId == prId))
722+ then $Tuple4(0, totalAmount, amBalance, ((prBalance - totalAmount) - feeAmount))
723+ else throw("invalid out asset id")
724+ let outAm = $t02780928116._1
725+ let outPr = $t02780928116._2
726+ let amBalanceNew = $t02780928116._3
727+ let prBalanceNew = $t02780928116._4
728+ let curPrX18 = cpbi(t1(prBalanceNew, prDecimals), t1(amBalanceNew, amDecimals))
729+ let curPr = f1(curPrX18, scale8)
730+ let outAssetIdOrWaves = if ((outAssetId == "WAVES"))
731+ then unit
732+ else fromBase58String(outAssetId)
733+ let sendFeeToMatcher = if ((feeAmount > 0))
734+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)]
735+ else nil
736+ let state = ([ScriptTransfer(userAddress, totalAmount, outAssetIdOrWaves), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, pmtAmt, curPr, height, lastBlock.timestamp)), IntegerEntry(pl(), curPr), IntegerEntry(ph(height, lastBlock.timestamp), curPr)] ++ sendFeeToMatcher)
737+ if ((state == state))
796738 then {
797- let feeAmount = $t03027430385._2
798- let totalGet = $t03027430385._1
799- let totalAmount = if (if ((minOutAmount > 0))
800- then (minOutAmount > totalGet)
801- else false)
802- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
803- else totalGet
804- let $t03057530882 = if ((outAssetId == amId))
805- then $Tuple4(totalAmount, 0, ((amBalance - totalAmount) - feeAmount), prBalance)
806- else if ((outAssetId == prId))
807- then $Tuple4(0, totalAmount, amBalance, ((prBalance - totalAmount) - feeAmount))
808- else throw("invalid out asset id")
809- let outAm = $t03057530882._1
810- let outPr = $t03057530882._2
811- let amBalanceNew = $t03057530882._3
812- let prBalanceNew = $t03057530882._4
813- let curPrX18 = cpbi(t1(prBalanceNew, prDecimals), t1(amBalanceNew, amDecimals))
814- let curPr = f1(curPrX18, scale8)
815- let outAssetIdOrWaves = if ((outAssetId == "WAVES"))
816- then unit
817- else fromBase58String(outAssetId)
818- let sendFeeToMatcher = if ((feeAmount > 0))
819- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)]
820- else nil
821- let state = ([ScriptTransfer(userAddress, totalAmount, outAssetIdOrWaves), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, pmtAmt, curPr, height, lastBlock.timestamp)), IntegerEntry(pl(), curPr), IntegerEntry(ph(height, lastBlock.timestamp), curPr)] ++ sendFeeToMatcher)
822- if ((state == state))
823- then {
824- let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
825- if ((burn == burn))
826- then {
827- let $t03166732017 = {
828- let feeAmountForCalc = if ((this == feeCollectorAddress))
829- then 0
830- else feeAmount
831- let outInAmountAsset = if ((parseAssetId(outAssetId) == cfgAmountAssetId))
832- then true
833- else false
834- if (outInAmountAsset)
835- then $Tuple2(-((totalGet + feeAmountForCalc)), 0)
836- else $Tuple2(0, -((totalGet + feeAmountForCalc)))
837- }
838- let amountAssetBalanceDelta = $t03166732017._1
839- let priceAssetBalanceDelta = $t03166732017._2
840- let $t03202032128 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
841- let refreshDLpActions = $t03202032128._1
842- let updatedDLp = $t03202032128._2
843- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
844- if ((isUpdatedDLpValid == isUpdatedDLpValid))
845- then $Tuple2((state ++ refreshDLpActions), totalAmount)
846- else throw("Strict value is not equal to itself.")
847- }
848- else throw("Strict value is not equal to itself.")
849- }
739+ let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
740+ if ((burn == burn))
741+ then $Tuple2(state, totalAmount)
850742 else throw("Strict value is not equal to itself.")
851743 }
852744 else throw("Strict value is not equal to itself.")
853745 }
746+ else throw("Strict value is not equal to itself.")
854747 }
855- else throw("Strict value is not equal to itself.")
856748 }
857749
858750
859751 func m () = match getString(mpk()) {
860752 case s: String =>
861753 fromBase58String(s)
862754 case _: Unit =>
863755 unit
864756 case _ =>
865757 throw("Match error")
866758 }
867759
868760
869761 func pm () = match getString(pmpk()) {
870762 case s: String =>
871763 fromBase58String(s)
872764 case _: Unit =>
873765 unit
874766 case _ =>
875767 throw("Match error")
876768 }
877769
878770
879771 let pd = throw("Permission denied")
880772
881773 func isManager (i) = match m() {
882774 case pk: ByteVector =>
883775 (i.callerPublicKey == pk)
884776 case _: Unit =>
885777 (i.caller == this)
886778 case _ =>
887779 throw("Match error")
888780 }
889781
890782
891783 func mm (i) = match m() {
892784 case pk: ByteVector =>
893785 if ((i.callerPublicKey == pk))
894786 then true
895787 else pd
896788 case _: Unit =>
897789 if ((i.caller == this))
898790 then true
899791 else pd
900792 case _ =>
901793 throw("Match error")
902794 }
903795
904796
905797 @Callable(i)
906798 func constructor (fc) = {
907799 let c = mm(i)
908800 if ((c == c))
909801 then [StringEntry(fc(), fc)]
910802 else throw("Strict value is not equal to itself.")
911803 }
912804
913805
914806
915807 @Callable(i)
916808 func setManager (pendingManagerPublicKey) = {
917809 let c = mm(i)
918810 if ((c == c))
919811 then {
920812 let cm = fromBase58String(pendingManagerPublicKey)
921813 if ((cm == cm))
922814 then [StringEntry(pmpk(), pendingManagerPublicKey)]
923815 else throw("Strict value is not equal to itself.")
924816 }
925817 else throw("Strict value is not equal to itself.")
926818 }
927819
928820
929821
930822 @Callable(i)
931823 func confirmManager () = {
932824 let p = pm()
933825 let hpm = if (isDefined(p))
934826 then true
935827 else throw("No pending manager")
936828 if ((hpm == hpm))
937829 then {
938830 let cpm = if ((i.callerPublicKey == value(p)))
939831 then true
940832 else throw("You are not pending manager")
941833 if ((cpm == cpm))
942834 then [StringEntry(mpk(), toBase58String(value(p))), DeleteEntry(pmpk())]
943835 else throw("Strict value is not equal to itself.")
944836 }
945837 else throw("Strict value is not equal to itself.")
946838 }
947839
948840
949841
950842 @Callable(i)
951843 func put (slip,autoStake) = {
952844 let factCfg = gfc()
953845 let stakingCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactStakCntr]), "Wr st addr")
954846 let slipCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactSlippCntr]), "Wr sl addr")
955847 if ((0 > slip))
956848 then throw("Wrong slippage")
957849 else if ((size(i.payments) != 2))
958850 then throw("2 pmnts expd")
959851 else {
960- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
961- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
962- let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amAssetPmt)
963- if ((amountAssetBalance == amountAssetBalance))
852+ let e = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], slip, true, false, true, 0, "")
853+ let emitLpAmt = e._2
854+ let lpAssetId = e._7
855+ let state = e._9
856+ let amDiff = e._10
857+ let prDiff = e._11
858+ let amId = e._12
859+ let prId = e._13
860+ let r = invoke(fca, "emit", [emitLpAmt], nil)
861+ if ((r == r))
964862 then {
965- let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - prAssetPmt)
966- if ((priceAssetBalance == priceAssetBalance))
863+ let el = match r {
864+ case legacy: Address =>
865+ invoke(legacy, "emit", [emitLpAmt], nil)
866+ case _ =>
867+ unit
868+ }
869+ if ((el == el))
967870 then {
968- let lpAssetEmission = toBigInt(value(assetInfo(cfgLpAssetId)).quantity)
969- if ((lpAssetEmission == lpAssetEmission))
871+ let sa = if ((amDiff > 0))
872+ then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)])
873+ else nil
874+ if ((sa == sa))
970875 then {
971- let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0))
972- if ((currentDLp == currentDLp))
876+ let sp = if ((prDiff > 0))
877+ then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)])
878+ else nil
879+ if ((sp == sp))
973880 then {
974- let e = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], slip, true, false, true, 0, "")
975- let emitLpAmt = e._2
976- let lpAssetId = e._7
977- let state = e._9
978- let amDiff = e._10
979- let prDiff = e._11
980- let amId = e._12
981- let prId = e._13
982- let r = invoke(fca, "emit", [emitLpAmt], nil)
983- if ((r == r))
881+ let lpTrnsfr = if (autoStake)
984882 then {
985- let el = match r {
986- case legacy: Address =>
987- invoke(legacy, "emit", [emitLpAmt], nil)
988- case _ =>
989- unit
990- }
991- if ((el == el))
992- then {
993- let sa = if ((amDiff > 0))
994- then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)])
995- else nil
996- if ((sa == sa))
997- then {
998- let sp = if ((prDiff > 0))
999- then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)])
1000- else nil
1001- if ((sp == sp))
1002- then {
1003- let lpTrnsfr = if (autoStake)
1004- then {
1005- let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
1006- if ((ss == ss))
1007- then nil
1008- else throw("Strict value is not equal to itself.")
1009- }
1010- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
1011- let $t03627736342 = refreshDLpInternal(0, 0, 0)
1012- let refreshDLpActions = $t03627736342._1
1013- let updatedDLp = $t03627736342._2
1014- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1015- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1016- then {
1017- let check = if ((updatedDLp >= currentDLp))
1018- then true
1019- else throwErr("updated DLp lower than current DLp")
1020- if ((check == check))
1021- then {
1022- let lpAssetEmissionAfter = value(assetInfo(cfgLpAssetId)).quantity
1023- if ((lpAssetEmissionAfter == lpAssetEmissionAfter))
1024- then ((state ++ lpTrnsfr) ++ refreshDLpActions)
1025- else throw("Strict value is not equal to itself.")
1026- }
1027- else throw("Strict value is not equal to itself.")
1028- }
1029- else throw("Strict value is not equal to itself.")
1030- }
1031- else throw("Strict value is not equal to itself.")
1032- }
1033- else throw("Strict value is not equal to itself.")
1034- }
883+ let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
884+ if ((ss == ss))
885+ then nil
1035886 else throw("Strict value is not equal to itself.")
1036887 }
1037- else throw("Strict value is not equal to itself.")
888+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
889+ (state ++ lpTrnsfr)
1038890 }
1039891 else throw("Strict value is not equal to itself.")
1040892 }
1041893 else throw("Strict value is not equal to itself.")
1042894 }
1043895 else throw("Strict value is not equal to itself.")
1044896 }
1045897 else throw("Strict value is not equal to itself.")
1046898 }
1047899 }
1048900
1049901
1050902
1051903 @Callable(i)
1052904 func putOneTknV2 (minOutAmount,autoStake) = {
1053905 let isPoolOneTokenOperationsDisabled = {
1054906 let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
1055907 if ($isInstanceOf(@, "Boolean"))
1056908 then @
1057909 else throw(($getType(@) + " couldn't be cast to Boolean"))
1058910 }
1059911 let isPutDisabled = if (if (if (igs())
1060912 then true
1061913 else (cfgPoolStatus == PoolPutDis))
1062914 then true
1063915 else (cfgPoolStatus == PoolShutdown))
1064916 then true
1065917 else isPoolOneTokenOperationsDisabled
1066918 let checks = [if (if (!(isPutDisabled))
1067919 then true
1068920 else isManager(i))
1069921 then true
1070922 else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1))
1071923 then true
1072924 else throwErr("exactly 1 payment are expected")]
1073925 if ((checks == checks))
1074926 then {
1075927 let poolConfig = gpc()
1076928 let amId = poolConfig[idxAmAsId]
1077929 let prId = poolConfig[idxPrAsId]
1078930 let lpId = fromBase58String(poolConfig[idxLPAsId])
1079931 let amDecimals = parseIntValue(poolConfig[idxAmtAsDcm])
1080932 let prDecimals = parseIntValue(poolConfig[idxPriceAsDcm])
1081933 let userAddress = if ((i.caller == this))
1082934 then i.originCaller
1083935 else i.caller
1084936 let pmt = value(i.payments[0])
1085937 let pmtAssetId = toBase58String(value(pmt.assetId))
1086938 let pmtAmt = pmt.amount
1087- let currentDLp = if ((pmt.assetId == cfgAmountAssetId))
1088- then calcCurrentDLp(toBigInt(pmtAmt), toBigInt(0), toBigInt(0))
1089- else calcCurrentDLp(toBigInt(0), toBigInt(pmtAmt), toBigInt(0))
1090- if ((currentDLp == currentDLp))
939+ let $t03347833636 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true)
940+ if (($t03347833636 == $t03347833636))
1091941 then {
1092- let $t03786438022 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true)
1093- if (($t03786438022 == $t03786438022))
942+ let feeAmount = $t03347833636._3
943+ let state = $t03347833636._2
944+ let estimLP = $t03347833636._1
945+ let emitLpAmt = if (if ((minOutAmount > 0))
946+ then (minOutAmount > estimLP)
947+ else false)
948+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
949+ else estimLP
950+ let e = invoke(fca, "emit", [emitLpAmt], nil)
951+ if ((e == e))
1094952 then {
1095- let feeAmount = $t03786438022._3
1096- let state = $t03786438022._2
1097- let estimLP = $t03786438022._1
1098- let emitLpAmt = if (if ((minOutAmount > 0))
1099- then (minOutAmount > estimLP)
1100- else false)
1101- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1102- else estimLP
1103- let e = invoke(fca, "emit", [emitLpAmt], nil)
1104- if ((e == e))
953+ let el = match e {
954+ case legacy: Address =>
955+ invoke(legacy, "emit", [emitLpAmt], nil)
956+ case _ =>
957+ unit
958+ }
959+ if ((el == el))
1105960 then {
1106- let el = match e {
1107- case legacy: Address =>
1108- invoke(legacy, "emit", [emitLpAmt], nil)
1109- case _ =>
1110- unit
1111- }
1112- if ((el == el))
961+ let lpTrnsfr = if (autoStake)
1113962 then {
1114- let lpTrnsfr = if (autoStake)
1115- then {
1116- let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)])
1117- if ((ss == ss))
1118- then nil
1119- else throw("Strict value is not equal to itself.")
1120- }
1121- else [ScriptTransfer(i.caller, emitLpAmt, lpId)]
1122- let sendFeeToMatcher = if ((feeAmount > 0))
1123- then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))]
1124- else nil
1125- let $t03883739186 = if ((this == feeCollectorAddress))
1126- then $Tuple2(0, 0)
1127- else {
1128- let paymentInAmountAsset = if ((pmt.assetId == cfgAmountAssetId))
1129- then true
1130- else false
1131- if (paymentInAmountAsset)
1132- then $Tuple2(-(feeAmount), 0)
1133- else $Tuple2(0, -(feeAmount))
1134- }
1135- let amountAssetBalanceDelta = $t03883739186._1
1136- let priceAssetBalanceDelta = $t03883739186._2
1137- let $t03918939297 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1138- let refreshDLpActions = $t03918939297._1
1139- let updatedDLp = $t03918939297._2
1140- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1141- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1142- then $Tuple2((((state ++ lpTrnsfr) ++ sendFeeToMatcher) ++ refreshDLpActions), emitLpAmt)
963+ let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)])
964+ if ((ss == ss))
965+ then nil
1143966 else throw("Strict value is not equal to itself.")
1144967 }
1145- else throw("Strict value is not equal to itself.")
968+ else [ScriptTransfer(i.caller, emitLpAmt, lpId)]
969+ let sendFeeToMatcher = if ((feeAmount > 0))
970+ then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))]
971+ else nil
972+ $Tuple2(((state ++ lpTrnsfr) ++ sendFeeToMatcher), emitLpAmt)
1146973 }
1147974 else throw("Strict value is not equal to itself.")
1148975 }
1149976 else throw("Strict value is not equal to itself.")
1150977 }
1151978 else throw("Strict value is not equal to itself.")
1152979 }
1153980 else throw("Strict value is not equal to itself.")
1154981 }
1155982
1156983
1157984
1158985 @Callable(i)
986+func putForFree (maxSlpg) = if ((0 > maxSlpg))
987+ then throw("Wrong slpg")
988+ else if ((size(i.payments) != 2))
989+ then throw("2 pmnts expd")
990+ else {
991+ let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], maxSlpg, false, false, true, 0, "")
992+ estPut._9
993+ }
994+
995+
996+
997+@Callable(i)
1159998 func get () = {
1160- let aab = toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId)))
1161- if ((aab == aab))
1162- then {
1163- let pab = toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId)))
1164- if ((pab == pab))
1165- then {
1166- let lae = toBigInt(value(assetInfo(cfgLpAssetId)).quantity)
1167- if ((lae == lae))
1168- then {
1169- let laea = (lae - toBigInt(value(i.payments[0]).amount))
1170- if ((laea == laea))
1171- then {
1172- let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1173- if ((currentDLp == currentDLp))
1174- then {
1175- let r = cg(i)
1176- let outAmtAmt = r._1
1177- let outPrAmt = r._2
1178- let pmtAmt = r._3
1179- let pmtAssetId = r._4
1180- let state = r._5
1181- let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1182- if ((b == b))
1183- then {
1184- let $t04159541752 = refreshDLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1185- let refreshDLpActions = $t04159541752._1
1186- let updatedDLp = $t04159541752._2
1187- let error = if ((updatedDLp >= currentDLp))
1188- then true
1189- else throwErr(makeString(["updated DLp lower than current DLp", toString(aab), toString(pab), toString(currentDLp), toString(updatedDLp), toString(lae), toString(laea)], " "))
1190- if ((error == error))
1191- then (state ++ refreshDLpActions)
1192- else throw("Strict value is not equal to itself.")
1193- }
1194- else throw("Strict value is not equal to itself.")
1195- }
1196- else throw("Strict value is not equal to itself.")
1197- }
1198- else throw("Strict value is not equal to itself.")
1199- }
1200- else throw("Strict value is not equal to itself.")
1201- }
1202- else throw("Strict value is not equal to itself.")
1203- }
999+ let r = cg(i)
1000+ let outAmtAmt = r._1
1001+ let outPrAmt = r._2
1002+ let pmtAmt = r._3
1003+ let pmtAssetId = r._4
1004+ let state = r._5
1005+ let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1006+ if ((b == b))
1007+ then state
12041008 else throw("Strict value is not equal to itself.")
12051009 }
12061010
12071011
12081012
12091013 @Callable(i)
12101014 func getOneTknV2 (outAssetId,minOutAmount) = {
12111015 let isPoolOneTokenOperationsDisabled = {
12121016 let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
12131017 if ($isInstanceOf(@, "Boolean"))
12141018 then @
12151019 else throw(($getType(@) + " couldn't be cast to Boolean"))
12161020 }
12171021 let isGetDisabled = if (if (igs())
12181022 then true
12191023 else (cfgPoolStatus == PoolShutdown))
12201024 then true
12211025 else isPoolOneTokenOperationsDisabled
12221026 let checks = [if (if (!(isGetDisabled))
12231027 then true
12241028 else isManager(i))
12251029 then true
12261030 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1))
12271031 then true
12281032 else throwErr("exactly 1 payment are expected")]
12291033 if ((checks == checks))
12301034 then {
1231- let $t04255142706 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId)
1232- let state = $t04255142706._1
1233- let totalAmount = $t04255142706._2
1035+ let $t03625836413 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId)
1036+ let state = $t03625836413._1
1037+ let totalAmount = $t03625836413._2
12341038 $Tuple2(state, totalAmount)
1235- }
1236- else throw("Strict value is not equal to itself.")
1237- }
1238-
1239-
1240-
1241-@Callable(i)
1242-func refreshDLp () = {
1243- let lastRefreshedBlockHeight = valueOrElse(getInteger(keyDLpRefreshedHeight), 0)
1244- let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= dLpRefreshDelay))
1245- then unit
1246- else throwErr(makeString([toString(dLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1247- if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1248- then {
1249- let dLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyDLp), "0")), fmtErr("invalid dLp"))
1250- let $t04323043294 = refreshDLpInternal(0, 0, 0)
1251- let dLpUpdateActions = $t04323043294._1
1252- let updatedDLp = $t04323043294._2
1253- let actions = if ((dLp != updatedDLp))
1254- then dLpUpdateActions
1255- else throwErr("nothing to refresh")
1256- $Tuple2(actions, toString(updatedDLp))
12571039 }
12581040 else throw("Strict value is not equal to itself.")
12591041 }
12601042
12611043
12621044
12631045 @Callable(i)
12641046 func getOneTknV2READONLY (outAssetId,lpAssetAmount) = {
12651047 let poolConfig = gpc()
12661048 let amId = poolConfig[idxAmAsId]
12671049 let prId = poolConfig[idxPrAsId]
12681050 let lpId = poolConfig[idxLPAsId]
12691051 let xp = [toBigInt(getAccBalance(amId)), toBigInt(getAccBalance(prId))]
12701052 let lpEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity)
12711053 let D0 = getD(xp)
12721054 let D1 = (D0 - fraction(toBigInt(lpAssetAmount), D0, lpEmission))
12731055 let index = if ((outAssetId == amId))
12741056 then 0
12751057 else if ((outAssetId == prId))
12761058 then 1
12771059 else throw("invalid out asset id")
12781060 let newY = getYD(xp, index, D1)
12791061 let dy = (xp[index] - newY)
12801062 let totalGetRaw = max([0, toInt((dy - big1))])
1281- let $t04419444243 = takeFee(totalGetRaw)
1282- let totalGet = $t04419444243._1
1283- let feeAmount = $t04419444243._2
1063+ let $t03720337258 = takeFee(totalGetRaw, outFee)
1064+ let totalGet = $t03720337258._1
1065+ let feeAmount = $t03720337258._2
12841066 $Tuple2(nil, $Tuple2(totalGet, feeAmount))
12851067 }
12861068
12871069
12881070
12891071 @Callable(i)
12901072 func getOneTknV2WithBonusREADONLY (outAssetId,lpAssetAmount) = {
12911073 let poolConfig = gpc()
12921074 let amId = poolConfig[idxAmAsId]
12931075 let prId = poolConfig[idxPrAsId]
12941076 let lpId = poolConfig[idxLPAsId]
12951077 let amBalance = getAccBalance(amId)
12961078 let prBalance = getAccBalance(prId)
1297- let $t04458844703 = {
1079+ let $t03760337718 = {
12981080 let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, lpAssetAmount], nil)
12991081 if ($isInstanceOf(@, "(Int, Int)"))
13001082 then @
13011083 else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
13021084 }
1303- let totalGet = $t04458844703._1
1304- let feeAmount = $t04458844703._2
1085+ let totalGet = $t03760337718._1
1086+ let feeAmount = $t03760337718._2
13051087 let r = ego("", lpId, lpAssetAmount, this)
13061088 let outAmAmt = r._1
13071089 let outPrAmt = r._2
13081090 let sumOfGetAssets = (outAmAmt + outPrAmt)
13091091 let bonus = if ((sumOfGetAssets == 0))
13101092 then if ((totalGet == 0))
13111093 then 0
13121094 else throw("bonus calculation error")
13131095 else fraction((totalGet - sumOfGetAssets), scale8, sumOfGetAssets)
13141096 $Tuple2(nil, $Tuple3(totalGet, feeAmount, bonus))
13151097 }
13161098
13171099
13181100
13191101 @Callable(i)
13201102 func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = {
13211103 let r = cg(i)
13221104 let outAmAmt = r._1
13231105 let outPrAmt = r._2
13241106 let pmtAmt = r._3
13251107 let pmtAssetId = r._4
13261108 let state = r._5
13271109 if ((noLessThenAmtAsset > outAmAmt))
13281110 then throw(((("Failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset)))
13291111 else if ((noLessThenPriceAsset > outPrAmt))
13301112 then throw(((("Failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
13311113 else {
1332- let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt))
13331114 let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
13341115 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1335- then {
1336- let $t04587145952 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1337- let refreshDLpActions = $t04587145952._1
1338- let updatedDLp = $t04587145952._2
1339- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1340- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1341- then (state ++ refreshDLpActions)
1342- else throw("Strict value is not equal to itself.")
1343- }
1116+ then state
13441117 else throw("Strict value is not equal to itself.")
13451118 }
13461119 }
13471120
13481121
13491122
13501123 @Callable(i)
13511124 func unstakeAndGet (amount) = {
13521125 let checkPayments = if ((size(i.payments) != 0))
13531126 then throw("No pmnts expd")
13541127 else true
13551128 if ((checkPayments == checkPayments))
13561129 then {
13571130 let cfg = gpc()
13581131 let factoryCfg = gfc()
13591132 let lpAssetId = fromBase58String(cfg[idxLPAsId])
13601133 let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
1361- let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
13621134 let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil)
13631135 if ((unstakeInv == unstakeInv))
13641136 then {
13651137 let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1366- let outAmAmt = r._1
1367- let outPrAmt = r._2
13681138 let sts = parseIntValue(r._9)
13691139 let state = r._10
13701140 let v = if (if (igs())
13711141 then true
13721142 else (sts == PoolShutdown))
13731143 then throw(("Blocked: " + toString(sts)))
13741144 else true
13751145 if ((v == v))
13761146 then {
13771147 let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
13781148 if ((burnA == burnA))
1379- then {
1380- let $t04701547096 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1381- let refreshDLpActions = $t04701547096._1
1382- let updatedDLp = $t04701547096._2
1383- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1384- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1385- then (state ++ refreshDLpActions)
1386- else throw("Strict value is not equal to itself.")
1387- }
1149+ then state
13881150 else throw("Strict value is not equal to itself.")
13891151 }
13901152 else throw("Strict value is not equal to itself.")
13911153 }
13921154 else throw("Strict value is not equal to itself.")
13931155 }
13941156 else throw("Strict value is not equal to itself.")
13951157 }
13961158
13971159
13981160
13991161 @Callable(i)
14001162 func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = {
14011163 let isGetDisabled = if (igs())
14021164 then true
14031165 else (cfgPoolStatus == PoolShutdown)
14041166 let checks = [if (!(isGetDisabled))
14051167 then true
14061168 else throw("get operation is blocked by admin"), if ((size(i.payments) == 0))
14071169 then true
14081170 else throw("no payments are expected")]
14091171 if ((checks == checks))
14101172 then {
1411- let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
14121173 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
14131174 if ((unstakeInv == unstakeInv))
14141175 then {
14151176 let res = ego(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
14161177 let outAmAmt = res._1
14171178 let outPrAmt = res._2
14181179 let state = res._10
14191180 let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
14201181 then true
14211182 else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
14221183 then true
14231184 else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
14241185 if ((checkAmounts == checkAmounts))
14251186 then {
14261187 let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
14271188 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1428- then {
1429- let $t04834448425 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1430- let refreshDLpActions = $t04834448425._1
1431- let updatedDLp = $t04834448425._2
1432- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1433- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1434- then (state ++ refreshDLpActions)
1435- else throw("Strict value is not equal to itself.")
1436- }
1189+ then state
14371190 else throw("Strict value is not equal to itself.")
14381191 }
14391192 else throw("Strict value is not equal to itself.")
14401193 }
14411194 else throw("Strict value is not equal to itself.")
14421195 }
14431196 else throw("Strict value is not equal to itself.")
14441197 }
14451198
14461199
14471200
14481201 @Callable(i)
14491202 func unstakeAndGetOneTknV2 (unstakeAmount,outAssetId,minOutAmount) = {
14501203 let isPoolOneTokenOperationsDisabled = {
14511204 let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
14521205 if ($isInstanceOf(@, "Boolean"))
14531206 then @
14541207 else throw(($getType(@) + " couldn't be cast to Boolean"))
14551208 }
14561209 let isGetDisabled = if (if (igs())
14571210 then true
14581211 else (cfgPoolStatus == PoolShutdown))
14591212 then true
14601213 else isPoolOneTokenOperationsDisabled
14611214 let checks = [if (if (!(isGetDisabled))
14621215 then true
14631216 else isManager(i))
14641217 then true
14651218 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0))
14661219 then true
14671220 else throwErr("no payments are expected")]
14681221 if ((checks == checks))
14691222 then {
14701223 let cfg = gpc()
14711224 let factoryCfg = gfc()
14721225 let lpAssetId = fromBase58String(cfg[idxLPAsId])
14731226 let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
14741227 let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), unstakeAmount], nil)
14751228 if ((unstakeInv == unstakeInv))
14761229 then {
1477- let $t04935949547 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId)
1478- let state = $t04935949547._1
1479- let totalAmount = $t04935949547._2
1230+ let $t04155641744 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId)
1231+ let state = $t04155641744._1
1232+ let totalAmount = $t04155641744._2
14801233 $Tuple2(state, totalAmount)
14811234 }
14821235 else throw("Strict value is not equal to itself.")
14831236 }
14841237 else throw("Strict value is not equal to itself.")
14851238 }
14861239
14871240
14881241
14891242 @Callable(i)
14901243 func putOneTknV2WithBonusREADONLY (paymentAmountRaw,paymentAssetId) = {
14911244 let poolConfig = gpc()
14921245 let amId = poolConfig[idxAmAsId]
14931246 let prId = poolConfig[idxPrAsId]
14941247 let lpId = poolConfig[idxLPAsId]
1495- let $t04980649909 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true)
1496- let lpAmount = $t04980649909._1
1497- let state = $t04980649909._2
1498- let feeAmount = $t04980649909._3
1499- let bonus = $t04980649909._4
1248+ let $t04200342106 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true)
1249+ let lpAmount = $t04200342106._1
1250+ let state = $t04200342106._2
1251+ let feeAmount = $t04200342106._3
1252+ let bonus = $t04200342106._4
15001253 $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus))
15011254 }
15021255
15031256
15041257
15051258 @Callable(i)
15061259 func putOneTknV2WithoutTakeFeeREADONLY (paymentAmountRaw,paymentAssetId) = {
15071260 let poolConfig = gpc()
15081261 let amId = poolConfig[idxAmAsId]
15091262 let prId = poolConfig[idxPrAsId]
15101263 let lpId = poolConfig[idxLPAsId]
1511- let $t05018850292 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false)
1512- let lpAmount = $t05018850292._1
1513- let state = $t05018850292._2
1514- let feeAmount = $t05018850292._3
1515- let bonus = $t05018850292._4
1264+ let $t04238542489 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false)
1265+ let lpAmount = $t04238542489._1
1266+ let state = $t04238542489._2
1267+ let feeAmount = $t04238542489._3
1268+ let bonus = $t04238542489._4
15161269 $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus))
15171270 }
15181271
15191272
15201273
15211274 @Callable(i)
15221275 func activate (amtAsStr,prAsStr) = if ((toString(i.caller) != toString(fca)))
15231276 then throw("denied")
15241277 else $Tuple2([StringEntry(aa(), amtAsStr), StringEntry(pa(), prAsStr)], "success")
15251278
15261279
15271280
15281281 @Callable(i)
15291282 func setS (k,v) = if ((toString(i.caller) != strf(this, ada())))
15301283 then pd
15311284 else [StringEntry(k, v)]
15321285
15331286
15341287
15351288 @Callable(i)
15361289 func setI (k,v) = if ((toString(i.caller) != strf(this, ada())))
15371290 then pd
15381291 else [IntegerEntry(k, v)]
15391292
15401293
15411294
15421295 @Callable(i)
15431296 func getPoolConfigWrapperREADONLY () = $Tuple2(nil, gpc())
15441297
15451298
15461299
15471300 @Callable(i)
15481301 func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId))
15491302
15501303
15511304
15521305 @Callable(i)
15531306 func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = {
15541307 let pr = calcPrices(amAmt, prAmt, lpAmt)
15551308 $Tuple2(nil, [toString(pr[0]), toString(pr[1]), toString(pr[2])])
15561309 }
15571310
15581311
15591312
15601313 @Callable(i)
15611314 func fromX18WrapperREADONLY (val,resScaleMult) = $Tuple2(nil, f1(parseBigIntValue(val), resScaleMult))
15621315
15631316
15641317
15651318 @Callable(i)
15661319 func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(t1(origVal, origScaleMult)))
15671320
15681321
15691322
15701323 @Callable(i)
15711324 func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(cpbi(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18))))
15721325
15731326
15741327
15751328 @Callable(i)
15761329 func estimatePutOperationWrapperREADONLY (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,usrAddr,isEval,emitLp) = $Tuple2(nil, epo(txId58, slippage, inAmAmt, inAmId, inPrAmt, inPrId, usrAddr, isEval, emitLp, true, false, 0, ""))
15771330
15781331
15791332
15801333 @Callable(i)
15811334 func estimateGetOperationWrapperREADONLY (txId58,pmtAsId,pmtLpAmt,usrAddr) = {
15821335 let r = ego(txId58, pmtAsId, pmtLpAmt, addressFromStringValue(usrAddr))
15831336 $Tuple2(nil, $Tuple10(r._1, r._2, r._3, r._4, r._5, r._6, r._7, toString(r._8), r._9, r._10))
15841337 }
15851338
15861339
1587-
1588-@Callable(i)
1589-func getFeeREADONLY () = $Tuple2(nil, fee)
1590-
1591-
15921340 @Verifier(tx)
15931341 func verify () = {
15941342 let targetPublicKey = match m() {
15951343 case pk: ByteVector =>
15961344 pk
15971345 case _: Unit =>
15981346 tx.senderPublicKey
15991347 case _ =>
16001348 throw("Match error")
16011349 }
16021350 match tx {
16031351 case order: Order =>
16041352 let matcherPub = mp()
1605- let orderValid = validateMatcherOrderAllowed(order)
1353+ let orderValid = moa(order)
16061354 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
16071355 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
16081356 if (if (if (orderValid)
16091357 then senderValid
16101358 else false)
16111359 then matcherValid
16121360 else false)
16131361 then true
16141362 else toe(orderValid, senderValid, matcherValid)
16151363 case s: SetScriptTransaction =>
16161364 let newHash = blake2b256(value(s.script))
16171365 let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash())))
16181366 let currentHash = scriptHash(this)
16191367 if (if ((allowedHash == newHash))
16201368 then (currentHash != newHash)
16211369 else false)
16221370 then true
16231371 else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
16241372 case _ =>
16251373 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
16261374 }
16271375 }
16281376

github/deemru/w8io/169f3d6 
243.59 ms