tx · HdufFhuuc2qNzHT8hAg5pUXdAiLX94Frnc2fr2MWs54A

3MtP3m8hWMxYcyDxXB6n299KrsLLyT8ehni:  -0.03700000 Waves

2023.01.19 12:46 [2411646] smart account 3MtP3m8hWMxYcyDxXB6n299KrsLLyT8ehni > SELF 0.00000000 Waves

{ "type": 13, "id": "HdufFhuuc2qNzHT8hAg5pUXdAiLX94Frnc2fr2MWs54A", "fee": 3700000, "feeAssetId": null, "timestamp": 1674121638433, "version": 1, "sender": "3MtP3m8hWMxYcyDxXB6n299KrsLLyT8ehni", "senderPublicKey": "BRyVaCURUMe7ssUbXucteig1g44bGwWirJQzugKahUQ1", "proofs": [ "34Dji3z6mgA9JF5rk692Mhy6TK3rcpHZp9UMj6QdUpgM6Efg258LED3nmcVtvVXVeD6pCDZWi6UqxQerYXyin3YY" ], "script": "base64:BgKwKQgCEgMKAQgSAwoBCBIAEgQKAgEEEgQKAgEEEgMKAQESABIECgIIARIAEgQKAggBEgQKAggBEgQKAgEBEgMKAQESBQoDAQEBEgUKAwEIARIECgIBCBIECgIBCBIECgIICBIECgIICBIECgIIARIAEgMKAQgSBQoDAQEBEgQKAggBEgQKAgEBEgQKAggIEgsKCQgBAQIBAggEBBIGCgQICAEIIgZzY2FsZTgiDHNjYWxlOEJpZ0ludCIHc2NhbGUxOCIKemVyb0JpZ0ludCIEYmlnMCIEYmlnMSIEYmlnMiIEYmlnMyIEYmlnNCIKc2xpcHBhZ2U0RCILd2F2ZXNTdHJpbmciBUFtdWx0IgVEY29udiIDU0VQIgVFTVBUWSIKUG9vbEFjdGl2ZSIKUG9vbFB1dERpcyIOUG9vbE1hdGNoZXJEaXMiDFBvb2xTaHV0ZG93biIOaWR4UG9vbEFkZHJlc3MiCWlkeFBvb2xTdCIJaWR4TFBBc0lkIglpZHhBbUFzSWQiCWlkeFByQXNJZCILaWR4QW10QXNEY20iDWlkeFByaWNlQXNEY20iC2lkeElBbXRBc0lkIg1pZHhJUHJpY2VBc0lkIg9pZHhGYW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hPQIFAmljBQJpYQcGCQD0AwMIBQJoVAlib2R5Qnl0ZXMJAJEDAggFAmhUBnByb29mcwAABQJoVgkA9AMDCAUCaFQJYm9keUJ5dGVzCQCRAwIIBQJoVAZwcm9vZnMAAAUCaFZGJSnc", "chainId": 84, "height": 2411646, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6MAGgcmJKUnxYKh4SkorsRhj81XqXCMmpezMcc5NL3Nz Next: 3tzL65BAr9dN82B8piJuqWDEyRoZ8jRZ51Fd9aP41Ksx 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)
1721
1822 let slippage4D = toBigInt((scale8 - ((scale8 * 1) / scale8)))
1923
6973 func f1 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18))
7074
7175
76+func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round))
77+
78+
79+func t2 (origVal,origScaleMult) = fraction(origVal, scale18, toBigInt(origScaleMult))
80+
81+
82+func f2 (val,resultScaleMult) = fraction(val, toBigInt(resultScaleMult), scale18)
83+
84+
7285 func ts (amt,resScale,curScale) = fraction(amt, resScale, curScale)
7386
7487
115128 func ada () = "%s__addonAddr"
116129
117130
131+let keyFee = "%s__fee"
132+
133+let fee = valueOrElse(getInteger(this, keyFee), feeDefault)
134+
135+let keyDLp = makeString(["%s", "dLp"], SEP)
136+
137+let keyDLpRefreshedHeight = makeString(["%s", "dLpRefreshedHeight"], SEP)
138+
139+let keyDLpRefreshDelay = makeString(["%s", "refreshDLpDelay"], SEP)
140+
141+let dLpRefreshDelayDefault = 1
142+
143+let dLpRefreshDelay = valueOrElse(getInteger(this, keyDLpRefreshDelay), dLpRefreshDelayDefault)
144+
118145 func fcfg () = "%s__factoryConfig"
119146
120147
139166 func toe (orV,sendrV,matchV) = throw(((((("Failed: ordValid=" + toString(orV)) + " sndrValid=") + toString(sendrV)) + " mtchrValid=") + toString(matchV)))
140167
141168
142-func str (val) = match val {
143- case valStr: String =>
144- valStr
145- case _ =>
146- throw("fail cast to String")
147-}
148-
149-
150169 func strf (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], ""))
151170
152171
154173
155174
156175 func throwErr (msg) = throw(makeString(["lp_stable.ride:", msg], " "))
176+
177+
178+func fmtErr (msg) = makeString(["lp_stable.ride:", msg], " ")
157179
158180
159181 let fca = addressFromStringValue(strf(this, fc()))
201223 else toBase58String(value(input))
202224
203225
204-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]))
226+func parsePoolConfig (poolConfig) = $Tuple9(addressFromStringValue(poolConfig[idxPoolAddress]), parseIntValue(poolConfig[idxPoolSt]), fromBase58String(poolConfig[idxLPAsId]), parseAssetId(poolConfig[idxAmAsId]), parseAssetId(poolConfig[idxPrAsId]), parseIntValue(poolConfig[idxAmtAsDcm]), parseIntValue(poolConfig[idxPriceAsDcm]), fromBase58String(poolConfig[idxIAmtAsId]), fromBase58String(poolConfig[idxIPriceAsId]))
205227
206228
207229 let poolConfigParsed = parsePoolConfig(gpc())
208230
209-let $t069097095 = poolConfigParsed
231+let $t077427971 = poolConfigParsed
210232
211-let cfgPoolAddress = $t069097095._1
233+let cfgPoolAddress = $t077427971._1
212234
213-let cfgPoolStatus = $t069097095._2
235+let cfgPoolStatus = $t077427971._2
214236
215-let cfgLpAssetId = $t069097095._3
237+let cfgLpAssetId = $t077427971._3
216238
217-let cfgAmountAssetId = $t069097095._4
239+let cfgAmountAssetId = $t077427971._4
218240
219-let cfgPriceAssetId = $t069097095._5
241+let cfgPriceAssetId = $t077427971._5
220242
221-let cfgAmountAssetDecimals = $t069097095._6
243+let cfgAmountAssetDecimals = $t077427971._6
222244
223-let cfgPriceAssetDecimals = $t069097095._7
245+let cfgPriceAssetDecimals = $t077427971._7
246+
247+let cfgInAmountAssedId = $t077427971._8
248+
249+let cfgInPriceAssetId = $t077427971._9
224250
225251 func gfc () = split(strf(fca, fcfg()), SEP)
226252
247273
248274
249275 func cpbi (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
276+
277+
278+func cpbir (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
250279
251280
252281 func vad (A1,A2,slippage) = {
277306
278307
279308 func calcPrices (amAmt,prAmt,lpAmt) = {
280- let cfg = gpc()
281- let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm])
282- let prAsDcm = parseIntValue(cfg[idxPriceAsDcm])
309+ let amtAsDcm = cfgAmountAssetDecimals
310+ let prAsDcm = cfgPriceAssetDecimals
283311 let priceX18 = pcp(amtAsDcm, prAsDcm, amAmt, prAmt)
284312 let amAmtX18 = t1(amAmt, amtAsDcm)
285313 let prAmtX18 = t1(prAmt, prAsDcm)
305333
306334
307335 func ego (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
308- let cfg = gpc()
309- let lpId = cfg[idxLPAsId]
310- let amId = cfg[idxAmAsId]
311- let prId = cfg[idxPrAsId]
312- let amDcm = parseIntValue(cfg[idxAmtAsDcm])
313- let prDcm = parseIntValue(cfg[idxPriceAsDcm])
314- let sts = cfg[idxPoolSt]
315- let lpEmiss = valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "Wrong LP id").quantity
316- if ((lpId != pmtAssetId))
336+ let lpId = cfgLpAssetId
337+ let amId = toBase58String(value(cfgAmountAssetId))
338+ let prId = toBase58String(value(cfgPriceAssetId))
339+ let amDcm = cfgAmountAssetDecimals
340+ let prDcm = cfgPriceAssetDecimals
341+ let sts = toString(cfgPoolStatus)
342+ let lpEmiss = valueOrErrorMessage(assetInfo(lpId), "Wrong LP id").quantity
343+ if ((toBase58String(lpId) != pmtAssetId))
317344 then throw("Wrong pmt asset")
318345 else {
319346 let amBalance = getAccBalance(amId)
326353 let lpEmissX18 = t1(lpEmiss, scale8)
327354 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissX18)
328355 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissX18)
329- let outAmAmt = f1(outAmAmtX18, amDcm)
330- let outPrAmt = f1(outPrAmtX18, prDcm)
356+ let outAmAmt = fromX18Round(outAmAmtX18, amDcm, FLOOR)
357+ let outPrAmt = fromX18Round(outPrAmtX18, prDcm, FLOOR)
331358 let state = if ((txId58 == ""))
332359 then nil
333360 else [ScriptTransfer(userAddress, outAmAmt, if ((amId == "WAVES"))
341368
342369
343370 func epo (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,userAddress,isEval,emitLp,isOneAsset,validateSlippage,pmtAmt,pmtId) = {
344- let cfg = gpc()
345- let lpId = fromBase58String(cfg[idxLPAsId])
346- let amIdStr = cfg[idxAmAsId]
347- let prIdStr = cfg[idxPrAsId]
348- let inAmIdStr = cfg[idxIAmtAsId]
349- let inPrIdStr = cfg[idxIPriceAsId]
350- let amtDcm = parseIntValue(cfg[idxAmtAsDcm])
351- let priceDcm = parseIntValue(cfg[idxPriceAsDcm])
352- let sts = cfg[idxPoolSt]
371+ let lpId = cfgLpAssetId
372+ let amIdStr = toBase58String(value(cfgAmountAssetId))
373+ let prIdStr = toBase58String(value(cfgPriceAssetId))
374+ let inAmIdStr = cfgInAmountAssedId
375+ let inPrIdStr = cfgInPriceAssetId
376+ let amtDcm = cfgAmountAssetDecimals
377+ let priceDcm = cfgPriceAssetDecimals
378+ let sts = toString(cfgPoolStatus)
353379 let lpEm = valueOrErrorMessage(assetInfo(lpId), "Wr lp as").quantity
354380 let amBalance = if (isEval)
355381 then getAccBalance(amIdStr)
393419 then throw(((("Price slippage " + toString(slippageRealX18)) + " > ") + toString(slippageX18)))
394420 else {
395421 let lpEmissionX18 = t1(lpEm, scale8)
396- let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
397- let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
422+ let prViaAmX18 = fraction(inAmAssetAmtX18, cpbir(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING)
423+ let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, cpbir(prBalanceX18, amBalanceX18, FLOOR), CEILING)
398424 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
399425 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
400426 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
401427 let expAmtAssetAmtX18 = expectedAmts._1
402428 let expPriceAssetAmtX18 = expectedAmts._2
403- let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
404- $Tuple5(f1(lpAmtX18, scale8), f1(expAmtAssetAmtX18, amtDcm), f1(expPriceAssetAmtX18, priceDcm), curPriceX18, slippageX18)
429+ let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR)
430+ $Tuple5((fromX18Round(lpAmtX18, scale8, FLOOR) - 100), fromX18Round(expAmtAssetAmtX18, amtDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceDcm, CEILING), curPriceX18, slippageX18)
405431 }
406432 }
407433 let calcLpAmt = r._1
417443 else calcLpAmt
418444 let amDiff = (inAmAmt - calcAmAssetPmt)
419445 let prDiff = (inPrAmt - calcPrAssetPmt)
420- let $t01756217907 = if (if (isOneAsset)
446+ let $t01862718972 = if (if (isOneAsset)
421447 then (pmtId == amIdStr)
422448 else false)
423449 then $Tuple2(pmtAmt, 0)
426452 else false)
427453 then $Tuple2(0, pmtAmt)
428454 else $Tuple2(calcAmAssetPmt, calcPrAssetPmt)
429- let writeAmAmt = $t01756217907._1
430- let writePrAmt = $t01756217907._2
455+ let writeAmAmt = $t01862718972._1
456+ let writePrAmt = $t01862718972._2
431457 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))]
432458 $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEm, lpId, sts, commonState, amDiff, prDiff, inAmId, inPrId)
433459 }
434460 }
435461
436462
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)
463+func getD (xp) = {
464+ let xp0 = xp[0]
465+ let xp1 = xp[1]
466+ let s = (xp0 + xp1)
467+ if ((s == big0))
468+ then big0
469+ else {
470+ let a = parseIntValue(A)
471+ let ann = (a * 2)
472+ let p = fraction(xp0, xp1, big1)
473+ let xp0_xp1_n_n = fraction(p, big4, big1)
474+ let ann_s = fraction(toBigInt(ann), s, big1)
475+ let ann_1 = toBigInt((ann - 1))
476+ func calcDNext (d) = {
477+ let dd = fraction(d, d, big1)
478+ let ddd = fraction(dd, d, big1)
479+ let dp = fraction(ddd, big1, xp0_xp1_n_n)
480+ fraction((ann_s + fraction(dp, big2, big1)), d, (fraction(ann_1, d, big1) + fraction(big3, dp, big1)), CEILING)
481+ }
482+
483+ func calc (acc,i) = if (acc._2)
484+ then acc
485+ else {
486+ let d = acc._1
487+ let dNext = calcDNext(d)
488+ let dDiffRaw = toInt((dNext - value(d)))
489+ let dDiff = if ((0 > dDiffRaw))
490+ then -(dDiffRaw)
491+ else dDiffRaw
492+ if ((1 >= dDiff))
493+ then $Tuple2(dNext, true)
494+ else $Tuple2(dNext, false)
495+ }
496+
497+ let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
498+ let $t02090020948 = {
499+ let $l = arr
500+ let $s = size($l)
501+ let $acc0 = $Tuple2(s, false)
502+ func $f0_1 ($a,$i) = if (($i >= $s))
503+ then $a
504+ else calc($a, $l[$i])
505+
506+ func $f0_2 ($a,$i) = if (($i >= $s))
507+ then $a
508+ else throw("List size exceeds 15")
509+
510+ $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)
511+ }
512+ let d = $t02090020948._1
513+ let found = $t02090020948._2
514+ if (found)
515+ then d
516+ else throw(("D calculation error, D = " + toString(d)))
517+ }
518+ }
519+
520+
521+func getDOld (xp) = {
522+ let n = big2
523+ let xp0 = xp[0]
524+ let xp1 = xp[1]
525+ let aPrecision = parseBigIntValue(Amult)
526+ let a = (parseBigIntValue(A) * aPrecision)
527+ let s = (xp0 + xp1)
528+ if ((s == big0))
529+ then big0
530+ else {
531+ let ann = (a * n)
532+ let xp0_xp1_n_n = (((xp0 * xp1) * n) * n)
533+ let ann_s_aPrecision = ((ann * s) / aPrecision)
534+ let ann_aPrecision = (ann - aPrecision)
535+ let n1 = (n + big1)
536+ func calc (acc,cur) = {
537+ let $t02157721597 = acc
538+ let d = $t02157721597._1
539+ let found = $t02157721597._2
540+ if ((found != unit))
541+ then acc
542+ else {
543+ let dp = (((d * d) * d) / xp0_xp1_n_n)
544+ let dNext = (((ann_s_aPrecision + (dp * n)) * d) / (((ann_aPrecision * d) / aPrecision) + (n1 * dp)))
545+ let dDiff = absBigInt((dNext - value(d)))
546+ if ((big1 >= dDiff))
547+ then $Tuple2(dNext, cur)
548+ else $Tuple2(dNext, unit)
549+ }
550+ }
551+
552+ let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
553+ let $t02201822065 = {
554+ let $l = arr
555+ let $s = size($l)
556+ let $acc0 = $Tuple2(s, unit)
557+ func $f0_1 ($a,$i) = if (($i >= $s))
558+ then $a
559+ else calc($a, $l[$i])
560+
561+ func $f0_2 ($a,$i) = if (($i >= $s))
562+ then $a
563+ else throw("List size exceeds 15")
564+
565+ $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)
566+ }
567+ let d = $t02201822065._1
568+ let found = $t02201822065._2
569+ if ((found != unit))
570+ then d
571+ else throw(("D calculation error, D = " + toString(d)))
572+ }
573+ }
574+
575+
576+func getYD (xp,i,D) = {
577+ let n = big2
578+ let x = xp[if ((i == 0))
579+ then 1
580+ else 0]
581+ let aPrecision = parseBigIntValue(Amult)
582+ let a = (parseBigIntValue(A) * aPrecision)
583+ let s = x
584+ let ann = (a * n)
585+ let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n))
586+ let b = ((s + ((D * aPrecision) / ann)) - D)
587+ func calc (acc,cur) = {
588+ let $t02256522585 = acc
589+ let y = $t02256522585._1
590+ let found = $t02256522585._2
591+ if ((found != unit))
592+ then acc
593+ else {
594+ let yNext = (((y * y) + c) / ((big2 * y) + b))
595+ let yDiff = absBigInt((yNext - value(y)))
596+ if ((big1 >= yDiff))
597+ then $Tuple2(yNext, cur)
598+ else $Tuple2(yNext, unit)
599+ }
600+ }
601+
602+ let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
603+ let $t02289222939 = {
604+ let $l = arr
605+ let $s = size($l)
606+ let $acc0 = $Tuple2(D, unit)
607+ func $f0_1 ($a,$i) = if (($i >= $s))
608+ then $a
609+ else calc($a, $l[$i])
610+
611+ func $f0_2 ($a,$i) = if (($i >= $s))
612+ then $a
613+ else throw("List size exceeds 15")
614+
615+ $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)
616+ }
617+ let y = $t02289222939._1
618+ let found = $t02289222939._2
619+ if ((found != unit))
620+ then y
621+ else throw(("Y calculation error, Y = " + toString(y)))
622+ }
623+
624+
625+func calcDLp (amountBalance,priceBalance,lpEmission) = {
626+ let updatedDLp = fraction(getD([amountBalance, priceBalance]), scale18, lpEmission)
627+ if ((lpEmission == big0))
628+ then big0
629+ else updatedDLp
630+ }
631+
632+
633+func calcCurrentDLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = {
634+ let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta)
635+ let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta)
636+ let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta)
637+ let currentDLp = calcDLp(amountAssetBalance, priceAssetBalance, lpAssetEmission)
638+ currentDLp
639+ }
640+
641+
642+func refreshDLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = {
643+ let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta)
644+ let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta)
645+ let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta)
646+ let updatedDLp = calcDLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission))
647+ let actions = [IntegerEntry(keyDLpRefreshedHeight, height), StringEntry(keyDLp, toString(updatedDLp))]
648+ $Tuple2(actions, updatedDLp)
649+ }
650+
651+
652+func validateUpdatedDLp (oldDLp,updatedDLp) = if ((updatedDLp >= oldDLp))
653+ then true
654+ else throwErr("updated DLp lower than current DLp")
655+
656+
657+func validateMatcherOrderAllowed (order) = {
658+ let amountAssetAmount = order.amount
659+ let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR)
660+ let $t02487825090 = if ((order.orderType == Buy))
661+ then $Tuple2(amountAssetAmount, -(priceAssetAmount))
662+ else $Tuple2(-(amountAssetAmount), priceAssetAmount)
663+ let amountAssetBalanceDelta = $t02487825090._1
664+ let priceAssetBalanceDelta = $t02487825090._2
450665 if (if (if (igs())
451666 then true
452- else (sts == PoolMatcherDis))
667+ else (cfgPoolStatus == PoolMatcherDis))
453668 then true
454- else (sts == PoolShutdown))
669+ else (cfgPoolStatus == PoolShutdown))
455670 then throw("Admin blocked")
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- }
671+ else if (if ((order.assetPair.amountAsset != cfgAmountAssetId))
672+ then true
673+ else (order.assetPair.priceAsset != cfgPriceAssetId))
674+ then throw("Wr assets")
675+ else {
676+ let dLp = parseBigIntValue(getStringValue(this, keyDLp))
677+ let $t02542025520 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
678+ let unusedActions = $t02542025520._1
679+ let dLpNew = $t02542025520._2
680+ let isOrderValid = (dLpNew >= dLp)
681+ isOrderValid
682+ }
479683 }
480684
481685
511715 }
512716
513717
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-
618718 func calcPutOneTkn (pmtAmtRaw,pmtAssetId,userAddress,txId,withTakeFee) = {
619- let poolConfig = gpc()
620- let amId = poolConfig[idxAmAsId]
621- let prId = poolConfig[idxPrAsId]
622- let lpId = poolConfig[idxLPAsId]
623- let amtDcm = parseIntValue(poolConfig[idxAmtAsDcm])
624- let priceDcm = parseIntValue(poolConfig[idxPriceAsDcm])
625- let lpAssetEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity)
719+ let amId = toBase58String(value(cfgAmountAssetId))
720+ let prId = toBase58String(value(cfgPriceAssetId))
721+ let lpId = cfgLpAssetId
722+ let amtDcm = cfgAmountAssetDecimals
723+ let priceDcm = cfgPriceAssetDecimals
724+ let lpAssetEmission = toBigInt(valueOrErrorMessage(assetInfo(lpId), "invalid lp asset").quantity)
626725 let chechEmission = if ((lpAssetEmission > big0))
627726 then true
628727 else throw("initial deposit requires all coins")
630729 then {
631730 let amBalance = getAccBalance(amId)
632731 let prBalance = getAccBalance(prId)
633- let $t02460425066 = if ((txId == ""))
732+ let $t02778628248 = if ((txId == ""))
634733 then $Tuple2(amBalance, prBalance)
635734 else if ((pmtAssetId == amId))
636735 then if ((pmtAmtRaw > amBalance))
641740 then throw("invalid payment amount")
642741 else $Tuple2(amBalance, (prBalance - pmtAmtRaw))
643742 else throw("wrong pmtAssetId")
644- let amBalanceOld = $t02460425066._1
645- let prBalanceOld = $t02460425066._2
646- let $t02507225248 = if ((pmtAssetId == amId))
743+ let amBalanceOld = $t02778628248._1
744+ let prBalanceOld = $t02778628248._2
745+ let $t02825428430 = if ((pmtAssetId == amId))
647746 then $Tuple2(pmtAmtRaw, 0)
648747 else if ((pmtAssetId == prId))
649748 then $Tuple2(0, pmtAmtRaw)
650749 else throw("invalid payment")
651- let amAmountRaw = $t02507225248._1
652- let prAmountRaw = $t02507225248._2
653- let $t02525225506 = if (withTakeFee)
750+ let amAmountRaw = $t02825428430._1
751+ let prAmountRaw = $t02825428430._2
752+ let $t02843428688 = if (withTakeFee)
654753 then $Tuple3(takeFee(amAmountRaw, inFee)._1, takeFee(prAmountRaw, inFee)._1, takeFee(pmtAmtRaw, inFee)._2)
655754 else $Tuple3(amAmountRaw, prAmountRaw, 0)
656- let amAmount = $t02525225506._1
657- let prAmount = $t02525225506._2
658- let feeAmount = $t02525225506._3
755+ let amAmount = $t02843428688._1
756+ let prAmount = $t02843428688._2
757+ let feeAmount = $t02843428688._3
659758 let amBalanceNew = (amBalanceOld + amAmount)
660759 let prBalanceNew = (prBalanceOld + prAmount)
661760 let D0 = getD([toBigInt(amBalanceOld), toBigInt(prBalanceOld)])
665764 else throw()
666765 if ((checkD == checkD))
667766 then {
668- let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0)
767+ let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0, FLOOR)
669768 let curPrice = f1(cpbi(t1(prBalanceNew, priceDcm), t1(amBalanceNew, amtDcm)), scale8)
670769 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))]
671770 let poolProportion = fraction(prBalanceOld, scale8, amBalanceOld)
682781
683782
684783 func getOneTknV2Internal (outAssetId,minOutAmount,payments,caller,originCaller,transactionId) = {
685- let poolConfig = gpc()
686- let lpId = poolConfig[idxLPAsId]
687- let amId = poolConfig[idxAmAsId]
688- let prId = poolConfig[idxPrAsId]
689- let amDecimals = parseIntValue(poolConfig[idxAmtAsDcm])
690- let prDecimals = parseIntValue(poolConfig[idxPriceAsDcm])
691- let poolStatus = poolConfig[idxPoolSt]
784+ let lpId = toBase58String(value(cfgLpAssetId))
785+ let amId = toBase58String(value(cfgAmountAssetId))
786+ let prId = toBase58String(value(cfgPriceAssetId))
787+ let amDecimals = cfgAmountAssetDecimals
788+ let prDecimals = cfgPriceAssetDecimals
789+ let poolStatus = cfgPoolStatus
692790 let userAddress = if ((caller == restContract))
693791 then originCaller
694792 else caller
695793 let pmt = value(payments[0])
696794 let pmtAssetId = value(pmt.assetId)
697795 let pmtAmt = pmt.amount
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))
796+ let currentDLp = calcCurrentDLp(big0, big0, big0)
797+ if ((currentDLp == currentDLp))
798+ then {
799+ let txId58 = toBase58String(transactionId)
800+ if ((lpId != toBase58String(pmtAssetId)))
801+ then throw("Wrong LP")
802+ else {
803+ let amBalance = getAccBalance(amId)
804+ let prBalance = getAccBalance(prId)
805+ let $t03073830849 = {
806+ let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil)
807+ if ($isInstanceOf(@, "(Int, Int)"))
808+ then @
809+ else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
810+ }
811+ if (($t03073830849 == $t03073830849))
738812 then {
739- let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
740- if ((burn == burn))
741- then $Tuple2(state, totalAmount)
813+ let feeAmount = $t03073830849._2
814+ let totalGet = $t03073830849._1
815+ let totalAmount = if (if ((minOutAmount > 0))
816+ then (minOutAmount > totalGet)
817+ else false)
818+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
819+ else totalGet
820+ let $t03103931346 = if ((outAssetId == amId))
821+ then $Tuple4(totalAmount, 0, ((amBalance - totalAmount) - feeAmount), prBalance)
822+ else if ((outAssetId == prId))
823+ then $Tuple4(0, totalAmount, amBalance, ((prBalance - totalAmount) - feeAmount))
824+ else throw("invalid out asset id")
825+ let outAm = $t03103931346._1
826+ let outPr = $t03103931346._2
827+ let amBalanceNew = $t03103931346._3
828+ let prBalanceNew = $t03103931346._4
829+ let curPrX18 = cpbi(t1(prBalanceNew, prDecimals), t1(amBalanceNew, amDecimals))
830+ let curPr = f1(curPrX18, scale8)
831+ let outAssetIdOrWaves = if ((outAssetId == "WAVES"))
832+ then unit
833+ else fromBase58String(outAssetId)
834+ let sendFeeToMatcher = if ((feeAmount > 0))
835+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)]
836+ else nil
837+ 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)
838+ if ((state == state))
839+ then {
840+ let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
841+ if ((burn == burn))
842+ then {
843+ let $t03213132481 = {
844+ let feeAmountForCalc = if ((this == feeCollectorAddress))
845+ then 0
846+ else feeAmount
847+ let outInAmountAsset = if ((parseAssetId(outAssetId) == cfgAmountAssetId))
848+ then true
849+ else false
850+ if (outInAmountAsset)
851+ then $Tuple2(-((totalGet + feeAmountForCalc)), 0)
852+ else $Tuple2(0, -((totalGet + feeAmountForCalc)))
853+ }
854+ let amountAssetBalanceDelta = $t03213132481._1
855+ let priceAssetBalanceDelta = $t03213132481._2
856+ let $t03248432592 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
857+ let refreshDLpActions = $t03248432592._1
858+ let updatedDLp = $t03248432592._2
859+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
860+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
861+ then $Tuple2((state ++ refreshDLpActions), totalAmount)
862+ else throw("Strict value is not equal to itself.")
863+ }
864+ else throw("Strict value is not equal to itself.")
865+ }
742866 else throw("Strict value is not equal to itself.")
743867 }
744868 else throw("Strict value is not equal to itself.")
745869 }
746- else throw("Strict value is not equal to itself.")
747870 }
871+ else throw("Strict value is not equal to itself.")
748872 }
749873
750874
849973 else if ((size(i.payments) != 2))
850974 then throw("2 pmnts expd")
851975 else {
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))
976+ let amAssetPmt = toBigInt(value(i.payments[0]).amount)
977+ let prAssetPmt = toBigInt(value(i.payments[1]).amount)
978+ let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amAssetPmt)
979+ if ((amountAssetBalance == amountAssetBalance))
862980 then {
863- let el = match r {
864- case legacy: Address =>
865- invoke(legacy, "emit", [emitLpAmt], nil)
866- case _ =>
867- unit
868- }
869- if ((el == el))
981+ let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - prAssetPmt)
982+ if ((priceAssetBalance == priceAssetBalance))
870983 then {
871- let sa = if ((amDiff > 0))
872- then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)])
873- else nil
874- if ((sa == sa))
984+ let lpAssetEmission = toBigInt(value(assetInfo(cfgLpAssetId)).quantity)
985+ if ((lpAssetEmission == lpAssetEmission))
875986 then {
876- let sp = if ((prDiff > 0))
877- then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)])
878- else nil
879- if ((sp == sp))
987+ let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0))
988+ if ((currentDLp == currentDLp))
880989 then {
881- let lpTrnsfr = if (autoStake)
990+ 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, "")
991+ let emitLpAmt = e._2
992+ let lpAssetId = e._7
993+ let state = e._9
994+ let amDiff = e._10
995+ let prDiff = e._11
996+ let amId = e._12
997+ let prId = e._13
998+ let r = invoke(fca, "emit", [emitLpAmt], nil)
999+ if ((r == r))
8821000 then {
883- let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
884- if ((ss == ss))
885- then nil
1001+ let el = match r {
1002+ case legacy: Address =>
1003+ invoke(legacy, "emit", [emitLpAmt], nil)
1004+ case _ =>
1005+ unit
1006+ }
1007+ if ((el == el))
1008+ then {
1009+ let sa = if ((amDiff > 0))
1010+ then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)])
1011+ else nil
1012+ if ((sa == sa))
1013+ then {
1014+ let sp = if ((prDiff > 0))
1015+ then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)])
1016+ else nil
1017+ if ((sp == sp))
1018+ then {
1019+ let lpTrnsfr = if (autoStake)
1020+ then {
1021+ let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
1022+ if ((ss == ss))
1023+ then nil
1024+ else throw("Strict value is not equal to itself.")
1025+ }
1026+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
1027+ let $t03674136883 = refreshDLpInternal(0, 0, 0)
1028+ let refreshDLpActions = $t03674136883._1
1029+ let updatedDLp = $t03674136883._2
1030+ let check = if ((updatedDLp >= currentDLp))
1031+ then true
1032+ else throwErr(makeString(["updated DLp lower than current DLp", toString(amountAssetBalance), toString(priceAssetBalance), toString(lpAssetEmission), toString(currentDLp), toString(updatedDLp), toString(amDiff), toString(prDiff)], " "))
1033+ if ((check == check))
1034+ then {
1035+ let lpAssetEmissionAfter = value(assetInfo(cfgLpAssetId)).quantity
1036+ if ((lpAssetEmissionAfter == lpAssetEmissionAfter))
1037+ then ((state ++ lpTrnsfr) ++ refreshDLpActions)
1038+ else throw("Strict value is not equal to itself.")
1039+ }
1040+ else throw("Strict value is not equal to itself.")
1041+ }
1042+ else throw("Strict value is not equal to itself.")
1043+ }
1044+ else throw("Strict value is not equal to itself.")
1045+ }
8861046 else throw("Strict value is not equal to itself.")
8871047 }
888- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
889- (state ++ lpTrnsfr)
1048+ else throw("Strict value is not equal to itself.")
8901049 }
8911050 else throw("Strict value is not equal to itself.")
8921051 }
9241083 else throwErr("exactly 1 payment are expected")]
9251084 if ((checks == checks))
9261085 then {
927- let poolConfig = gpc()
928- let amId = poolConfig[idxAmAsId]
929- let prId = poolConfig[idxPrAsId]
930- let lpId = fromBase58String(poolConfig[idxLPAsId])
931- let amDecimals = parseIntValue(poolConfig[idxAmtAsDcm])
932- let prDecimals = parseIntValue(poolConfig[idxPriceAsDcm])
1086+ let amId = toBase58String(value(cfgAmountAssetId))
1087+ let prId = toBase58String(value(cfgPriceAssetId))
1088+ let lpId = cfgLpAssetId
1089+ let amDecimals = cfgAmountAssetDecimals
1090+ let prDecimals = cfgPriceAssetDecimals
9331091 let userAddress = if ((i.caller == this))
9341092 then i.originCaller
9351093 else i.caller
9361094 let pmt = value(i.payments[0])
9371095 let pmtAssetId = toBase58String(value(pmt.assetId))
9381096 let pmtAmt = pmt.amount
939- let $t03347833636 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true)
940- if (($t03347833636 == $t03347833636))
1097+ let currentDLp = if ((pmt.assetId == cfgAmountAssetId))
1098+ then calcCurrentDLp(toBigInt(pmtAmt), toBigInt(0), toBigInt(0))
1099+ else calcCurrentDLp(toBigInt(0), toBigInt(pmtAmt), toBigInt(0))
1100+ if ((currentDLp == currentDLp))
9411101 then {
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))
1102+ let $t03852438682 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true)
1103+ if (($t03852438682 == $t03852438682))
9521104 then {
953- let el = match e {
954- case legacy: Address =>
955- invoke(legacy, "emit", [emitLpAmt], nil)
956- case _ =>
957- unit
958- }
959- if ((el == el))
1105+ let feeAmount = $t03852438682._3
1106+ let state = $t03852438682._2
1107+ let estimLP = $t03852438682._1
1108+ let emitLpAmt = if (if ((minOutAmount > 0))
1109+ then (minOutAmount > estimLP)
1110+ else false)
1111+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1112+ else estimLP
1113+ let e = invoke(fca, "emit", [emitLpAmt], nil)
1114+ if ((e == e))
9601115 then {
961- let lpTrnsfr = if (autoStake)
1116+ let el = match e {
1117+ case legacy: Address =>
1118+ invoke(legacy, "emit", [emitLpAmt], nil)
1119+ case _ =>
1120+ unit
1121+ }
1122+ if ((el == el))
9621123 then {
963- let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)])
964- if ((ss == ss))
965- then nil
1124+ let lpTrnsfr = if (autoStake)
1125+ then {
1126+ let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)])
1127+ if ((ss == ss))
1128+ then nil
1129+ else throw("Strict value is not equal to itself.")
1130+ }
1131+ else [ScriptTransfer(i.caller, emitLpAmt, lpId)]
1132+ let sendFeeToMatcher = if ((feeAmount > 0))
1133+ then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))]
1134+ else nil
1135+ let $t03949739846 = if ((this == feeCollectorAddress))
1136+ then $Tuple2(0, 0)
1137+ else {
1138+ let paymentInAmountAsset = if ((pmt.assetId == cfgAmountAssetId))
1139+ then true
1140+ else false
1141+ if (paymentInAmountAsset)
1142+ then $Tuple2(-(feeAmount), 0)
1143+ else $Tuple2(0, -(feeAmount))
1144+ }
1145+ let amountAssetBalanceDelta = $t03949739846._1
1146+ let priceAssetBalanceDelta = $t03949739846._2
1147+ let $t03984939957 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1148+ let refreshDLpActions = $t03984939957._1
1149+ let updatedDLp = $t03984939957._2
1150+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1151+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1152+ then $Tuple2((((state ++ lpTrnsfr) ++ sendFeeToMatcher) ++ refreshDLpActions), emitLpAmt)
9661153 else throw("Strict value is not equal to itself.")
9671154 }
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)
1155+ else throw("Strict value is not equal to itself.")
9731156 }
9741157 else throw("Strict value is not equal to itself.")
9751158 }
9891172 then throw("2 pmnts expd")
9901173 else {
9911174 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
1175+ let state = estPut._9
1176+ let amAssetPmt = toBigInt(value(i.payments[0]).amount)
1177+ let prAssetPmt = toBigInt(value(i.payments[1]).amount)
1178+ let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0))
1179+ if ((currentDLp == currentDLp))
1180+ then {
1181+ let $t04098741052 = refreshDLpInternal(0, 0, 0)
1182+ let refreshDLpActions = $t04098741052._1
1183+ let updatedDLp = $t04098741052._2
1184+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1185+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1186+ then (state ++ refreshDLpActions)
1187+ else throw("Strict value is not equal to itself.")
1188+ }
1189+ else throw("Strict value is not equal to itself.")
9931190 }
9941191
9951192
9961193
9971194 @Callable(i)
9981195 func get () = {
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
1196+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1197+ if ((currentDLp == currentDLp))
1198+ then {
1199+ let r = cg(i)
1200+ let outAmtAmt = r._1
1201+ let outPrAmt = r._2
1202+ let pmtAmt = r._3
1203+ let pmtAssetId = r._4
1204+ let state = r._5
1205+ let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1206+ if ((b == b))
1207+ then {
1208+ let $t04222542307 = refreshDLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1209+ let refreshDLpActions = $t04222542307._1
1210+ let updatedDLp = $t04222542307._2
1211+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1212+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1213+ then (state ++ refreshDLpActions)
1214+ else throw("Strict value is not equal to itself.")
1215+ }
1216+ else throw("Strict value is not equal to itself.")
1217+ }
10081218 else throw("Strict value is not equal to itself.")
10091219 }
10101220
10321242 else throwErr("exactly 1 payment are expected")]
10331243 if ((checks == checks))
10341244 then {
1035- let $t03625836413 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId)
1036- let state = $t03625836413._1
1037- let totalAmount = $t03625836413._2
1245+ let $t04292543080 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId)
1246+ let state = $t04292543080._1
1247+ let totalAmount = $t04292543080._2
10381248 $Tuple2(state, totalAmount)
10391249 }
10401250 else throw("Strict value is not equal to itself.")
10431253
10441254
10451255 @Callable(i)
1256+func refreshDLp () = {
1257+ let lastRefreshedBlockHeight = valueOrElse(getInteger(keyDLpRefreshedHeight), 0)
1258+ let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= dLpRefreshDelay))
1259+ then unit
1260+ else throwErr(makeString([toString(dLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1261+ if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1262+ then {
1263+ let dLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyDLp), "0")), fmtErr("invalid dLp"))
1264+ let $t04360443668 = refreshDLpInternal(0, 0, 0)
1265+ let dLpUpdateActions = $t04360443668._1
1266+ let updatedDLp = $t04360443668._2
1267+ let actions = if ((dLp != updatedDLp))
1268+ then dLpUpdateActions
1269+ else throwErr("nothing to refresh")
1270+ $Tuple2(actions, toString(updatedDLp))
1271+ }
1272+ else throw("Strict value is not equal to itself.")
1273+ }
1274+
1275+
1276+
1277+@Callable(i)
10461278 func getOneTknV2READONLY (outAssetId,lpAssetAmount) = {
1047- let poolConfig = gpc()
1048- let amId = poolConfig[idxAmAsId]
1049- let prId = poolConfig[idxPrAsId]
1050- let lpId = poolConfig[idxLPAsId]
1279+ let amId = toBase58String(value(cfgAmountAssetId))
1280+ let prId = toBase58String(value(cfgPriceAssetId))
1281+ let lpId = toBase58String(value(cfgLpAssetId))
10511282 let xp = [toBigInt(getAccBalance(amId)), toBigInt(getAccBalance(prId))]
10521283 let lpEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity)
10531284 let D0 = getD(xp)
10601291 let newY = getYD(xp, index, D1)
10611292 let dy = (xp[index] - newY)
10621293 let totalGetRaw = max([0, toInt((dy - big1))])
1063- let $t03720337258 = takeFee(totalGetRaw, outFee)
1064- let totalGet = $t03720337258._1
1065- let feeAmount = $t03720337258._2
1294+ let $t04459844653 = takeFee(totalGetRaw, outFee)
1295+ let totalGet = $t04459844653._1
1296+ let feeAmount = $t04459844653._2
10661297 $Tuple2(nil, $Tuple2(totalGet, feeAmount))
10671298 }
10681299
10701301
10711302 @Callable(i)
10721303 func getOneTknV2WithBonusREADONLY (outAssetId,lpAssetAmount) = {
1073- let poolConfig = gpc()
1074- let amId = poolConfig[idxAmAsId]
1075- let prId = poolConfig[idxPrAsId]
1076- let lpId = poolConfig[idxLPAsId]
1304+ let amId = toBase58String(value(cfgAmountAssetId))
1305+ let prId = toBase58String(value(cfgPriceAssetId))
1306+ let lpId = toBase58String(value(cfgLpAssetId))
10771307 let amBalance = getAccBalance(amId)
10781308 let prBalance = getAccBalance(prId)
1079- let $t03760337718 = {
1309+ let $t04502845143 = {
10801310 let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, lpAssetAmount], nil)
10811311 if ($isInstanceOf(@, "(Int, Int)"))
10821312 then @
10831313 else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
10841314 }
1085- let totalGet = $t03760337718._1
1086- let feeAmount = $t03760337718._2
1315+ let totalGet = $t04502845143._1
1316+ let feeAmount = $t04502845143._2
10871317 let r = ego("", lpId, lpAssetAmount, this)
10881318 let outAmAmt = r._1
10891319 let outPrAmt = r._2
11111341 else if ((noLessThenPriceAsset > outPrAmt))
11121342 then throw(((("Failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
11131343 else {
1114- let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1115- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1116- then state
1344+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1345+ if ((currentDLp == currentDLp))
1346+ then {
1347+ let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1348+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1349+ then {
1350+ let $t04630946390 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1351+ let refreshDLpActions = $t04630946390._1
1352+ let updatedDLp = $t04630946390._2
1353+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1354+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1355+ then (state ++ refreshDLpActions)
1356+ else throw("Strict value is not equal to itself.")
1357+ }
1358+ else throw("Strict value is not equal to itself.")
1359+ }
11171360 else throw("Strict value is not equal to itself.")
11181361 }
11191362 }
11271370 else true
11281371 if ((checkPayments == checkPayments))
11291372 then {
1130- let cfg = gpc()
11311373 let factoryCfg = gfc()
1132- let lpAssetId = fromBase58String(cfg[idxLPAsId])
1374+ let lpAssetId = cfgLpAssetId
11331375 let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
1376+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
11341377 let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil)
11351378 if ((unstakeInv == unstakeInv))
11361379 then {
11371380 let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1381+ let outAmAmt = r._1
1382+ let outPrAmt = r._2
11381383 let sts = parseIntValue(r._9)
11391384 let state = r._10
11401385 let v = if (if (igs())
11461391 then {
11471392 let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
11481393 if ((burnA == burnA))
1149- then state
1394+ then {
1395+ let $t04741447495 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1396+ let refreshDLpActions = $t04741447495._1
1397+ let updatedDLp = $t04741447495._2
1398+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1399+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1400+ then (state ++ refreshDLpActions)
1401+ else throw("Strict value is not equal to itself.")
1402+ }
11501403 else throw("Strict value is not equal to itself.")
11511404 }
11521405 else throw("Strict value is not equal to itself.")
11701423 else throw("no payments are expected")]
11711424 if ((checks == checks))
11721425 then {
1426+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
11731427 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
11741428 if ((unstakeInv == unstakeInv))
11751429 then {
11861440 then {
11871441 let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
11881442 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1189- then state
1443+ then {
1444+ let $t04874348824 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1445+ let refreshDLpActions = $t04874348824._1
1446+ let updatedDLp = $t04874348824._2
1447+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1448+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1449+ then (state ++ refreshDLpActions)
1450+ else throw("Strict value is not equal to itself.")
1451+ }
11901452 else throw("Strict value is not equal to itself.")
11911453 }
11921454 else throw("Strict value is not equal to itself.")
12201482 else throwErr("no payments are expected")]
12211483 if ((checks == checks))
12221484 then {
1223- let cfg = gpc()
12241485 let factoryCfg = gfc()
1225- let lpAssetId = fromBase58String(cfg[idxLPAsId])
1486+ let lpAssetId = cfgLpAssetId
12261487 let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
12271488 let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), unstakeAmount], nil)
12281489 if ((unstakeInv == unstakeInv))
12291490 then {
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
1491+ let $t04971949907 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId)
1492+ let state = $t04971949907._1
1493+ let totalAmount = $t04971949907._2
12331494 $Tuple2(state, totalAmount)
12341495 }
12351496 else throw("Strict value is not equal to itself.")
12411502
12421503 @Callable(i)
12431504 func putOneTknV2WithBonusREADONLY (paymentAmountRaw,paymentAssetId) = {
1244- let poolConfig = gpc()
1245- let amId = poolConfig[idxAmAsId]
1246- let prId = poolConfig[idxPrAsId]
1247- let lpId = poolConfig[idxLPAsId]
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
1505+ let $t05003550138 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true)
1506+ let lpAmount = $t05003550138._1
1507+ let state = $t05003550138._2
1508+ let feeAmount = $t05003550138._3
1509+ let bonus = $t05003550138._4
12531510 $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus))
12541511 }
12551512
12571514
12581515 @Callable(i)
12591516 func putOneTknV2WithoutTakeFeeREADONLY (paymentAmountRaw,paymentAssetId) = {
1260- let poolConfig = gpc()
1261- let amId = poolConfig[idxAmAsId]
1262- let prId = poolConfig[idxPrAsId]
1263- let lpId = poolConfig[idxLPAsId]
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
1517+ let $t05028650390 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false)
1518+ let lpAmount = $t05028650390._1
1519+ let state = $t05028650390._2
1520+ let feeAmount = $t05028650390._3
1521+ let bonus = $t05028650390._4
12691522 $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus))
12701523 }
12711524
13501603 match tx {
13511604 case order: Order =>
13521605 let matcherPub = mp()
1353- let orderValid = moa(order)
1606+ let orderValid = validateMatcherOrderAllowed(order)
13541607 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
13551608 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
13561609 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)
1721
1822 let slippage4D = toBigInt((scale8 - ((scale8 * 1) / scale8)))
1923
2024 let wavesString = "WAVES"
2125
2226 let Amult = "100"
2327
2428 let Dconv = "1"
2529
2630 let SEP = "__"
2731
2832 let EMPTY = ""
2933
3034 let PoolActive = 1
3135
3236 let PoolPutDis = 2
3337
3438 let PoolMatcherDis = 3
3539
3640 let PoolShutdown = 4
3741
3842 let idxPoolAddress = 1
3943
4044 let idxPoolSt = 2
4145
4246 let idxLPAsId = 3
4347
4448 let idxAmAsId = 4
4549
4650 let idxPrAsId = 5
4751
4852 let idxAmtAsDcm = 6
4953
5054 let idxPriceAsDcm = 7
5155
5256 let idxIAmtAsId = 8
5357
5458 let idxIPriceAsId = 9
5559
5660 let idxFactStakCntr = 1
5761
5862 let idxFactoryRestCntr = 6
5963
6064 let idxFactSlippCntr = 7
6165
6266 let idxFactGwxRewCntr = 10
6367
6468 let feeDefault = fraction(10, scale8, 10000)
6569
6670 func t1 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult))
6771
6872
6973 func f1 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18))
7074
7175
76+func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round))
77+
78+
79+func t2 (origVal,origScaleMult) = fraction(origVal, scale18, toBigInt(origScaleMult))
80+
81+
82+func f2 (val,resultScaleMult) = fraction(val, toBigInt(resultScaleMult), scale18)
83+
84+
7285 func ts (amt,resScale,curScale) = fraction(amt, resScale, curScale)
7386
7487
7588 func abs (val) = if ((zeroBigInt > val))
7689 then -(val)
7790 else val
7891
7992
8093 func absBigInt (val) = if ((zeroBigInt > val))
8194 then -(val)
8295 else val
8396
8497
8598 func fc () = "%s__factoryContract"
8699
87100
88101 func mpk () = "%s__managerPublicKey"
89102
90103
91104 func pmpk () = "%s__pendingManagerPublicKey"
92105
93106
94107 func pl () = "%s%s__price__last"
95108
96109
97110 func ph (h,t) = makeString(["%s%s%d%d__price__history", toString(h), toString(t)], SEP)
98111
99112
100113 func pau (ua,txId) = ((("%s%s%s__P__" + ua) + "__") + txId)
101114
102115
103116 func gau (ua,txId) = ((("%s%s%s__G__" + ua) + "__") + txId)
104117
105118
106119 func aa () = "%s__amountAsset"
107120
108121
109122 func pa () = "%s__priceAsset"
110123
111124
112125 func amp () = "%s__amp"
113126
114127
115128 func ada () = "%s__addonAddr"
116129
117130
131+let keyFee = "%s__fee"
132+
133+let fee = valueOrElse(getInteger(this, keyFee), feeDefault)
134+
135+let keyDLp = makeString(["%s", "dLp"], SEP)
136+
137+let keyDLpRefreshedHeight = makeString(["%s", "dLpRefreshedHeight"], SEP)
138+
139+let keyDLpRefreshDelay = makeString(["%s", "refreshDLpDelay"], SEP)
140+
141+let dLpRefreshDelayDefault = 1
142+
143+let dLpRefreshDelay = valueOrElse(getInteger(this, keyDLpRefreshDelay), dLpRefreshDelayDefault)
144+
118145 func fcfg () = "%s__factoryConfig"
119146
120147
121148 func mtpk () = "%s%s__matcher__publicKey"
122149
123150
124151 func pc (iAmtAs,iPrAs) = (((("%d%d%s__" + iAmtAs) + "__") + iPrAs) + "__config")
125152
126153
127154 func mba (bAStr) = ("%s%s%s__mappings__baseAsset2internalId__" + bAStr)
128155
129156
130157 func aps () = "%s__shutdown"
131158
132159
133160 func keyAllowedLpStableScriptHash () = "%s__allowedLpStableScriptHash"
134161
135162
136163 func keyFeeCollectorAddress () = "%s__feeCollectorAddress"
137164
138165
139166 func toe (orV,sendrV,matchV) = throw(((((("Failed: ordValid=" + toString(orV)) + " sndrValid=") + toString(sendrV)) + " mtchrValid=") + toString(matchV)))
140167
141168
142-func str (val) = match val {
143- case valStr: String =>
144- valStr
145- case _ =>
146- throw("fail cast to String")
147-}
148-
149-
150169 func strf (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], ""))
151170
152171
153172 func intf (addr,key) = valueOrErrorMessage(getInteger(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], ""))
154173
155174
156175 func throwErr (msg) = throw(makeString(["lp_stable.ride:", msg], " "))
176+
177+
178+func fmtErr (msg) = makeString(["lp_stable.ride:", msg], " ")
157179
158180
159181 let fca = addressFromStringValue(strf(this, fc()))
160182
161183 let inFee = {
162184 let @ = invoke(fca, "getInFeeREADONLY", [toString(this)], nil)
163185 if ($isInstanceOf(@, "Int"))
164186 then @
165187 else throw(($getType(@) + " couldn't be cast to Int"))
166188 }
167189
168190 let outFee = {
169191 let @ = invoke(fca, "getOutFeeREADONLY", [toString(this)], nil)
170192 if ($isInstanceOf(@, "Int"))
171193 then @
172194 else throw(($getType(@) + " couldn't be cast to Int"))
173195 }
174196
175197 let A = strf(this, amp())
176198
177199 func igs () = valueOrElse(getBoolean(fca, aps()), false)
178200
179201
180202 func mp () = fromBase58String(strf(fca, mtpk()))
181203
182204
183205 let feeCollectorAddress = addressFromStringValue(strf(fca, keyFeeCollectorAddress()))
184206
185207 func gpc () = {
186208 let amtAs = strf(this, aa())
187209 let priceAs = strf(this, pa())
188210 let iPriceAs = intf(fca, mba(priceAs))
189211 let iAmtAs = intf(fca, mba(amtAs))
190212 split(strf(fca, pc(toString(iAmtAs), toString(iPriceAs))), SEP)
191213 }
192214
193215
194216 func parseAssetId (input) = if ((input == wavesString))
195217 then unit
196218 else fromBase58String(input)
197219
198220
199221 func assetIdToString (input) = if ((input == unit))
200222 then wavesString
201223 else toBase58String(value(input))
202224
203225
204-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]))
226+func parsePoolConfig (poolConfig) = $Tuple9(addressFromStringValue(poolConfig[idxPoolAddress]), parseIntValue(poolConfig[idxPoolSt]), fromBase58String(poolConfig[idxLPAsId]), parseAssetId(poolConfig[idxAmAsId]), parseAssetId(poolConfig[idxPrAsId]), parseIntValue(poolConfig[idxAmtAsDcm]), parseIntValue(poolConfig[idxPriceAsDcm]), fromBase58String(poolConfig[idxIAmtAsId]), fromBase58String(poolConfig[idxIPriceAsId]))
205227
206228
207229 let poolConfigParsed = parsePoolConfig(gpc())
208230
209-let $t069097095 = poolConfigParsed
231+let $t077427971 = poolConfigParsed
210232
211-let cfgPoolAddress = $t069097095._1
233+let cfgPoolAddress = $t077427971._1
212234
213-let cfgPoolStatus = $t069097095._2
235+let cfgPoolStatus = $t077427971._2
214236
215-let cfgLpAssetId = $t069097095._3
237+let cfgLpAssetId = $t077427971._3
216238
217-let cfgAmountAssetId = $t069097095._4
239+let cfgAmountAssetId = $t077427971._4
218240
219-let cfgPriceAssetId = $t069097095._5
241+let cfgPriceAssetId = $t077427971._5
220242
221-let cfgAmountAssetDecimals = $t069097095._6
243+let cfgAmountAssetDecimals = $t077427971._6
222244
223-let cfgPriceAssetDecimals = $t069097095._7
245+let cfgPriceAssetDecimals = $t077427971._7
246+
247+let cfgInAmountAssedId = $t077427971._8
248+
249+let cfgInPriceAssetId = $t077427971._9
224250
225251 func gfc () = split(strf(fca, fcfg()), SEP)
226252
227253
228254 let factoryConfig = gfc()
229255
230256 let stakingContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactStakCntr]), "Invalid staking contract address")
231257
232258 let slipageContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactSlippCntr]), "Invalid slipage contract address")
233259
234260 let gwxContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactGwxRewCntr]), "Invalid gwx contract address")
235261
236262 let restContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactoryRestCntr]), "Invalid gwx contract address")
237263
238264 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)
239265
240266
241267 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)
242268
243269
244270 func getAccBalance (assetId) = if ((assetId == "WAVES"))
245271 then wavesBalance(this).available
246272 else assetBalance(this, fromBase58String(assetId))
247273
248274
249275 func cpbi (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
276+
277+
278+func cpbir (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
250279
251280
252281 func vad (A1,A2,slippage) = {
253282 let diff = fraction((A1 - A2), scale8BigInt, A2)
254283 let pass = ((slippage - abs(diff)) > zeroBigInt)
255284 if (!(pass))
256285 then throw(("Big slpg: " + toString(diff)))
257286 else $Tuple2(pass, min([A1, A2]))
258287 }
259288
260289
261290 func vd (D1,D0,slpg) = {
262291 let diff = fraction(D0, scale8BigInt, D1)
263292 let fail = (slpg > diff)
264293 if (if (fail)
265294 then true
266295 else (D0 > D1))
267296 then throw(((((((toString(D0) + " ") + toString(D1)) + " ") + toString(diff)) + " ") + toString(slpg)))
268297 else fail
269298 }
270299
271300
272301 func pcp (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
273302 let amtAsAmtX18 = t1(amAmt, amAssetDcm)
274303 let prAsAmtX18 = t1(prAmt, prAssetDcm)
275304 cpbi(prAsAmtX18, amtAsAmtX18)
276305 }
277306
278307
279308 func calcPrices (amAmt,prAmt,lpAmt) = {
280- let cfg = gpc()
281- let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm])
282- let prAsDcm = parseIntValue(cfg[idxPriceAsDcm])
309+ let amtAsDcm = cfgAmountAssetDecimals
310+ let prAsDcm = cfgPriceAssetDecimals
283311 let priceX18 = pcp(amtAsDcm, prAsDcm, amAmt, prAmt)
284312 let amAmtX18 = t1(amAmt, amtAsDcm)
285313 let prAmtX18 = t1(prAmt, prAsDcm)
286314 let lpAmtX18 = t1(lpAmt, scale8)
287315 let lpPrInAmAsX18 = cpbi(amAmtX18, lpAmtX18)
288316 let lpPrInPrAsX18 = cpbi(prAmtX18, lpAmtX18)
289317 [priceX18, lpPrInAmAsX18, lpPrInPrAsX18]
290318 }
291319
292320
293321 func calculatePrices (amAmt,prAmt,lpAmt) = {
294322 let p = calcPrices(amAmt, prAmt, lpAmt)
295323 [f1(p[0], scale8), f1(p[1], scale8), f1(p[2], scale8)]
296324 }
297325
298326
299327 func takeFee (amount,fee) = {
300328 let feeAmount = if ((fee == 0))
301329 then 0
302330 else fraction(amount, fee, scale8)
303331 $Tuple2((amount - feeAmount), feeAmount)
304332 }
305333
306334
307335 func ego (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
308- let cfg = gpc()
309- let lpId = cfg[idxLPAsId]
310- let amId = cfg[idxAmAsId]
311- let prId = cfg[idxPrAsId]
312- let amDcm = parseIntValue(cfg[idxAmtAsDcm])
313- let prDcm = parseIntValue(cfg[idxPriceAsDcm])
314- let sts = cfg[idxPoolSt]
315- let lpEmiss = valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "Wrong LP id").quantity
316- if ((lpId != pmtAssetId))
336+ let lpId = cfgLpAssetId
337+ let amId = toBase58String(value(cfgAmountAssetId))
338+ let prId = toBase58String(value(cfgPriceAssetId))
339+ let amDcm = cfgAmountAssetDecimals
340+ let prDcm = cfgPriceAssetDecimals
341+ let sts = toString(cfgPoolStatus)
342+ let lpEmiss = valueOrErrorMessage(assetInfo(lpId), "Wrong LP id").quantity
343+ if ((toBase58String(lpId) != pmtAssetId))
317344 then throw("Wrong pmt asset")
318345 else {
319346 let amBalance = getAccBalance(amId)
320347 let amBalanceX18 = t1(amBalance, amDcm)
321348 let prBalance = getAccBalance(prId)
322349 let prBalanceX18 = t1(prBalance, prDcm)
323350 let curPriceX18 = cpbi(prBalanceX18, amBalanceX18)
324351 let curPrice = f1(curPriceX18, scale8)
325352 let pmtLpAmtX18 = t1(pmtLpAmt, scale8)
326353 let lpEmissX18 = t1(lpEmiss, scale8)
327354 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissX18)
328355 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissX18)
329- let outAmAmt = f1(outAmAmtX18, amDcm)
330- let outPrAmt = f1(outPrAmtX18, prDcm)
356+ let outAmAmt = fromX18Round(outAmAmtX18, amDcm, FLOOR)
357+ let outPrAmt = fromX18Round(outPrAmtX18, prDcm, FLOOR)
331358 let state = if ((txId58 == ""))
332359 then nil
333360 else [ScriptTransfer(userAddress, outAmAmt, if ((amId == "WAVES"))
334361 then unit
335362 else fromBase58String(amId)), ScriptTransfer(userAddress, outPrAmt, if ((prId == "WAVES"))
336363 then unit
337364 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)]
338365 $Tuple10(outAmAmt, outPrAmt, amId, prId, amBalance, prBalance, lpEmiss, curPriceX18, sts, state)
339366 }
340367 }
341368
342369
343370 func epo (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,userAddress,isEval,emitLp,isOneAsset,validateSlippage,pmtAmt,pmtId) = {
344- let cfg = gpc()
345- let lpId = fromBase58String(cfg[idxLPAsId])
346- let amIdStr = cfg[idxAmAsId]
347- let prIdStr = cfg[idxPrAsId]
348- let inAmIdStr = cfg[idxIAmtAsId]
349- let inPrIdStr = cfg[idxIPriceAsId]
350- let amtDcm = parseIntValue(cfg[idxAmtAsDcm])
351- let priceDcm = parseIntValue(cfg[idxPriceAsDcm])
352- let sts = cfg[idxPoolSt]
371+ let lpId = cfgLpAssetId
372+ let amIdStr = toBase58String(value(cfgAmountAssetId))
373+ let prIdStr = toBase58String(value(cfgPriceAssetId))
374+ let inAmIdStr = cfgInAmountAssedId
375+ let inPrIdStr = cfgInPriceAssetId
376+ let amtDcm = cfgAmountAssetDecimals
377+ let priceDcm = cfgPriceAssetDecimals
378+ let sts = toString(cfgPoolStatus)
353379 let lpEm = valueOrErrorMessage(assetInfo(lpId), "Wr lp as").quantity
354380 let amBalance = if (isEval)
355381 then getAccBalance(amIdStr)
356382 else if (if (isOneAsset)
357383 then (pmtId == amIdStr)
358384 else false)
359385 then (getAccBalance(amIdStr) - pmtAmt)
360386 else if (isOneAsset)
361387 then getAccBalance(amIdStr)
362388 else (getAccBalance(amIdStr) - inAmAmt)
363389 let prBalance = if (isEval)
364390 then getAccBalance(prIdStr)
365391 else if (if (isOneAsset)
366392 then (pmtId == prIdStr)
367393 else false)
368394 then (getAccBalance(prIdStr) - pmtAmt)
369395 else if (isOneAsset)
370396 then getAccBalance(prIdStr)
371397 else (getAccBalance(prIdStr) - inPrAmt)
372398 let inAmAssetAmtX18 = t1(inAmAmt, amtDcm)
373399 let inPrAssetAmtX18 = t1(inPrAmt, priceDcm)
374400 let userPriceX18 = cpbi(inPrAssetAmtX18, inAmAssetAmtX18)
375401 let amBalanceX18 = t1(amBalance, amtDcm)
376402 let prBalanceX18 = t1(prBalance, priceDcm)
377403 let r = if ((lpEm == 0))
378404 then {
379405 let curPriceX18 = zeroBigInt
380406 let slippageX18 = zeroBigInt
381407 let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN)
382408 $Tuple5(f1(lpAmtX18, scale8), f1(inAmAssetAmtX18, amtDcm), f1(inPrAssetAmtX18, priceDcm), cpbi((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
383409 }
384410 else {
385411 let curPriceX18 = cpbi(prBalanceX18, amBalanceX18)
386412 let slippageRealX18 = fraction(abs((curPriceX18 - userPriceX18)), scale18, curPriceX18)
387413 let slippageX18 = t1(slippage, scale8)
388414 if (if (if (validateSlippage)
389415 then (curPriceX18 != zeroBigInt)
390416 else false)
391417 then (slippageRealX18 > slippageX18)
392418 else false)
393419 then throw(((("Price slippage " + toString(slippageRealX18)) + " > ") + toString(slippageX18)))
394420 else {
395421 let lpEmissionX18 = t1(lpEm, scale8)
396- let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
397- let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
422+ let prViaAmX18 = fraction(inAmAssetAmtX18, cpbir(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING)
423+ let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, cpbir(prBalanceX18, amBalanceX18, FLOOR), CEILING)
398424 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
399425 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
400426 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
401427 let expAmtAssetAmtX18 = expectedAmts._1
402428 let expPriceAssetAmtX18 = expectedAmts._2
403- let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
404- $Tuple5(f1(lpAmtX18, scale8), f1(expAmtAssetAmtX18, amtDcm), f1(expPriceAssetAmtX18, priceDcm), curPriceX18, slippageX18)
429+ let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR)
430+ $Tuple5((fromX18Round(lpAmtX18, scale8, FLOOR) - 100), fromX18Round(expAmtAssetAmtX18, amtDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceDcm, CEILING), curPriceX18, slippageX18)
405431 }
406432 }
407433 let calcLpAmt = r._1
408434 let calcAmAssetPmt = r._2
409435 let calcPrAssetPmt = r._3
410436 let curPrice = f1(r._4, scale8)
411437 let slippageCalc = f1(r._5, scale8)
412438 if ((0 >= calcLpAmt))
413439 then throw("LP <= 0")
414440 else {
415441 let emitLpAmt = if (!(emitLp))
416442 then 0
417443 else calcLpAmt
418444 let amDiff = (inAmAmt - calcAmAssetPmt)
419445 let prDiff = (inPrAmt - calcPrAssetPmt)
420- let $t01756217907 = if (if (isOneAsset)
446+ let $t01862718972 = if (if (isOneAsset)
421447 then (pmtId == amIdStr)
422448 else false)
423449 then $Tuple2(pmtAmt, 0)
424450 else if (if (isOneAsset)
425451 then (pmtId == prIdStr)
426452 else false)
427453 then $Tuple2(0, pmtAmt)
428454 else $Tuple2(calcAmAssetPmt, calcPrAssetPmt)
429- let writeAmAmt = $t01756217907._1
430- let writePrAmt = $t01756217907._2
455+ let writeAmAmt = $t01862718972._1
456+ let writePrAmt = $t01862718972._2
431457 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))]
432458 $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEm, lpId, sts, commonState, amDiff, prDiff, inAmId, inPrId)
433459 }
434460 }
435461
436462
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)
463+func getD (xp) = {
464+ let xp0 = xp[0]
465+ let xp1 = xp[1]
466+ let s = (xp0 + xp1)
467+ if ((s == big0))
468+ then big0
469+ else {
470+ let a = parseIntValue(A)
471+ let ann = (a * 2)
472+ let p = fraction(xp0, xp1, big1)
473+ let xp0_xp1_n_n = fraction(p, big4, big1)
474+ let ann_s = fraction(toBigInt(ann), s, big1)
475+ let ann_1 = toBigInt((ann - 1))
476+ func calcDNext (d) = {
477+ let dd = fraction(d, d, big1)
478+ let ddd = fraction(dd, d, big1)
479+ let dp = fraction(ddd, big1, xp0_xp1_n_n)
480+ fraction((ann_s + fraction(dp, big2, big1)), d, (fraction(ann_1, d, big1) + fraction(big3, dp, big1)), CEILING)
481+ }
482+
483+ func calc (acc,i) = if (acc._2)
484+ then acc
485+ else {
486+ let d = acc._1
487+ let dNext = calcDNext(d)
488+ let dDiffRaw = toInt((dNext - value(d)))
489+ let dDiff = if ((0 > dDiffRaw))
490+ then -(dDiffRaw)
491+ else dDiffRaw
492+ if ((1 >= dDiff))
493+ then $Tuple2(dNext, true)
494+ else $Tuple2(dNext, false)
495+ }
496+
497+ let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
498+ let $t02090020948 = {
499+ let $l = arr
500+ let $s = size($l)
501+ let $acc0 = $Tuple2(s, false)
502+ func $f0_1 ($a,$i) = if (($i >= $s))
503+ then $a
504+ else calc($a, $l[$i])
505+
506+ func $f0_2 ($a,$i) = if (($i >= $s))
507+ then $a
508+ else throw("List size exceeds 15")
509+
510+ $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)
511+ }
512+ let d = $t02090020948._1
513+ let found = $t02090020948._2
514+ if (found)
515+ then d
516+ else throw(("D calculation error, D = " + toString(d)))
517+ }
518+ }
519+
520+
521+func getDOld (xp) = {
522+ let n = big2
523+ let xp0 = xp[0]
524+ let xp1 = xp[1]
525+ let aPrecision = parseBigIntValue(Amult)
526+ let a = (parseBigIntValue(A) * aPrecision)
527+ let s = (xp0 + xp1)
528+ if ((s == big0))
529+ then big0
530+ else {
531+ let ann = (a * n)
532+ let xp0_xp1_n_n = (((xp0 * xp1) * n) * n)
533+ let ann_s_aPrecision = ((ann * s) / aPrecision)
534+ let ann_aPrecision = (ann - aPrecision)
535+ let n1 = (n + big1)
536+ func calc (acc,cur) = {
537+ let $t02157721597 = acc
538+ let d = $t02157721597._1
539+ let found = $t02157721597._2
540+ if ((found != unit))
541+ then acc
542+ else {
543+ let dp = (((d * d) * d) / xp0_xp1_n_n)
544+ let dNext = (((ann_s_aPrecision + (dp * n)) * d) / (((ann_aPrecision * d) / aPrecision) + (n1 * dp)))
545+ let dDiff = absBigInt((dNext - value(d)))
546+ if ((big1 >= dDiff))
547+ then $Tuple2(dNext, cur)
548+ else $Tuple2(dNext, unit)
549+ }
550+ }
551+
552+ let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
553+ let $t02201822065 = {
554+ let $l = arr
555+ let $s = size($l)
556+ let $acc0 = $Tuple2(s, unit)
557+ func $f0_1 ($a,$i) = if (($i >= $s))
558+ then $a
559+ else calc($a, $l[$i])
560+
561+ func $f0_2 ($a,$i) = if (($i >= $s))
562+ then $a
563+ else throw("List size exceeds 15")
564+
565+ $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)
566+ }
567+ let d = $t02201822065._1
568+ let found = $t02201822065._2
569+ if ((found != unit))
570+ then d
571+ else throw(("D calculation error, D = " + toString(d)))
572+ }
573+ }
574+
575+
576+func getYD (xp,i,D) = {
577+ let n = big2
578+ let x = xp[if ((i == 0))
579+ then 1
580+ else 0]
581+ let aPrecision = parseBigIntValue(Amult)
582+ let a = (parseBigIntValue(A) * aPrecision)
583+ let s = x
584+ let ann = (a * n)
585+ let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n))
586+ let b = ((s + ((D * aPrecision) / ann)) - D)
587+ func calc (acc,cur) = {
588+ let $t02256522585 = acc
589+ let y = $t02256522585._1
590+ let found = $t02256522585._2
591+ if ((found != unit))
592+ then acc
593+ else {
594+ let yNext = (((y * y) + c) / ((big2 * y) + b))
595+ let yDiff = absBigInt((yNext - value(y)))
596+ if ((big1 >= yDiff))
597+ then $Tuple2(yNext, cur)
598+ else $Tuple2(yNext, unit)
599+ }
600+ }
601+
602+ let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
603+ let $t02289222939 = {
604+ let $l = arr
605+ let $s = size($l)
606+ let $acc0 = $Tuple2(D, unit)
607+ func $f0_1 ($a,$i) = if (($i >= $s))
608+ then $a
609+ else calc($a, $l[$i])
610+
611+ func $f0_2 ($a,$i) = if (($i >= $s))
612+ then $a
613+ else throw("List size exceeds 15")
614+
615+ $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)
616+ }
617+ let y = $t02289222939._1
618+ let found = $t02289222939._2
619+ if ((found != unit))
620+ then y
621+ else throw(("Y calculation error, Y = " + toString(y)))
622+ }
623+
624+
625+func calcDLp (amountBalance,priceBalance,lpEmission) = {
626+ let updatedDLp = fraction(getD([amountBalance, priceBalance]), scale18, lpEmission)
627+ if ((lpEmission == big0))
628+ then big0
629+ else updatedDLp
630+ }
631+
632+
633+func calcCurrentDLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = {
634+ let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta)
635+ let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta)
636+ let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta)
637+ let currentDLp = calcDLp(amountAssetBalance, priceAssetBalance, lpAssetEmission)
638+ currentDLp
639+ }
640+
641+
642+func refreshDLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = {
643+ let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta)
644+ let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta)
645+ let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta)
646+ let updatedDLp = calcDLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission))
647+ let actions = [IntegerEntry(keyDLpRefreshedHeight, height), StringEntry(keyDLp, toString(updatedDLp))]
648+ $Tuple2(actions, updatedDLp)
649+ }
650+
651+
652+func validateUpdatedDLp (oldDLp,updatedDLp) = if ((updatedDLp >= oldDLp))
653+ then true
654+ else throwErr("updated DLp lower than current DLp")
655+
656+
657+func validateMatcherOrderAllowed (order) = {
658+ let amountAssetAmount = order.amount
659+ let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR)
660+ let $t02487825090 = if ((order.orderType == Buy))
661+ then $Tuple2(amountAssetAmount, -(priceAssetAmount))
662+ else $Tuple2(-(amountAssetAmount), priceAssetAmount)
663+ let amountAssetBalanceDelta = $t02487825090._1
664+ let priceAssetBalanceDelta = $t02487825090._2
450665 if (if (if (igs())
451666 then true
452- else (sts == PoolMatcherDis))
667+ else (cfgPoolStatus == PoolMatcherDis))
453668 then true
454- else (sts == PoolShutdown))
669+ else (cfgPoolStatus == PoolShutdown))
455670 then throw("Admin blocked")
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- }
671+ else if (if ((order.assetPair.amountAsset != cfgAmountAssetId))
672+ then true
673+ else (order.assetPair.priceAsset != cfgPriceAssetId))
674+ then throw("Wr assets")
675+ else {
676+ let dLp = parseBigIntValue(getStringValue(this, keyDLp))
677+ let $t02542025520 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
678+ let unusedActions = $t02542025520._1
679+ let dLpNew = $t02542025520._2
680+ let isOrderValid = (dLpNew >= dLp)
681+ isOrderValid
682+ }
479683 }
480684
481685
482686 func cg (i) = if ((size(i.payments) != 1))
483687 then throw("1 pmnt exp")
484688 else {
485689 let pmt = value(i.payments[0])
486690 let pmtAssetId = value(pmt.assetId)
487691 let pmtAmt = pmt.amount
488692 let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller)
489693 let outAmAmt = r._1
490694 let outPrAmt = r._2
491695 let sts = parseIntValue(r._9)
492696 let state = r._10
493697 if (if (igs())
494698 then true
495699 else (sts == PoolShutdown))
496700 then throw(("Admin blocked: " + toString(sts)))
497701 else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state)
498702 }
499703
500704
501705 func cp (caller,txId,amAsPmt,prAsPmt,slippage,emitLp,isOneAsset,validateSlippage,pmtAmt,pmtId) = {
502706 let r = epo(txId, slippage, value(amAsPmt).amount, value(amAsPmt).assetId, value(prAsPmt).amount, value(prAsPmt).assetId, caller, (txId == ""), emitLp, isOneAsset, validateSlippage, pmtAmt, pmtId)
503707 let sts = parseIntValue(r._8)
504708 if (if (if (igs())
505709 then true
506710 else (sts == PoolPutDis))
507711 then true
508712 else (sts == PoolShutdown))
509713 then throw(("Blocked:" + toString(sts)))
510714 else r
511715 }
512716
513717
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-
618718 func calcPutOneTkn (pmtAmtRaw,pmtAssetId,userAddress,txId,withTakeFee) = {
619- let poolConfig = gpc()
620- let amId = poolConfig[idxAmAsId]
621- let prId = poolConfig[idxPrAsId]
622- let lpId = poolConfig[idxLPAsId]
623- let amtDcm = parseIntValue(poolConfig[idxAmtAsDcm])
624- let priceDcm = parseIntValue(poolConfig[idxPriceAsDcm])
625- let lpAssetEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity)
719+ let amId = toBase58String(value(cfgAmountAssetId))
720+ let prId = toBase58String(value(cfgPriceAssetId))
721+ let lpId = cfgLpAssetId
722+ let amtDcm = cfgAmountAssetDecimals
723+ let priceDcm = cfgPriceAssetDecimals
724+ let lpAssetEmission = toBigInt(valueOrErrorMessage(assetInfo(lpId), "invalid lp asset").quantity)
626725 let chechEmission = if ((lpAssetEmission > big0))
627726 then true
628727 else throw("initial deposit requires all coins")
629728 if ((chechEmission == chechEmission))
630729 then {
631730 let amBalance = getAccBalance(amId)
632731 let prBalance = getAccBalance(prId)
633- let $t02460425066 = if ((txId == ""))
732+ let $t02778628248 = if ((txId == ""))
634733 then $Tuple2(amBalance, prBalance)
635734 else if ((pmtAssetId == amId))
636735 then if ((pmtAmtRaw > amBalance))
637736 then throw("invalid payment amount")
638737 else $Tuple2((amBalance - pmtAmtRaw), prBalance)
639738 else if ((pmtAssetId == prId))
640739 then if ((pmtAmtRaw > prBalance))
641740 then throw("invalid payment amount")
642741 else $Tuple2(amBalance, (prBalance - pmtAmtRaw))
643742 else throw("wrong pmtAssetId")
644- let amBalanceOld = $t02460425066._1
645- let prBalanceOld = $t02460425066._2
646- let $t02507225248 = if ((pmtAssetId == amId))
743+ let amBalanceOld = $t02778628248._1
744+ let prBalanceOld = $t02778628248._2
745+ let $t02825428430 = if ((pmtAssetId == amId))
647746 then $Tuple2(pmtAmtRaw, 0)
648747 else if ((pmtAssetId == prId))
649748 then $Tuple2(0, pmtAmtRaw)
650749 else throw("invalid payment")
651- let amAmountRaw = $t02507225248._1
652- let prAmountRaw = $t02507225248._2
653- let $t02525225506 = if (withTakeFee)
750+ let amAmountRaw = $t02825428430._1
751+ let prAmountRaw = $t02825428430._2
752+ let $t02843428688 = if (withTakeFee)
654753 then $Tuple3(takeFee(amAmountRaw, inFee)._1, takeFee(prAmountRaw, inFee)._1, takeFee(pmtAmtRaw, inFee)._2)
655754 else $Tuple3(amAmountRaw, prAmountRaw, 0)
656- let amAmount = $t02525225506._1
657- let prAmount = $t02525225506._2
658- let feeAmount = $t02525225506._3
755+ let amAmount = $t02843428688._1
756+ let prAmount = $t02843428688._2
757+ let feeAmount = $t02843428688._3
659758 let amBalanceNew = (amBalanceOld + amAmount)
660759 let prBalanceNew = (prBalanceOld + prAmount)
661760 let D0 = getD([toBigInt(amBalanceOld), toBigInt(prBalanceOld)])
662761 let D1 = getD([toBigInt(amBalanceNew), toBigInt(prBalanceNew)])
663762 let checkD = if ((D1 > D0))
664763 then true
665764 else throw()
666765 if ((checkD == checkD))
667766 then {
668- let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0)
767+ let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0, FLOOR)
669768 let curPrice = f1(cpbi(t1(prBalanceNew, priceDcm), t1(amBalanceNew, amtDcm)), scale8)
670769 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))]
671770 let poolProportion = fraction(prBalanceOld, scale8, amBalanceOld)
672771 let amountAssetPart = fraction(pmtAmtRaw, scale8, (poolProportion + scale8))
673772 let priceAssetPart = (pmtAmtRaw - amountAssetPart)
674773 let lpAmtBoth = fraction(lpAssetEmission, toBigInt(priceAssetPart), toBigInt(prBalanceOld))
675774 let bonus = toInt(fraction((lpAmount - lpAmtBoth), scale8BigInt, lpAmtBoth))
676775 $Tuple4(toInt(lpAmount), commonState, feeAmount, bonus)
677776 }
678777 else throw("Strict value is not equal to itself.")
679778 }
680779 else throw("Strict value is not equal to itself.")
681780 }
682781
683782
684783 func getOneTknV2Internal (outAssetId,minOutAmount,payments,caller,originCaller,transactionId) = {
685- let poolConfig = gpc()
686- let lpId = poolConfig[idxLPAsId]
687- let amId = poolConfig[idxAmAsId]
688- let prId = poolConfig[idxPrAsId]
689- let amDecimals = parseIntValue(poolConfig[idxAmtAsDcm])
690- let prDecimals = parseIntValue(poolConfig[idxPriceAsDcm])
691- let poolStatus = poolConfig[idxPoolSt]
784+ let lpId = toBase58String(value(cfgLpAssetId))
785+ let amId = toBase58String(value(cfgAmountAssetId))
786+ let prId = toBase58String(value(cfgPriceAssetId))
787+ let amDecimals = cfgAmountAssetDecimals
788+ let prDecimals = cfgPriceAssetDecimals
789+ let poolStatus = cfgPoolStatus
692790 let userAddress = if ((caller == restContract))
693791 then originCaller
694792 else caller
695793 let pmt = value(payments[0])
696794 let pmtAssetId = value(pmt.assetId)
697795 let pmtAmt = pmt.amount
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))
796+ let currentDLp = calcCurrentDLp(big0, big0, big0)
797+ if ((currentDLp == currentDLp))
798+ then {
799+ let txId58 = toBase58String(transactionId)
800+ if ((lpId != toBase58String(pmtAssetId)))
801+ then throw("Wrong LP")
802+ else {
803+ let amBalance = getAccBalance(amId)
804+ let prBalance = getAccBalance(prId)
805+ let $t03073830849 = {
806+ let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil)
807+ if ($isInstanceOf(@, "(Int, Int)"))
808+ then @
809+ else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
810+ }
811+ if (($t03073830849 == $t03073830849))
738812 then {
739- let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
740- if ((burn == burn))
741- then $Tuple2(state, totalAmount)
813+ let feeAmount = $t03073830849._2
814+ let totalGet = $t03073830849._1
815+ let totalAmount = if (if ((minOutAmount > 0))
816+ then (minOutAmount > totalGet)
817+ else false)
818+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
819+ else totalGet
820+ let $t03103931346 = if ((outAssetId == amId))
821+ then $Tuple4(totalAmount, 0, ((amBalance - totalAmount) - feeAmount), prBalance)
822+ else if ((outAssetId == prId))
823+ then $Tuple4(0, totalAmount, amBalance, ((prBalance - totalAmount) - feeAmount))
824+ else throw("invalid out asset id")
825+ let outAm = $t03103931346._1
826+ let outPr = $t03103931346._2
827+ let amBalanceNew = $t03103931346._3
828+ let prBalanceNew = $t03103931346._4
829+ let curPrX18 = cpbi(t1(prBalanceNew, prDecimals), t1(amBalanceNew, amDecimals))
830+ let curPr = f1(curPrX18, scale8)
831+ let outAssetIdOrWaves = if ((outAssetId == "WAVES"))
832+ then unit
833+ else fromBase58String(outAssetId)
834+ let sendFeeToMatcher = if ((feeAmount > 0))
835+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)]
836+ else nil
837+ 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)
838+ if ((state == state))
839+ then {
840+ let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
841+ if ((burn == burn))
842+ then {
843+ let $t03213132481 = {
844+ let feeAmountForCalc = if ((this == feeCollectorAddress))
845+ then 0
846+ else feeAmount
847+ let outInAmountAsset = if ((parseAssetId(outAssetId) == cfgAmountAssetId))
848+ then true
849+ else false
850+ if (outInAmountAsset)
851+ then $Tuple2(-((totalGet + feeAmountForCalc)), 0)
852+ else $Tuple2(0, -((totalGet + feeAmountForCalc)))
853+ }
854+ let amountAssetBalanceDelta = $t03213132481._1
855+ let priceAssetBalanceDelta = $t03213132481._2
856+ let $t03248432592 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
857+ let refreshDLpActions = $t03248432592._1
858+ let updatedDLp = $t03248432592._2
859+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
860+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
861+ then $Tuple2((state ++ refreshDLpActions), totalAmount)
862+ else throw("Strict value is not equal to itself.")
863+ }
864+ else throw("Strict value is not equal to itself.")
865+ }
742866 else throw("Strict value is not equal to itself.")
743867 }
744868 else throw("Strict value is not equal to itself.")
745869 }
746- else throw("Strict value is not equal to itself.")
747870 }
871+ else throw("Strict value is not equal to itself.")
748872 }
749873
750874
751875 func m () = match getString(mpk()) {
752876 case s: String =>
753877 fromBase58String(s)
754878 case _: Unit =>
755879 unit
756880 case _ =>
757881 throw("Match error")
758882 }
759883
760884
761885 func pm () = match getString(pmpk()) {
762886 case s: String =>
763887 fromBase58String(s)
764888 case _: Unit =>
765889 unit
766890 case _ =>
767891 throw("Match error")
768892 }
769893
770894
771895 let pd = throw("Permission denied")
772896
773897 func isManager (i) = match m() {
774898 case pk: ByteVector =>
775899 (i.callerPublicKey == pk)
776900 case _: Unit =>
777901 (i.caller == this)
778902 case _ =>
779903 throw("Match error")
780904 }
781905
782906
783907 func mm (i) = match m() {
784908 case pk: ByteVector =>
785909 if ((i.callerPublicKey == pk))
786910 then true
787911 else pd
788912 case _: Unit =>
789913 if ((i.caller == this))
790914 then true
791915 else pd
792916 case _ =>
793917 throw("Match error")
794918 }
795919
796920
797921 @Callable(i)
798922 func constructor (fc) = {
799923 let c = mm(i)
800924 if ((c == c))
801925 then [StringEntry(fc(), fc)]
802926 else throw("Strict value is not equal to itself.")
803927 }
804928
805929
806930
807931 @Callable(i)
808932 func setManager (pendingManagerPublicKey) = {
809933 let c = mm(i)
810934 if ((c == c))
811935 then {
812936 let cm = fromBase58String(pendingManagerPublicKey)
813937 if ((cm == cm))
814938 then [StringEntry(pmpk(), pendingManagerPublicKey)]
815939 else throw("Strict value is not equal to itself.")
816940 }
817941 else throw("Strict value is not equal to itself.")
818942 }
819943
820944
821945
822946 @Callable(i)
823947 func confirmManager () = {
824948 let p = pm()
825949 let hpm = if (isDefined(p))
826950 then true
827951 else throw("No pending manager")
828952 if ((hpm == hpm))
829953 then {
830954 let cpm = if ((i.callerPublicKey == value(p)))
831955 then true
832956 else throw("You are not pending manager")
833957 if ((cpm == cpm))
834958 then [StringEntry(mpk(), toBase58String(value(p))), DeleteEntry(pmpk())]
835959 else throw("Strict value is not equal to itself.")
836960 }
837961 else throw("Strict value is not equal to itself.")
838962 }
839963
840964
841965
842966 @Callable(i)
843967 func put (slip,autoStake) = {
844968 let factCfg = gfc()
845969 let stakingCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactStakCntr]), "Wr st addr")
846970 let slipCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactSlippCntr]), "Wr sl addr")
847971 if ((0 > slip))
848972 then throw("Wrong slippage")
849973 else if ((size(i.payments) != 2))
850974 then throw("2 pmnts expd")
851975 else {
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))
976+ let amAssetPmt = toBigInt(value(i.payments[0]).amount)
977+ let prAssetPmt = toBigInt(value(i.payments[1]).amount)
978+ let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amAssetPmt)
979+ if ((amountAssetBalance == amountAssetBalance))
862980 then {
863- let el = match r {
864- case legacy: Address =>
865- invoke(legacy, "emit", [emitLpAmt], nil)
866- case _ =>
867- unit
868- }
869- if ((el == el))
981+ let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - prAssetPmt)
982+ if ((priceAssetBalance == priceAssetBalance))
870983 then {
871- let sa = if ((amDiff > 0))
872- then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)])
873- else nil
874- if ((sa == sa))
984+ let lpAssetEmission = toBigInt(value(assetInfo(cfgLpAssetId)).quantity)
985+ if ((lpAssetEmission == lpAssetEmission))
875986 then {
876- let sp = if ((prDiff > 0))
877- then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)])
878- else nil
879- if ((sp == sp))
987+ let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0))
988+ if ((currentDLp == currentDLp))
880989 then {
881- let lpTrnsfr = if (autoStake)
990+ 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, "")
991+ let emitLpAmt = e._2
992+ let lpAssetId = e._7
993+ let state = e._9
994+ let amDiff = e._10
995+ let prDiff = e._11
996+ let amId = e._12
997+ let prId = e._13
998+ let r = invoke(fca, "emit", [emitLpAmt], nil)
999+ if ((r == r))
8821000 then {
883- let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
884- if ((ss == ss))
885- then nil
1001+ let el = match r {
1002+ case legacy: Address =>
1003+ invoke(legacy, "emit", [emitLpAmt], nil)
1004+ case _ =>
1005+ unit
1006+ }
1007+ if ((el == el))
1008+ then {
1009+ let sa = if ((amDiff > 0))
1010+ then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)])
1011+ else nil
1012+ if ((sa == sa))
1013+ then {
1014+ let sp = if ((prDiff > 0))
1015+ then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)])
1016+ else nil
1017+ if ((sp == sp))
1018+ then {
1019+ let lpTrnsfr = if (autoStake)
1020+ then {
1021+ let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
1022+ if ((ss == ss))
1023+ then nil
1024+ else throw("Strict value is not equal to itself.")
1025+ }
1026+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
1027+ let $t03674136883 = refreshDLpInternal(0, 0, 0)
1028+ let refreshDLpActions = $t03674136883._1
1029+ let updatedDLp = $t03674136883._2
1030+ let check = if ((updatedDLp >= currentDLp))
1031+ then true
1032+ else throwErr(makeString(["updated DLp lower than current DLp", toString(amountAssetBalance), toString(priceAssetBalance), toString(lpAssetEmission), toString(currentDLp), toString(updatedDLp), toString(amDiff), toString(prDiff)], " "))
1033+ if ((check == check))
1034+ then {
1035+ let lpAssetEmissionAfter = value(assetInfo(cfgLpAssetId)).quantity
1036+ if ((lpAssetEmissionAfter == lpAssetEmissionAfter))
1037+ then ((state ++ lpTrnsfr) ++ refreshDLpActions)
1038+ else throw("Strict value is not equal to itself.")
1039+ }
1040+ else throw("Strict value is not equal to itself.")
1041+ }
1042+ else throw("Strict value is not equal to itself.")
1043+ }
1044+ else throw("Strict value is not equal to itself.")
1045+ }
8861046 else throw("Strict value is not equal to itself.")
8871047 }
888- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
889- (state ++ lpTrnsfr)
1048+ else throw("Strict value is not equal to itself.")
8901049 }
8911050 else throw("Strict value is not equal to itself.")
8921051 }
8931052 else throw("Strict value is not equal to itself.")
8941053 }
8951054 else throw("Strict value is not equal to itself.")
8961055 }
8971056 else throw("Strict value is not equal to itself.")
8981057 }
8991058 }
9001059
9011060
9021061
9031062 @Callable(i)
9041063 func putOneTknV2 (minOutAmount,autoStake) = {
9051064 let isPoolOneTokenOperationsDisabled = {
9061065 let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
9071066 if ($isInstanceOf(@, "Boolean"))
9081067 then @
9091068 else throw(($getType(@) + " couldn't be cast to Boolean"))
9101069 }
9111070 let isPutDisabled = if (if (if (igs())
9121071 then true
9131072 else (cfgPoolStatus == PoolPutDis))
9141073 then true
9151074 else (cfgPoolStatus == PoolShutdown))
9161075 then true
9171076 else isPoolOneTokenOperationsDisabled
9181077 let checks = [if (if (!(isPutDisabled))
9191078 then true
9201079 else isManager(i))
9211080 then true
9221081 else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1))
9231082 then true
9241083 else throwErr("exactly 1 payment are expected")]
9251084 if ((checks == checks))
9261085 then {
927- let poolConfig = gpc()
928- let amId = poolConfig[idxAmAsId]
929- let prId = poolConfig[idxPrAsId]
930- let lpId = fromBase58String(poolConfig[idxLPAsId])
931- let amDecimals = parseIntValue(poolConfig[idxAmtAsDcm])
932- let prDecimals = parseIntValue(poolConfig[idxPriceAsDcm])
1086+ let amId = toBase58String(value(cfgAmountAssetId))
1087+ let prId = toBase58String(value(cfgPriceAssetId))
1088+ let lpId = cfgLpAssetId
1089+ let amDecimals = cfgAmountAssetDecimals
1090+ let prDecimals = cfgPriceAssetDecimals
9331091 let userAddress = if ((i.caller == this))
9341092 then i.originCaller
9351093 else i.caller
9361094 let pmt = value(i.payments[0])
9371095 let pmtAssetId = toBase58String(value(pmt.assetId))
9381096 let pmtAmt = pmt.amount
939- let $t03347833636 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true)
940- if (($t03347833636 == $t03347833636))
1097+ let currentDLp = if ((pmt.assetId == cfgAmountAssetId))
1098+ then calcCurrentDLp(toBigInt(pmtAmt), toBigInt(0), toBigInt(0))
1099+ else calcCurrentDLp(toBigInt(0), toBigInt(pmtAmt), toBigInt(0))
1100+ if ((currentDLp == currentDLp))
9411101 then {
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))
1102+ let $t03852438682 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true)
1103+ if (($t03852438682 == $t03852438682))
9521104 then {
953- let el = match e {
954- case legacy: Address =>
955- invoke(legacy, "emit", [emitLpAmt], nil)
956- case _ =>
957- unit
958- }
959- if ((el == el))
1105+ let feeAmount = $t03852438682._3
1106+ let state = $t03852438682._2
1107+ let estimLP = $t03852438682._1
1108+ let emitLpAmt = if (if ((minOutAmount > 0))
1109+ then (minOutAmount > estimLP)
1110+ else false)
1111+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1112+ else estimLP
1113+ let e = invoke(fca, "emit", [emitLpAmt], nil)
1114+ if ((e == e))
9601115 then {
961- let lpTrnsfr = if (autoStake)
1116+ let el = match e {
1117+ case legacy: Address =>
1118+ invoke(legacy, "emit", [emitLpAmt], nil)
1119+ case _ =>
1120+ unit
1121+ }
1122+ if ((el == el))
9621123 then {
963- let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)])
964- if ((ss == ss))
965- then nil
1124+ let lpTrnsfr = if (autoStake)
1125+ then {
1126+ let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)])
1127+ if ((ss == ss))
1128+ then nil
1129+ else throw("Strict value is not equal to itself.")
1130+ }
1131+ else [ScriptTransfer(i.caller, emitLpAmt, lpId)]
1132+ let sendFeeToMatcher = if ((feeAmount > 0))
1133+ then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))]
1134+ else nil
1135+ let $t03949739846 = if ((this == feeCollectorAddress))
1136+ then $Tuple2(0, 0)
1137+ else {
1138+ let paymentInAmountAsset = if ((pmt.assetId == cfgAmountAssetId))
1139+ then true
1140+ else false
1141+ if (paymentInAmountAsset)
1142+ then $Tuple2(-(feeAmount), 0)
1143+ else $Tuple2(0, -(feeAmount))
1144+ }
1145+ let amountAssetBalanceDelta = $t03949739846._1
1146+ let priceAssetBalanceDelta = $t03949739846._2
1147+ let $t03984939957 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1148+ let refreshDLpActions = $t03984939957._1
1149+ let updatedDLp = $t03984939957._2
1150+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1151+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1152+ then $Tuple2((((state ++ lpTrnsfr) ++ sendFeeToMatcher) ++ refreshDLpActions), emitLpAmt)
9661153 else throw("Strict value is not equal to itself.")
9671154 }
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)
1155+ else throw("Strict value is not equal to itself.")
9731156 }
9741157 else throw("Strict value is not equal to itself.")
9751158 }
9761159 else throw("Strict value is not equal to itself.")
9771160 }
9781161 else throw("Strict value is not equal to itself.")
9791162 }
9801163 else throw("Strict value is not equal to itself.")
9811164 }
9821165
9831166
9841167
9851168 @Callable(i)
9861169 func putForFree (maxSlpg) = if ((0 > maxSlpg))
9871170 then throw("Wrong slpg")
9881171 else if ((size(i.payments) != 2))
9891172 then throw("2 pmnts expd")
9901173 else {
9911174 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
1175+ let state = estPut._9
1176+ let amAssetPmt = toBigInt(value(i.payments[0]).amount)
1177+ let prAssetPmt = toBigInt(value(i.payments[1]).amount)
1178+ let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0))
1179+ if ((currentDLp == currentDLp))
1180+ then {
1181+ let $t04098741052 = refreshDLpInternal(0, 0, 0)
1182+ let refreshDLpActions = $t04098741052._1
1183+ let updatedDLp = $t04098741052._2
1184+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1185+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1186+ then (state ++ refreshDLpActions)
1187+ else throw("Strict value is not equal to itself.")
1188+ }
1189+ else throw("Strict value is not equal to itself.")
9931190 }
9941191
9951192
9961193
9971194 @Callable(i)
9981195 func get () = {
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
1196+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1197+ if ((currentDLp == currentDLp))
1198+ then {
1199+ let r = cg(i)
1200+ let outAmtAmt = r._1
1201+ let outPrAmt = r._2
1202+ let pmtAmt = r._3
1203+ let pmtAssetId = r._4
1204+ let state = r._5
1205+ let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1206+ if ((b == b))
1207+ then {
1208+ let $t04222542307 = refreshDLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1209+ let refreshDLpActions = $t04222542307._1
1210+ let updatedDLp = $t04222542307._2
1211+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1212+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1213+ then (state ++ refreshDLpActions)
1214+ else throw("Strict value is not equal to itself.")
1215+ }
1216+ else throw("Strict value is not equal to itself.")
1217+ }
10081218 else throw("Strict value is not equal to itself.")
10091219 }
10101220
10111221
10121222
10131223 @Callable(i)
10141224 func getOneTknV2 (outAssetId,minOutAmount) = {
10151225 let isPoolOneTokenOperationsDisabled = {
10161226 let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
10171227 if ($isInstanceOf(@, "Boolean"))
10181228 then @
10191229 else throw(($getType(@) + " couldn't be cast to Boolean"))
10201230 }
10211231 let isGetDisabled = if (if (igs())
10221232 then true
10231233 else (cfgPoolStatus == PoolShutdown))
10241234 then true
10251235 else isPoolOneTokenOperationsDisabled
10261236 let checks = [if (if (!(isGetDisabled))
10271237 then true
10281238 else isManager(i))
10291239 then true
10301240 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1))
10311241 then true
10321242 else throwErr("exactly 1 payment are expected")]
10331243 if ((checks == checks))
10341244 then {
1035- let $t03625836413 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId)
1036- let state = $t03625836413._1
1037- let totalAmount = $t03625836413._2
1245+ let $t04292543080 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId)
1246+ let state = $t04292543080._1
1247+ let totalAmount = $t04292543080._2
10381248 $Tuple2(state, totalAmount)
10391249 }
10401250 else throw("Strict value is not equal to itself.")
10411251 }
10421252
10431253
10441254
10451255 @Callable(i)
1256+func refreshDLp () = {
1257+ let lastRefreshedBlockHeight = valueOrElse(getInteger(keyDLpRefreshedHeight), 0)
1258+ let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= dLpRefreshDelay))
1259+ then unit
1260+ else throwErr(makeString([toString(dLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1261+ if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1262+ then {
1263+ let dLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyDLp), "0")), fmtErr("invalid dLp"))
1264+ let $t04360443668 = refreshDLpInternal(0, 0, 0)
1265+ let dLpUpdateActions = $t04360443668._1
1266+ let updatedDLp = $t04360443668._2
1267+ let actions = if ((dLp != updatedDLp))
1268+ then dLpUpdateActions
1269+ else throwErr("nothing to refresh")
1270+ $Tuple2(actions, toString(updatedDLp))
1271+ }
1272+ else throw("Strict value is not equal to itself.")
1273+ }
1274+
1275+
1276+
1277+@Callable(i)
10461278 func getOneTknV2READONLY (outAssetId,lpAssetAmount) = {
1047- let poolConfig = gpc()
1048- let amId = poolConfig[idxAmAsId]
1049- let prId = poolConfig[idxPrAsId]
1050- let lpId = poolConfig[idxLPAsId]
1279+ let amId = toBase58String(value(cfgAmountAssetId))
1280+ let prId = toBase58String(value(cfgPriceAssetId))
1281+ let lpId = toBase58String(value(cfgLpAssetId))
10511282 let xp = [toBigInt(getAccBalance(amId)), toBigInt(getAccBalance(prId))]
10521283 let lpEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity)
10531284 let D0 = getD(xp)
10541285 let D1 = (D0 - fraction(toBigInt(lpAssetAmount), D0, lpEmission))
10551286 let index = if ((outAssetId == amId))
10561287 then 0
10571288 else if ((outAssetId == prId))
10581289 then 1
10591290 else throw("invalid out asset id")
10601291 let newY = getYD(xp, index, D1)
10611292 let dy = (xp[index] - newY)
10621293 let totalGetRaw = max([0, toInt((dy - big1))])
1063- let $t03720337258 = takeFee(totalGetRaw, outFee)
1064- let totalGet = $t03720337258._1
1065- let feeAmount = $t03720337258._2
1294+ let $t04459844653 = takeFee(totalGetRaw, outFee)
1295+ let totalGet = $t04459844653._1
1296+ let feeAmount = $t04459844653._2
10661297 $Tuple2(nil, $Tuple2(totalGet, feeAmount))
10671298 }
10681299
10691300
10701301
10711302 @Callable(i)
10721303 func getOneTknV2WithBonusREADONLY (outAssetId,lpAssetAmount) = {
1073- let poolConfig = gpc()
1074- let amId = poolConfig[idxAmAsId]
1075- let prId = poolConfig[idxPrAsId]
1076- let lpId = poolConfig[idxLPAsId]
1304+ let amId = toBase58String(value(cfgAmountAssetId))
1305+ let prId = toBase58String(value(cfgPriceAssetId))
1306+ let lpId = toBase58String(value(cfgLpAssetId))
10771307 let amBalance = getAccBalance(amId)
10781308 let prBalance = getAccBalance(prId)
1079- let $t03760337718 = {
1309+ let $t04502845143 = {
10801310 let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, lpAssetAmount], nil)
10811311 if ($isInstanceOf(@, "(Int, Int)"))
10821312 then @
10831313 else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
10841314 }
1085- let totalGet = $t03760337718._1
1086- let feeAmount = $t03760337718._2
1315+ let totalGet = $t04502845143._1
1316+ let feeAmount = $t04502845143._2
10871317 let r = ego("", lpId, lpAssetAmount, this)
10881318 let outAmAmt = r._1
10891319 let outPrAmt = r._2
10901320 let sumOfGetAssets = (outAmAmt + outPrAmt)
10911321 let bonus = if ((sumOfGetAssets == 0))
10921322 then if ((totalGet == 0))
10931323 then 0
10941324 else throw("bonus calculation error")
10951325 else fraction((totalGet - sumOfGetAssets), scale8, sumOfGetAssets)
10961326 $Tuple2(nil, $Tuple3(totalGet, feeAmount, bonus))
10971327 }
10981328
10991329
11001330
11011331 @Callable(i)
11021332 func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = {
11031333 let r = cg(i)
11041334 let outAmAmt = r._1
11051335 let outPrAmt = r._2
11061336 let pmtAmt = r._3
11071337 let pmtAssetId = r._4
11081338 let state = r._5
11091339 if ((noLessThenAmtAsset > outAmAmt))
11101340 then throw(((("Failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset)))
11111341 else if ((noLessThenPriceAsset > outPrAmt))
11121342 then throw(((("Failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
11131343 else {
1114- let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1115- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1116- then state
1344+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1345+ if ((currentDLp == currentDLp))
1346+ then {
1347+ let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1348+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1349+ then {
1350+ let $t04630946390 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1351+ let refreshDLpActions = $t04630946390._1
1352+ let updatedDLp = $t04630946390._2
1353+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1354+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1355+ then (state ++ refreshDLpActions)
1356+ else throw("Strict value is not equal to itself.")
1357+ }
1358+ else throw("Strict value is not equal to itself.")
1359+ }
11171360 else throw("Strict value is not equal to itself.")
11181361 }
11191362 }
11201363
11211364
11221365
11231366 @Callable(i)
11241367 func unstakeAndGet (amount) = {
11251368 let checkPayments = if ((size(i.payments) != 0))
11261369 then throw("No pmnts expd")
11271370 else true
11281371 if ((checkPayments == checkPayments))
11291372 then {
1130- let cfg = gpc()
11311373 let factoryCfg = gfc()
1132- let lpAssetId = fromBase58String(cfg[idxLPAsId])
1374+ let lpAssetId = cfgLpAssetId
11331375 let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
1376+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
11341377 let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil)
11351378 if ((unstakeInv == unstakeInv))
11361379 then {
11371380 let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1381+ let outAmAmt = r._1
1382+ let outPrAmt = r._2
11381383 let sts = parseIntValue(r._9)
11391384 let state = r._10
11401385 let v = if (if (igs())
11411386 then true
11421387 else (sts == PoolShutdown))
11431388 then throw(("Blocked: " + toString(sts)))
11441389 else true
11451390 if ((v == v))
11461391 then {
11471392 let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
11481393 if ((burnA == burnA))
1149- then state
1394+ then {
1395+ let $t04741447495 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1396+ let refreshDLpActions = $t04741447495._1
1397+ let updatedDLp = $t04741447495._2
1398+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1399+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1400+ then (state ++ refreshDLpActions)
1401+ else throw("Strict value is not equal to itself.")
1402+ }
11501403 else throw("Strict value is not equal to itself.")
11511404 }
11521405 else throw("Strict value is not equal to itself.")
11531406 }
11541407 else throw("Strict value is not equal to itself.")
11551408 }
11561409 else throw("Strict value is not equal to itself.")
11571410 }
11581411
11591412
11601413
11611414 @Callable(i)
11621415 func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = {
11631416 let isGetDisabled = if (igs())
11641417 then true
11651418 else (cfgPoolStatus == PoolShutdown)
11661419 let checks = [if (!(isGetDisabled))
11671420 then true
11681421 else throw("get operation is blocked by admin"), if ((size(i.payments) == 0))
11691422 then true
11701423 else throw("no payments are expected")]
11711424 if ((checks == checks))
11721425 then {
1426+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
11731427 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
11741428 if ((unstakeInv == unstakeInv))
11751429 then {
11761430 let res = ego(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
11771431 let outAmAmt = res._1
11781432 let outPrAmt = res._2
11791433 let state = res._10
11801434 let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
11811435 then true
11821436 else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
11831437 then true
11841438 else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
11851439 if ((checkAmounts == checkAmounts))
11861440 then {
11871441 let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
11881442 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1189- then state
1443+ then {
1444+ let $t04874348824 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1445+ let refreshDLpActions = $t04874348824._1
1446+ let updatedDLp = $t04874348824._2
1447+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1448+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1449+ then (state ++ refreshDLpActions)
1450+ else throw("Strict value is not equal to itself.")
1451+ }
11901452 else throw("Strict value is not equal to itself.")
11911453 }
11921454 else throw("Strict value is not equal to itself.")
11931455 }
11941456 else throw("Strict value is not equal to itself.")
11951457 }
11961458 else throw("Strict value is not equal to itself.")
11971459 }
11981460
11991461
12001462
12011463 @Callable(i)
12021464 func unstakeAndGetOneTknV2 (unstakeAmount,outAssetId,minOutAmount) = {
12031465 let isPoolOneTokenOperationsDisabled = {
12041466 let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
12051467 if ($isInstanceOf(@, "Boolean"))
12061468 then @
12071469 else throw(($getType(@) + " couldn't be cast to Boolean"))
12081470 }
12091471 let isGetDisabled = if (if (igs())
12101472 then true
12111473 else (cfgPoolStatus == PoolShutdown))
12121474 then true
12131475 else isPoolOneTokenOperationsDisabled
12141476 let checks = [if (if (!(isGetDisabled))
12151477 then true
12161478 else isManager(i))
12171479 then true
12181480 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0))
12191481 then true
12201482 else throwErr("no payments are expected")]
12211483 if ((checks == checks))
12221484 then {
1223- let cfg = gpc()
12241485 let factoryCfg = gfc()
1225- let lpAssetId = fromBase58String(cfg[idxLPAsId])
1486+ let lpAssetId = cfgLpAssetId
12261487 let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
12271488 let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), unstakeAmount], nil)
12281489 if ((unstakeInv == unstakeInv))
12291490 then {
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
1491+ let $t04971949907 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId)
1492+ let state = $t04971949907._1
1493+ let totalAmount = $t04971949907._2
12331494 $Tuple2(state, totalAmount)
12341495 }
12351496 else throw("Strict value is not equal to itself.")
12361497 }
12371498 else throw("Strict value is not equal to itself.")
12381499 }
12391500
12401501
12411502
12421503 @Callable(i)
12431504 func putOneTknV2WithBonusREADONLY (paymentAmountRaw,paymentAssetId) = {
1244- let poolConfig = gpc()
1245- let amId = poolConfig[idxAmAsId]
1246- let prId = poolConfig[idxPrAsId]
1247- let lpId = poolConfig[idxLPAsId]
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
1505+ let $t05003550138 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true)
1506+ let lpAmount = $t05003550138._1
1507+ let state = $t05003550138._2
1508+ let feeAmount = $t05003550138._3
1509+ let bonus = $t05003550138._4
12531510 $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus))
12541511 }
12551512
12561513
12571514
12581515 @Callable(i)
12591516 func putOneTknV2WithoutTakeFeeREADONLY (paymentAmountRaw,paymentAssetId) = {
1260- let poolConfig = gpc()
1261- let amId = poolConfig[idxAmAsId]
1262- let prId = poolConfig[idxPrAsId]
1263- let lpId = poolConfig[idxLPAsId]
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
1517+ let $t05028650390 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false)
1518+ let lpAmount = $t05028650390._1
1519+ let state = $t05028650390._2
1520+ let feeAmount = $t05028650390._3
1521+ let bonus = $t05028650390._4
12691522 $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus))
12701523 }
12711524
12721525
12731526
12741527 @Callable(i)
12751528 func activate (amtAsStr,prAsStr) = if ((toString(i.caller) != toString(fca)))
12761529 then throw("denied")
12771530 else $Tuple2([StringEntry(aa(), amtAsStr), StringEntry(pa(), prAsStr)], "success")
12781531
12791532
12801533
12811534 @Callable(i)
12821535 func setS (k,v) = if ((toString(i.caller) != strf(this, ada())))
12831536 then pd
12841537 else [StringEntry(k, v)]
12851538
12861539
12871540
12881541 @Callable(i)
12891542 func setI (k,v) = if ((toString(i.caller) != strf(this, ada())))
12901543 then pd
12911544 else [IntegerEntry(k, v)]
12921545
12931546
12941547
12951548 @Callable(i)
12961549 func getPoolConfigWrapperREADONLY () = $Tuple2(nil, gpc())
12971550
12981551
12991552
13001553 @Callable(i)
13011554 func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId))
13021555
13031556
13041557
13051558 @Callable(i)
13061559 func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = {
13071560 let pr = calcPrices(amAmt, prAmt, lpAmt)
13081561 $Tuple2(nil, [toString(pr[0]), toString(pr[1]), toString(pr[2])])
13091562 }
13101563
13111564
13121565
13131566 @Callable(i)
13141567 func fromX18WrapperREADONLY (val,resScaleMult) = $Tuple2(nil, f1(parseBigIntValue(val), resScaleMult))
13151568
13161569
13171570
13181571 @Callable(i)
13191572 func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(t1(origVal, origScaleMult)))
13201573
13211574
13221575
13231576 @Callable(i)
13241577 func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(cpbi(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18))))
13251578
13261579
13271580
13281581 @Callable(i)
13291582 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, ""))
13301583
13311584
13321585
13331586 @Callable(i)
13341587 func estimateGetOperationWrapperREADONLY (txId58,pmtAsId,pmtLpAmt,usrAddr) = {
13351588 let r = ego(txId58, pmtAsId, pmtLpAmt, addressFromStringValue(usrAddr))
13361589 $Tuple2(nil, $Tuple10(r._1, r._2, r._3, r._4, r._5, r._6, r._7, toString(r._8), r._9, r._10))
13371590 }
13381591
13391592
13401593 @Verifier(tx)
13411594 func verify () = {
13421595 let targetPublicKey = match m() {
13431596 case pk: ByteVector =>
13441597 pk
13451598 case _: Unit =>
13461599 tx.senderPublicKey
13471600 case _ =>
13481601 throw("Match error")
13491602 }
13501603 match tx {
13511604 case order: Order =>
13521605 let matcherPub = mp()
1353- let orderValid = moa(order)
1606+ let orderValid = validateMatcherOrderAllowed(order)
13541607 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
13551608 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
13561609 if (if (if (orderValid)
13571610 then senderValid
13581611 else false)
13591612 then matcherValid
13601613 else false)
13611614 then true
13621615 else toe(orderValid, senderValid, matcherValid)
13631616 case s: SetScriptTransaction =>
13641617 let newHash = blake2b256(value(s.script))
13651618 let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash())))
13661619 let currentHash = scriptHash(this)
13671620 if (if ((allowedHash == newHash))
13681621 then (currentHash != newHash)
13691622 else false)
13701623 then true
13711624 else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
13721625 case _ =>
13731626 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
13741627 }
13751628 }
13761629

github/deemru/w8io/026f985 
217.82 ms