tx · Gm59MEY78Hw4gwPA5rhY7dMdDAVeZw3BX9kVG1962tmP

3NAefciWv6f9fWvEXdGgpHfanJFG8HqfjuT:  -0.04000000 Waves

2023.02.27 15:32 [2468124] smart account 3NAefciWv6f9fWvEXdGgpHfanJFG8HqfjuT > SELF 0.00000000 Waves

{ "type": 13, "id": "Gm59MEY78Hw4gwPA5rhY7dMdDAVeZw3BX9kVG1962tmP", "fee": 4000000, "feeAssetId": null, "timestamp": 1677501168351, "version": 2, "chainId": 84, "sender": "3NAefciWv6f9fWvEXdGgpHfanJFG8HqfjuT", "senderPublicKey": "D1BL65meykxFZTCuq7jq9HSGLLnWvQamQPUNrguW5w39", "proofs": [ "5uZMVznhjFRRSRKupWnTyWEkgUBqguZJnpN8i8Gsk1NEC2ZHEamAPDPgx61QrUN3XDkiqvR1eYJU21zhnUZZ6uWT" ], "script": "base64:BgKCKwgCEgUKAwEEARIHCgUBBAEIARIDCgEIEgMKAQgSABIECgIBBBIECgIBBBIDCgEBEgASBAoCCAESABIECgIIARIECgIIARIECgIBARIDCgEBEgUKAwEBARIFCgMBCAESBAoCAQgSBAoCAQgSBAoCCAgSBAoCCAgSBAoCCAESABIDCgEIEgUKAwEBARIECgIIARIECgIBARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCCIGc2NhbGU4IgxzY2FsZThCaWdJbnQiB3NjYWxlMTgiCnplcm9CaWdJbnQiBGJpZzAiBGJpZzEiBGJpZzIiBGJpZzMiBGJpZzQiCnNsaXBwYWdlNEQiC3dhdmVzU3RyaW5nIgVBbXVsdCIFRGNvbnYiA1NFUCIFRU1QVFkiClBvb2xBY3RpdmUiClBvb2xQdXREaXMiDlBvb2xNYXRjaGVyRGlzIgxQb29sU2h1dGRvd24iDmlkeFBvb2xBZGRyZXNzIglpZHhQb29sU3QiCWlkeExQQXNJZCIJaWR4QW1Bc0lkIglpZHhQckFzSWQiC2lkeEFtdEFzRGNtIg1pZHhQcmljZUFzRGNtIgtpZHhJQW10QXNJZCINa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JlWgUCZ2wEAmlsCQECYVcABAJpbQkBAmVZAQUCZVoEAmFGCAUCaW0CXzEEAmFHCAUCaW0CXzIEAmFICQD0AwMIBQJlWglib2R5Qnl0ZXMJAJEDAggFAmVaBnByb29mcwAACAUCZVoPc2VuZGVyUHVibGljS2V5BAJhSQkA9AMDCAUCZVoJYm9keUJ5dGVzCQCRAwIIBQJlWgZwcm9vZnMAAQUCaWwDAwMFAmFGBQJhSAcFAmFJBwYJAQJhRQQFAmFGBQJhRwUCYUgFAmFJAwkAAQIFAmdsAhRTZXRTY3JpcHRUcmFuc2FjdGlvbgQCY0MFAmdsAwkA9AMDCAUCaWkJYm9keUJ5dGVzCQCRAwIIBQJpaQZwcm9vZnMAAAUCaWsGBAJpbgkA9gMBCQEFdmFsdWUBCAUCY0MGc2NyaXB0BAJpbwkA2wQBCQEFdmFsdWUBCQCdCAIFAmFRCQECYUMABAJpcAkA8QcBBQR0aGlzAwkAAAIFAmlvBQJpbgkBAiE9AgUCaXAFAmluBwkA9AMDCAUCaWkJYm9keUJ5dGVzCQCRAwIIBQJpaQZwcm9vZnMAAAUCaWso85DP", "height": 2468124, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FCgGzRvw6fdH5SmPd5M5JNpfGPqa99GziSpQ8X6sGo1A Next: BUaUbouNtcJFNd9t2A4gyxL76b3rZHzADjL53CZ35mLK 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
6670 func t1 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult))
6771
6872
73+func t1BigInt (origVal,origScaleMult) = fraction(origVal, scale18, origScaleMult)
74+
75+
6976 func f1 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18))
77+
78+
79+func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round))
80+
81+
82+func t2 (origVal,origScaleMult) = fraction(origVal, scale18, toBigInt(origScaleMult))
83+
84+
85+func f2 (val,resultScaleMult) = fraction(val, toBigInt(resultScaleMult), scale18)
7086
7187
7288 func ts (amt,resScale,curScale) = fraction(amt, resScale, curScale)
115131 func ada () = "%s__addonAddr"
116132
117133
134+let keyFee = "%s__fee"
135+
136+let fee = valueOrElse(getInteger(this, keyFee), feeDefault)
137+
138+let keyDLp = makeString(["%s", "dLp"], SEP)
139+
140+let keyDLpRefreshedHeight = makeString(["%s", "dLpRefreshedHeight"], SEP)
141+
142+let keyDLpRefreshDelay = makeString(["%s", "refreshDLpDelay"], SEP)
143+
144+let dLpRefreshDelayDefault = 30
145+
146+let dLpRefreshDelay = valueOrElse(getInteger(this, keyDLpRefreshDelay), dLpRefreshDelayDefault)
147+
118148 func fcfg () = "%s__factoryConfig"
119149
120150
136166 func keyFeeCollectorAddress () = "%s__feeCollectorAddress"
137167
138168
139-func toe (orV,sendrV,matchV) = throw(((((("Failed: ordValid=" + toString(orV)) + " sndrValid=") + toString(sendrV)) + " mtchrValid=") + toString(matchV)))
140-
141-
142-func str (val) = match val {
143- case valStr: String =>
144- valStr
145- case _ =>
146- throw("fail cast to String")
147-}
169+func throwOrderError (orderValid,orderValidInfo,senderValid,matcherValid) = throw((((((((("order validation failed: orderValid=" + toString(orderValid)) + " (") + orderValidInfo) + ")") + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid)))
148170
149171
150172 func strf (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], ""))
154176
155177
156178 func throwErr (msg) = throw(makeString(["lp_stable.ride:", msg], " "))
179+
180+
181+func fmtErr (msg) = makeString(["lp_stable.ride:", msg], " ")
157182
158183
159184 let fca = addressFromStringValue(strf(this, fc()))
201226 else toBase58String(value(input))
202227
203228
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]))
229+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]))
205230
206231
207232 let poolConfigParsed = parsePoolConfig(gpc())
208233
209-let $t069097095 = poolConfigParsed
234+let $t079658194 = poolConfigParsed
210235
211-let cfgPoolAddress = $t069097095._1
236+let cfgPoolAddress = $t079658194._1
212237
213-let cfgPoolStatus = $t069097095._2
238+let cfgPoolStatus = $t079658194._2
214239
215-let cfgLpAssetId = $t069097095._3
240+let cfgLpAssetId = $t079658194._3
216241
217-let cfgAmountAssetId = $t069097095._4
242+let cfgAmountAssetId = $t079658194._4
218243
219-let cfgPriceAssetId = $t069097095._5
244+let cfgPriceAssetId = $t079658194._5
220245
221-let cfgAmountAssetDecimals = $t069097095._6
246+let cfgAmountAssetDecimals = $t079658194._6
222247
223-let cfgPriceAssetDecimals = $t069097095._7
248+let cfgPriceAssetDecimals = $t079658194._7
249+
250+let cfgInAmountAssedId = $t079658194._8
251+
252+let cfgInPriceAssetId = $t079658194._9
224253
225254 func gfc () = split(strf(fca, fcfg()), SEP)
226255
247276
248277
249278 func cpbi (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
279+
280+
281+func cpbir (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
250282
251283
252284 func vad (A1,A2,slippage) = {
277309
278310
279311 func calcPrices (amAmt,prAmt,lpAmt) = {
280- let cfg = gpc()
281- let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm])
282- let prAsDcm = parseIntValue(cfg[idxPriceAsDcm])
312+ let amtAsDcm = cfgAmountAssetDecimals
313+ let prAsDcm = cfgPriceAssetDecimals
283314 let priceX18 = pcp(amtAsDcm, prAsDcm, amAmt, prAmt)
284315 let amAmtX18 = t1(amAmt, amtAsDcm)
285316 let prAmtX18 = t1(prAmt, prAsDcm)
304335 }
305336
306337
338+func getD (xp) = {
339+ let xp0 = xp[0]
340+ let xp1 = xp[1]
341+ let s = (xp0 + xp1)
342+ if ((s == big0))
343+ then big0
344+ else {
345+ let a = parseIntValue(A)
346+ let ann = (a * 2)
347+ let p = fraction(xp0, xp1, big1)
348+ let xp0_xp1_n_n = fraction(p, big4, big1)
349+ let ann_s = fraction(toBigInt(ann), s, big1)
350+ let ann_1 = toBigInt((ann - 1))
351+ func calcDNext (d) = {
352+ let dd = fraction(d, d, big1)
353+ let ddd = fraction(dd, d, big1)
354+ let dp = fraction(ddd, big1, xp0_xp1_n_n)
355+ fraction((ann_s + fraction(dp, big2, big1)), d, (fraction(ann_1, d, big1) + fraction(big3, dp, big1)))
356+ }
357+
358+ func calc (acc,i) = if (acc._2)
359+ then acc
360+ else {
361+ let d = acc._1
362+ let dNext = calcDNext(d)
363+ let dDiffRaw = (dNext - value(d))
364+ let dDiff = if ((big0 > dDiffRaw))
365+ then -(dDiffRaw)
366+ else dDiffRaw
367+ if ((big1 >= dDiff))
368+ then $Tuple2(dNext, true)
369+ else $Tuple2(dNext, false)
370+ }
371+
372+ let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
373+ let $t01270312751 = {
374+ let $l = arr
375+ let $s = size($l)
376+ let $acc0 = $Tuple2(s, false)
377+ func $f0_1 ($a,$i) = if (($i >= $s))
378+ then $a
379+ else calc($a, $l[$i])
380+
381+ func $f0_2 ($a,$i) = if (($i >= $s))
382+ then $a
383+ else throw("List size exceeds 18")
384+
385+ $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($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18)
386+ }
387+ let d = $t01270312751._1
388+ let found = $t01270312751._2
389+ if (found)
390+ then d
391+ else throw(("D calculation error, D = " + toString(d)))
392+ }
393+ }
394+
395+
307396 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))
397+ let lpId = cfgLpAssetId
398+ let amId = toBase58String(value(cfgAmountAssetId))
399+ let prId = toBase58String(value(cfgPriceAssetId))
400+ let amDcm = cfgAmountAssetDecimals
401+ let prDcm = cfgPriceAssetDecimals
402+ let sts = toString(cfgPoolStatus)
403+ let lpEmiss = valueOrErrorMessage(assetInfo(lpId), "Wrong LP id").quantity
404+ if ((toBase58String(lpId) != pmtAssetId))
317405 then throw("Wrong pmt asset")
318406 else {
319407 let amBalance = getAccBalance(amId)
326414 let lpEmissX18 = t1(lpEmiss, scale8)
327415 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissX18)
328416 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissX18)
329- let outAmAmt = f1(outAmAmtX18, amDcm)
330- let outPrAmt = f1(outPrAmtX18, prDcm)
417+ let outAmAmt = fromX18Round(outAmAmtX18, amDcm, FLOOR)
418+ let outPrAmt = fromX18Round(outPrAmtX18, prDcm, FLOOR)
331419 let state = if ((txId58 == ""))
332420 then nil
333421 else [ScriptTransfer(userAddress, outAmAmt, if ((amId == "WAVES"))
341429
342430
343431 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]
432+ let lpId = cfgLpAssetId
433+ let amIdStr = toBase58String(value(cfgAmountAssetId))
434+ let prIdStr = toBase58String(value(cfgPriceAssetId))
435+ let inAmIdStr = cfgInAmountAssedId
436+ let inPrIdStr = cfgInPriceAssetId
437+ let amtDcm = cfgAmountAssetDecimals
438+ let priceDcm = cfgPriceAssetDecimals
439+ let sts = toString(cfgPoolStatus)
353440 let lpEm = valueOrErrorMessage(assetInfo(lpId), "Wr lp as").quantity
354441 let amBalance = if (isEval)
355442 then getAccBalance(amIdStr)
374461 let userPriceX18 = cpbi(inPrAssetAmtX18, inAmAssetAmtX18)
375462 let amBalanceX18 = t1(amBalance, amtDcm)
376463 let prBalanceX18 = t1(prBalance, priceDcm)
464+ let D0 = getD([amBalanceX18, prBalanceX18])
377465 let r = if ((lpEm == 0))
378466 then {
379- let curPriceX18 = zeroBigInt
380- let slippageX18 = zeroBigInt
381- let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN)
382- $Tuple5(f1(lpAmtX18, scale8), f1(inAmAssetAmtX18, amtDcm), f1(inPrAssetAmtX18, priceDcm), cpbi((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
467+ let D1 = getD([(amBalanceX18 + inAmAssetAmtX18), (prBalanceX18 + inPrAssetAmtX18)])
468+ let checkD = if ((D1 > D0))
469+ then true
470+ else throw("D1 should be greater than D0")
471+ if ((checkD == checkD))
472+ then {
473+ let curPriceX18 = zeroBigInt
474+ let slippageX18 = zeroBigInt
475+ let lpAmtX18 = D1
476+ $Tuple5(f1(lpAmtX18, scale8), f1(inAmAssetAmtX18, amtDcm), f1(inPrAssetAmtX18, priceDcm), cpbi((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
477+ }
478+ else throw("Strict value is not equal to itself.")
383479 }
384480 else {
385481 let curPriceX18 = cpbi(prBalanceX18, amBalanceX18)
393489 then throw(((("Price slippage " + toString(slippageRealX18)) + " > ") + toString(slippageX18)))
394490 else {
395491 let lpEmissionX18 = t1(lpEm, scale8)
396- let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
397- let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
492+ let prViaAmX18 = fraction(inAmAssetAmtX18, cpbir(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING)
493+ let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, cpbir(prBalanceX18, amBalanceX18, FLOOR), CEILING)
398494 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
399495 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
400496 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
401497 let expAmtAssetAmtX18 = expectedAmts._1
402498 let expPriceAssetAmtX18 = expectedAmts._2
403- let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
404- $Tuple5(f1(lpAmtX18, scale8), f1(expAmtAssetAmtX18, amtDcm), f1(expPriceAssetAmtX18, priceDcm), curPriceX18, slippageX18)
499+ let D1 = getD([(amBalanceX18 + expAmtAssetAmtX18), (prBalanceX18 + expPriceAssetAmtX18)])
500+ let checkD = if ((D1 > D0))
501+ then true
502+ else throw("D1 should be greater than D0")
503+ if ((checkD == checkD))
504+ then {
505+ let lpAmtX18 = fraction(lpEmissionX18, (D1 - D0), D0)
506+ $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceDcm, CEILING), curPriceX18, slippageX18)
507+ }
508+ else throw("Strict value is not equal to itself.")
405509 }
406510 }
407511 let calcLpAmt = r._1
417521 else calcLpAmt
418522 let amDiff = (inAmAmt - calcAmAssetPmt)
419523 let prDiff = (inPrAmt - calcPrAssetPmt)
420- let $t01756217907 = if (if (isOneAsset)
524+ let $t02059020935 = if (if (isOneAsset)
421525 then (pmtId == amIdStr)
422526 else false)
423527 then $Tuple2(pmtAmt, 0)
426530 else false)
427531 then $Tuple2(0, pmtAmt)
428532 else $Tuple2(calcAmAssetPmt, calcPrAssetPmt)
429- let writeAmAmt = $t01756217907._1
430- let writePrAmt = $t01756217907._2
533+ let writeAmAmt = $t02059020935._1
534+ let writePrAmt = $t02059020935._2
431535 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))]
432536 $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEm, lpId, sts, commonState, amDiff, prDiff, inAmId, inPrId)
433537 }
434538 }
435539
436540
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)
541+func getYD (xp,i,D) = {
542+ let n = big2
543+ let x = xp[if ((i == 0))
544+ then 1
545+ else 0]
546+ let aPrecision = parseBigIntValue(Amult)
547+ let a = (parseBigIntValue(A) * aPrecision)
548+ let s = x
549+ let ann = (a * n)
550+ let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n))
551+ let b = ((s + ((D * aPrecision) / ann)) - D)
552+ func calc (acc,cur) = {
553+ let $t02213022150 = acc
554+ let y = $t02213022150._1
555+ let found = $t02213022150._2
556+ if ((found != unit))
557+ then acc
558+ else {
559+ let yNext = (((y * y) + c) / ((big2 * y) + b))
560+ let yDiff = absBigInt((yNext - value(y)))
561+ if ((big1 >= yDiff))
562+ then $Tuple2(yNext, cur)
563+ else $Tuple2(yNext, unit)
564+ }
565+ }
566+
567+ let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
568+ let $t02245722504 = {
569+ let $l = arr
570+ let $s = size($l)
571+ let $acc0 = $Tuple2(D, unit)
572+ func $f0_1 ($a,$i) = if (($i >= $s))
573+ then $a
574+ else calc($a, $l[$i])
575+
576+ func $f0_2 ($a,$i) = if (($i >= $s))
577+ then $a
578+ else throw("List size exceeds 15")
579+
580+ $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)
581+ }
582+ let y = $t02245722504._1
583+ let found = $t02245722504._2
584+ if ((found != unit))
585+ then y
586+ else throw(("Y calculation error, Y = " + toString(y)))
587+ }
588+
589+
590+func calcDLp (amountBalance,priceBalance,lpEmission) = {
591+ let updatedDLp = fraction(getD([t1BigInt(amountBalance, toBigInt(cfgAmountAssetDecimals)), t1BigInt(priceBalance, toBigInt(cfgPriceAssetDecimals))]), scale18, lpEmission)
592+ if ((lpEmission == big0))
593+ then big0
594+ else updatedDLp
595+ }
596+
597+
598+func calcCurrentDLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = {
599+ let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta)
600+ let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta)
601+ let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta)
602+ let currentDLp = calcDLp(amountAssetBalance, priceAssetBalance, lpAssetEmission)
603+ currentDLp
604+ }
605+
606+
607+func refreshDLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = {
608+ let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta)
609+ let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta)
610+ let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta)
611+ let updatedDLp = calcDLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission))
612+ let actions = [IntegerEntry(keyDLpRefreshedHeight, height), StringEntry(keyDLp, toString(updatedDLp))]
613+ $Tuple2(actions, updatedDLp)
614+ }
615+
616+
617+func validateUpdatedDLp (oldDLp,updatedDLp) = if ((updatedDLp >= oldDLp))
618+ then true
619+ else throwErr("updated DLp lower than current DLp")
620+
621+
622+func validateMatcherOrderAllowed (order) = {
623+ let amountAssetBalance = getAccBalance(assetIdToString(cfgAmountAssetId))
624+ let priceAssetBalance = getAccBalance(assetIdToString(cfgPriceAssetId))
625+ let amountAssetAmount = order.amount
626+ let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR)
627+ let $t02470224914 = if ((order.orderType == Buy))
628+ then $Tuple2(amountAssetAmount, -(priceAssetAmount))
629+ else $Tuple2(-(amountAssetAmount), priceAssetAmount)
630+ let amountAssetBalanceDelta = $t02470224914._1
631+ let priceAssetBalanceDelta = $t02470224914._2
450632 if (if (if (igs())
451633 then true
452- else (sts == PoolMatcherDis))
634+ else (cfgPoolStatus == PoolMatcherDis))
453635 then true
454- else (sts == PoolShutdown))
636+ else (cfgPoolStatus == PoolShutdown))
455637 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- }
638+ else if (if ((order.assetPair.amountAsset != cfgAmountAssetId))
639+ then true
640+ else (order.assetPair.priceAsset != cfgPriceAssetId))
641+ then throw("Wr assets")
642+ else {
643+ let dLp = parseBigIntValue(valueOrElse(getString(this, keyDLp), "0"))
644+ let $t02525625356 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
645+ let unusedActions = $t02525625356._1
646+ let dLpNew = $t02525625356._2
647+ let isOrderValid = (dLpNew >= dLp)
648+ let info = makeString(["dLp=", toString(dLp), " dLpNew=", toString(dLpNew), " amountAssetBalance=", toString(amountAssetBalance), " priceAssetBalance=", toString(priceAssetBalance), " amountAssetBalanceDelta=", toString(amountAssetBalanceDelta), " priceAssetBalanceDelta=", toString(priceAssetBalanceDelta), " height=", toString(height)], "")
649+ $Tuple2(isOrderValid, info)
650+ }
479651 }
480652
481653
511683 }
512684
513685
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-
618686 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)
687+ let amId = toBase58String(value(cfgAmountAssetId))
688+ let prId = toBase58String(value(cfgPriceAssetId))
689+ let lpId = cfgLpAssetId
690+ let amtDcm = cfgAmountAssetDecimals
691+ let priceDcm = cfgPriceAssetDecimals
692+ let lpAssetEmission = toBigInt(valueOrErrorMessage(assetInfo(lpId), "invalid lp asset").quantity)
626693 let chechEmission = if ((lpAssetEmission > big0))
627694 then true
628695 else throw("initial deposit requires all coins")
630697 then {
631698 let amBalance = getAccBalance(amId)
632699 let prBalance = getAccBalance(prId)
633- let $t02460425066 = if ((txId == ""))
700+ let $t02801228474 = if ((txId == ""))
634701 then $Tuple2(amBalance, prBalance)
635702 else if ((pmtAssetId == amId))
636703 then if ((pmtAmtRaw > amBalance))
641708 then throw("invalid payment amount")
642709 else $Tuple2(amBalance, (prBalance - pmtAmtRaw))
643710 else throw("wrong pmtAssetId")
644- let amBalanceOld = $t02460425066._1
645- let prBalanceOld = $t02460425066._2
646- let $t02507225248 = if ((pmtAssetId == amId))
711+ let amBalanceOld = $t02801228474._1
712+ let prBalanceOld = $t02801228474._2
713+ let $t02848028656 = if ((pmtAssetId == amId))
647714 then $Tuple2(pmtAmtRaw, 0)
648715 else if ((pmtAssetId == prId))
649716 then $Tuple2(0, pmtAmtRaw)
650717 else throw("invalid payment")
651- let amAmountRaw = $t02507225248._1
652- let prAmountRaw = $t02507225248._2
653- let $t02525225506 = if (withTakeFee)
718+ let amAmountRaw = $t02848028656._1
719+ let prAmountRaw = $t02848028656._2
720+ let $t02866028914 = if (withTakeFee)
654721 then $Tuple3(takeFee(amAmountRaw, inFee)._1, takeFee(prAmountRaw, inFee)._1, takeFee(pmtAmtRaw, inFee)._2)
655722 else $Tuple3(amAmountRaw, prAmountRaw, 0)
656- let amAmount = $t02525225506._1
657- let prAmount = $t02525225506._2
658- let feeAmount = $t02525225506._3
723+ let amAmount = $t02866028914._1
724+ let prAmount = $t02866028914._2
725+ let feeAmount = $t02866028914._3
659726 let amBalanceNew = (amBalanceOld + amAmount)
660727 let prBalanceNew = (prBalanceOld + prAmount)
661- let D0 = getD([toBigInt(amBalanceOld), toBigInt(prBalanceOld)])
662- let D1 = getD([toBigInt(amBalanceNew), toBigInt(prBalanceNew)])
728+ let D0 = getD([t1(amBalanceOld, cfgAmountAssetDecimals), t1(prBalanceOld, cfgPriceAssetDecimals)])
729+ let D1 = getD([t1(amBalanceNew, cfgAmountAssetDecimals), t1(prBalanceNew, cfgPriceAssetDecimals)])
663730 let checkD = if ((D1 > D0))
664731 then true
665732 else throw()
666733 if ((checkD == checkD))
667734 then {
668- let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0)
735+ let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0, FLOOR)
669736 let curPrice = f1(cpbi(t1(prBalanceNew, priceDcm), t1(amBalanceNew, amtDcm)), scale8)
670737 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))]
671738 let poolProportion = fraction(prBalanceOld, scale8, amBalanceOld)
682749
683750
684751 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]
752+ let lpId = toBase58String(value(cfgLpAssetId))
753+ let amId = toBase58String(value(cfgAmountAssetId))
754+ let prId = toBase58String(value(cfgPriceAssetId))
755+ let amDecimals = cfgAmountAssetDecimals
756+ let prDecimals = cfgPriceAssetDecimals
757+ let poolStatus = cfgPoolStatus
692758 let userAddress = if ((caller == restContract))
693759 then originCaller
694760 else caller
695761 let pmt = value(payments[0])
696762 let pmtAssetId = value(pmt.assetId)
697763 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))
764+ let currentDLp = calcCurrentDLp(big0, big0, big0)
765+ if ((currentDLp == currentDLp))
766+ then {
767+ let txId58 = toBase58String(transactionId)
768+ if ((lpId != toBase58String(pmtAssetId)))
769+ then throw("Wrong LP")
770+ else {
771+ let amBalance = getAccBalance(amId)
772+ let prBalance = getAccBalance(prId)
773+ let $t03102631137 = {
774+ let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil)
775+ if ($isInstanceOf(@, "(Int, Int)"))
776+ then @
777+ else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
778+ }
779+ if (($t03102631137 == $t03102631137))
738780 then {
739- let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
740- if ((burn == burn))
741- then $Tuple2(state, totalAmount)
781+ let feeAmount = $t03102631137._2
782+ let totalGet = $t03102631137._1
783+ let totalAmount = if (if ((minOutAmount > 0))
784+ then (minOutAmount > totalGet)
785+ else false)
786+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
787+ else totalGet
788+ let $t03132731634 = if ((outAssetId == amId))
789+ then $Tuple4(totalAmount, 0, ((amBalance - totalAmount) - feeAmount), prBalance)
790+ else if ((outAssetId == prId))
791+ then $Tuple4(0, totalAmount, amBalance, ((prBalance - totalAmount) - feeAmount))
792+ else throw("invalid out asset id")
793+ let outAm = $t03132731634._1
794+ let outPr = $t03132731634._2
795+ let amBalanceNew = $t03132731634._3
796+ let prBalanceNew = $t03132731634._4
797+ let curPrX18 = cpbi(t1(prBalanceNew, prDecimals), t1(amBalanceNew, amDecimals))
798+ let curPr = f1(curPrX18, scale8)
799+ let outAssetIdOrWaves = if ((outAssetId == "WAVES"))
800+ then unit
801+ else fromBase58String(outAssetId)
802+ let sendFeeToMatcher = if ((feeAmount > 0))
803+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)]
804+ else nil
805+ 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)
806+ if ((state == state))
807+ then {
808+ let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
809+ if ((burn == burn))
810+ then {
811+ let $t03241932769 = {
812+ let feeAmountForCalc = if ((this == feeCollectorAddress))
813+ then 0
814+ else feeAmount
815+ let outInAmountAsset = if ((parseAssetId(outAssetId) == cfgAmountAssetId))
816+ then true
817+ else false
818+ if (outInAmountAsset)
819+ then $Tuple2(-((totalGet + feeAmountForCalc)), 0)
820+ else $Tuple2(0, -((totalGet + feeAmountForCalc)))
821+ }
822+ let amountAssetBalanceDelta = $t03241932769._1
823+ let priceAssetBalanceDelta = $t03241932769._2
824+ let $t03277232880 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
825+ let refreshDLpActions = $t03277232880._1
826+ let updatedDLp = $t03277232880._2
827+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
828+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
829+ then $Tuple2((state ++ refreshDLpActions), totalAmount)
830+ else throw("Strict value is not equal to itself.")
831+ }
832+ else throw("Strict value is not equal to itself.")
833+ }
742834 else throw("Strict value is not equal to itself.")
743835 }
744836 else throw("Strict value is not equal to itself.")
745837 }
746- else throw("Strict value is not equal to itself.")
747838 }
839+ else throw("Strict value is not equal to itself.")
748840 }
749841
750842
792884 case _ =>
793885 throw("Match error")
794886 }
887+
888+
889+func getY (isReverse,D,poolAmountInBalance) = {
890+ let poolConfig = gpc()
891+ let amId = poolConfig[idxAmAsId]
892+ let prId = poolConfig[idxPrAsId]
893+ let n = big2
894+ let aPrecision = parseBigIntValue(Amult)
895+ let a = (parseBigIntValue(A) * aPrecision)
896+ let xp = if ((isReverse == false))
897+ then [(toBigInt(getAccBalance(amId)) + poolAmountInBalance), toBigInt(getAccBalance(prId))]
898+ else [(toBigInt(getAccBalance(prId)) + poolAmountInBalance), toBigInt(getAccBalance(amId))]
899+ let x = xp[0]
900+ let s = x
901+ let ann = (a * n)
902+ let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n))
903+ let b = ((s + ((D * aPrecision) / ann)) - D)
904+ func calc (acc,cur) = {
905+ let $t03432734347 = acc
906+ let y = $t03432734347._1
907+ let found = $t03432734347._2
908+ if ((found != unit))
909+ then acc
910+ else {
911+ let yNext = (((y * y) + c) / ((big2 * y) + b))
912+ let yDiff = absBigInt((yNext - value(y)))
913+ if ((big1 >= yDiff))
914+ then $Tuple2(yNext, cur)
915+ else $Tuple2(yNext, unit)
916+ }
917+ }
918+
919+ let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
920+ let $t03467834725 = {
921+ let $l = arr
922+ let $s = size($l)
923+ let $acc0 = $Tuple2(D, unit)
924+ func $f0_1 ($a,$i) = if (($i >= $s))
925+ then $a
926+ else calc($a, $l[$i])
927+
928+ func $f0_2 ($a,$i) = if (($i >= $s))
929+ then $a
930+ else throw("List size exceeds 15")
931+
932+ $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)
933+ }
934+ let y = $t03467834725._1
935+ let found = $t03467834725._2
936+ if ((found != unit))
937+ then y
938+ else throw(("Y calculation error, Y = " + toString(y)))
939+ }
940+
941+
942+@Callable(i)
943+func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse,feePoolAmount) = {
944+ let $t03496635390 = if ((isReverse == false))
945+ then {
946+ let assetOut = strf(this, pa())
947+ let poolAmountInBalance = (toBigInt(getAccBalance(strf(this, aa()))) + toBigInt(cleanAmountIn))
948+ $Tuple2(assetOut, poolAmountInBalance)
949+ }
950+ else {
951+ let assetOut = strf(this, aa())
952+ let poolAmountInBalance = (toBigInt(getAccBalance(strf(this, pa()))) + toBigInt(cleanAmountIn))
953+ $Tuple2(assetOut, poolAmountInBalance)
954+ }
955+ let assetOut = $t03496635390._1
956+ let poolAmountInBalance = $t03496635390._2
957+ let poolConfig = gpc()
958+ let amId = poolConfig[idxAmAsId]
959+ let prId = poolConfig[idxPrAsId]
960+ let xp = [toBigInt(getAccBalance(amId)), toBigInt(getAccBalance(prId))]
961+ let D = getD(xp)
962+ let y = getY(isReverse, D, toBigInt(cleanAmountIn))
963+ let dy = ((toBigInt(getAccBalance(assetOut)) - y) - toBigInt(1))
964+ let totalGetRaw = max([0, toInt(dy)])
965+ let newXp = if ((isReverse == false))
966+ then [((toBigInt(getAccBalance(amId)) + toBigInt(cleanAmountIn)) + toBigInt(feePoolAmount)), (toBigInt(getAccBalance(prId)) - dy)]
967+ else [(toBigInt(getAccBalance(amId)) - dy), ((toBigInt(getAccBalance(prId)) + toBigInt(cleanAmountIn)) + toBigInt(feePoolAmount))]
968+ let newD = getD(newXp)
969+ let checkD = if ((newD >= D))
970+ then true
971+ else throw(makeString(["new D is fewer error", toString(D), toString(newD)], "__"))
972+ if ((checkD == checkD))
973+ then $Tuple2(nil, totalGetRaw)
974+ else throw("Strict value is not equal to itself.")
975+ }
976+
977+
978+
979+@Callable(i)
980+func calculateAmountOutForSwapAndSendTokens (cleanAmountIn,isReverse,amountOutMin,addressTo,feePoolAmount) = {
981+ let swapContact = {
982+ let @ = invoke(fca, "getSwapContractREADONLY", nil, nil)
983+ if ($isInstanceOf(@, "String"))
984+ then @
985+ else throw(($getType(@) + " couldn't be cast to String"))
986+ }
987+ let checks = [if ((value(i.payments[0]).amount >= cleanAmountIn))
988+ then true
989+ else throwErr("Wrong amount"), if ((i.caller == addressFromStringValue(swapContact)))
990+ then true
991+ else throwErr("Permission denied")]
992+ if ((checks == checks))
993+ then {
994+ let pmt = value(i.payments[0])
995+ let assetIn = assetIdToString(pmt.assetId)
996+ let $t03682637220 = if ((isReverse == false))
997+ then {
998+ let assetOut = strf(this, pa())
999+ let poolAmountInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount)
1000+ $Tuple2(assetOut, poolAmountInBalance)
1001+ }
1002+ else {
1003+ let assetOut = strf(this, aa())
1004+ let poolAmountInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount)
1005+ $Tuple2(assetOut, poolAmountInBalance)
1006+ }
1007+ let assetOut = $t03682637220._1
1008+ let poolAmountInBalance = $t03682637220._2
1009+ let poolConfig = gpc()
1010+ let amId = poolConfig[idxAmAsId]
1011+ let prId = poolConfig[idxPrAsId]
1012+ let xp = if ((isReverse == false))
1013+ then [(toBigInt(getAccBalance(amId)) - toBigInt(value(i.payments[0]).amount)), toBigInt(getAccBalance(prId))]
1014+ else [toBigInt(getAccBalance(amId)), (toBigInt(getAccBalance(prId)) - toBigInt(value(i.payments[0]).amount))]
1015+ let D = getD(xp)
1016+ let y = getY(isReverse, D, toBigInt(0))
1017+ let dy = ((toBigInt(getAccBalance(assetOut)) - y) - toBigInt(1))
1018+ let totalGetRaw = max([0, toInt(dy)])
1019+ let checkMin = if ((totalGetRaw >= amountOutMin))
1020+ then true
1021+ else throw("Exchange result is fewer coins than expected")
1022+ if ((checkMin == checkMin))
1023+ then {
1024+ let newXp = if ((isReverse == false))
1025+ then [(toBigInt(getAccBalance(amId)) + toBigInt(feePoolAmount)), (toBigInt(getAccBalance(prId)) - dy)]
1026+ else [(toBigInt(getAccBalance(amId)) - dy), (toBigInt(getAccBalance(prId)) + toBigInt(feePoolAmount))]
1027+ let newD = getD(newXp)
1028+ let checkD = if ((newD >= D))
1029+ then true
1030+ else throw("new D is fewer error")
1031+ if ((checkD == checkD))
1032+ then $Tuple2([ScriptTransfer(addressFromStringValue(addressTo), totalGetRaw, parseAssetId(assetOut))], totalGetRaw)
1033+ else throw("Strict value is not equal to itself.")
1034+ }
1035+ else throw("Strict value is not equal to itself.")
1036+ }
1037+ else throw("Strict value is not equal to itself.")
1038+ }
1039+
7951040
7961041
7971042 @Callable(i)
8491094 else if ((size(i.payments) != 2))
8501095 then throw("2 pmnts expd")
8511096 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))
1097+ let amAssetPmt = toBigInt(value(i.payments[0]).amount)
1098+ let prAssetPmt = toBigInt(value(i.payments[1]).amount)
1099+ let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amAssetPmt)
1100+ if ((amountAssetBalance == amountAssetBalance))
8621101 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))
1102+ let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - prAssetPmt)
1103+ if ((priceAssetBalance == priceAssetBalance))
8701104 then {
871- let sa = if ((amDiff > 0))
872- then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)])
873- else nil
874- if ((sa == sa))
1105+ let lpAssetEmission = toBigInt(value(assetInfo(cfgLpAssetId)).quantity)
1106+ if ((lpAssetEmission == lpAssetEmission))
8751107 then {
876- let sp = if ((prDiff > 0))
877- then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)])
878- else nil
879- if ((sp == sp))
1108+ let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0))
1109+ if ((currentDLp == currentDLp))
8801110 then {
881- let lpTrnsfr = if (autoStake)
1111+ 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, "")
1112+ let emitLpAmt = e._2
1113+ let lpAssetId = e._7
1114+ let state = e._9
1115+ let amDiff = e._10
1116+ let prDiff = e._11
1117+ let amId = e._12
1118+ let prId = e._13
1119+ let r = invoke(fca, "emit", [emitLpAmt], nil)
1120+ if ((r == r))
8821121 then {
883- let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
884- if ((ss == ss))
885- then nil
1122+ let el = match r {
1123+ case legacy: Address =>
1124+ invoke(legacy, "emit", [emitLpAmt], nil)
1125+ case _ =>
1126+ unit
1127+ }
1128+ if ((el == el))
1129+ then {
1130+ let sa = if ((amDiff > 0))
1131+ then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)])
1132+ else nil
1133+ if ((sa == sa))
1134+ then {
1135+ let sp = if ((prDiff > 0))
1136+ then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)])
1137+ else nil
1138+ if ((sp == sp))
1139+ then {
1140+ let lpTrnsfr = if (autoStake)
1141+ then {
1142+ let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
1143+ if ((ss == ss))
1144+ then nil
1145+ else throw("Strict value is not equal to itself.")
1146+ }
1147+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
1148+ let $t04183941981 = refreshDLpInternal(0, 0, 0)
1149+ let refreshDLpActions = $t04183941981._1
1150+ let updatedDLp = $t04183941981._2
1151+ let check = if ((updatedDLp >= currentDLp))
1152+ then true
1153+ else throwErr(makeString(["updated DLp lower than current DLp", toString(amountAssetBalance), toString(priceAssetBalance), toString(lpAssetEmission), toString(currentDLp), toString(updatedDLp), toString(amDiff), toString(prDiff)], " "))
1154+ if ((check == check))
1155+ then {
1156+ let lpAssetEmissionAfter = value(assetInfo(cfgLpAssetId)).quantity
1157+ if ((lpAssetEmissionAfter == lpAssetEmissionAfter))
1158+ then ((state ++ lpTrnsfr) ++ refreshDLpActions)
1159+ else throw("Strict value is not equal to itself.")
1160+ }
1161+ else throw("Strict value is not equal to itself.")
1162+ }
1163+ else throw("Strict value is not equal to itself.")
1164+ }
1165+ else throw("Strict value is not equal to itself.")
1166+ }
8861167 else throw("Strict value is not equal to itself.")
8871168 }
888- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
889- (state ++ lpTrnsfr)
1169+ else throw("Strict value is not equal to itself.")
8901170 }
8911171 else throw("Strict value is not equal to itself.")
8921172 }
9241204 else throwErr("exactly 1 payment are expected")]
9251205 if ((checks == checks))
9261206 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])
1207+ let amId = toBase58String(value(cfgAmountAssetId))
1208+ let prId = toBase58String(value(cfgPriceAssetId))
1209+ let lpId = cfgLpAssetId
1210+ let amDecimals = cfgAmountAssetDecimals
1211+ let prDecimals = cfgPriceAssetDecimals
9331212 let userAddress = if ((i.caller == this))
9341213 then i.originCaller
9351214 else i.caller
9361215 let pmt = value(i.payments[0])
9371216 let pmtAssetId = toBase58String(value(pmt.assetId))
9381217 let pmtAmt = pmt.amount
939- let $t03347833636 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true)
940- if (($t03347833636 == $t03347833636))
1218+ let currentDLp = if ((pmt.assetId == cfgAmountAssetId))
1219+ then calcCurrentDLp(toBigInt(pmtAmt), toBigInt(0), toBigInt(0))
1220+ else calcCurrentDLp(toBigInt(0), toBigInt(pmtAmt), toBigInt(0))
1221+ if ((currentDLp == currentDLp))
9411222 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))
1223+ let $t04362243780 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true)
1224+ if (($t04362243780 == $t04362243780))
9521225 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))
1226+ let feeAmount = $t04362243780._3
1227+ let state = $t04362243780._2
1228+ let estimLP = $t04362243780._1
1229+ let emitLpAmt = if (if ((minOutAmount > 0))
1230+ then (minOutAmount > estimLP)
1231+ else false)
1232+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1233+ else estimLP
1234+ let e = invoke(fca, "emit", [emitLpAmt], nil)
1235+ if ((e == e))
9601236 then {
961- let lpTrnsfr = if (autoStake)
1237+ let el = match e {
1238+ case legacy: Address =>
1239+ invoke(legacy, "emit", [emitLpAmt], nil)
1240+ case _ =>
1241+ unit
1242+ }
1243+ if ((el == el))
9621244 then {
963- let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)])
964- if ((ss == ss))
965- then nil
1245+ let lpTrnsfr = if (autoStake)
1246+ then {
1247+ let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)])
1248+ if ((ss == ss))
1249+ then nil
1250+ else throw("Strict value is not equal to itself.")
1251+ }
1252+ else [ScriptTransfer(i.caller, emitLpAmt, lpId)]
1253+ let sendFeeToMatcher = if ((feeAmount > 0))
1254+ then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))]
1255+ else nil
1256+ let $t04459544944 = if ((this == feeCollectorAddress))
1257+ then $Tuple2(0, 0)
1258+ else {
1259+ let paymentInAmountAsset = if ((pmt.assetId == cfgAmountAssetId))
1260+ then true
1261+ else false
1262+ if (paymentInAmountAsset)
1263+ then $Tuple2(-(feeAmount), 0)
1264+ else $Tuple2(0, -(feeAmount))
1265+ }
1266+ let amountAssetBalanceDelta = $t04459544944._1
1267+ let priceAssetBalanceDelta = $t04459544944._2
1268+ let $t04494745055 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1269+ let refreshDLpActions = $t04494745055._1
1270+ let updatedDLp = $t04494745055._2
1271+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1272+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1273+ then $Tuple2((((state ++ lpTrnsfr) ++ sendFeeToMatcher) ++ refreshDLpActions), emitLpAmt)
9661274 else throw("Strict value is not equal to itself.")
9671275 }
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)
1276+ else throw("Strict value is not equal to itself.")
9731277 }
9741278 else throw("Strict value is not equal to itself.")
9751279 }
9891293 then throw("2 pmnts expd")
9901294 else {
9911295 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
1296+ let state = estPut._9
1297+ let amAssetPmt = toBigInt(value(i.payments[0]).amount)
1298+ let prAssetPmt = toBigInt(value(i.payments[1]).amount)
1299+ let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0))
1300+ if ((currentDLp == currentDLp))
1301+ then {
1302+ let $t04608546150 = refreshDLpInternal(0, 0, 0)
1303+ let refreshDLpActions = $t04608546150._1
1304+ let updatedDLp = $t04608546150._2
1305+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1306+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1307+ then (state ++ refreshDLpActions)
1308+ else throw("Strict value is not equal to itself.")
1309+ }
1310+ else throw("Strict value is not equal to itself.")
9931311 }
9941312
9951313
9961314
9971315 @Callable(i)
9981316 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
1317+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1318+ if ((currentDLp == currentDLp))
1319+ then {
1320+ let r = cg(i)
1321+ let outAmtAmt = r._1
1322+ let outPrAmt = r._2
1323+ let pmtAmt = r._3
1324+ let pmtAssetId = r._4
1325+ let state = r._5
1326+ let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1327+ if ((b == b))
1328+ then {
1329+ let $t04732347405 = refreshDLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1330+ let refreshDLpActions = $t04732347405._1
1331+ let updatedDLp = $t04732347405._2
1332+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1333+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1334+ then (state ++ refreshDLpActions)
1335+ else throw("Strict value is not equal to itself.")
1336+ }
1337+ else throw("Strict value is not equal to itself.")
1338+ }
10081339 else throw("Strict value is not equal to itself.")
10091340 }
10101341
10321363 else throwErr("exactly 1 payment are expected")]
10331364 if ((checks == checks))
10341365 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
1366+ let $t04802348178 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId)
1367+ let state = $t04802348178._1
1368+ let totalAmount = $t04802348178._2
10381369 $Tuple2(state, totalAmount)
10391370 }
10401371 else throw("Strict value is not equal to itself.")
10431374
10441375
10451376 @Callable(i)
1377+func refreshDLp () = {
1378+ let lastRefreshedBlockHeight = valueOrElse(getInteger(keyDLpRefreshedHeight), 0)
1379+ let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= dLpRefreshDelay))
1380+ then unit
1381+ else throwErr(makeString([toString(dLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1382+ if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1383+ then {
1384+ let dLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyDLp), "0")), fmtErr("invalid dLp"))
1385+ let $t04870248766 = refreshDLpInternal(0, 0, 0)
1386+ let dLpUpdateActions = $t04870248766._1
1387+ let updatedDLp = $t04870248766._2
1388+ let actions = if ((dLp != updatedDLp))
1389+ then dLpUpdateActions
1390+ else throwErr("nothing to refresh")
1391+ $Tuple2(actions, toString(updatedDLp))
1392+ }
1393+ else throw("Strict value is not equal to itself.")
1394+ }
1395+
1396+
1397+
1398+@Callable(i)
10461399 func getOneTknV2READONLY (outAssetId,lpAssetAmount) = {
1047- let poolConfig = gpc()
1048- let amId = poolConfig[idxAmAsId]
1049- let prId = poolConfig[idxPrAsId]
1050- let lpId = poolConfig[idxLPAsId]
1400+ let amId = toBase58String(value(cfgAmountAssetId))
1401+ let prId = toBase58String(value(cfgPriceAssetId))
1402+ let lpId = toBase58String(value(cfgLpAssetId))
10511403 let xp = [toBigInt(getAccBalance(amId)), toBigInt(getAccBalance(prId))]
10521404 let lpEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity)
10531405 let D0 = getD(xp)
10601412 let newY = getYD(xp, index, D1)
10611413 let dy = (xp[index] - newY)
10621414 let totalGetRaw = max([0, toInt((dy - big1))])
1063- let $t03720337258 = takeFee(totalGetRaw, outFee)
1064- let totalGet = $t03720337258._1
1065- let feeAmount = $t03720337258._2
1415+ let $t04977649831 = takeFee(totalGetRaw, outFee)
1416+ let totalGet = $t04977649831._1
1417+ let feeAmount = $t04977649831._2
10661418 $Tuple2(nil, $Tuple2(totalGet, feeAmount))
10671419 }
10681420
10701422
10711423 @Callable(i)
10721424 func getOneTknV2WithBonusREADONLY (outAssetId,lpAssetAmount) = {
1073- let poolConfig = gpc()
1074- let amId = poolConfig[idxAmAsId]
1075- let prId = poolConfig[idxPrAsId]
1076- let lpId = poolConfig[idxLPAsId]
1425+ let amId = toBase58String(value(cfgAmountAssetId))
1426+ let prId = toBase58String(value(cfgPriceAssetId))
1427+ let lpId = toBase58String(value(cfgLpAssetId))
10771428 let amBalance = getAccBalance(amId)
10781429 let prBalance = getAccBalance(prId)
1079- let $t03760337718 = {
1430+ let $t05020650321 = {
10801431 let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, lpAssetAmount], nil)
10811432 if ($isInstanceOf(@, "(Int, Int)"))
10821433 then @
10831434 else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
10841435 }
1085- let totalGet = $t03760337718._1
1086- let feeAmount = $t03760337718._2
1436+ let totalGet = $t05020650321._1
1437+ let feeAmount = $t05020650321._2
10871438 let r = ego("", lpId, lpAssetAmount, this)
10881439 let outAmAmt = r._1
10891440 let outPrAmt = r._2
11111462 else if ((noLessThenPriceAsset > outPrAmt))
11121463 then throw(((("Failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
11131464 else {
1114- let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1115- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1116- then state
1465+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1466+ if ((currentDLp == currentDLp))
1467+ then {
1468+ let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1469+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1470+ then {
1471+ let $t05148751568 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1472+ let refreshDLpActions = $t05148751568._1
1473+ let updatedDLp = $t05148751568._2
1474+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1475+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1476+ then (state ++ refreshDLpActions)
1477+ else throw("Strict value is not equal to itself.")
1478+ }
1479+ else throw("Strict value is not equal to itself.")
1480+ }
11171481 else throw("Strict value is not equal to itself.")
11181482 }
11191483 }
11271491 else true
11281492 if ((checkPayments == checkPayments))
11291493 then {
1130- let cfg = gpc()
11311494 let factoryCfg = gfc()
1132- let lpAssetId = fromBase58String(cfg[idxLPAsId])
1495+ let lpAssetId = cfgLpAssetId
11331496 let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
1134- let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil)
1135- if ((unstakeInv == unstakeInv))
1497+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1498+ if ((currentDLp == currentDLp))
11361499 then {
1137- let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1138- let sts = parseIntValue(r._9)
1139- let state = r._10
1140- let v = if (if (igs())
1141- then true
1142- else (sts == PoolShutdown))
1143- then throw(("Blocked: " + toString(sts)))
1144- else true
1145- if ((v == v))
1500+ let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil)
1501+ if ((unstakeInv == unstakeInv))
11461502 then {
1147- let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1148- if ((burnA == burnA))
1149- then state
1503+ let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1504+ let outAmAmt = r._1
1505+ let outPrAmt = r._2
1506+ let sts = parseIntValue(r._9)
1507+ let state = r._10
1508+ let v = if (if (igs())
1509+ then true
1510+ else (sts == PoolShutdown))
1511+ then throw(("Blocked: " + toString(sts)))
1512+ else true
1513+ if ((v == v))
1514+ then {
1515+ let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1516+ if ((burnA == burnA))
1517+ then {
1518+ let $t05259552676 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1519+ let refreshDLpActions = $t05259552676._1
1520+ let updatedDLp = $t05259552676._2
1521+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1522+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1523+ then (state ++ refreshDLpActions)
1524+ else throw("Strict value is not equal to itself.")
1525+ }
1526+ else throw("Strict value is not equal to itself.")
1527+ }
11501528 else throw("Strict value is not equal to itself.")
11511529 }
11521530 else throw("Strict value is not equal to itself.")
11701548 else throw("no payments are expected")]
11711549 if ((checks == checks))
11721550 then {
1173- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1174- if ((unstakeInv == unstakeInv))
1551+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1552+ if ((currentDLp == currentDLp))
11751553 then {
1176- let res = ego(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1177- let outAmAmt = res._1
1178- let outPrAmt = res._2
1179- let state = res._10
1180- let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1181- then true
1182- else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1183- then true
1184- else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1185- if ((checkAmounts == checkAmounts))
1554+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1555+ if ((unstakeInv == unstakeInv))
11861556 then {
1187- let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1188- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1189- then state
1557+ let res = ego(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1558+ let outAmAmt = res._1
1559+ let outPrAmt = res._2
1560+ let state = res._10
1561+ let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1562+ then true
1563+ else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1564+ then true
1565+ else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1566+ if ((checkAmounts == checkAmounts))
1567+ then {
1568+ let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1569+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1570+ then {
1571+ let $t05392754008 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1572+ let refreshDLpActions = $t05392754008._1
1573+ let updatedDLp = $t05392754008._2
1574+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1575+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1576+ then (state ++ refreshDLpActions)
1577+ else throw("Strict value is not equal to itself.")
1578+ }
1579+ else throw("Strict value is not equal to itself.")
1580+ }
11901581 else throw("Strict value is not equal to itself.")
11911582 }
11921583 else throw("Strict value is not equal to itself.")
12201611 else throwErr("no payments are expected")]
12211612 if ((checks == checks))
12221613 then {
1223- let cfg = gpc()
12241614 let factoryCfg = gfc()
1225- let lpAssetId = fromBase58String(cfg[idxLPAsId])
1615+ let lpAssetId = cfgLpAssetId
12261616 let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
12271617 let userAddress = i.caller
12281618 let lpAssetRecipientAddress = this
12291619 let unstakeInv = invoke(staking, "unstakeINTERNAL", [lpAssetId, unstakeAmount, userAddress.bytes, lpAssetRecipientAddress.bytes], nil)
12301620 if ((unstakeInv == unstakeInv))
12311621 then {
1232- let $t04168341871 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId)
1233- let state = $t04168341871._1
1234- let totalAmount = $t04168341871._2
1622+ let $t05503055218 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId)
1623+ let state = $t05503055218._1
1624+ let totalAmount = $t05503055218._2
12351625 $Tuple2(state, totalAmount)
12361626 }
12371627 else throw("Strict value is not equal to itself.")
12431633
12441634 @Callable(i)
12451635 func putOneTknV2WithBonusREADONLY (paymentAmountRaw,paymentAssetId) = {
1246- let poolConfig = gpc()
1247- let amId = poolConfig[idxAmAsId]
1248- let prId = poolConfig[idxPrAsId]
1249- let lpId = poolConfig[idxLPAsId]
1250- let $t04213042233 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true)
1251- let lpAmount = $t04213042233._1
1252- let state = $t04213042233._2
1253- let feeAmount = $t04213042233._3
1254- let bonus = $t04213042233._4
1636+ let $t05534655449 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true)
1637+ let lpAmount = $t05534655449._1
1638+ let state = $t05534655449._2
1639+ let feeAmount = $t05534655449._3
1640+ let bonus = $t05534655449._4
12551641 $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus))
12561642 }
12571643
12591645
12601646 @Callable(i)
12611647 func putOneTknV2WithoutTakeFeeREADONLY (paymentAmountRaw,paymentAssetId) = {
1262- let poolConfig = gpc()
1263- let amId = poolConfig[idxAmAsId]
1264- let prId = poolConfig[idxPrAsId]
1265- let lpId = poolConfig[idxLPAsId]
1266- let $t04251242616 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false)
1267- let lpAmount = $t04251242616._1
1268- let state = $t04251242616._2
1269- let feeAmount = $t04251242616._3
1270- let bonus = $t04251242616._4
1648+ let $t05559755701 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false)
1649+ let lpAmount = $t05559755701._1
1650+ let state = $t05559755701._2
1651+ let feeAmount = $t05559755701._3
1652+ let bonus = $t05559755701._4
12711653 $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus))
12721654 }
12731655
13521734 match tx {
13531735 case order: Order =>
13541736 let matcherPub = mp()
1355- let orderValid = moa(order)
1737+ let $t05849358562 = validateMatcherOrderAllowed(order)
1738+ let orderValid = $t05849358562._1
1739+ let orderValidInfo = $t05849358562._2
13561740 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
13571741 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
13581742 if (if (if (orderValid)
13611745 then matcherValid
13621746 else false)
13631747 then true
1364- else toe(orderValid, senderValid, matcherValid)
1748+ else throwOrderError(orderValid, orderValidInfo, senderValid, matcherValid)
13651749 case s: SetScriptTransaction =>
1366- let newHash = blake2b256(value(s.script))
1367- let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash())))
1368- let currentHash = scriptHash(this)
1369- if (if ((allowedHash == newHash))
1370- then (currentHash != newHash)
1371- else false)
1750+ if (sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey))
13721751 then true
1373- else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
1752+ else {
1753+ let newHash = blake2b256(value(s.script))
1754+ let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash())))
1755+ let currentHash = scriptHash(this)
1756+ if ((allowedHash == newHash))
1757+ then (currentHash != newHash)
1758+ else false
1759+ }
13741760 case _ =>
13751761 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
13761762 }
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
73+func t1BigInt (origVal,origScaleMult) = fraction(origVal, scale18, origScaleMult)
74+
75+
6976 func f1 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18))
77+
78+
79+func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round))
80+
81+
82+func t2 (origVal,origScaleMult) = fraction(origVal, scale18, toBigInt(origScaleMult))
83+
84+
85+func f2 (val,resultScaleMult) = fraction(val, toBigInt(resultScaleMult), scale18)
7086
7187
7288 func ts (amt,resScale,curScale) = fraction(amt, resScale, curScale)
7389
7490
7591 func abs (val) = if ((zeroBigInt > val))
7692 then -(val)
7793 else val
7894
7995
8096 func absBigInt (val) = if ((zeroBigInt > val))
8197 then -(val)
8298 else val
8399
84100
85101 func fc () = "%s__factoryContract"
86102
87103
88104 func mpk () = "%s__managerPublicKey"
89105
90106
91107 func pmpk () = "%s__pendingManagerPublicKey"
92108
93109
94110 func pl () = "%s%s__price__last"
95111
96112
97113 func ph (h,t) = makeString(["%s%s%d%d__price__history", toString(h), toString(t)], SEP)
98114
99115
100116 func pau (ua,txId) = ((("%s%s%s__P__" + ua) + "__") + txId)
101117
102118
103119 func gau (ua,txId) = ((("%s%s%s__G__" + ua) + "__") + txId)
104120
105121
106122 func aa () = "%s__amountAsset"
107123
108124
109125 func pa () = "%s__priceAsset"
110126
111127
112128 func amp () = "%s__amp"
113129
114130
115131 func ada () = "%s__addonAddr"
116132
117133
134+let keyFee = "%s__fee"
135+
136+let fee = valueOrElse(getInteger(this, keyFee), feeDefault)
137+
138+let keyDLp = makeString(["%s", "dLp"], SEP)
139+
140+let keyDLpRefreshedHeight = makeString(["%s", "dLpRefreshedHeight"], SEP)
141+
142+let keyDLpRefreshDelay = makeString(["%s", "refreshDLpDelay"], SEP)
143+
144+let dLpRefreshDelayDefault = 30
145+
146+let dLpRefreshDelay = valueOrElse(getInteger(this, keyDLpRefreshDelay), dLpRefreshDelayDefault)
147+
118148 func fcfg () = "%s__factoryConfig"
119149
120150
121151 func mtpk () = "%s%s__matcher__publicKey"
122152
123153
124154 func pc (iAmtAs,iPrAs) = (((("%d%d%s__" + iAmtAs) + "__") + iPrAs) + "__config")
125155
126156
127157 func mba (bAStr) = ("%s%s%s__mappings__baseAsset2internalId__" + bAStr)
128158
129159
130160 func aps () = "%s__shutdown"
131161
132162
133163 func keyAllowedLpStableScriptHash () = "%s__allowedLpStableScriptHash"
134164
135165
136166 func keyFeeCollectorAddress () = "%s__feeCollectorAddress"
137167
138168
139-func toe (orV,sendrV,matchV) = throw(((((("Failed: ordValid=" + toString(orV)) + " sndrValid=") + toString(sendrV)) + " mtchrValid=") + toString(matchV)))
140-
141-
142-func str (val) = match val {
143- case valStr: String =>
144- valStr
145- case _ =>
146- throw("fail cast to String")
147-}
169+func throwOrderError (orderValid,orderValidInfo,senderValid,matcherValid) = throw((((((((("order validation failed: orderValid=" + toString(orderValid)) + " (") + orderValidInfo) + ")") + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid)))
148170
149171
150172 func strf (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], ""))
151173
152174
153175 func intf (addr,key) = valueOrErrorMessage(getInteger(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], ""))
154176
155177
156178 func throwErr (msg) = throw(makeString(["lp_stable.ride:", msg], " "))
179+
180+
181+func fmtErr (msg) = makeString(["lp_stable.ride:", msg], " ")
157182
158183
159184 let fca = addressFromStringValue(strf(this, fc()))
160185
161186 let inFee = {
162187 let @ = invoke(fca, "getInFeeREADONLY", [toString(this)], nil)
163188 if ($isInstanceOf(@, "Int"))
164189 then @
165190 else throw(($getType(@) + " couldn't be cast to Int"))
166191 }
167192
168193 let outFee = {
169194 let @ = invoke(fca, "getOutFeeREADONLY", [toString(this)], nil)
170195 if ($isInstanceOf(@, "Int"))
171196 then @
172197 else throw(($getType(@) + " couldn't be cast to Int"))
173198 }
174199
175200 let A = strf(this, amp())
176201
177202 func igs () = valueOrElse(getBoolean(fca, aps()), false)
178203
179204
180205 func mp () = fromBase58String(strf(fca, mtpk()))
181206
182207
183208 let feeCollectorAddress = addressFromStringValue(strf(fca, keyFeeCollectorAddress()))
184209
185210 func gpc () = {
186211 let amtAs = strf(this, aa())
187212 let priceAs = strf(this, pa())
188213 let iPriceAs = intf(fca, mba(priceAs))
189214 let iAmtAs = intf(fca, mba(amtAs))
190215 split(strf(fca, pc(toString(iAmtAs), toString(iPriceAs))), SEP)
191216 }
192217
193218
194219 func parseAssetId (input) = if ((input == wavesString))
195220 then unit
196221 else fromBase58String(input)
197222
198223
199224 func assetIdToString (input) = if ((input == unit))
200225 then wavesString
201226 else toBase58String(value(input))
202227
203228
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]))
229+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]))
205230
206231
207232 let poolConfigParsed = parsePoolConfig(gpc())
208233
209-let $t069097095 = poolConfigParsed
234+let $t079658194 = poolConfigParsed
210235
211-let cfgPoolAddress = $t069097095._1
236+let cfgPoolAddress = $t079658194._1
212237
213-let cfgPoolStatus = $t069097095._2
238+let cfgPoolStatus = $t079658194._2
214239
215-let cfgLpAssetId = $t069097095._3
240+let cfgLpAssetId = $t079658194._3
216241
217-let cfgAmountAssetId = $t069097095._4
242+let cfgAmountAssetId = $t079658194._4
218243
219-let cfgPriceAssetId = $t069097095._5
244+let cfgPriceAssetId = $t079658194._5
220245
221-let cfgAmountAssetDecimals = $t069097095._6
246+let cfgAmountAssetDecimals = $t079658194._6
222247
223-let cfgPriceAssetDecimals = $t069097095._7
248+let cfgPriceAssetDecimals = $t079658194._7
249+
250+let cfgInAmountAssedId = $t079658194._8
251+
252+let cfgInPriceAssetId = $t079658194._9
224253
225254 func gfc () = split(strf(fca, fcfg()), SEP)
226255
227256
228257 let factoryConfig = gfc()
229258
230259 let stakingContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactStakCntr]), "Invalid staking contract address")
231260
232261 let slipageContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactSlippCntr]), "Invalid slipage contract address")
233262
234263 let gwxContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactGwxRewCntr]), "Invalid gwx contract address")
235264
236265 let restContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactoryRestCntr]), "Invalid gwx contract address")
237266
238267 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)
239268
240269
241270 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)
242271
243272
244273 func getAccBalance (assetId) = if ((assetId == "WAVES"))
245274 then wavesBalance(this).available
246275 else assetBalance(this, fromBase58String(assetId))
247276
248277
249278 func cpbi (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
279+
280+
281+func cpbir (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
250282
251283
252284 func vad (A1,A2,slippage) = {
253285 let diff = fraction((A1 - A2), scale8BigInt, A2)
254286 let pass = ((slippage - abs(diff)) > zeroBigInt)
255287 if (!(pass))
256288 then throw(("Big slpg: " + toString(diff)))
257289 else $Tuple2(pass, min([A1, A2]))
258290 }
259291
260292
261293 func vd (D1,D0,slpg) = {
262294 let diff = fraction(D0, scale8BigInt, D1)
263295 let fail = (slpg > diff)
264296 if (if (fail)
265297 then true
266298 else (D0 > D1))
267299 then throw(((((((toString(D0) + " ") + toString(D1)) + " ") + toString(diff)) + " ") + toString(slpg)))
268300 else fail
269301 }
270302
271303
272304 func pcp (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
273305 let amtAsAmtX18 = t1(amAmt, amAssetDcm)
274306 let prAsAmtX18 = t1(prAmt, prAssetDcm)
275307 cpbi(prAsAmtX18, amtAsAmtX18)
276308 }
277309
278310
279311 func calcPrices (amAmt,prAmt,lpAmt) = {
280- let cfg = gpc()
281- let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm])
282- let prAsDcm = parseIntValue(cfg[idxPriceAsDcm])
312+ let amtAsDcm = cfgAmountAssetDecimals
313+ let prAsDcm = cfgPriceAssetDecimals
283314 let priceX18 = pcp(amtAsDcm, prAsDcm, amAmt, prAmt)
284315 let amAmtX18 = t1(amAmt, amtAsDcm)
285316 let prAmtX18 = t1(prAmt, prAsDcm)
286317 let lpAmtX18 = t1(lpAmt, scale8)
287318 let lpPrInAmAsX18 = cpbi(amAmtX18, lpAmtX18)
288319 let lpPrInPrAsX18 = cpbi(prAmtX18, lpAmtX18)
289320 [priceX18, lpPrInAmAsX18, lpPrInPrAsX18]
290321 }
291322
292323
293324 func calculatePrices (amAmt,prAmt,lpAmt) = {
294325 let p = calcPrices(amAmt, prAmt, lpAmt)
295326 [f1(p[0], scale8), f1(p[1], scale8), f1(p[2], scale8)]
296327 }
297328
298329
299330 func takeFee (amount,fee) = {
300331 let feeAmount = if ((fee == 0))
301332 then 0
302333 else fraction(amount, fee, scale8)
303334 $Tuple2((amount - feeAmount), feeAmount)
304335 }
305336
306337
338+func getD (xp) = {
339+ let xp0 = xp[0]
340+ let xp1 = xp[1]
341+ let s = (xp0 + xp1)
342+ if ((s == big0))
343+ then big0
344+ else {
345+ let a = parseIntValue(A)
346+ let ann = (a * 2)
347+ let p = fraction(xp0, xp1, big1)
348+ let xp0_xp1_n_n = fraction(p, big4, big1)
349+ let ann_s = fraction(toBigInt(ann), s, big1)
350+ let ann_1 = toBigInt((ann - 1))
351+ func calcDNext (d) = {
352+ let dd = fraction(d, d, big1)
353+ let ddd = fraction(dd, d, big1)
354+ let dp = fraction(ddd, big1, xp0_xp1_n_n)
355+ fraction((ann_s + fraction(dp, big2, big1)), d, (fraction(ann_1, d, big1) + fraction(big3, dp, big1)))
356+ }
357+
358+ func calc (acc,i) = if (acc._2)
359+ then acc
360+ else {
361+ let d = acc._1
362+ let dNext = calcDNext(d)
363+ let dDiffRaw = (dNext - value(d))
364+ let dDiff = if ((big0 > dDiffRaw))
365+ then -(dDiffRaw)
366+ else dDiffRaw
367+ if ((big1 >= dDiff))
368+ then $Tuple2(dNext, true)
369+ else $Tuple2(dNext, false)
370+ }
371+
372+ let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
373+ let $t01270312751 = {
374+ let $l = arr
375+ let $s = size($l)
376+ let $acc0 = $Tuple2(s, false)
377+ func $f0_1 ($a,$i) = if (($i >= $s))
378+ then $a
379+ else calc($a, $l[$i])
380+
381+ func $f0_2 ($a,$i) = if (($i >= $s))
382+ then $a
383+ else throw("List size exceeds 18")
384+
385+ $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($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18)
386+ }
387+ let d = $t01270312751._1
388+ let found = $t01270312751._2
389+ if (found)
390+ then d
391+ else throw(("D calculation error, D = " + toString(d)))
392+ }
393+ }
394+
395+
307396 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))
397+ let lpId = cfgLpAssetId
398+ let amId = toBase58String(value(cfgAmountAssetId))
399+ let prId = toBase58String(value(cfgPriceAssetId))
400+ let amDcm = cfgAmountAssetDecimals
401+ let prDcm = cfgPriceAssetDecimals
402+ let sts = toString(cfgPoolStatus)
403+ let lpEmiss = valueOrErrorMessage(assetInfo(lpId), "Wrong LP id").quantity
404+ if ((toBase58String(lpId) != pmtAssetId))
317405 then throw("Wrong pmt asset")
318406 else {
319407 let amBalance = getAccBalance(amId)
320408 let amBalanceX18 = t1(amBalance, amDcm)
321409 let prBalance = getAccBalance(prId)
322410 let prBalanceX18 = t1(prBalance, prDcm)
323411 let curPriceX18 = cpbi(prBalanceX18, amBalanceX18)
324412 let curPrice = f1(curPriceX18, scale8)
325413 let pmtLpAmtX18 = t1(pmtLpAmt, scale8)
326414 let lpEmissX18 = t1(lpEmiss, scale8)
327415 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissX18)
328416 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissX18)
329- let outAmAmt = f1(outAmAmtX18, amDcm)
330- let outPrAmt = f1(outPrAmtX18, prDcm)
417+ let outAmAmt = fromX18Round(outAmAmtX18, amDcm, FLOOR)
418+ let outPrAmt = fromX18Round(outPrAmtX18, prDcm, FLOOR)
331419 let state = if ((txId58 == ""))
332420 then nil
333421 else [ScriptTransfer(userAddress, outAmAmt, if ((amId == "WAVES"))
334422 then unit
335423 else fromBase58String(amId)), ScriptTransfer(userAddress, outPrAmt, if ((prId == "WAVES"))
336424 then unit
337425 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)]
338426 $Tuple10(outAmAmt, outPrAmt, amId, prId, amBalance, prBalance, lpEmiss, curPriceX18, sts, state)
339427 }
340428 }
341429
342430
343431 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]
432+ let lpId = cfgLpAssetId
433+ let amIdStr = toBase58String(value(cfgAmountAssetId))
434+ let prIdStr = toBase58String(value(cfgPriceAssetId))
435+ let inAmIdStr = cfgInAmountAssedId
436+ let inPrIdStr = cfgInPriceAssetId
437+ let amtDcm = cfgAmountAssetDecimals
438+ let priceDcm = cfgPriceAssetDecimals
439+ let sts = toString(cfgPoolStatus)
353440 let lpEm = valueOrErrorMessage(assetInfo(lpId), "Wr lp as").quantity
354441 let amBalance = if (isEval)
355442 then getAccBalance(amIdStr)
356443 else if (if (isOneAsset)
357444 then (pmtId == amIdStr)
358445 else false)
359446 then (getAccBalance(amIdStr) - pmtAmt)
360447 else if (isOneAsset)
361448 then getAccBalance(amIdStr)
362449 else (getAccBalance(amIdStr) - inAmAmt)
363450 let prBalance = if (isEval)
364451 then getAccBalance(prIdStr)
365452 else if (if (isOneAsset)
366453 then (pmtId == prIdStr)
367454 else false)
368455 then (getAccBalance(prIdStr) - pmtAmt)
369456 else if (isOneAsset)
370457 then getAccBalance(prIdStr)
371458 else (getAccBalance(prIdStr) - inPrAmt)
372459 let inAmAssetAmtX18 = t1(inAmAmt, amtDcm)
373460 let inPrAssetAmtX18 = t1(inPrAmt, priceDcm)
374461 let userPriceX18 = cpbi(inPrAssetAmtX18, inAmAssetAmtX18)
375462 let amBalanceX18 = t1(amBalance, amtDcm)
376463 let prBalanceX18 = t1(prBalance, priceDcm)
464+ let D0 = getD([amBalanceX18, prBalanceX18])
377465 let r = if ((lpEm == 0))
378466 then {
379- let curPriceX18 = zeroBigInt
380- let slippageX18 = zeroBigInt
381- let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN)
382- $Tuple5(f1(lpAmtX18, scale8), f1(inAmAssetAmtX18, amtDcm), f1(inPrAssetAmtX18, priceDcm), cpbi((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
467+ let D1 = getD([(amBalanceX18 + inAmAssetAmtX18), (prBalanceX18 + inPrAssetAmtX18)])
468+ let checkD = if ((D1 > D0))
469+ then true
470+ else throw("D1 should be greater than D0")
471+ if ((checkD == checkD))
472+ then {
473+ let curPriceX18 = zeroBigInt
474+ let slippageX18 = zeroBigInt
475+ let lpAmtX18 = D1
476+ $Tuple5(f1(lpAmtX18, scale8), f1(inAmAssetAmtX18, amtDcm), f1(inPrAssetAmtX18, priceDcm), cpbi((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
477+ }
478+ else throw("Strict value is not equal to itself.")
383479 }
384480 else {
385481 let curPriceX18 = cpbi(prBalanceX18, amBalanceX18)
386482 let slippageRealX18 = fraction(abs((curPriceX18 - userPriceX18)), scale18, curPriceX18)
387483 let slippageX18 = t1(slippage, scale8)
388484 if (if (if (validateSlippage)
389485 then (curPriceX18 != zeroBigInt)
390486 else false)
391487 then (slippageRealX18 > slippageX18)
392488 else false)
393489 then throw(((("Price slippage " + toString(slippageRealX18)) + " > ") + toString(slippageX18)))
394490 else {
395491 let lpEmissionX18 = t1(lpEm, scale8)
396- let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
397- let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
492+ let prViaAmX18 = fraction(inAmAssetAmtX18, cpbir(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING)
493+ let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, cpbir(prBalanceX18, amBalanceX18, FLOOR), CEILING)
398494 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
399495 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
400496 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
401497 let expAmtAssetAmtX18 = expectedAmts._1
402498 let expPriceAssetAmtX18 = expectedAmts._2
403- let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
404- $Tuple5(f1(lpAmtX18, scale8), f1(expAmtAssetAmtX18, amtDcm), f1(expPriceAssetAmtX18, priceDcm), curPriceX18, slippageX18)
499+ let D1 = getD([(amBalanceX18 + expAmtAssetAmtX18), (prBalanceX18 + expPriceAssetAmtX18)])
500+ let checkD = if ((D1 > D0))
501+ then true
502+ else throw("D1 should be greater than D0")
503+ if ((checkD == checkD))
504+ then {
505+ let lpAmtX18 = fraction(lpEmissionX18, (D1 - D0), D0)
506+ $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceDcm, CEILING), curPriceX18, slippageX18)
507+ }
508+ else throw("Strict value is not equal to itself.")
405509 }
406510 }
407511 let calcLpAmt = r._1
408512 let calcAmAssetPmt = r._2
409513 let calcPrAssetPmt = r._3
410514 let curPrice = f1(r._4, scale8)
411515 let slippageCalc = f1(r._5, scale8)
412516 if ((0 >= calcLpAmt))
413517 then throw("LP <= 0")
414518 else {
415519 let emitLpAmt = if (!(emitLp))
416520 then 0
417521 else calcLpAmt
418522 let amDiff = (inAmAmt - calcAmAssetPmt)
419523 let prDiff = (inPrAmt - calcPrAssetPmt)
420- let $t01756217907 = if (if (isOneAsset)
524+ let $t02059020935 = if (if (isOneAsset)
421525 then (pmtId == amIdStr)
422526 else false)
423527 then $Tuple2(pmtAmt, 0)
424528 else if (if (isOneAsset)
425529 then (pmtId == prIdStr)
426530 else false)
427531 then $Tuple2(0, pmtAmt)
428532 else $Tuple2(calcAmAssetPmt, calcPrAssetPmt)
429- let writeAmAmt = $t01756217907._1
430- let writePrAmt = $t01756217907._2
533+ let writeAmAmt = $t02059020935._1
534+ let writePrAmt = $t02059020935._2
431535 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))]
432536 $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEm, lpId, sts, commonState, amDiff, prDiff, inAmId, inPrId)
433537 }
434538 }
435539
436540
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)
541+func getYD (xp,i,D) = {
542+ let n = big2
543+ let x = xp[if ((i == 0))
544+ then 1
545+ else 0]
546+ let aPrecision = parseBigIntValue(Amult)
547+ let a = (parseBigIntValue(A) * aPrecision)
548+ let s = x
549+ let ann = (a * n)
550+ let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n))
551+ let b = ((s + ((D * aPrecision) / ann)) - D)
552+ func calc (acc,cur) = {
553+ let $t02213022150 = acc
554+ let y = $t02213022150._1
555+ let found = $t02213022150._2
556+ if ((found != unit))
557+ then acc
558+ else {
559+ let yNext = (((y * y) + c) / ((big2 * y) + b))
560+ let yDiff = absBigInt((yNext - value(y)))
561+ if ((big1 >= yDiff))
562+ then $Tuple2(yNext, cur)
563+ else $Tuple2(yNext, unit)
564+ }
565+ }
566+
567+ let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
568+ let $t02245722504 = {
569+ let $l = arr
570+ let $s = size($l)
571+ let $acc0 = $Tuple2(D, unit)
572+ func $f0_1 ($a,$i) = if (($i >= $s))
573+ then $a
574+ else calc($a, $l[$i])
575+
576+ func $f0_2 ($a,$i) = if (($i >= $s))
577+ then $a
578+ else throw("List size exceeds 15")
579+
580+ $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)
581+ }
582+ let y = $t02245722504._1
583+ let found = $t02245722504._2
584+ if ((found != unit))
585+ then y
586+ else throw(("Y calculation error, Y = " + toString(y)))
587+ }
588+
589+
590+func calcDLp (amountBalance,priceBalance,lpEmission) = {
591+ let updatedDLp = fraction(getD([t1BigInt(amountBalance, toBigInt(cfgAmountAssetDecimals)), t1BigInt(priceBalance, toBigInt(cfgPriceAssetDecimals))]), scale18, lpEmission)
592+ if ((lpEmission == big0))
593+ then big0
594+ else updatedDLp
595+ }
596+
597+
598+func calcCurrentDLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = {
599+ let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta)
600+ let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta)
601+ let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta)
602+ let currentDLp = calcDLp(amountAssetBalance, priceAssetBalance, lpAssetEmission)
603+ currentDLp
604+ }
605+
606+
607+func refreshDLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = {
608+ let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta)
609+ let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta)
610+ let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta)
611+ let updatedDLp = calcDLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission))
612+ let actions = [IntegerEntry(keyDLpRefreshedHeight, height), StringEntry(keyDLp, toString(updatedDLp))]
613+ $Tuple2(actions, updatedDLp)
614+ }
615+
616+
617+func validateUpdatedDLp (oldDLp,updatedDLp) = if ((updatedDLp >= oldDLp))
618+ then true
619+ else throwErr("updated DLp lower than current DLp")
620+
621+
622+func validateMatcherOrderAllowed (order) = {
623+ let amountAssetBalance = getAccBalance(assetIdToString(cfgAmountAssetId))
624+ let priceAssetBalance = getAccBalance(assetIdToString(cfgPriceAssetId))
625+ let amountAssetAmount = order.amount
626+ let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR)
627+ let $t02470224914 = if ((order.orderType == Buy))
628+ then $Tuple2(amountAssetAmount, -(priceAssetAmount))
629+ else $Tuple2(-(amountAssetAmount), priceAssetAmount)
630+ let amountAssetBalanceDelta = $t02470224914._1
631+ let priceAssetBalanceDelta = $t02470224914._2
450632 if (if (if (igs())
451633 then true
452- else (sts == PoolMatcherDis))
634+ else (cfgPoolStatus == PoolMatcherDis))
453635 then true
454- else (sts == PoolShutdown))
636+ else (cfgPoolStatus == PoolShutdown))
455637 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- }
638+ else if (if ((order.assetPair.amountAsset != cfgAmountAssetId))
639+ then true
640+ else (order.assetPair.priceAsset != cfgPriceAssetId))
641+ then throw("Wr assets")
642+ else {
643+ let dLp = parseBigIntValue(valueOrElse(getString(this, keyDLp), "0"))
644+ let $t02525625356 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
645+ let unusedActions = $t02525625356._1
646+ let dLpNew = $t02525625356._2
647+ let isOrderValid = (dLpNew >= dLp)
648+ let info = makeString(["dLp=", toString(dLp), " dLpNew=", toString(dLpNew), " amountAssetBalance=", toString(amountAssetBalance), " priceAssetBalance=", toString(priceAssetBalance), " amountAssetBalanceDelta=", toString(amountAssetBalanceDelta), " priceAssetBalanceDelta=", toString(priceAssetBalanceDelta), " height=", toString(height)], "")
649+ $Tuple2(isOrderValid, info)
650+ }
479651 }
480652
481653
482654 func cg (i) = if ((size(i.payments) != 1))
483655 then throw("1 pmnt exp")
484656 else {
485657 let pmt = value(i.payments[0])
486658 let pmtAssetId = value(pmt.assetId)
487659 let pmtAmt = pmt.amount
488660 let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller)
489661 let outAmAmt = r._1
490662 let outPrAmt = r._2
491663 let sts = parseIntValue(r._9)
492664 let state = r._10
493665 if (if (igs())
494666 then true
495667 else (sts == PoolShutdown))
496668 then throw(("Admin blocked: " + toString(sts)))
497669 else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state)
498670 }
499671
500672
501673 func cp (caller,txId,amAsPmt,prAsPmt,slippage,emitLp,isOneAsset,validateSlippage,pmtAmt,pmtId) = {
502674 let r = epo(txId, slippage, value(amAsPmt).amount, value(amAsPmt).assetId, value(prAsPmt).amount, value(prAsPmt).assetId, caller, (txId == ""), emitLp, isOneAsset, validateSlippage, pmtAmt, pmtId)
503675 let sts = parseIntValue(r._8)
504676 if (if (if (igs())
505677 then true
506678 else (sts == PoolPutDis))
507679 then true
508680 else (sts == PoolShutdown))
509681 then throw(("Blocked:" + toString(sts)))
510682 else r
511683 }
512684
513685
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-
618686 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)
687+ let amId = toBase58String(value(cfgAmountAssetId))
688+ let prId = toBase58String(value(cfgPriceAssetId))
689+ let lpId = cfgLpAssetId
690+ let amtDcm = cfgAmountAssetDecimals
691+ let priceDcm = cfgPriceAssetDecimals
692+ let lpAssetEmission = toBigInt(valueOrErrorMessage(assetInfo(lpId), "invalid lp asset").quantity)
626693 let chechEmission = if ((lpAssetEmission > big0))
627694 then true
628695 else throw("initial deposit requires all coins")
629696 if ((chechEmission == chechEmission))
630697 then {
631698 let amBalance = getAccBalance(amId)
632699 let prBalance = getAccBalance(prId)
633- let $t02460425066 = if ((txId == ""))
700+ let $t02801228474 = if ((txId == ""))
634701 then $Tuple2(amBalance, prBalance)
635702 else if ((pmtAssetId == amId))
636703 then if ((pmtAmtRaw > amBalance))
637704 then throw("invalid payment amount")
638705 else $Tuple2((amBalance - pmtAmtRaw), prBalance)
639706 else if ((pmtAssetId == prId))
640707 then if ((pmtAmtRaw > prBalance))
641708 then throw("invalid payment amount")
642709 else $Tuple2(amBalance, (prBalance - pmtAmtRaw))
643710 else throw("wrong pmtAssetId")
644- let amBalanceOld = $t02460425066._1
645- let prBalanceOld = $t02460425066._2
646- let $t02507225248 = if ((pmtAssetId == amId))
711+ let amBalanceOld = $t02801228474._1
712+ let prBalanceOld = $t02801228474._2
713+ let $t02848028656 = if ((pmtAssetId == amId))
647714 then $Tuple2(pmtAmtRaw, 0)
648715 else if ((pmtAssetId == prId))
649716 then $Tuple2(0, pmtAmtRaw)
650717 else throw("invalid payment")
651- let amAmountRaw = $t02507225248._1
652- let prAmountRaw = $t02507225248._2
653- let $t02525225506 = if (withTakeFee)
718+ let amAmountRaw = $t02848028656._1
719+ let prAmountRaw = $t02848028656._2
720+ let $t02866028914 = if (withTakeFee)
654721 then $Tuple3(takeFee(amAmountRaw, inFee)._1, takeFee(prAmountRaw, inFee)._1, takeFee(pmtAmtRaw, inFee)._2)
655722 else $Tuple3(amAmountRaw, prAmountRaw, 0)
656- let amAmount = $t02525225506._1
657- let prAmount = $t02525225506._2
658- let feeAmount = $t02525225506._3
723+ let amAmount = $t02866028914._1
724+ let prAmount = $t02866028914._2
725+ let feeAmount = $t02866028914._3
659726 let amBalanceNew = (amBalanceOld + amAmount)
660727 let prBalanceNew = (prBalanceOld + prAmount)
661- let D0 = getD([toBigInt(amBalanceOld), toBigInt(prBalanceOld)])
662- let D1 = getD([toBigInt(amBalanceNew), toBigInt(prBalanceNew)])
728+ let D0 = getD([t1(amBalanceOld, cfgAmountAssetDecimals), t1(prBalanceOld, cfgPriceAssetDecimals)])
729+ let D1 = getD([t1(amBalanceNew, cfgAmountAssetDecimals), t1(prBalanceNew, cfgPriceAssetDecimals)])
663730 let checkD = if ((D1 > D0))
664731 then true
665732 else throw()
666733 if ((checkD == checkD))
667734 then {
668- let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0)
735+ let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0, FLOOR)
669736 let curPrice = f1(cpbi(t1(prBalanceNew, priceDcm), t1(amBalanceNew, amtDcm)), scale8)
670737 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))]
671738 let poolProportion = fraction(prBalanceOld, scale8, amBalanceOld)
672739 let amountAssetPart = fraction(pmtAmtRaw, scale8, (poolProportion + scale8))
673740 let priceAssetPart = (pmtAmtRaw - amountAssetPart)
674741 let lpAmtBoth = fraction(lpAssetEmission, toBigInt(priceAssetPart), toBigInt(prBalanceOld))
675742 let bonus = toInt(fraction((lpAmount - lpAmtBoth), scale8BigInt, lpAmtBoth))
676743 $Tuple4(toInt(lpAmount), commonState, feeAmount, bonus)
677744 }
678745 else throw("Strict value is not equal to itself.")
679746 }
680747 else throw("Strict value is not equal to itself.")
681748 }
682749
683750
684751 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]
752+ let lpId = toBase58String(value(cfgLpAssetId))
753+ let amId = toBase58String(value(cfgAmountAssetId))
754+ let prId = toBase58String(value(cfgPriceAssetId))
755+ let amDecimals = cfgAmountAssetDecimals
756+ let prDecimals = cfgPriceAssetDecimals
757+ let poolStatus = cfgPoolStatus
692758 let userAddress = if ((caller == restContract))
693759 then originCaller
694760 else caller
695761 let pmt = value(payments[0])
696762 let pmtAssetId = value(pmt.assetId)
697763 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))
764+ let currentDLp = calcCurrentDLp(big0, big0, big0)
765+ if ((currentDLp == currentDLp))
766+ then {
767+ let txId58 = toBase58String(transactionId)
768+ if ((lpId != toBase58String(pmtAssetId)))
769+ then throw("Wrong LP")
770+ else {
771+ let amBalance = getAccBalance(amId)
772+ let prBalance = getAccBalance(prId)
773+ let $t03102631137 = {
774+ let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil)
775+ if ($isInstanceOf(@, "(Int, Int)"))
776+ then @
777+ else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
778+ }
779+ if (($t03102631137 == $t03102631137))
738780 then {
739- let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
740- if ((burn == burn))
741- then $Tuple2(state, totalAmount)
781+ let feeAmount = $t03102631137._2
782+ let totalGet = $t03102631137._1
783+ let totalAmount = if (if ((minOutAmount > 0))
784+ then (minOutAmount > totalGet)
785+ else false)
786+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
787+ else totalGet
788+ let $t03132731634 = if ((outAssetId == amId))
789+ then $Tuple4(totalAmount, 0, ((amBalance - totalAmount) - feeAmount), prBalance)
790+ else if ((outAssetId == prId))
791+ then $Tuple4(0, totalAmount, amBalance, ((prBalance - totalAmount) - feeAmount))
792+ else throw("invalid out asset id")
793+ let outAm = $t03132731634._1
794+ let outPr = $t03132731634._2
795+ let amBalanceNew = $t03132731634._3
796+ let prBalanceNew = $t03132731634._4
797+ let curPrX18 = cpbi(t1(prBalanceNew, prDecimals), t1(amBalanceNew, amDecimals))
798+ let curPr = f1(curPrX18, scale8)
799+ let outAssetIdOrWaves = if ((outAssetId == "WAVES"))
800+ then unit
801+ else fromBase58String(outAssetId)
802+ let sendFeeToMatcher = if ((feeAmount > 0))
803+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)]
804+ else nil
805+ 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)
806+ if ((state == state))
807+ then {
808+ let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
809+ if ((burn == burn))
810+ then {
811+ let $t03241932769 = {
812+ let feeAmountForCalc = if ((this == feeCollectorAddress))
813+ then 0
814+ else feeAmount
815+ let outInAmountAsset = if ((parseAssetId(outAssetId) == cfgAmountAssetId))
816+ then true
817+ else false
818+ if (outInAmountAsset)
819+ then $Tuple2(-((totalGet + feeAmountForCalc)), 0)
820+ else $Tuple2(0, -((totalGet + feeAmountForCalc)))
821+ }
822+ let amountAssetBalanceDelta = $t03241932769._1
823+ let priceAssetBalanceDelta = $t03241932769._2
824+ let $t03277232880 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
825+ let refreshDLpActions = $t03277232880._1
826+ let updatedDLp = $t03277232880._2
827+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
828+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
829+ then $Tuple2((state ++ refreshDLpActions), totalAmount)
830+ else throw("Strict value is not equal to itself.")
831+ }
832+ else throw("Strict value is not equal to itself.")
833+ }
742834 else throw("Strict value is not equal to itself.")
743835 }
744836 else throw("Strict value is not equal to itself.")
745837 }
746- else throw("Strict value is not equal to itself.")
747838 }
839+ else throw("Strict value is not equal to itself.")
748840 }
749841
750842
751843 func m () = match getString(mpk()) {
752844 case s: String =>
753845 fromBase58String(s)
754846 case _: Unit =>
755847 unit
756848 case _ =>
757849 throw("Match error")
758850 }
759851
760852
761853 func pm () = match getString(pmpk()) {
762854 case s: String =>
763855 fromBase58String(s)
764856 case _: Unit =>
765857 unit
766858 case _ =>
767859 throw("Match error")
768860 }
769861
770862
771863 let pd = throw("Permission denied")
772864
773865 func isManager (i) = match m() {
774866 case pk: ByteVector =>
775867 (i.callerPublicKey == pk)
776868 case _: Unit =>
777869 (i.caller == this)
778870 case _ =>
779871 throw("Match error")
780872 }
781873
782874
783875 func mm (i) = match m() {
784876 case pk: ByteVector =>
785877 if ((i.callerPublicKey == pk))
786878 then true
787879 else pd
788880 case _: Unit =>
789881 if ((i.caller == this))
790882 then true
791883 else pd
792884 case _ =>
793885 throw("Match error")
794886 }
887+
888+
889+func getY (isReverse,D,poolAmountInBalance) = {
890+ let poolConfig = gpc()
891+ let amId = poolConfig[idxAmAsId]
892+ let prId = poolConfig[idxPrAsId]
893+ let n = big2
894+ let aPrecision = parseBigIntValue(Amult)
895+ let a = (parseBigIntValue(A) * aPrecision)
896+ let xp = if ((isReverse == false))
897+ then [(toBigInt(getAccBalance(amId)) + poolAmountInBalance), toBigInt(getAccBalance(prId))]
898+ else [(toBigInt(getAccBalance(prId)) + poolAmountInBalance), toBigInt(getAccBalance(amId))]
899+ let x = xp[0]
900+ let s = x
901+ let ann = (a * n)
902+ let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n))
903+ let b = ((s + ((D * aPrecision) / ann)) - D)
904+ func calc (acc,cur) = {
905+ let $t03432734347 = acc
906+ let y = $t03432734347._1
907+ let found = $t03432734347._2
908+ if ((found != unit))
909+ then acc
910+ else {
911+ let yNext = (((y * y) + c) / ((big2 * y) + b))
912+ let yDiff = absBigInt((yNext - value(y)))
913+ if ((big1 >= yDiff))
914+ then $Tuple2(yNext, cur)
915+ else $Tuple2(yNext, unit)
916+ }
917+ }
918+
919+ let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
920+ let $t03467834725 = {
921+ let $l = arr
922+ let $s = size($l)
923+ let $acc0 = $Tuple2(D, unit)
924+ func $f0_1 ($a,$i) = if (($i >= $s))
925+ then $a
926+ else calc($a, $l[$i])
927+
928+ func $f0_2 ($a,$i) = if (($i >= $s))
929+ then $a
930+ else throw("List size exceeds 15")
931+
932+ $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)
933+ }
934+ let y = $t03467834725._1
935+ let found = $t03467834725._2
936+ if ((found != unit))
937+ then y
938+ else throw(("Y calculation error, Y = " + toString(y)))
939+ }
940+
941+
942+@Callable(i)
943+func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse,feePoolAmount) = {
944+ let $t03496635390 = if ((isReverse == false))
945+ then {
946+ let assetOut = strf(this, pa())
947+ let poolAmountInBalance = (toBigInt(getAccBalance(strf(this, aa()))) + toBigInt(cleanAmountIn))
948+ $Tuple2(assetOut, poolAmountInBalance)
949+ }
950+ else {
951+ let assetOut = strf(this, aa())
952+ let poolAmountInBalance = (toBigInt(getAccBalance(strf(this, pa()))) + toBigInt(cleanAmountIn))
953+ $Tuple2(assetOut, poolAmountInBalance)
954+ }
955+ let assetOut = $t03496635390._1
956+ let poolAmountInBalance = $t03496635390._2
957+ let poolConfig = gpc()
958+ let amId = poolConfig[idxAmAsId]
959+ let prId = poolConfig[idxPrAsId]
960+ let xp = [toBigInt(getAccBalance(amId)), toBigInt(getAccBalance(prId))]
961+ let D = getD(xp)
962+ let y = getY(isReverse, D, toBigInt(cleanAmountIn))
963+ let dy = ((toBigInt(getAccBalance(assetOut)) - y) - toBigInt(1))
964+ let totalGetRaw = max([0, toInt(dy)])
965+ let newXp = if ((isReverse == false))
966+ then [((toBigInt(getAccBalance(amId)) + toBigInt(cleanAmountIn)) + toBigInt(feePoolAmount)), (toBigInt(getAccBalance(prId)) - dy)]
967+ else [(toBigInt(getAccBalance(amId)) - dy), ((toBigInt(getAccBalance(prId)) + toBigInt(cleanAmountIn)) + toBigInt(feePoolAmount))]
968+ let newD = getD(newXp)
969+ let checkD = if ((newD >= D))
970+ then true
971+ else throw(makeString(["new D is fewer error", toString(D), toString(newD)], "__"))
972+ if ((checkD == checkD))
973+ then $Tuple2(nil, totalGetRaw)
974+ else throw("Strict value is not equal to itself.")
975+ }
976+
977+
978+
979+@Callable(i)
980+func calculateAmountOutForSwapAndSendTokens (cleanAmountIn,isReverse,amountOutMin,addressTo,feePoolAmount) = {
981+ let swapContact = {
982+ let @ = invoke(fca, "getSwapContractREADONLY", nil, nil)
983+ if ($isInstanceOf(@, "String"))
984+ then @
985+ else throw(($getType(@) + " couldn't be cast to String"))
986+ }
987+ let checks = [if ((value(i.payments[0]).amount >= cleanAmountIn))
988+ then true
989+ else throwErr("Wrong amount"), if ((i.caller == addressFromStringValue(swapContact)))
990+ then true
991+ else throwErr("Permission denied")]
992+ if ((checks == checks))
993+ then {
994+ let pmt = value(i.payments[0])
995+ let assetIn = assetIdToString(pmt.assetId)
996+ let $t03682637220 = if ((isReverse == false))
997+ then {
998+ let assetOut = strf(this, pa())
999+ let poolAmountInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount)
1000+ $Tuple2(assetOut, poolAmountInBalance)
1001+ }
1002+ else {
1003+ let assetOut = strf(this, aa())
1004+ let poolAmountInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount)
1005+ $Tuple2(assetOut, poolAmountInBalance)
1006+ }
1007+ let assetOut = $t03682637220._1
1008+ let poolAmountInBalance = $t03682637220._2
1009+ let poolConfig = gpc()
1010+ let amId = poolConfig[idxAmAsId]
1011+ let prId = poolConfig[idxPrAsId]
1012+ let xp = if ((isReverse == false))
1013+ then [(toBigInt(getAccBalance(amId)) - toBigInt(value(i.payments[0]).amount)), toBigInt(getAccBalance(prId))]
1014+ else [toBigInt(getAccBalance(amId)), (toBigInt(getAccBalance(prId)) - toBigInt(value(i.payments[0]).amount))]
1015+ let D = getD(xp)
1016+ let y = getY(isReverse, D, toBigInt(0))
1017+ let dy = ((toBigInt(getAccBalance(assetOut)) - y) - toBigInt(1))
1018+ let totalGetRaw = max([0, toInt(dy)])
1019+ let checkMin = if ((totalGetRaw >= amountOutMin))
1020+ then true
1021+ else throw("Exchange result is fewer coins than expected")
1022+ if ((checkMin == checkMin))
1023+ then {
1024+ let newXp = if ((isReverse == false))
1025+ then [(toBigInt(getAccBalance(amId)) + toBigInt(feePoolAmount)), (toBigInt(getAccBalance(prId)) - dy)]
1026+ else [(toBigInt(getAccBalance(amId)) - dy), (toBigInt(getAccBalance(prId)) + toBigInt(feePoolAmount))]
1027+ let newD = getD(newXp)
1028+ let checkD = if ((newD >= D))
1029+ then true
1030+ else throw("new D is fewer error")
1031+ if ((checkD == checkD))
1032+ then $Tuple2([ScriptTransfer(addressFromStringValue(addressTo), totalGetRaw, parseAssetId(assetOut))], totalGetRaw)
1033+ else throw("Strict value is not equal to itself.")
1034+ }
1035+ else throw("Strict value is not equal to itself.")
1036+ }
1037+ else throw("Strict value is not equal to itself.")
1038+ }
1039+
7951040
7961041
7971042 @Callable(i)
7981043 func constructor (fc) = {
7991044 let c = mm(i)
8001045 if ((c == c))
8011046 then [StringEntry(fc(), fc)]
8021047 else throw("Strict value is not equal to itself.")
8031048 }
8041049
8051050
8061051
8071052 @Callable(i)
8081053 func setManager (pendingManagerPublicKey) = {
8091054 let c = mm(i)
8101055 if ((c == c))
8111056 then {
8121057 let cm = fromBase58String(pendingManagerPublicKey)
8131058 if ((cm == cm))
8141059 then [StringEntry(pmpk(), pendingManagerPublicKey)]
8151060 else throw("Strict value is not equal to itself.")
8161061 }
8171062 else throw("Strict value is not equal to itself.")
8181063 }
8191064
8201065
8211066
8221067 @Callable(i)
8231068 func confirmManager () = {
8241069 let p = pm()
8251070 let hpm = if (isDefined(p))
8261071 then true
8271072 else throw("No pending manager")
8281073 if ((hpm == hpm))
8291074 then {
8301075 let cpm = if ((i.callerPublicKey == value(p)))
8311076 then true
8321077 else throw("You are not pending manager")
8331078 if ((cpm == cpm))
8341079 then [StringEntry(mpk(), toBase58String(value(p))), DeleteEntry(pmpk())]
8351080 else throw("Strict value is not equal to itself.")
8361081 }
8371082 else throw("Strict value is not equal to itself.")
8381083 }
8391084
8401085
8411086
8421087 @Callable(i)
8431088 func put (slip,autoStake) = {
8441089 let factCfg = gfc()
8451090 let stakingCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactStakCntr]), "Wr st addr")
8461091 let slipCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactSlippCntr]), "Wr sl addr")
8471092 if ((0 > slip))
8481093 then throw("Wrong slippage")
8491094 else if ((size(i.payments) != 2))
8501095 then throw("2 pmnts expd")
8511096 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))
1097+ let amAssetPmt = toBigInt(value(i.payments[0]).amount)
1098+ let prAssetPmt = toBigInt(value(i.payments[1]).amount)
1099+ let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amAssetPmt)
1100+ if ((amountAssetBalance == amountAssetBalance))
8621101 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))
1102+ let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - prAssetPmt)
1103+ if ((priceAssetBalance == priceAssetBalance))
8701104 then {
871- let sa = if ((amDiff > 0))
872- then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)])
873- else nil
874- if ((sa == sa))
1105+ let lpAssetEmission = toBigInt(value(assetInfo(cfgLpAssetId)).quantity)
1106+ if ((lpAssetEmission == lpAssetEmission))
8751107 then {
876- let sp = if ((prDiff > 0))
877- then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)])
878- else nil
879- if ((sp == sp))
1108+ let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0))
1109+ if ((currentDLp == currentDLp))
8801110 then {
881- let lpTrnsfr = if (autoStake)
1111+ 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, "")
1112+ let emitLpAmt = e._2
1113+ let lpAssetId = e._7
1114+ let state = e._9
1115+ let amDiff = e._10
1116+ let prDiff = e._11
1117+ let amId = e._12
1118+ let prId = e._13
1119+ let r = invoke(fca, "emit", [emitLpAmt], nil)
1120+ if ((r == r))
8821121 then {
883- let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
884- if ((ss == ss))
885- then nil
1122+ let el = match r {
1123+ case legacy: Address =>
1124+ invoke(legacy, "emit", [emitLpAmt], nil)
1125+ case _ =>
1126+ unit
1127+ }
1128+ if ((el == el))
1129+ then {
1130+ let sa = if ((amDiff > 0))
1131+ then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)])
1132+ else nil
1133+ if ((sa == sa))
1134+ then {
1135+ let sp = if ((prDiff > 0))
1136+ then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)])
1137+ else nil
1138+ if ((sp == sp))
1139+ then {
1140+ let lpTrnsfr = if (autoStake)
1141+ then {
1142+ let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
1143+ if ((ss == ss))
1144+ then nil
1145+ else throw("Strict value is not equal to itself.")
1146+ }
1147+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
1148+ let $t04183941981 = refreshDLpInternal(0, 0, 0)
1149+ let refreshDLpActions = $t04183941981._1
1150+ let updatedDLp = $t04183941981._2
1151+ let check = if ((updatedDLp >= currentDLp))
1152+ then true
1153+ else throwErr(makeString(["updated DLp lower than current DLp", toString(amountAssetBalance), toString(priceAssetBalance), toString(lpAssetEmission), toString(currentDLp), toString(updatedDLp), toString(amDiff), toString(prDiff)], " "))
1154+ if ((check == check))
1155+ then {
1156+ let lpAssetEmissionAfter = value(assetInfo(cfgLpAssetId)).quantity
1157+ if ((lpAssetEmissionAfter == lpAssetEmissionAfter))
1158+ then ((state ++ lpTrnsfr) ++ refreshDLpActions)
1159+ else throw("Strict value is not equal to itself.")
1160+ }
1161+ else throw("Strict value is not equal to itself.")
1162+ }
1163+ else throw("Strict value is not equal to itself.")
1164+ }
1165+ else throw("Strict value is not equal to itself.")
1166+ }
8861167 else throw("Strict value is not equal to itself.")
8871168 }
888- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
889- (state ++ lpTrnsfr)
1169+ else throw("Strict value is not equal to itself.")
8901170 }
8911171 else throw("Strict value is not equal to itself.")
8921172 }
8931173 else throw("Strict value is not equal to itself.")
8941174 }
8951175 else throw("Strict value is not equal to itself.")
8961176 }
8971177 else throw("Strict value is not equal to itself.")
8981178 }
8991179 }
9001180
9011181
9021182
9031183 @Callable(i)
9041184 func putOneTknV2 (minOutAmount,autoStake) = {
9051185 let isPoolOneTokenOperationsDisabled = {
9061186 let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
9071187 if ($isInstanceOf(@, "Boolean"))
9081188 then @
9091189 else throw(($getType(@) + " couldn't be cast to Boolean"))
9101190 }
9111191 let isPutDisabled = if (if (if (igs())
9121192 then true
9131193 else (cfgPoolStatus == PoolPutDis))
9141194 then true
9151195 else (cfgPoolStatus == PoolShutdown))
9161196 then true
9171197 else isPoolOneTokenOperationsDisabled
9181198 let checks = [if (if (!(isPutDisabled))
9191199 then true
9201200 else isManager(i))
9211201 then true
9221202 else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1))
9231203 then true
9241204 else throwErr("exactly 1 payment are expected")]
9251205 if ((checks == checks))
9261206 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])
1207+ let amId = toBase58String(value(cfgAmountAssetId))
1208+ let prId = toBase58String(value(cfgPriceAssetId))
1209+ let lpId = cfgLpAssetId
1210+ let amDecimals = cfgAmountAssetDecimals
1211+ let prDecimals = cfgPriceAssetDecimals
9331212 let userAddress = if ((i.caller == this))
9341213 then i.originCaller
9351214 else i.caller
9361215 let pmt = value(i.payments[0])
9371216 let pmtAssetId = toBase58String(value(pmt.assetId))
9381217 let pmtAmt = pmt.amount
939- let $t03347833636 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true)
940- if (($t03347833636 == $t03347833636))
1218+ let currentDLp = if ((pmt.assetId == cfgAmountAssetId))
1219+ then calcCurrentDLp(toBigInt(pmtAmt), toBigInt(0), toBigInt(0))
1220+ else calcCurrentDLp(toBigInt(0), toBigInt(pmtAmt), toBigInt(0))
1221+ if ((currentDLp == currentDLp))
9411222 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))
1223+ let $t04362243780 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true)
1224+ if (($t04362243780 == $t04362243780))
9521225 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))
1226+ let feeAmount = $t04362243780._3
1227+ let state = $t04362243780._2
1228+ let estimLP = $t04362243780._1
1229+ let emitLpAmt = if (if ((minOutAmount > 0))
1230+ then (minOutAmount > estimLP)
1231+ else false)
1232+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1233+ else estimLP
1234+ let e = invoke(fca, "emit", [emitLpAmt], nil)
1235+ if ((e == e))
9601236 then {
961- let lpTrnsfr = if (autoStake)
1237+ let el = match e {
1238+ case legacy: Address =>
1239+ invoke(legacy, "emit", [emitLpAmt], nil)
1240+ case _ =>
1241+ unit
1242+ }
1243+ if ((el == el))
9621244 then {
963- let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)])
964- if ((ss == ss))
965- then nil
1245+ let lpTrnsfr = if (autoStake)
1246+ then {
1247+ let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)])
1248+ if ((ss == ss))
1249+ then nil
1250+ else throw("Strict value is not equal to itself.")
1251+ }
1252+ else [ScriptTransfer(i.caller, emitLpAmt, lpId)]
1253+ let sendFeeToMatcher = if ((feeAmount > 0))
1254+ then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))]
1255+ else nil
1256+ let $t04459544944 = if ((this == feeCollectorAddress))
1257+ then $Tuple2(0, 0)
1258+ else {
1259+ let paymentInAmountAsset = if ((pmt.assetId == cfgAmountAssetId))
1260+ then true
1261+ else false
1262+ if (paymentInAmountAsset)
1263+ then $Tuple2(-(feeAmount), 0)
1264+ else $Tuple2(0, -(feeAmount))
1265+ }
1266+ let amountAssetBalanceDelta = $t04459544944._1
1267+ let priceAssetBalanceDelta = $t04459544944._2
1268+ let $t04494745055 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1269+ let refreshDLpActions = $t04494745055._1
1270+ let updatedDLp = $t04494745055._2
1271+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1272+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1273+ then $Tuple2((((state ++ lpTrnsfr) ++ sendFeeToMatcher) ++ refreshDLpActions), emitLpAmt)
9661274 else throw("Strict value is not equal to itself.")
9671275 }
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)
1276+ else throw("Strict value is not equal to itself.")
9731277 }
9741278 else throw("Strict value is not equal to itself.")
9751279 }
9761280 else throw("Strict value is not equal to itself.")
9771281 }
9781282 else throw("Strict value is not equal to itself.")
9791283 }
9801284 else throw("Strict value is not equal to itself.")
9811285 }
9821286
9831287
9841288
9851289 @Callable(i)
9861290 func putForFree (maxSlpg) = if ((0 > maxSlpg))
9871291 then throw("Wrong slpg")
9881292 else if ((size(i.payments) != 2))
9891293 then throw("2 pmnts expd")
9901294 else {
9911295 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
1296+ let state = estPut._9
1297+ let amAssetPmt = toBigInt(value(i.payments[0]).amount)
1298+ let prAssetPmt = toBigInt(value(i.payments[1]).amount)
1299+ let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0))
1300+ if ((currentDLp == currentDLp))
1301+ then {
1302+ let $t04608546150 = refreshDLpInternal(0, 0, 0)
1303+ let refreshDLpActions = $t04608546150._1
1304+ let updatedDLp = $t04608546150._2
1305+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1306+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1307+ then (state ++ refreshDLpActions)
1308+ else throw("Strict value is not equal to itself.")
1309+ }
1310+ else throw("Strict value is not equal to itself.")
9931311 }
9941312
9951313
9961314
9971315 @Callable(i)
9981316 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
1317+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1318+ if ((currentDLp == currentDLp))
1319+ then {
1320+ let r = cg(i)
1321+ let outAmtAmt = r._1
1322+ let outPrAmt = r._2
1323+ let pmtAmt = r._3
1324+ let pmtAssetId = r._4
1325+ let state = r._5
1326+ let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1327+ if ((b == b))
1328+ then {
1329+ let $t04732347405 = refreshDLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1330+ let refreshDLpActions = $t04732347405._1
1331+ let updatedDLp = $t04732347405._2
1332+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1333+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1334+ then (state ++ refreshDLpActions)
1335+ else throw("Strict value is not equal to itself.")
1336+ }
1337+ else throw("Strict value is not equal to itself.")
1338+ }
10081339 else throw("Strict value is not equal to itself.")
10091340 }
10101341
10111342
10121343
10131344 @Callable(i)
10141345 func getOneTknV2 (outAssetId,minOutAmount) = {
10151346 let isPoolOneTokenOperationsDisabled = {
10161347 let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
10171348 if ($isInstanceOf(@, "Boolean"))
10181349 then @
10191350 else throw(($getType(@) + " couldn't be cast to Boolean"))
10201351 }
10211352 let isGetDisabled = if (if (igs())
10221353 then true
10231354 else (cfgPoolStatus == PoolShutdown))
10241355 then true
10251356 else isPoolOneTokenOperationsDisabled
10261357 let checks = [if (if (!(isGetDisabled))
10271358 then true
10281359 else isManager(i))
10291360 then true
10301361 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1))
10311362 then true
10321363 else throwErr("exactly 1 payment are expected")]
10331364 if ((checks == checks))
10341365 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
1366+ let $t04802348178 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId)
1367+ let state = $t04802348178._1
1368+ let totalAmount = $t04802348178._2
10381369 $Tuple2(state, totalAmount)
10391370 }
10401371 else throw("Strict value is not equal to itself.")
10411372 }
10421373
10431374
10441375
10451376 @Callable(i)
1377+func refreshDLp () = {
1378+ let lastRefreshedBlockHeight = valueOrElse(getInteger(keyDLpRefreshedHeight), 0)
1379+ let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= dLpRefreshDelay))
1380+ then unit
1381+ else throwErr(makeString([toString(dLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1382+ if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1383+ then {
1384+ let dLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyDLp), "0")), fmtErr("invalid dLp"))
1385+ let $t04870248766 = refreshDLpInternal(0, 0, 0)
1386+ let dLpUpdateActions = $t04870248766._1
1387+ let updatedDLp = $t04870248766._2
1388+ let actions = if ((dLp != updatedDLp))
1389+ then dLpUpdateActions
1390+ else throwErr("nothing to refresh")
1391+ $Tuple2(actions, toString(updatedDLp))
1392+ }
1393+ else throw("Strict value is not equal to itself.")
1394+ }
1395+
1396+
1397+
1398+@Callable(i)
10461399 func getOneTknV2READONLY (outAssetId,lpAssetAmount) = {
1047- let poolConfig = gpc()
1048- let amId = poolConfig[idxAmAsId]
1049- let prId = poolConfig[idxPrAsId]
1050- let lpId = poolConfig[idxLPAsId]
1400+ let amId = toBase58String(value(cfgAmountAssetId))
1401+ let prId = toBase58String(value(cfgPriceAssetId))
1402+ let lpId = toBase58String(value(cfgLpAssetId))
10511403 let xp = [toBigInt(getAccBalance(amId)), toBigInt(getAccBalance(prId))]
10521404 let lpEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity)
10531405 let D0 = getD(xp)
10541406 let D1 = (D0 - fraction(toBigInt(lpAssetAmount), D0, lpEmission))
10551407 let index = if ((outAssetId == amId))
10561408 then 0
10571409 else if ((outAssetId == prId))
10581410 then 1
10591411 else throw("invalid out asset id")
10601412 let newY = getYD(xp, index, D1)
10611413 let dy = (xp[index] - newY)
10621414 let totalGetRaw = max([0, toInt((dy - big1))])
1063- let $t03720337258 = takeFee(totalGetRaw, outFee)
1064- let totalGet = $t03720337258._1
1065- let feeAmount = $t03720337258._2
1415+ let $t04977649831 = takeFee(totalGetRaw, outFee)
1416+ let totalGet = $t04977649831._1
1417+ let feeAmount = $t04977649831._2
10661418 $Tuple2(nil, $Tuple2(totalGet, feeAmount))
10671419 }
10681420
10691421
10701422
10711423 @Callable(i)
10721424 func getOneTknV2WithBonusREADONLY (outAssetId,lpAssetAmount) = {
1073- let poolConfig = gpc()
1074- let amId = poolConfig[idxAmAsId]
1075- let prId = poolConfig[idxPrAsId]
1076- let lpId = poolConfig[idxLPAsId]
1425+ let amId = toBase58String(value(cfgAmountAssetId))
1426+ let prId = toBase58String(value(cfgPriceAssetId))
1427+ let lpId = toBase58String(value(cfgLpAssetId))
10771428 let amBalance = getAccBalance(amId)
10781429 let prBalance = getAccBalance(prId)
1079- let $t03760337718 = {
1430+ let $t05020650321 = {
10801431 let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, lpAssetAmount], nil)
10811432 if ($isInstanceOf(@, "(Int, Int)"))
10821433 then @
10831434 else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
10841435 }
1085- let totalGet = $t03760337718._1
1086- let feeAmount = $t03760337718._2
1436+ let totalGet = $t05020650321._1
1437+ let feeAmount = $t05020650321._2
10871438 let r = ego("", lpId, lpAssetAmount, this)
10881439 let outAmAmt = r._1
10891440 let outPrAmt = r._2
10901441 let sumOfGetAssets = (outAmAmt + outPrAmt)
10911442 let bonus = if ((sumOfGetAssets == 0))
10921443 then if ((totalGet == 0))
10931444 then 0
10941445 else throw("bonus calculation error")
10951446 else fraction((totalGet - sumOfGetAssets), scale8, sumOfGetAssets)
10961447 $Tuple2(nil, $Tuple3(totalGet, feeAmount, bonus))
10971448 }
10981449
10991450
11001451
11011452 @Callable(i)
11021453 func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = {
11031454 let r = cg(i)
11041455 let outAmAmt = r._1
11051456 let outPrAmt = r._2
11061457 let pmtAmt = r._3
11071458 let pmtAssetId = r._4
11081459 let state = r._5
11091460 if ((noLessThenAmtAsset > outAmAmt))
11101461 then throw(((("Failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset)))
11111462 else if ((noLessThenPriceAsset > outPrAmt))
11121463 then throw(((("Failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
11131464 else {
1114- let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1115- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1116- then state
1465+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1466+ if ((currentDLp == currentDLp))
1467+ then {
1468+ let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1469+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1470+ then {
1471+ let $t05148751568 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1472+ let refreshDLpActions = $t05148751568._1
1473+ let updatedDLp = $t05148751568._2
1474+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1475+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1476+ then (state ++ refreshDLpActions)
1477+ else throw("Strict value is not equal to itself.")
1478+ }
1479+ else throw("Strict value is not equal to itself.")
1480+ }
11171481 else throw("Strict value is not equal to itself.")
11181482 }
11191483 }
11201484
11211485
11221486
11231487 @Callable(i)
11241488 func unstakeAndGet (amount) = {
11251489 let checkPayments = if ((size(i.payments) != 0))
11261490 then throw("No pmnts expd")
11271491 else true
11281492 if ((checkPayments == checkPayments))
11291493 then {
1130- let cfg = gpc()
11311494 let factoryCfg = gfc()
1132- let lpAssetId = fromBase58String(cfg[idxLPAsId])
1495+ let lpAssetId = cfgLpAssetId
11331496 let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
1134- let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil)
1135- if ((unstakeInv == unstakeInv))
1497+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1498+ if ((currentDLp == currentDLp))
11361499 then {
1137- let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1138- let sts = parseIntValue(r._9)
1139- let state = r._10
1140- let v = if (if (igs())
1141- then true
1142- else (sts == PoolShutdown))
1143- then throw(("Blocked: " + toString(sts)))
1144- else true
1145- if ((v == v))
1500+ let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil)
1501+ if ((unstakeInv == unstakeInv))
11461502 then {
1147- let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1148- if ((burnA == burnA))
1149- then state
1503+ let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1504+ let outAmAmt = r._1
1505+ let outPrAmt = r._2
1506+ let sts = parseIntValue(r._9)
1507+ let state = r._10
1508+ let v = if (if (igs())
1509+ then true
1510+ else (sts == PoolShutdown))
1511+ then throw(("Blocked: " + toString(sts)))
1512+ else true
1513+ if ((v == v))
1514+ then {
1515+ let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1516+ if ((burnA == burnA))
1517+ then {
1518+ let $t05259552676 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1519+ let refreshDLpActions = $t05259552676._1
1520+ let updatedDLp = $t05259552676._2
1521+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1522+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1523+ then (state ++ refreshDLpActions)
1524+ else throw("Strict value is not equal to itself.")
1525+ }
1526+ else throw("Strict value is not equal to itself.")
1527+ }
11501528 else throw("Strict value is not equal to itself.")
11511529 }
11521530 else throw("Strict value is not equal to itself.")
11531531 }
11541532 else throw("Strict value is not equal to itself.")
11551533 }
11561534 else throw("Strict value is not equal to itself.")
11571535 }
11581536
11591537
11601538
11611539 @Callable(i)
11621540 func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = {
11631541 let isGetDisabled = if (igs())
11641542 then true
11651543 else (cfgPoolStatus == PoolShutdown)
11661544 let checks = [if (!(isGetDisabled))
11671545 then true
11681546 else throw("get operation is blocked by admin"), if ((size(i.payments) == 0))
11691547 then true
11701548 else throw("no payments are expected")]
11711549 if ((checks == checks))
11721550 then {
1173- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1174- if ((unstakeInv == unstakeInv))
1551+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1552+ if ((currentDLp == currentDLp))
11751553 then {
1176- let res = ego(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1177- let outAmAmt = res._1
1178- let outPrAmt = res._2
1179- let state = res._10
1180- let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1181- then true
1182- else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1183- then true
1184- else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1185- if ((checkAmounts == checkAmounts))
1554+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1555+ if ((unstakeInv == unstakeInv))
11861556 then {
1187- let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1188- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1189- then state
1557+ let res = ego(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1558+ let outAmAmt = res._1
1559+ let outPrAmt = res._2
1560+ let state = res._10
1561+ let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1562+ then true
1563+ else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1564+ then true
1565+ else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1566+ if ((checkAmounts == checkAmounts))
1567+ then {
1568+ let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1569+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1570+ then {
1571+ let $t05392754008 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1572+ let refreshDLpActions = $t05392754008._1
1573+ let updatedDLp = $t05392754008._2
1574+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1575+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1576+ then (state ++ refreshDLpActions)
1577+ else throw("Strict value is not equal to itself.")
1578+ }
1579+ else throw("Strict value is not equal to itself.")
1580+ }
11901581 else throw("Strict value is not equal to itself.")
11911582 }
11921583 else throw("Strict value is not equal to itself.")
11931584 }
11941585 else throw("Strict value is not equal to itself.")
11951586 }
11961587 else throw("Strict value is not equal to itself.")
11971588 }
11981589
11991590
12001591
12011592 @Callable(i)
12021593 func unstakeAndGetOneTknV2 (unstakeAmount,outAssetId,minOutAmount) = {
12031594 let isPoolOneTokenOperationsDisabled = {
12041595 let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
12051596 if ($isInstanceOf(@, "Boolean"))
12061597 then @
12071598 else throw(($getType(@) + " couldn't be cast to Boolean"))
12081599 }
12091600 let isGetDisabled = if (if (igs())
12101601 then true
12111602 else (cfgPoolStatus == PoolShutdown))
12121603 then true
12131604 else isPoolOneTokenOperationsDisabled
12141605 let checks = [if (if (!(isGetDisabled))
12151606 then true
12161607 else isManager(i))
12171608 then true
12181609 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0))
12191610 then true
12201611 else throwErr("no payments are expected")]
12211612 if ((checks == checks))
12221613 then {
1223- let cfg = gpc()
12241614 let factoryCfg = gfc()
1225- let lpAssetId = fromBase58String(cfg[idxLPAsId])
1615+ let lpAssetId = cfgLpAssetId
12261616 let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
12271617 let userAddress = i.caller
12281618 let lpAssetRecipientAddress = this
12291619 let unstakeInv = invoke(staking, "unstakeINTERNAL", [lpAssetId, unstakeAmount, userAddress.bytes, lpAssetRecipientAddress.bytes], nil)
12301620 if ((unstakeInv == unstakeInv))
12311621 then {
1232- let $t04168341871 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId)
1233- let state = $t04168341871._1
1234- let totalAmount = $t04168341871._2
1622+ let $t05503055218 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId)
1623+ let state = $t05503055218._1
1624+ let totalAmount = $t05503055218._2
12351625 $Tuple2(state, totalAmount)
12361626 }
12371627 else throw("Strict value is not equal to itself.")
12381628 }
12391629 else throw("Strict value is not equal to itself.")
12401630 }
12411631
12421632
12431633
12441634 @Callable(i)
12451635 func putOneTknV2WithBonusREADONLY (paymentAmountRaw,paymentAssetId) = {
1246- let poolConfig = gpc()
1247- let amId = poolConfig[idxAmAsId]
1248- let prId = poolConfig[idxPrAsId]
1249- let lpId = poolConfig[idxLPAsId]
1250- let $t04213042233 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true)
1251- let lpAmount = $t04213042233._1
1252- let state = $t04213042233._2
1253- let feeAmount = $t04213042233._3
1254- let bonus = $t04213042233._4
1636+ let $t05534655449 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true)
1637+ let lpAmount = $t05534655449._1
1638+ let state = $t05534655449._2
1639+ let feeAmount = $t05534655449._3
1640+ let bonus = $t05534655449._4
12551641 $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus))
12561642 }
12571643
12581644
12591645
12601646 @Callable(i)
12611647 func putOneTknV2WithoutTakeFeeREADONLY (paymentAmountRaw,paymentAssetId) = {
1262- let poolConfig = gpc()
1263- let amId = poolConfig[idxAmAsId]
1264- let prId = poolConfig[idxPrAsId]
1265- let lpId = poolConfig[idxLPAsId]
1266- let $t04251242616 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false)
1267- let lpAmount = $t04251242616._1
1268- let state = $t04251242616._2
1269- let feeAmount = $t04251242616._3
1270- let bonus = $t04251242616._4
1648+ let $t05559755701 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false)
1649+ let lpAmount = $t05559755701._1
1650+ let state = $t05559755701._2
1651+ let feeAmount = $t05559755701._3
1652+ let bonus = $t05559755701._4
12711653 $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus))
12721654 }
12731655
12741656
12751657
12761658 @Callable(i)
12771659 func activate (amtAsStr,prAsStr) = if ((toString(i.caller) != toString(fca)))
12781660 then throw("denied")
12791661 else $Tuple2([StringEntry(aa(), amtAsStr), StringEntry(pa(), prAsStr)], "success")
12801662
12811663
12821664
12831665 @Callable(i)
12841666 func setS (k,v) = if ((toString(i.caller) != strf(this, ada())))
12851667 then pd
12861668 else [StringEntry(k, v)]
12871669
12881670
12891671
12901672 @Callable(i)
12911673 func setI (k,v) = if ((toString(i.caller) != strf(this, ada())))
12921674 then pd
12931675 else [IntegerEntry(k, v)]
12941676
12951677
12961678
12971679 @Callable(i)
12981680 func getPoolConfigWrapperREADONLY () = $Tuple2(nil, gpc())
12991681
13001682
13011683
13021684 @Callable(i)
13031685 func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId))
13041686
13051687
13061688
13071689 @Callable(i)
13081690 func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = {
13091691 let pr = calcPrices(amAmt, prAmt, lpAmt)
13101692 $Tuple2(nil, [toString(pr[0]), toString(pr[1]), toString(pr[2])])
13111693 }
13121694
13131695
13141696
13151697 @Callable(i)
13161698 func fromX18WrapperREADONLY (val,resScaleMult) = $Tuple2(nil, f1(parseBigIntValue(val), resScaleMult))
13171699
13181700
13191701
13201702 @Callable(i)
13211703 func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(t1(origVal, origScaleMult)))
13221704
13231705
13241706
13251707 @Callable(i)
13261708 func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(cpbi(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18))))
13271709
13281710
13291711
13301712 @Callable(i)
13311713 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, ""))
13321714
13331715
13341716
13351717 @Callable(i)
13361718 func estimateGetOperationWrapperREADONLY (txId58,pmtAsId,pmtLpAmt,usrAddr) = {
13371719 let r = ego(txId58, pmtAsId, pmtLpAmt, addressFromStringValue(usrAddr))
13381720 $Tuple2(nil, $Tuple10(r._1, r._2, r._3, r._4, r._5, r._6, r._7, toString(r._8), r._9, r._10))
13391721 }
13401722
13411723
13421724 @Verifier(tx)
13431725 func verify () = {
13441726 let targetPublicKey = match m() {
13451727 case pk: ByteVector =>
13461728 pk
13471729 case _: Unit =>
13481730 tx.senderPublicKey
13491731 case _ =>
13501732 throw("Match error")
13511733 }
13521734 match tx {
13531735 case order: Order =>
13541736 let matcherPub = mp()
1355- let orderValid = moa(order)
1737+ let $t05849358562 = validateMatcherOrderAllowed(order)
1738+ let orderValid = $t05849358562._1
1739+ let orderValidInfo = $t05849358562._2
13561740 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
13571741 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
13581742 if (if (if (orderValid)
13591743 then senderValid
13601744 else false)
13611745 then matcherValid
13621746 else false)
13631747 then true
1364- else toe(orderValid, senderValid, matcherValid)
1748+ else throwOrderError(orderValid, orderValidInfo, senderValid, matcherValid)
13651749 case s: SetScriptTransaction =>
1366- let newHash = blake2b256(value(s.script))
1367- let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash())))
1368- let currentHash = scriptHash(this)
1369- if (if ((allowedHash == newHash))
1370- then (currentHash != newHash)
1371- else false)
1750+ if (sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey))
13721751 then true
1373- else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
1752+ else {
1753+ let newHash = blake2b256(value(s.script))
1754+ let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash())))
1755+ let currentHash = scriptHash(this)
1756+ if ((allowedHash == newHash))
1757+ then (currentHash != newHash)
1758+ else false
1759+ }
13741760 case _ =>
13751761 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
13761762 }
13771763 }
13781764

github/deemru/w8io/026f985 
204.90 ms