tx · HaCm9rH4DQY94cT8vVtvKsaUsAHAQdqTassK9GhdcJqb 3MzKSdTH2jFbypLsoNfrH7QgkzSbx3EYwCA: -0.03600000 Waves 2022.12.16 09:28 [2362493] smart account 3MzKSdTH2jFbypLsoNfrH7QgkzSbx3EYwCA > SELF 0.00000000 Waves
{ "type": 13, "id": "HaCm9rH4DQY94cT8vVtvKsaUsAHAQdqTassK9GhdcJqb", "fee": 3600000, "feeAssetId": null, "timestamp": 1671172029988, "version": 1, "sender": "3MzKSdTH2jFbypLsoNfrH7QgkzSbx3EYwCA", "senderPublicKey": "35yd3qw1gxKDxKwGAykHN9fANbXNWwseaUwbWDj24o3x", "proofs": [ "yxFRYzmPZ74fjzCLwEfkznzdMSUJ8zCViVTqfUdbG83JdXMScaDXE72UGfUBMmo5JqGJq6y8Q43jcXcmBCdzoJh" ], "script": "base64:BgLiKAgCEgMKAQgSAwoBCBIAEgQKAgEEEgQKAgEEEgMKAQESABIECgIIARIAEgQKAggBEgQKAggBEgQKAgEBEgMKAQESBQoDAQEBEgUKAwEIARIECgIBCBIECgIBCBIECgIICBIECgIICBIECgIIARIAEgMKAQgSBQoDAQEBEgQKAggBEgQKAgEBEgQKAggIEgsKCQgBAQIBAggEBBIGCgQICAEIEgAiBnNjYWxlOCIMc2NhbGU4QmlnSW50IgdzY2FsZTE4Igp6ZXJvQmlnSW50IgRiaWcwIgRiaWcxIgRiaWcyIgRiaWczIgRiaWc0IgpzbGlwcGFnZTREIgt3YXZlc1N0cmluZyIFQW11bHQiBURjb252IgNTRVAiBUVNUFRZIgpQb29sQWN0aXZlIgpQb29sUHV0RGlzIg5Qb29sTWF0Y2hlckRpcyIMUG9vbFNodXRkb3duIg5pZHhQb29sQWRkcmVzcyIJaWR4UG9vbFN0IglpZHhMUEFzSWQiCWlkeEFtQXNJZCIJaWR4UHJBc0lkIgtpZHhBbXRBc0RjbSINaWR4UHJpY2VBc0RjbSILaWR4SUFtdEFzSWQiDWlkeElQcmljZUFzSWQiD2l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CBQJoVwUCaFUHBgkA9AMDCAUCaE4JYm9keUJ5dGVzCQCRAwIIBQJoTgZwcm9vZnMAAAUCaFAJAPQDAwgFAmhOCWJvZHlCeXRlcwkAkQMCCAUCaE4GcHJvb2ZzAAAFAmhQpomYwQ==", "chainId": 84, "height": 2362493, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7H7PFEizq66vK856b2PANgiYbvGLVrMixjzFMaamd9G2 Next: HjsH5rQaUnzwmTQBwsTcPXASbdeV3777gCMb9j3WuJac Diff:
Old | New | Differences | |
---|---|---|---|
14 | 14 | let big1 = toBigInt(1) | |
15 | 15 | ||
16 | 16 | let big2 = toBigInt(2) | |
17 | + | ||
18 | + | let big3 = toBigInt(3) | |
19 | + | ||
20 | + | let big4 = toBigInt(4) | |
17 | 21 | ||
18 | 22 | let slippage4D = toBigInt((scale8 - ((scale8 * 1) / scale8))) | |
19 | 23 | ||
69 | 73 | func f1 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18)) | |
70 | 74 | ||
71 | 75 | ||
76 | + | func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round)) | |
77 | + | ||
78 | + | ||
72 | 79 | func ts (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
73 | 80 | ||
74 | 81 | ||
115 | 122 | func ada () = "%s__addonAddr" | |
116 | 123 | ||
117 | 124 | ||
125 | + | let keyFee = "%s__fee" | |
126 | + | ||
127 | + | let fee = valueOrElse(getInteger(this, keyFee), feeDefault) | |
128 | + | ||
129 | + | let keyDLp = makeString(["%s", "dLp"], SEP) | |
130 | + | ||
131 | + | let keyDLpRefreshedHeight = makeString(["%s", "dLpRefreshedHeight"], SEP) | |
132 | + | ||
133 | + | let keyDLpRefreshDelay = makeString(["%s", "refreshDLpDelay"], SEP) | |
134 | + | ||
135 | + | let dLpRefreshDelayDefault = 1 | |
136 | + | ||
137 | + | let dLpRefreshDelay = valueOrElse(getInteger(this, keyDLpRefreshDelay), dLpRefreshDelayDefault) | |
138 | + | ||
118 | 139 | func fcfg () = "%s__factoryConfig" | |
119 | 140 | ||
120 | 141 | ||
156 | 177 | func throwErr (msg) = throw(makeString(["lp_stable.ride:", msg], " ")) | |
157 | 178 | ||
158 | 179 | ||
180 | + | func fmtErr (msg) = makeString(["lp_stable.ride:", msg], " ") | |
181 | + | ||
182 | + | ||
159 | 183 | let fca = addressFromStringValue(strf(this, fc())) | |
160 | - | ||
161 | - | let inFee = { | |
162 | - | let @ = invoke(fca, "getInFeeREADONLY", [toString(this)], nil) | |
163 | - | if ($isInstanceOf(@, "Int")) | |
164 | - | then @ | |
165 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
166 | - | } | |
167 | - | ||
168 | - | let outFee = { | |
169 | - | let @ = invoke(fca, "getOutFeeREADONLY", [toString(this)], nil) | |
170 | - | if ($isInstanceOf(@, "Int")) | |
171 | - | then @ | |
172 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
173 | - | } | |
174 | 184 | ||
175 | 185 | let A = strf(this, amp()) | |
176 | 186 | ||
206 | 216 | ||
207 | 217 | let poolConfigParsed = parsePoolConfig(gpc()) | |
208 | 218 | ||
209 | - | let $ | |
219 | + | let $t074067592 = poolConfigParsed | |
210 | 220 | ||
211 | - | let cfgPoolAddress = $ | |
221 | + | let cfgPoolAddress = $t074067592._1 | |
212 | 222 | ||
213 | - | let cfgPoolStatus = $ | |
223 | + | let cfgPoolStatus = $t074067592._2 | |
214 | 224 | ||
215 | - | let cfgLpAssetId = $ | |
225 | + | let cfgLpAssetId = $t074067592._3 | |
216 | 226 | ||
217 | - | let cfgAmountAssetId = $ | |
227 | + | let cfgAmountAssetId = $t074067592._4 | |
218 | 228 | ||
219 | - | let cfgPriceAssetId = $ | |
229 | + | let cfgPriceAssetId = $t074067592._5 | |
220 | 230 | ||
221 | - | let cfgAmountAssetDecimals = $ | |
231 | + | let cfgAmountAssetDecimals = $t074067592._6 | |
222 | 232 | ||
223 | - | let cfgPriceAssetDecimals = $ | |
233 | + | let cfgPriceAssetDecimals = $t074067592._7 | |
224 | 234 | ||
225 | 235 | func gfc () = split(strf(fca, fcfg()), SEP) | |
226 | 236 | ||
296 | 306 | } | |
297 | 307 | ||
298 | 308 | ||
299 | - | func takeFee (amount,fee) = { | |
300 | - | let feeAmount = if ((fee == 0)) | |
301 | - | then 0 | |
302 | - | else fraction(amount, fee, scale8) | |
309 | + | func takeFee (amount) = { | |
310 | + | let feeAmount = fraction(amount, fee, scale8) | |
303 | 311 | $Tuple2((amount - feeAmount), feeAmount) | |
304 | 312 | } | |
305 | 313 | ||
326 | 334 | let lpEmissX18 = t1(lpEmiss, scale8) | |
327 | 335 | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissX18) | |
328 | 336 | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissX18) | |
329 | - | let outAmAmt = | |
330 | - | let outPrAmt = | |
337 | + | let outAmAmt = fromX18Round(outAmAmtX18, amDcm, FLOOR) | |
338 | + | let outPrAmt = fromX18Round(outPrAmtX18, prDcm, FLOOR) | |
331 | 339 | let state = if ((txId58 == "")) | |
332 | 340 | then nil | |
333 | 341 | else [ScriptTransfer(userAddress, outAmAmt, if ((amId == "WAVES")) | |
401 | 409 | let expAmtAssetAmtX18 = expectedAmts._1 | |
402 | 410 | let expPriceAssetAmtX18 = expectedAmts._2 | |
403 | 411 | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18) | |
404 | - | $Tuple5( | |
412 | + | $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceDcm, CEILING), curPriceX18, slippageX18) | |
405 | 413 | } | |
406 | 414 | } | |
407 | 415 | let calcLpAmt = r._1 | |
417 | 425 | else calcLpAmt | |
418 | 426 | let amDiff = (inAmAmt - calcAmAssetPmt) | |
419 | 427 | let prDiff = (inPrAmt - calcPrAssetPmt) | |
420 | - | let $ | |
428 | + | let $t01811218457 = if (if (isOneAsset) | |
421 | 429 | then (pmtId == amIdStr) | |
422 | 430 | else false) | |
423 | 431 | then $Tuple2(pmtAmt, 0) | |
426 | 434 | else false) | |
427 | 435 | then $Tuple2(0, pmtAmt) | |
428 | 436 | else $Tuple2(calcAmAssetPmt, calcPrAssetPmt) | |
429 | - | let writeAmAmt = $ | |
430 | - | let writePrAmt = $ | |
437 | + | let writeAmAmt = $t01811218457._1 | |
438 | + | let writePrAmt = $t01811218457._2 | |
431 | 439 | 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))] | |
432 | 440 | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEm, lpId, sts, commonState, amDiff, prDiff, inAmId, inPrId) | |
433 | 441 | } | |
434 | 442 | } | |
435 | 443 | ||
436 | 444 | ||
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) | |
445 | + | func getD (xp) = { | |
446 | + | let xp0 = xp[0] | |
447 | + | let xp1 = xp[1] | |
448 | + | let s = (xp0 + xp1) | |
449 | + | if ((s == big0)) | |
450 | + | then big0 | |
451 | + | else { | |
452 | + | let a = parseIntValue(A) | |
453 | + | let ann = (a * 2) | |
454 | + | let p = fraction(xp0, xp1, big1) | |
455 | + | let xp0_xp1_n_n = fraction(p, big4, big1) | |
456 | + | let ann_s = fraction(toBigInt(ann), s, big1) | |
457 | + | let ann_1 = toBigInt((ann - 1)) | |
458 | + | func calcDNext (d) = { | |
459 | + | let dd = fraction(d, d, big1) | |
460 | + | let ddd = fraction(dd, d, big1) | |
461 | + | let dp = fraction(ddd, big1, xp0_xp1_n_n) | |
462 | + | fraction((ann_s + fraction(dp, big2, big1)), d, (fraction(ann_1, d, big1) + fraction(big3, dp, big1)), CEILING) | |
463 | + | } | |
464 | + | ||
465 | + | func calc (acc,i) = if (acc._2) | |
466 | + | then acc | |
467 | + | else { | |
468 | + | let d = acc._1 | |
469 | + | let dNext = calcDNext(d) | |
470 | + | let dDiffRaw = toInt((dNext - value(d))) | |
471 | + | let dDiff = if ((0 > dDiffRaw)) | |
472 | + | then -(dDiffRaw) | |
473 | + | else dDiffRaw | |
474 | + | if ((1 >= dDiff)) | |
475 | + | then $Tuple2(dNext, true) | |
476 | + | else $Tuple2(dNext, false) | |
477 | + | } | |
478 | + | ||
479 | + | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
480 | + | let $t02038520433 = { | |
481 | + | let $l = arr | |
482 | + | let $s = size($l) | |
483 | + | let $acc0 = $Tuple2(s, false) | |
484 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
485 | + | then $a | |
486 | + | else calc($a, $l[$i]) | |
487 | + | ||
488 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
489 | + | then $a | |
490 | + | else throw("List size exceeds 15") | |
491 | + | ||
492 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15) | |
493 | + | } | |
494 | + | let d = $t02038520433._1 | |
495 | + | let found = $t02038520433._2 | |
496 | + | if (found) | |
497 | + | then d | |
498 | + | else throw(("D calculation error, D = " + toString(d))) | |
499 | + | } | |
500 | + | } | |
501 | + | ||
502 | + | ||
503 | + | func getDOld (xp) = { | |
504 | + | let n = big2 | |
505 | + | let xp0 = xp[0] | |
506 | + | let xp1 = xp[1] | |
507 | + | let aPrecision = parseBigIntValue(Amult) | |
508 | + | let a = (parseBigIntValue(A) * aPrecision) | |
509 | + | let s = (xp0 + xp1) | |
510 | + | if ((s == big0)) | |
511 | + | then big0 | |
512 | + | else { | |
513 | + | let ann = (a * n) | |
514 | + | let xp0_xp1_n_n = (((xp0 * xp1) * n) * n) | |
515 | + | let ann_s_aPrecision = ((ann * s) / aPrecision) | |
516 | + | let ann_aPrecision = (ann - aPrecision) | |
517 | + | let n1 = (n + big1) | |
518 | + | func calc (acc,cur) = { | |
519 | + | let $t02106221082 = acc | |
520 | + | let d = $t02106221082._1 | |
521 | + | let found = $t02106221082._2 | |
522 | + | if ((found != unit)) | |
523 | + | then acc | |
524 | + | else { | |
525 | + | let dp = (((d * d) * d) / xp0_xp1_n_n) | |
526 | + | let dNext = (((ann_s_aPrecision + (dp * n)) * d) / (((ann_aPrecision * d) / aPrecision) + (n1 * dp))) | |
527 | + | let dDiff = absBigInt((dNext - value(d))) | |
528 | + | if ((big1 >= dDiff)) | |
529 | + | then $Tuple2(dNext, cur) | |
530 | + | else $Tuple2(dNext, unit) | |
531 | + | } | |
532 | + | } | |
533 | + | ||
534 | + | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
535 | + | let $t02150321550 = { | |
536 | + | let $l = arr | |
537 | + | let $s = size($l) | |
538 | + | let $acc0 = $Tuple2(s, unit) | |
539 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
540 | + | then $a | |
541 | + | else calc($a, $l[$i]) | |
542 | + | ||
543 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
544 | + | then $a | |
545 | + | else throw("List size exceeds 15") | |
546 | + | ||
547 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15) | |
548 | + | } | |
549 | + | let d = $t02150321550._1 | |
550 | + | let found = $t02150321550._2 | |
551 | + | if ((found != unit)) | |
552 | + | then d | |
553 | + | else throw(("D calculation error, D = " + toString(d))) | |
554 | + | } | |
555 | + | } | |
556 | + | ||
557 | + | ||
558 | + | func getYD (xp,i,D) = { | |
559 | + | let n = big2 | |
560 | + | let x = xp[if ((i == 0)) | |
561 | + | then 1 | |
562 | + | else 0] | |
563 | + | let aPrecision = parseBigIntValue(Amult) | |
564 | + | let a = (parseBigIntValue(A) * aPrecision) | |
565 | + | let s = x | |
566 | + | let ann = (a * n) | |
567 | + | let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n)) | |
568 | + | let b = ((s + ((D * aPrecision) / ann)) - D) | |
569 | + | func calc (acc,cur) = { | |
570 | + | let $t02205022070 = acc | |
571 | + | let y = $t02205022070._1 | |
572 | + | let found = $t02205022070._2 | |
573 | + | if ((found != unit)) | |
574 | + | then acc | |
575 | + | else { | |
576 | + | let yNext = (((y * y) + c) / ((big2 * y) + b)) | |
577 | + | let yDiff = absBigInt((yNext - value(y))) | |
578 | + | if ((big1 >= yDiff)) | |
579 | + | then $Tuple2(yNext, cur) | |
580 | + | else $Tuple2(yNext, unit) | |
581 | + | } | |
582 | + | } | |
583 | + | ||
584 | + | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
585 | + | let $t02237722424 = { | |
586 | + | let $l = arr | |
587 | + | let $s = size($l) | |
588 | + | let $acc0 = $Tuple2(D, unit) | |
589 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
590 | + | then $a | |
591 | + | else calc($a, $l[$i]) | |
592 | + | ||
593 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
594 | + | then $a | |
595 | + | else throw("List size exceeds 15") | |
596 | + | ||
597 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15) | |
598 | + | } | |
599 | + | let y = $t02237722424._1 | |
600 | + | let found = $t02237722424._2 | |
601 | + | if ((found != unit)) | |
602 | + | then y | |
603 | + | else throw(("Y calculation error, Y = " + toString(y))) | |
604 | + | } | |
605 | + | ||
606 | + | ||
607 | + | func calcDLp (amountBalance,priceBalance,lpEmission) = { | |
608 | + | let updatedDLp = fraction(getD([amountBalance, priceBalance]), scale18, lpEmission) | |
609 | + | if ((lpEmission == big0)) | |
610 | + | then big0 | |
611 | + | else updatedDLp | |
612 | + | } | |
613 | + | ||
614 | + | ||
615 | + | func calcCurrentDLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = { | |
616 | + | let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta) | |
617 | + | let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta) | |
618 | + | let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta) | |
619 | + | let currentDLp = calcDLp(amountAssetBalance, priceAssetBalance, lpAssetEmission) | |
620 | + | currentDLp | |
621 | + | } | |
622 | + | ||
623 | + | ||
624 | + | func refreshDLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
625 | + | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
626 | + | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
627 | + | let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta) | |
628 | + | let updatedDLp = calcDLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
629 | + | let actions = [IntegerEntry(keyDLpRefreshedHeight, height), StringEntry(keyDLp, toString(updatedDLp))] | |
630 | + | $Tuple2(actions, updatedDLp) | |
631 | + | } | |
632 | + | ||
633 | + | ||
634 | + | func validateUpdatedDLp (oldDLp,updatedDLp) = if ((updatedDLp >= oldDLp)) | |
635 | + | then true | |
636 | + | else throwErr("updated DLp lower than current DLp") | |
637 | + | ||
638 | + | ||
639 | + | func validateMatcherOrderAllowed (order) = { | |
640 | + | let amountAssetAmount = order.amount | |
641 | + | let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR) | |
642 | + | let $t02436324575 = if ((order.orderType == Buy)) | |
643 | + | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
644 | + | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
645 | + | let amountAssetBalanceDelta = $t02436324575._1 | |
646 | + | let priceAssetBalanceDelta = $t02436324575._2 | |
450 | 647 | if (if (if (igs()) | |
451 | 648 | then true | |
452 | - | else ( | |
649 | + | else (cfgPoolStatus == PoolMatcherDis)) | |
453 | 650 | then true | |
454 | - | else ( | |
651 | + | else (cfgPoolStatus == PoolShutdown)) | |
455 | 652 | 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 | - | } | |
653 | + | else if (if ((order.assetPair.amountAsset != cfgAmountAssetId)) | |
654 | + | then true | |
655 | + | else (order.assetPair.priceAsset != cfgPriceAssetId)) | |
656 | + | then throw("Wr assets") | |
657 | + | else { | |
658 | + | let dLp = parseBigIntValue(getStringValue(this, keyDLp)) | |
659 | + | let $t02490525005 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
660 | + | let unusedActions = $t02490525005._1 | |
661 | + | let dLpNew = $t02490525005._2 | |
662 | + | let isOrderValid = (dLpNew >= dLp) | |
663 | + | isOrderValid | |
664 | + | } | |
479 | 665 | } | |
480 | 666 | ||
481 | 667 | ||
511 | 697 | } | |
512 | 698 | ||
513 | 699 | ||
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 | - | ||
618 | 700 | func calcPutOneTkn (pmtAmtRaw,pmtAssetId,userAddress,txId,withTakeFee) = { | |
619 | 701 | let poolConfig = gpc() | |
620 | 702 | let amId = poolConfig[idxAmAsId] | |
630 | 712 | then { | |
631 | 713 | let amBalance = getAccBalance(amId) | |
632 | 714 | let prBalance = getAccBalance(prId) | |
633 | - | let $ | |
715 | + | let $t02732227784 = if ((txId == "")) | |
634 | 716 | then $Tuple2(amBalance, prBalance) | |
635 | 717 | else if ((pmtAssetId == amId)) | |
636 | 718 | then if ((pmtAmtRaw > amBalance)) | |
641 | 723 | then throw("invalid payment amount") | |
642 | 724 | else $Tuple2(amBalance, (prBalance - pmtAmtRaw)) | |
643 | 725 | else throw("wrong pmtAssetId") | |
644 | - | let amBalanceOld = $ | |
645 | - | let prBalanceOld = $ | |
646 | - | let $ | |
726 | + | let amBalanceOld = $t02732227784._1 | |
727 | + | let prBalanceOld = $t02732227784._2 | |
728 | + | let $t02779027966 = if ((pmtAssetId == amId)) | |
647 | 729 | then $Tuple2(pmtAmtRaw, 0) | |
648 | 730 | else if ((pmtAssetId == prId)) | |
649 | 731 | then $Tuple2(0, pmtAmtRaw) | |
650 | 732 | else throw("invalid payment") | |
651 | - | let amAmountRaw = $ | |
652 | - | let prAmountRaw = $ | |
653 | - | let $ | |
654 | - | then $Tuple3(takeFee(amAmountRaw | |
733 | + | let amAmountRaw = $t02779027966._1 | |
734 | + | let prAmountRaw = $t02779027966._2 | |
735 | + | let $t02797028209 = if (withTakeFee) | |
736 | + | then $Tuple3(takeFee(amAmountRaw)._1, takeFee(prAmountRaw)._1, takeFee(pmtAmtRaw)._2) | |
655 | 737 | else $Tuple3(amAmountRaw, prAmountRaw, 0) | |
656 | - | let amAmount = $ | |
657 | - | let prAmount = $ | |
658 | - | let feeAmount = $ | |
738 | + | let amAmount = $t02797028209._1 | |
739 | + | let prAmount = $t02797028209._2 | |
740 | + | let feeAmount = $t02797028209._3 | |
659 | 741 | let amBalanceNew = (amBalanceOld + amAmount) | |
660 | 742 | let prBalanceNew = (prBalanceOld + prAmount) | |
661 | 743 | let D0 = getD([toBigInt(amBalanceOld), toBigInt(prBalanceOld)]) | |
665 | 747 | else throw() | |
666 | 748 | if ((checkD == checkD)) | |
667 | 749 | then { | |
668 | - | let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0) | |
750 | + | let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0, FLOOR) | |
669 | 751 | let curPrice = f1(cpbi(t1(prBalanceNew, priceDcm), t1(amBalanceNew, amtDcm)), scale8) | |
670 | 752 | 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))] | |
671 | 753 | let poolProportion = fraction(prBalanceOld, scale8, amBalanceOld) | |
695 | 777 | let pmt = value(payments[0]) | |
696 | 778 | let pmtAssetId = value(pmt.assetId) | |
697 | 779 | 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)) | |
780 | + | let currentDLp = calcCurrentDLp(big0, big0, big0) | |
781 | + | if ((currentDLp == currentDLp)) | |
782 | + | then { | |
783 | + | let txId58 = toBase58String(transactionId) | |
784 | + | if ((lpId != toBase58String(pmtAssetId))) | |
785 | + | then throw("Wrong LP") | |
786 | + | else { | |
787 | + | let amBalance = getAccBalance(amId) | |
788 | + | let prBalance = getAccBalance(prId) | |
789 | + | let $t03027430385 = { | |
790 | + | let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil) | |
791 | + | if ($isInstanceOf(@, "(Int, Int)")) | |
792 | + | then @ | |
793 | + | else throw(($getType(@) + " couldn't be cast to (Int, Int)")) | |
794 | + | } | |
795 | + | if (($t03027430385 == $t03027430385)) | |
738 | 796 | then { | |
739 | - | let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
740 | - | if ((burn == burn)) | |
741 | - | then $Tuple2(state, totalAmount) | |
797 | + | let feeAmount = $t03027430385._2 | |
798 | + | let totalGet = $t03027430385._1 | |
799 | + | let totalAmount = if (if ((minOutAmount > 0)) | |
800 | + | then (minOutAmount > totalGet) | |
801 | + | else false) | |
802 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
803 | + | else totalGet | |
804 | + | let $t03057530882 = if ((outAssetId == amId)) | |
805 | + | then $Tuple4(totalAmount, 0, ((amBalance - totalAmount) - feeAmount), prBalance) | |
806 | + | else if ((outAssetId == prId)) | |
807 | + | then $Tuple4(0, totalAmount, amBalance, ((prBalance - totalAmount) - feeAmount)) | |
808 | + | else throw("invalid out asset id") | |
809 | + | let outAm = $t03057530882._1 | |
810 | + | let outPr = $t03057530882._2 | |
811 | + | let amBalanceNew = $t03057530882._3 | |
812 | + | let prBalanceNew = $t03057530882._4 | |
813 | + | let curPrX18 = cpbi(t1(prBalanceNew, prDecimals), t1(amBalanceNew, amDecimals)) | |
814 | + | let curPr = f1(curPrX18, scale8) | |
815 | + | let outAssetIdOrWaves = if ((outAssetId == "WAVES")) | |
816 | + | then unit | |
817 | + | else fromBase58String(outAssetId) | |
818 | + | let sendFeeToMatcher = if ((feeAmount > 0)) | |
819 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)] | |
820 | + | else nil | |
821 | + | let state = ([ScriptTransfer(userAddress, totalAmount, outAssetIdOrWaves), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, pmtAmt, curPr, height, lastBlock.timestamp)), IntegerEntry(pl(), curPr), IntegerEntry(ph(height, lastBlock.timestamp), curPr)] ++ sendFeeToMatcher) | |
822 | + | if ((state == state)) | |
823 | + | then { | |
824 | + | let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
825 | + | if ((burn == burn)) | |
826 | + | then { | |
827 | + | let $t03166732017 = { | |
828 | + | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
829 | + | then 0 | |
830 | + | else feeAmount | |
831 | + | let outInAmountAsset = if ((parseAssetId(outAssetId) == cfgAmountAssetId)) | |
832 | + | then true | |
833 | + | else false | |
834 | + | if (outInAmountAsset) | |
835 | + | then $Tuple2(-((totalGet + feeAmountForCalc)), 0) | |
836 | + | else $Tuple2(0, -((totalGet + feeAmountForCalc))) | |
837 | + | } | |
838 | + | let amountAssetBalanceDelta = $t03166732017._1 | |
839 | + | let priceAssetBalanceDelta = $t03166732017._2 | |
840 | + | let $t03202032128 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
841 | + | let refreshDLpActions = $t03202032128._1 | |
842 | + | let updatedDLp = $t03202032128._2 | |
843 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
844 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
845 | + | then $Tuple2((state ++ refreshDLpActions), totalAmount) | |
846 | + | else throw("Strict value is not equal to itself.") | |
847 | + | } | |
848 | + | else throw("Strict value is not equal to itself.") | |
849 | + | } | |
742 | 850 | else throw("Strict value is not equal to itself.") | |
743 | 851 | } | |
744 | 852 | else throw("Strict value is not equal to itself.") | |
745 | 853 | } | |
746 | - | else throw("Strict value is not equal to itself.") | |
747 | 854 | } | |
855 | + | else throw("Strict value is not equal to itself.") | |
748 | 856 | } | |
749 | 857 | ||
750 | 858 | ||
849 | 957 | else if ((size(i.payments) != 2)) | |
850 | 958 | then throw("2 pmnts expd") | |
851 | 959 | 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)) | |
960 | + | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
961 | + | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
962 | + | let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
963 | + | if ((currentDLp == currentDLp)) | |
862 | 964 | 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)) | |
965 | + | 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, "") | |
966 | + | let emitLpAmt = e._2 | |
967 | + | let lpAssetId = e._7 | |
968 | + | let state = e._9 | |
969 | + | let amDiff = e._10 | |
970 | + | let prDiff = e._11 | |
971 | + | let amId = e._12 | |
972 | + | let prId = e._13 | |
973 | + | let r = invoke(fca, "emit", [emitLpAmt], nil) | |
974 | + | if ((r == r)) | |
870 | 975 | then { | |
871 | - | let sa = if ((amDiff > 0)) | |
872 | - | then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)]) | |
873 | - | else nil | |
874 | - | if ((sa == sa)) | |
976 | + | let el = match r { | |
977 | + | case legacy: Address => | |
978 | + | invoke(legacy, "emit", [emitLpAmt], nil) | |
979 | + | case _ => | |
980 | + | unit | |
981 | + | } | |
982 | + | if ((el == el)) | |
875 | 983 | then { | |
876 | - | let | |
877 | - | then invoke(slipCntr, "put", nil, [AttachedPayment( | |
984 | + | let sa = if ((amDiff > 0)) | |
985 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)]) | |
878 | 986 | else nil | |
879 | - | if (( | |
987 | + | if ((sa == sa)) | |
880 | 988 | then { | |
881 | - | let lpTrnsfr = if (autoStake) | |
989 | + | let sp = if ((prDiff > 0)) | |
990 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)]) | |
991 | + | else nil | |
992 | + | if ((sp == sp)) | |
882 | 993 | then { | |
883 | - | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
884 | - | if ((ss == ss)) | |
885 | - | then nil | |
994 | + | let lpTrnsfr = if (autoStake) | |
995 | + | then { | |
996 | + | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
997 | + | if ((ss == ss)) | |
998 | + | then nil | |
999 | + | else throw("Strict value is not equal to itself.") | |
1000 | + | } | |
1001 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
1002 | + | let $t03598436049 = refreshDLpInternal(0, 0, 0) | |
1003 | + | let refreshDLpActions = $t03598436049._1 | |
1004 | + | let updatedDLp = $t03598436049._2 | |
1005 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1006 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1007 | + | then ((state ++ lpTrnsfr) ++ refreshDLpActions) | |
886 | 1008 | else throw("Strict value is not equal to itself.") | |
887 | 1009 | } | |
888 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
889 | - | (state ++ lpTrnsfr) | |
1010 | + | else throw("Strict value is not equal to itself.") | |
890 | 1011 | } | |
891 | 1012 | else throw("Strict value is not equal to itself.") | |
892 | 1013 | } | |
936 | 1057 | let pmt = value(i.payments[0]) | |
937 | 1058 | let pmtAssetId = toBase58String(value(pmt.assetId)) | |
938 | 1059 | let pmtAmt = pmt.amount | |
939 | - | let $ | |
940 | - | if (($ | |
1060 | + | let $t03718637344 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true) | |
1061 | + | if (($t03718637344 == $t03718637344)) | |
941 | 1062 | then { | |
942 | - | let feeAmount = $ | |
943 | - | let state = $ | |
944 | - | let estimLP = $ | |
1063 | + | let feeAmount = $t03718637344._3 | |
1064 | + | let state = $t03718637344._2 | |
1065 | + | let estimLP = $t03718637344._1 | |
945 | 1066 | let emitLpAmt = if (if ((minOutAmount > 0)) | |
946 | 1067 | then (minOutAmount > estimLP) | |
947 | 1068 | else false) | |
969 | 1090 | let sendFeeToMatcher = if ((feeAmount > 0)) | |
970 | 1091 | then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))] | |
971 | 1092 | else nil | |
972 | - | $Tuple2(((state ++ lpTrnsfr) ++ sendFeeToMatcher), emitLpAmt) | |
1093 | + | let $t03815938508 = if ((this == feeCollectorAddress)) | |
1094 | + | then $Tuple2(0, 0) | |
1095 | + | else { | |
1096 | + | let paymentInAmountAsset = if ((pmt.assetId == cfgAmountAssetId)) | |
1097 | + | then true | |
1098 | + | else false | |
1099 | + | if (paymentInAmountAsset) | |
1100 | + | then $Tuple2(-(feeAmount), 0) | |
1101 | + | else $Tuple2(0, -(feeAmount)) | |
1102 | + | } | |
1103 | + | let amountAssetBalanceDelta = $t03815938508._1 | |
1104 | + | let priceAssetBalanceDelta = $t03815938508._2 | |
1105 | + | let $t03851138619 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1106 | + | let refreshDLpActions = $t03851138619._1 | |
1107 | + | let updatedDLp = $t03851138619._2 | |
1108 | + | $Tuple2((((state ++ lpTrnsfr) ++ sendFeeToMatcher) ++ refreshDLpActions), emitLpAmt) | |
973 | 1109 | } | |
974 | 1110 | else throw("Strict value is not equal to itself.") | |
975 | 1111 | } | |
989 | 1125 | then throw("2 pmnts expd") | |
990 | 1126 | else { | |
991 | 1127 | 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 | |
1128 | + | let state = estPut._9 | |
1129 | + | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
1130 | + | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
1131 | + | let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
1132 | + | if ((currentDLp == currentDLp)) | |
1133 | + | then { | |
1134 | + | let $t03957839643 = refreshDLpInternal(0, 0, 0) | |
1135 | + | let refreshDLpActions = $t03957839643._1 | |
1136 | + | let updatedDLp = $t03957839643._2 | |
1137 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1138 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1139 | + | then (state ++ refreshDLpActions) | |
1140 | + | else throw("Strict value is not equal to itself.") | |
1141 | + | } | |
1142 | + | else throw("Strict value is not equal to itself.") | |
993 | 1143 | } | |
994 | 1144 | ||
995 | 1145 | ||
1004 | 1154 | let state = r._5 | |
1005 | 1155 | let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1006 | 1156 | if ((b == b)) | |
1007 | - | then state | |
1157 | + | then { | |
1158 | + | let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt)) | |
1159 | + | let $t04043240514 = refreshDLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1160 | + | let refreshDLpActions = $t04043240514._1 | |
1161 | + | let updatedDLp = $t04043240514._2 | |
1162 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1163 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1164 | + | then (state ++ refreshDLpActions) | |
1165 | + | else throw("Strict value is not equal to itself.") | |
1166 | + | } | |
1008 | 1167 | else throw("Strict value is not equal to itself.") | |
1009 | 1168 | } | |
1010 | 1169 | ||
1032 | 1191 | else throwErr("exactly 1 payment are expected")] | |
1033 | 1192 | if ((checks == checks)) | |
1034 | 1193 | then { | |
1035 | - | let $ | |
1036 | - | let state = $ | |
1037 | - | let totalAmount = $ | |
1194 | + | let $t04113241287 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId) | |
1195 | + | let state = $t04113241287._1 | |
1196 | + | let totalAmount = $t04113241287._2 | |
1038 | 1197 | $Tuple2(state, totalAmount) | |
1198 | + | } | |
1199 | + | else throw("Strict value is not equal to itself.") | |
1200 | + | } | |
1201 | + | ||
1202 | + | ||
1203 | + | ||
1204 | + | @Callable(i) | |
1205 | + | func refreshDLp () = { | |
1206 | + | let lastRefreshedBlockHeight = valueOrElse(getInteger(keyDLpRefreshedHeight), 0) | |
1207 | + | let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= dLpRefreshDelay)) | |
1208 | + | then unit | |
1209 | + | else throwErr(makeString([toString(dLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1210 | + | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1211 | + | then { | |
1212 | + | let dLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyDLp), "0")), fmtErr("invalid dLp")) | |
1213 | + | let $t04181141875 = refreshDLpInternal(0, 0, 0) | |
1214 | + | let dLpUpdateActions = $t04181141875._1 | |
1215 | + | let updatedDLp = $t04181141875._2 | |
1216 | + | let actions = if ((dLp != updatedDLp)) | |
1217 | + | then dLpUpdateActions | |
1218 | + | else throwErr("nothing to refresh") | |
1219 | + | $Tuple2(actions, toString(updatedDLp)) | |
1039 | 1220 | } | |
1040 | 1221 | else throw("Strict value is not equal to itself.") | |
1041 | 1222 | } | |
1060 | 1241 | let newY = getYD(xp, index, D1) | |
1061 | 1242 | let dy = (xp[index] - newY) | |
1062 | 1243 | let totalGetRaw = max([0, toInt((dy - big1))]) | |
1063 | - | let $ | |
1064 | - | let totalGet = $ | |
1065 | - | let feeAmount = $ | |
1244 | + | let $t04277542824 = takeFee(totalGetRaw) | |
1245 | + | let totalGet = $t04277542824._1 | |
1246 | + | let feeAmount = $t04277542824._2 | |
1066 | 1247 | $Tuple2(nil, $Tuple2(totalGet, feeAmount)) | |
1067 | 1248 | } | |
1068 | 1249 | ||
1076 | 1257 | let lpId = poolConfig[idxLPAsId] | |
1077 | 1258 | let amBalance = getAccBalance(amId) | |
1078 | 1259 | let prBalance = getAccBalance(prId) | |
1079 | - | let $ | |
1260 | + | let $t04316943284 = { | |
1080 | 1261 | let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, lpAssetAmount], nil) | |
1081 | 1262 | if ($isInstanceOf(@, "(Int, Int)")) | |
1082 | 1263 | then @ | |
1083 | 1264 | else throw(($getType(@) + " couldn't be cast to (Int, Int)")) | |
1084 | 1265 | } | |
1085 | - | let totalGet = $ | |
1086 | - | let feeAmount = $ | |
1266 | + | let totalGet = $t04316943284._1 | |
1267 | + | let feeAmount = $t04316943284._2 | |
1087 | 1268 | let r = ego("", lpId, lpAssetAmount, this) | |
1088 | 1269 | let outAmAmt = r._1 | |
1089 | 1270 | let outPrAmt = r._2 | |
1111 | 1292 | else if ((noLessThenPriceAsset > outPrAmt)) | |
1112 | 1293 | then throw(((("Failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
1113 | 1294 | else { | |
1295 | + | let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt)) | |
1114 | 1296 | let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1115 | 1297 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1116 | - | then state | |
1298 | + | then { | |
1299 | + | let $t04445244533 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1300 | + | let refreshDLpActions = $t04445244533._1 | |
1301 | + | let updatedDLp = $t04445244533._2 | |
1302 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1303 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1304 | + | then (state ++ refreshDLpActions) | |
1305 | + | else throw("Strict value is not equal to itself.") | |
1306 | + | } | |
1117 | 1307 | else throw("Strict value is not equal to itself.") | |
1118 | 1308 | } | |
1119 | 1309 | } | |
1131 | 1321 | let factoryCfg = gfc() | |
1132 | 1322 | let lpAssetId = fromBase58String(cfg[idxLPAsId]) | |
1133 | 1323 | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr") | |
1324 | + | let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1134 | 1325 | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1135 | 1326 | if ((unstakeInv == unstakeInv)) | |
1136 | 1327 | then { | |
1137 | 1328 | let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1329 | + | let outAmAmt = r._1 | |
1330 | + | let outPrAmt = r._2 | |
1138 | 1331 | let sts = parseIntValue(r._9) | |
1139 | 1332 | let state = r._10 | |
1140 | 1333 | let v = if (if (igs()) | |
1146 | 1339 | then { | |
1147 | 1340 | let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1148 | 1341 | if ((burnA == burnA)) | |
1149 | - | then state | |
1342 | + | then { | |
1343 | + | let $t04559645677 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1344 | + | let refreshDLpActions = $t04559645677._1 | |
1345 | + | let updatedDLp = $t04559645677._2 | |
1346 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1347 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1348 | + | then (state ++ refreshDLpActions) | |
1349 | + | else throw("Strict value is not equal to itself.") | |
1350 | + | } | |
1150 | 1351 | else throw("Strict value is not equal to itself.") | |
1151 | 1352 | } | |
1152 | 1353 | else throw("Strict value is not equal to itself.") | |
1170 | 1371 | else throw("no payments are expected")] | |
1171 | 1372 | if ((checks == checks)) | |
1172 | 1373 | then { | |
1374 | + | let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1173 | 1375 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1174 | 1376 | if ((unstakeInv == unstakeInv)) | |
1175 | 1377 | then { | |
1186 | 1388 | then { | |
1187 | 1389 | let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1188 | 1390 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1189 | - | then state | |
1391 | + | then { | |
1392 | + | let $t04692547006 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1393 | + | let refreshDLpActions = $t04692547006._1 | |
1394 | + | let updatedDLp = $t04692547006._2 | |
1395 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1396 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1397 | + | then (state ++ refreshDLpActions) | |
1398 | + | else throw("Strict value is not equal to itself.") | |
1399 | + | } | |
1190 | 1400 | else throw("Strict value is not equal to itself.") | |
1191 | 1401 | } | |
1192 | 1402 | else throw("Strict value is not equal to itself.") | |
1227 | 1437 | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), unstakeAmount], nil) | |
1228 | 1438 | if ((unstakeInv == unstakeInv)) | |
1229 | 1439 | then { | |
1230 | - | let $ | |
1231 | - | let state = $ | |
1232 | - | let totalAmount = $ | |
1440 | + | let $t04794048128 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId) | |
1441 | + | let state = $t04794048128._1 | |
1442 | + | let totalAmount = $t04794048128._2 | |
1233 | 1443 | $Tuple2(state, totalAmount) | |
1234 | 1444 | } | |
1235 | 1445 | else throw("Strict value is not equal to itself.") | |
1245 | 1455 | let amId = poolConfig[idxAmAsId] | |
1246 | 1456 | let prId = poolConfig[idxPrAsId] | |
1247 | 1457 | let lpId = poolConfig[idxLPAsId] | |
1248 | - | let $ | |
1249 | - | let lpAmount = $ | |
1250 | - | let state = $ | |
1251 | - | let feeAmount = $ | |
1252 | - | let bonus = $ | |
1458 | + | let $t04838748490 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true) | |
1459 | + | let lpAmount = $t04838748490._1 | |
1460 | + | let state = $t04838748490._2 | |
1461 | + | let feeAmount = $t04838748490._3 | |
1462 | + | let bonus = $t04838748490._4 | |
1253 | 1463 | $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus)) | |
1254 | 1464 | } | |
1255 | 1465 | ||
1261 | 1471 | let amId = poolConfig[idxAmAsId] | |
1262 | 1472 | let prId = poolConfig[idxPrAsId] | |
1263 | 1473 | let lpId = poolConfig[idxLPAsId] | |
1264 | - | let $ | |
1265 | - | let lpAmount = $ | |
1266 | - | let state = $ | |
1267 | - | let feeAmount = $ | |
1268 | - | let bonus = $ | |
1474 | + | let $t04876948873 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false) | |
1475 | + | let lpAmount = $t04876948873._1 | |
1476 | + | let state = $t04876948873._2 | |
1477 | + | let feeAmount = $t04876948873._3 | |
1478 | + | let bonus = $t04876948873._4 | |
1269 | 1479 | $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus)) | |
1270 | 1480 | } | |
1271 | 1481 | ||
1337 | 1547 | } | |
1338 | 1548 | ||
1339 | 1549 | ||
1550 | + | ||
1551 | + | @Callable(i) | |
1552 | + | func getFeeREADONLY () = $Tuple2(nil, fee) | |
1553 | + | ||
1554 | + | ||
1340 | 1555 | @Verifier(tx) | |
1341 | 1556 | func verify () = { | |
1342 | 1557 | let targetPublicKey = match m() { | |
1350 | 1565 | match tx { | |
1351 | 1566 | case order: Order => | |
1352 | 1567 | let matcherPub = mp() | |
1353 | - | let orderValid = | |
1568 | + | let orderValid = validateMatcherOrderAllowed(order) | |
1354 | 1569 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1355 | 1570 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1356 | 1571 | if (if (if (orderValid) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let scale8 = 100000000 | |
5 | 5 | ||
6 | 6 | let scale8BigInt = toBigInt(100000000) | |
7 | 7 | ||
8 | 8 | let scale18 = toBigInt(1000000000000000000) | |
9 | 9 | ||
10 | 10 | let zeroBigInt = toBigInt(0) | |
11 | 11 | ||
12 | 12 | let big0 = toBigInt(0) | |
13 | 13 | ||
14 | 14 | let big1 = toBigInt(1) | |
15 | 15 | ||
16 | 16 | let big2 = toBigInt(2) | |
17 | + | ||
18 | + | let big3 = toBigInt(3) | |
19 | + | ||
20 | + | let big4 = toBigInt(4) | |
17 | 21 | ||
18 | 22 | let slippage4D = toBigInt((scale8 - ((scale8 * 1) / scale8))) | |
19 | 23 | ||
20 | 24 | let wavesString = "WAVES" | |
21 | 25 | ||
22 | 26 | let Amult = "100" | |
23 | 27 | ||
24 | 28 | let Dconv = "1" | |
25 | 29 | ||
26 | 30 | let SEP = "__" | |
27 | 31 | ||
28 | 32 | let EMPTY = "" | |
29 | 33 | ||
30 | 34 | let PoolActive = 1 | |
31 | 35 | ||
32 | 36 | let PoolPutDis = 2 | |
33 | 37 | ||
34 | 38 | let PoolMatcherDis = 3 | |
35 | 39 | ||
36 | 40 | let PoolShutdown = 4 | |
37 | 41 | ||
38 | 42 | let idxPoolAddress = 1 | |
39 | 43 | ||
40 | 44 | let idxPoolSt = 2 | |
41 | 45 | ||
42 | 46 | let idxLPAsId = 3 | |
43 | 47 | ||
44 | 48 | let idxAmAsId = 4 | |
45 | 49 | ||
46 | 50 | let idxPrAsId = 5 | |
47 | 51 | ||
48 | 52 | let idxAmtAsDcm = 6 | |
49 | 53 | ||
50 | 54 | let idxPriceAsDcm = 7 | |
51 | 55 | ||
52 | 56 | let idxIAmtAsId = 8 | |
53 | 57 | ||
54 | 58 | let idxIPriceAsId = 9 | |
55 | 59 | ||
56 | 60 | let idxFactStakCntr = 1 | |
57 | 61 | ||
58 | 62 | let idxFactoryRestCntr = 6 | |
59 | 63 | ||
60 | 64 | let idxFactSlippCntr = 7 | |
61 | 65 | ||
62 | 66 | let idxFactGwxRewCntr = 10 | |
63 | 67 | ||
64 | 68 | let feeDefault = fraction(10, scale8, 10000) | |
65 | 69 | ||
66 | 70 | func t1 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult)) | |
67 | 71 | ||
68 | 72 | ||
69 | 73 | func f1 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18)) | |
70 | 74 | ||
71 | 75 | ||
76 | + | func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round)) | |
77 | + | ||
78 | + | ||
72 | 79 | func ts (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
73 | 80 | ||
74 | 81 | ||
75 | 82 | func abs (val) = if ((zeroBigInt > val)) | |
76 | 83 | then -(val) | |
77 | 84 | else val | |
78 | 85 | ||
79 | 86 | ||
80 | 87 | func absBigInt (val) = if ((zeroBigInt > val)) | |
81 | 88 | then -(val) | |
82 | 89 | else val | |
83 | 90 | ||
84 | 91 | ||
85 | 92 | func fc () = "%s__factoryContract" | |
86 | 93 | ||
87 | 94 | ||
88 | 95 | func mpk () = "%s__managerPublicKey" | |
89 | 96 | ||
90 | 97 | ||
91 | 98 | func pmpk () = "%s__pendingManagerPublicKey" | |
92 | 99 | ||
93 | 100 | ||
94 | 101 | func pl () = "%s%s__price__last" | |
95 | 102 | ||
96 | 103 | ||
97 | 104 | func ph (h,t) = makeString(["%s%s%d%d__price__history", toString(h), toString(t)], SEP) | |
98 | 105 | ||
99 | 106 | ||
100 | 107 | func pau (ua,txId) = ((("%s%s%s__P__" + ua) + "__") + txId) | |
101 | 108 | ||
102 | 109 | ||
103 | 110 | func gau (ua,txId) = ((("%s%s%s__G__" + ua) + "__") + txId) | |
104 | 111 | ||
105 | 112 | ||
106 | 113 | func aa () = "%s__amountAsset" | |
107 | 114 | ||
108 | 115 | ||
109 | 116 | func pa () = "%s__priceAsset" | |
110 | 117 | ||
111 | 118 | ||
112 | 119 | func amp () = "%s__amp" | |
113 | 120 | ||
114 | 121 | ||
115 | 122 | func ada () = "%s__addonAddr" | |
116 | 123 | ||
117 | 124 | ||
125 | + | let keyFee = "%s__fee" | |
126 | + | ||
127 | + | let fee = valueOrElse(getInteger(this, keyFee), feeDefault) | |
128 | + | ||
129 | + | let keyDLp = makeString(["%s", "dLp"], SEP) | |
130 | + | ||
131 | + | let keyDLpRefreshedHeight = makeString(["%s", "dLpRefreshedHeight"], SEP) | |
132 | + | ||
133 | + | let keyDLpRefreshDelay = makeString(["%s", "refreshDLpDelay"], SEP) | |
134 | + | ||
135 | + | let dLpRefreshDelayDefault = 1 | |
136 | + | ||
137 | + | let dLpRefreshDelay = valueOrElse(getInteger(this, keyDLpRefreshDelay), dLpRefreshDelayDefault) | |
138 | + | ||
118 | 139 | func fcfg () = "%s__factoryConfig" | |
119 | 140 | ||
120 | 141 | ||
121 | 142 | func mtpk () = "%s%s__matcher__publicKey" | |
122 | 143 | ||
123 | 144 | ||
124 | 145 | func pc (iAmtAs,iPrAs) = (((("%d%d%s__" + iAmtAs) + "__") + iPrAs) + "__config") | |
125 | 146 | ||
126 | 147 | ||
127 | 148 | func mba (bAStr) = ("%s%s%s__mappings__baseAsset2internalId__" + bAStr) | |
128 | 149 | ||
129 | 150 | ||
130 | 151 | func aps () = "%s__shutdown" | |
131 | 152 | ||
132 | 153 | ||
133 | 154 | func keyAllowedLpStableScriptHash () = "%s__allowedLpStableScriptHash" | |
134 | 155 | ||
135 | 156 | ||
136 | 157 | func keyFeeCollectorAddress () = "%s__feeCollectorAddress" | |
137 | 158 | ||
138 | 159 | ||
139 | 160 | func toe (orV,sendrV,matchV) = throw(((((("Failed: ordValid=" + toString(orV)) + " sndrValid=") + toString(sendrV)) + " mtchrValid=") + toString(matchV))) | |
140 | 161 | ||
141 | 162 | ||
142 | 163 | func str (val) = match val { | |
143 | 164 | case valStr: String => | |
144 | 165 | valStr | |
145 | 166 | case _ => | |
146 | 167 | throw("fail cast to String") | |
147 | 168 | } | |
148 | 169 | ||
149 | 170 | ||
150 | 171 | func strf (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
151 | 172 | ||
152 | 173 | ||
153 | 174 | func intf (addr,key) = valueOrErrorMessage(getInteger(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
154 | 175 | ||
155 | 176 | ||
156 | 177 | func throwErr (msg) = throw(makeString(["lp_stable.ride:", msg], " ")) | |
157 | 178 | ||
158 | 179 | ||
180 | + | func fmtErr (msg) = makeString(["lp_stable.ride:", msg], " ") | |
181 | + | ||
182 | + | ||
159 | 183 | let fca = addressFromStringValue(strf(this, fc())) | |
160 | - | ||
161 | - | let inFee = { | |
162 | - | let @ = invoke(fca, "getInFeeREADONLY", [toString(this)], nil) | |
163 | - | if ($isInstanceOf(@, "Int")) | |
164 | - | then @ | |
165 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
166 | - | } | |
167 | - | ||
168 | - | let outFee = { | |
169 | - | let @ = invoke(fca, "getOutFeeREADONLY", [toString(this)], nil) | |
170 | - | if ($isInstanceOf(@, "Int")) | |
171 | - | then @ | |
172 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
173 | - | } | |
174 | 184 | ||
175 | 185 | let A = strf(this, amp()) | |
176 | 186 | ||
177 | 187 | func igs () = valueOrElse(getBoolean(fca, aps()), false) | |
178 | 188 | ||
179 | 189 | ||
180 | 190 | func mp () = fromBase58String(strf(fca, mtpk())) | |
181 | 191 | ||
182 | 192 | ||
183 | 193 | let feeCollectorAddress = addressFromStringValue(strf(fca, keyFeeCollectorAddress())) | |
184 | 194 | ||
185 | 195 | func gpc () = { | |
186 | 196 | let amtAs = strf(this, aa()) | |
187 | 197 | let priceAs = strf(this, pa()) | |
188 | 198 | let iPriceAs = intf(fca, mba(priceAs)) | |
189 | 199 | let iAmtAs = intf(fca, mba(amtAs)) | |
190 | 200 | split(strf(fca, pc(toString(iAmtAs), toString(iPriceAs))), SEP) | |
191 | 201 | } | |
192 | 202 | ||
193 | 203 | ||
194 | 204 | func parseAssetId (input) = if ((input == wavesString)) | |
195 | 205 | then unit | |
196 | 206 | else fromBase58String(input) | |
197 | 207 | ||
198 | 208 | ||
199 | 209 | func assetIdToString (input) = if ((input == unit)) | |
200 | 210 | then wavesString | |
201 | 211 | else toBase58String(value(input)) | |
202 | 212 | ||
203 | 213 | ||
204 | 214 | 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])) | |
205 | 215 | ||
206 | 216 | ||
207 | 217 | let poolConfigParsed = parsePoolConfig(gpc()) | |
208 | 218 | ||
209 | - | let $ | |
219 | + | let $t074067592 = poolConfigParsed | |
210 | 220 | ||
211 | - | let cfgPoolAddress = $ | |
221 | + | let cfgPoolAddress = $t074067592._1 | |
212 | 222 | ||
213 | - | let cfgPoolStatus = $ | |
223 | + | let cfgPoolStatus = $t074067592._2 | |
214 | 224 | ||
215 | - | let cfgLpAssetId = $ | |
225 | + | let cfgLpAssetId = $t074067592._3 | |
216 | 226 | ||
217 | - | let cfgAmountAssetId = $ | |
227 | + | let cfgAmountAssetId = $t074067592._4 | |
218 | 228 | ||
219 | - | let cfgPriceAssetId = $ | |
229 | + | let cfgPriceAssetId = $t074067592._5 | |
220 | 230 | ||
221 | - | let cfgAmountAssetDecimals = $ | |
231 | + | let cfgAmountAssetDecimals = $t074067592._6 | |
222 | 232 | ||
223 | - | let cfgPriceAssetDecimals = $ | |
233 | + | let cfgPriceAssetDecimals = $t074067592._7 | |
224 | 234 | ||
225 | 235 | func gfc () = split(strf(fca, fcfg()), SEP) | |
226 | 236 | ||
227 | 237 | ||
228 | 238 | let factoryConfig = gfc() | |
229 | 239 | ||
230 | 240 | let stakingContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactStakCntr]), "Invalid staking contract address") | |
231 | 241 | ||
232 | 242 | let slipageContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactSlippCntr]), "Invalid slipage contract address") | |
233 | 243 | ||
234 | 244 | let gwxContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactGwxRewCntr]), "Invalid gwx contract address") | |
235 | 245 | ||
236 | 246 | let restContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactoryRestCntr]), "Invalid gwx contract address") | |
237 | 247 | ||
238 | 248 | 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) | |
239 | 249 | ||
240 | 250 | ||
241 | 251 | 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) | |
242 | 252 | ||
243 | 253 | ||
244 | 254 | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
245 | 255 | then wavesBalance(this).available | |
246 | 256 | else assetBalance(this, fromBase58String(assetId)) | |
247 | 257 | ||
248 | 258 | ||
249 | 259 | func cpbi (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
250 | 260 | ||
251 | 261 | ||
252 | 262 | func vad (A1,A2,slippage) = { | |
253 | 263 | let diff = fraction((A1 - A2), scale8BigInt, A2) | |
254 | 264 | let pass = ((slippage - abs(diff)) > zeroBigInt) | |
255 | 265 | if (!(pass)) | |
256 | 266 | then throw(("Big slpg: " + toString(diff))) | |
257 | 267 | else $Tuple2(pass, min([A1, A2])) | |
258 | 268 | } | |
259 | 269 | ||
260 | 270 | ||
261 | 271 | func vd (D1,D0,slpg) = { | |
262 | 272 | let diff = fraction(D0, scale8BigInt, D1) | |
263 | 273 | let fail = (slpg > diff) | |
264 | 274 | if (if (fail) | |
265 | 275 | then true | |
266 | 276 | else (D0 > D1)) | |
267 | 277 | then throw(((((((toString(D0) + " ") + toString(D1)) + " ") + toString(diff)) + " ") + toString(slpg))) | |
268 | 278 | else fail | |
269 | 279 | } | |
270 | 280 | ||
271 | 281 | ||
272 | 282 | func pcp (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
273 | 283 | let amtAsAmtX18 = t1(amAmt, amAssetDcm) | |
274 | 284 | let prAsAmtX18 = t1(prAmt, prAssetDcm) | |
275 | 285 | cpbi(prAsAmtX18, amtAsAmtX18) | |
276 | 286 | } | |
277 | 287 | ||
278 | 288 | ||
279 | 289 | func calcPrices (amAmt,prAmt,lpAmt) = { | |
280 | 290 | let cfg = gpc() | |
281 | 291 | let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
282 | 292 | let prAsDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
283 | 293 | let priceX18 = pcp(amtAsDcm, prAsDcm, amAmt, prAmt) | |
284 | 294 | let amAmtX18 = t1(amAmt, amtAsDcm) | |
285 | 295 | let prAmtX18 = t1(prAmt, prAsDcm) | |
286 | 296 | let lpAmtX18 = t1(lpAmt, scale8) | |
287 | 297 | let lpPrInAmAsX18 = cpbi(amAmtX18, lpAmtX18) | |
288 | 298 | let lpPrInPrAsX18 = cpbi(prAmtX18, lpAmtX18) | |
289 | 299 | [priceX18, lpPrInAmAsX18, lpPrInPrAsX18] | |
290 | 300 | } | |
291 | 301 | ||
292 | 302 | ||
293 | 303 | func calculatePrices (amAmt,prAmt,lpAmt) = { | |
294 | 304 | let p = calcPrices(amAmt, prAmt, lpAmt) | |
295 | 305 | [f1(p[0], scale8), f1(p[1], scale8), f1(p[2], scale8)] | |
296 | 306 | } | |
297 | 307 | ||
298 | 308 | ||
299 | - | func takeFee (amount,fee) = { | |
300 | - | let feeAmount = if ((fee == 0)) | |
301 | - | then 0 | |
302 | - | else fraction(amount, fee, scale8) | |
309 | + | func takeFee (amount) = { | |
310 | + | let feeAmount = fraction(amount, fee, scale8) | |
303 | 311 | $Tuple2((amount - feeAmount), feeAmount) | |
304 | 312 | } | |
305 | 313 | ||
306 | 314 | ||
307 | 315 | func ego (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
308 | 316 | let cfg = gpc() | |
309 | 317 | let lpId = cfg[idxLPAsId] | |
310 | 318 | let amId = cfg[idxAmAsId] | |
311 | 319 | let prId = cfg[idxPrAsId] | |
312 | 320 | let amDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
313 | 321 | let prDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
314 | 322 | let sts = cfg[idxPoolSt] | |
315 | 323 | let lpEmiss = valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "Wrong LP id").quantity | |
316 | 324 | if ((lpId != pmtAssetId)) | |
317 | 325 | then throw("Wrong pmt asset") | |
318 | 326 | else { | |
319 | 327 | let amBalance = getAccBalance(amId) | |
320 | 328 | let amBalanceX18 = t1(amBalance, amDcm) | |
321 | 329 | let prBalance = getAccBalance(prId) | |
322 | 330 | let prBalanceX18 = t1(prBalance, prDcm) | |
323 | 331 | let curPriceX18 = cpbi(prBalanceX18, amBalanceX18) | |
324 | 332 | let curPrice = f1(curPriceX18, scale8) | |
325 | 333 | let pmtLpAmtX18 = t1(pmtLpAmt, scale8) | |
326 | 334 | let lpEmissX18 = t1(lpEmiss, scale8) | |
327 | 335 | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissX18) | |
328 | 336 | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissX18) | |
329 | - | let outAmAmt = | |
330 | - | let outPrAmt = | |
337 | + | let outAmAmt = fromX18Round(outAmAmtX18, amDcm, FLOOR) | |
338 | + | let outPrAmt = fromX18Round(outPrAmtX18, prDcm, FLOOR) | |
331 | 339 | let state = if ((txId58 == "")) | |
332 | 340 | then nil | |
333 | 341 | else [ScriptTransfer(userAddress, outAmAmt, if ((amId == "WAVES")) | |
334 | 342 | then unit | |
335 | 343 | else fromBase58String(amId)), ScriptTransfer(userAddress, outPrAmt, if ((prId == "WAVES")) | |
336 | 344 | then unit | |
337 | 345 | 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)] | |
338 | 346 | $Tuple10(outAmAmt, outPrAmt, amId, prId, amBalance, prBalance, lpEmiss, curPriceX18, sts, state) | |
339 | 347 | } | |
340 | 348 | } | |
341 | 349 | ||
342 | 350 | ||
343 | 351 | func epo (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,userAddress,isEval,emitLp,isOneAsset,validateSlippage,pmtAmt,pmtId) = { | |
344 | 352 | let cfg = gpc() | |
345 | 353 | let lpId = fromBase58String(cfg[idxLPAsId]) | |
346 | 354 | let amIdStr = cfg[idxAmAsId] | |
347 | 355 | let prIdStr = cfg[idxPrAsId] | |
348 | 356 | let inAmIdStr = cfg[idxIAmtAsId] | |
349 | 357 | let inPrIdStr = cfg[idxIPriceAsId] | |
350 | 358 | let amtDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
351 | 359 | let priceDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
352 | 360 | let sts = cfg[idxPoolSt] | |
353 | 361 | let lpEm = valueOrErrorMessage(assetInfo(lpId), "Wr lp as").quantity | |
354 | 362 | let amBalance = if (isEval) | |
355 | 363 | then getAccBalance(amIdStr) | |
356 | 364 | else if (if (isOneAsset) | |
357 | 365 | then (pmtId == amIdStr) | |
358 | 366 | else false) | |
359 | 367 | then (getAccBalance(amIdStr) - pmtAmt) | |
360 | 368 | else if (isOneAsset) | |
361 | 369 | then getAccBalance(amIdStr) | |
362 | 370 | else (getAccBalance(amIdStr) - inAmAmt) | |
363 | 371 | let prBalance = if (isEval) | |
364 | 372 | then getAccBalance(prIdStr) | |
365 | 373 | else if (if (isOneAsset) | |
366 | 374 | then (pmtId == prIdStr) | |
367 | 375 | else false) | |
368 | 376 | then (getAccBalance(prIdStr) - pmtAmt) | |
369 | 377 | else if (isOneAsset) | |
370 | 378 | then getAccBalance(prIdStr) | |
371 | 379 | else (getAccBalance(prIdStr) - inPrAmt) | |
372 | 380 | let inAmAssetAmtX18 = t1(inAmAmt, amtDcm) | |
373 | 381 | let inPrAssetAmtX18 = t1(inPrAmt, priceDcm) | |
374 | 382 | let userPriceX18 = cpbi(inPrAssetAmtX18, inAmAssetAmtX18) | |
375 | 383 | let amBalanceX18 = t1(amBalance, amtDcm) | |
376 | 384 | let prBalanceX18 = t1(prBalance, priceDcm) | |
377 | 385 | let r = if ((lpEm == 0)) | |
378 | 386 | then { | |
379 | 387 | let curPriceX18 = zeroBigInt | |
380 | 388 | let slippageX18 = zeroBigInt | |
381 | 389 | let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN) | |
382 | 390 | $Tuple5(f1(lpAmtX18, scale8), f1(inAmAssetAmtX18, amtDcm), f1(inPrAssetAmtX18, priceDcm), cpbi((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
383 | 391 | } | |
384 | 392 | else { | |
385 | 393 | let curPriceX18 = cpbi(prBalanceX18, amBalanceX18) | |
386 | 394 | let slippageRealX18 = fraction(abs((curPriceX18 - userPriceX18)), scale18, curPriceX18) | |
387 | 395 | let slippageX18 = t1(slippage, scale8) | |
388 | 396 | if (if (if (validateSlippage) | |
389 | 397 | then (curPriceX18 != zeroBigInt) | |
390 | 398 | else false) | |
391 | 399 | then (slippageRealX18 > slippageX18) | |
392 | 400 | else false) | |
393 | 401 | then throw(((("Price slippage " + toString(slippageRealX18)) + " > ") + toString(slippageX18))) | |
394 | 402 | else { | |
395 | 403 | let lpEmissionX18 = t1(lpEm, scale8) | |
396 | 404 | let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
397 | 405 | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
398 | 406 | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
399 | 407 | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
400 | 408 | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
401 | 409 | let expAmtAssetAmtX18 = expectedAmts._1 | |
402 | 410 | let expPriceAssetAmtX18 = expectedAmts._2 | |
403 | 411 | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18) | |
404 | - | $Tuple5( | |
412 | + | $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceDcm, CEILING), curPriceX18, slippageX18) | |
405 | 413 | } | |
406 | 414 | } | |
407 | 415 | let calcLpAmt = r._1 | |
408 | 416 | let calcAmAssetPmt = r._2 | |
409 | 417 | let calcPrAssetPmt = r._3 | |
410 | 418 | let curPrice = f1(r._4, scale8) | |
411 | 419 | let slippageCalc = f1(r._5, scale8) | |
412 | 420 | if ((0 >= calcLpAmt)) | |
413 | 421 | then throw("LP <= 0") | |
414 | 422 | else { | |
415 | 423 | let emitLpAmt = if (!(emitLp)) | |
416 | 424 | then 0 | |
417 | 425 | else calcLpAmt | |
418 | 426 | let amDiff = (inAmAmt - calcAmAssetPmt) | |
419 | 427 | let prDiff = (inPrAmt - calcPrAssetPmt) | |
420 | - | let $ | |
428 | + | let $t01811218457 = if (if (isOneAsset) | |
421 | 429 | then (pmtId == amIdStr) | |
422 | 430 | else false) | |
423 | 431 | then $Tuple2(pmtAmt, 0) | |
424 | 432 | else if (if (isOneAsset) | |
425 | 433 | then (pmtId == prIdStr) | |
426 | 434 | else false) | |
427 | 435 | then $Tuple2(0, pmtAmt) | |
428 | 436 | else $Tuple2(calcAmAssetPmt, calcPrAssetPmt) | |
429 | - | let writeAmAmt = $ | |
430 | - | let writePrAmt = $ | |
437 | + | let writeAmAmt = $t01811218457._1 | |
438 | + | let writePrAmt = $t01811218457._2 | |
431 | 439 | 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))] | |
432 | 440 | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEm, lpId, sts, commonState, amDiff, prDiff, inAmId, inPrId) | |
433 | 441 | } | |
434 | 442 | } | |
435 | 443 | ||
436 | 444 | ||
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) | |
445 | + | func getD (xp) = { | |
446 | + | let xp0 = xp[0] | |
447 | + | let xp1 = xp[1] | |
448 | + | let s = (xp0 + xp1) | |
449 | + | if ((s == big0)) | |
450 | + | then big0 | |
451 | + | else { | |
452 | + | let a = parseIntValue(A) | |
453 | + | let ann = (a * 2) | |
454 | + | let p = fraction(xp0, xp1, big1) | |
455 | + | let xp0_xp1_n_n = fraction(p, big4, big1) | |
456 | + | let ann_s = fraction(toBigInt(ann), s, big1) | |
457 | + | let ann_1 = toBigInt((ann - 1)) | |
458 | + | func calcDNext (d) = { | |
459 | + | let dd = fraction(d, d, big1) | |
460 | + | let ddd = fraction(dd, d, big1) | |
461 | + | let dp = fraction(ddd, big1, xp0_xp1_n_n) | |
462 | + | fraction((ann_s + fraction(dp, big2, big1)), d, (fraction(ann_1, d, big1) + fraction(big3, dp, big1)), CEILING) | |
463 | + | } | |
464 | + | ||
465 | + | func calc (acc,i) = if (acc._2) | |
466 | + | then acc | |
467 | + | else { | |
468 | + | let d = acc._1 | |
469 | + | let dNext = calcDNext(d) | |
470 | + | let dDiffRaw = toInt((dNext - value(d))) | |
471 | + | let dDiff = if ((0 > dDiffRaw)) | |
472 | + | then -(dDiffRaw) | |
473 | + | else dDiffRaw | |
474 | + | if ((1 >= dDiff)) | |
475 | + | then $Tuple2(dNext, true) | |
476 | + | else $Tuple2(dNext, false) | |
477 | + | } | |
478 | + | ||
479 | + | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
480 | + | let $t02038520433 = { | |
481 | + | let $l = arr | |
482 | + | let $s = size($l) | |
483 | + | let $acc0 = $Tuple2(s, false) | |
484 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
485 | + | then $a | |
486 | + | else calc($a, $l[$i]) | |
487 | + | ||
488 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
489 | + | then $a | |
490 | + | else throw("List size exceeds 15") | |
491 | + | ||
492 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15) | |
493 | + | } | |
494 | + | let d = $t02038520433._1 | |
495 | + | let found = $t02038520433._2 | |
496 | + | if (found) | |
497 | + | then d | |
498 | + | else throw(("D calculation error, D = " + toString(d))) | |
499 | + | } | |
500 | + | } | |
501 | + | ||
502 | + | ||
503 | + | func getDOld (xp) = { | |
504 | + | let n = big2 | |
505 | + | let xp0 = xp[0] | |
506 | + | let xp1 = xp[1] | |
507 | + | let aPrecision = parseBigIntValue(Amult) | |
508 | + | let a = (parseBigIntValue(A) * aPrecision) | |
509 | + | let s = (xp0 + xp1) | |
510 | + | if ((s == big0)) | |
511 | + | then big0 | |
512 | + | else { | |
513 | + | let ann = (a * n) | |
514 | + | let xp0_xp1_n_n = (((xp0 * xp1) * n) * n) | |
515 | + | let ann_s_aPrecision = ((ann * s) / aPrecision) | |
516 | + | let ann_aPrecision = (ann - aPrecision) | |
517 | + | let n1 = (n + big1) | |
518 | + | func calc (acc,cur) = { | |
519 | + | let $t02106221082 = acc | |
520 | + | let d = $t02106221082._1 | |
521 | + | let found = $t02106221082._2 | |
522 | + | if ((found != unit)) | |
523 | + | then acc | |
524 | + | else { | |
525 | + | let dp = (((d * d) * d) / xp0_xp1_n_n) | |
526 | + | let dNext = (((ann_s_aPrecision + (dp * n)) * d) / (((ann_aPrecision * d) / aPrecision) + (n1 * dp))) | |
527 | + | let dDiff = absBigInt((dNext - value(d))) | |
528 | + | if ((big1 >= dDiff)) | |
529 | + | then $Tuple2(dNext, cur) | |
530 | + | else $Tuple2(dNext, unit) | |
531 | + | } | |
532 | + | } | |
533 | + | ||
534 | + | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
535 | + | let $t02150321550 = { | |
536 | + | let $l = arr | |
537 | + | let $s = size($l) | |
538 | + | let $acc0 = $Tuple2(s, unit) | |
539 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
540 | + | then $a | |
541 | + | else calc($a, $l[$i]) | |
542 | + | ||
543 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
544 | + | then $a | |
545 | + | else throw("List size exceeds 15") | |
546 | + | ||
547 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15) | |
548 | + | } | |
549 | + | let d = $t02150321550._1 | |
550 | + | let found = $t02150321550._2 | |
551 | + | if ((found != unit)) | |
552 | + | then d | |
553 | + | else throw(("D calculation error, D = " + toString(d))) | |
554 | + | } | |
555 | + | } | |
556 | + | ||
557 | + | ||
558 | + | func getYD (xp,i,D) = { | |
559 | + | let n = big2 | |
560 | + | let x = xp[if ((i == 0)) | |
561 | + | then 1 | |
562 | + | else 0] | |
563 | + | let aPrecision = parseBigIntValue(Amult) | |
564 | + | let a = (parseBigIntValue(A) * aPrecision) | |
565 | + | let s = x | |
566 | + | let ann = (a * n) | |
567 | + | let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n)) | |
568 | + | let b = ((s + ((D * aPrecision) / ann)) - D) | |
569 | + | func calc (acc,cur) = { | |
570 | + | let $t02205022070 = acc | |
571 | + | let y = $t02205022070._1 | |
572 | + | let found = $t02205022070._2 | |
573 | + | if ((found != unit)) | |
574 | + | then acc | |
575 | + | else { | |
576 | + | let yNext = (((y * y) + c) / ((big2 * y) + b)) | |
577 | + | let yDiff = absBigInt((yNext - value(y))) | |
578 | + | if ((big1 >= yDiff)) | |
579 | + | then $Tuple2(yNext, cur) | |
580 | + | else $Tuple2(yNext, unit) | |
581 | + | } | |
582 | + | } | |
583 | + | ||
584 | + | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
585 | + | let $t02237722424 = { | |
586 | + | let $l = arr | |
587 | + | let $s = size($l) | |
588 | + | let $acc0 = $Tuple2(D, unit) | |
589 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
590 | + | then $a | |
591 | + | else calc($a, $l[$i]) | |
592 | + | ||
593 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
594 | + | then $a | |
595 | + | else throw("List size exceeds 15") | |
596 | + | ||
597 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15) | |
598 | + | } | |
599 | + | let y = $t02237722424._1 | |
600 | + | let found = $t02237722424._2 | |
601 | + | if ((found != unit)) | |
602 | + | then y | |
603 | + | else throw(("Y calculation error, Y = " + toString(y))) | |
604 | + | } | |
605 | + | ||
606 | + | ||
607 | + | func calcDLp (amountBalance,priceBalance,lpEmission) = { | |
608 | + | let updatedDLp = fraction(getD([amountBalance, priceBalance]), scale18, lpEmission) | |
609 | + | if ((lpEmission == big0)) | |
610 | + | then big0 | |
611 | + | else updatedDLp | |
612 | + | } | |
613 | + | ||
614 | + | ||
615 | + | func calcCurrentDLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = { | |
616 | + | let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta) | |
617 | + | let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta) | |
618 | + | let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta) | |
619 | + | let currentDLp = calcDLp(amountAssetBalance, priceAssetBalance, lpAssetEmission) | |
620 | + | currentDLp | |
621 | + | } | |
622 | + | ||
623 | + | ||
624 | + | func refreshDLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
625 | + | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
626 | + | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
627 | + | let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta) | |
628 | + | let updatedDLp = calcDLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
629 | + | let actions = [IntegerEntry(keyDLpRefreshedHeight, height), StringEntry(keyDLp, toString(updatedDLp))] | |
630 | + | $Tuple2(actions, updatedDLp) | |
631 | + | } | |
632 | + | ||
633 | + | ||
634 | + | func validateUpdatedDLp (oldDLp,updatedDLp) = if ((updatedDLp >= oldDLp)) | |
635 | + | then true | |
636 | + | else throwErr("updated DLp lower than current DLp") | |
637 | + | ||
638 | + | ||
639 | + | func validateMatcherOrderAllowed (order) = { | |
640 | + | let amountAssetAmount = order.amount | |
641 | + | let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR) | |
642 | + | let $t02436324575 = if ((order.orderType == Buy)) | |
643 | + | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
644 | + | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
645 | + | let amountAssetBalanceDelta = $t02436324575._1 | |
646 | + | let priceAssetBalanceDelta = $t02436324575._2 | |
450 | 647 | if (if (if (igs()) | |
451 | 648 | then true | |
452 | - | else ( | |
649 | + | else (cfgPoolStatus == PoolMatcherDis)) | |
453 | 650 | then true | |
454 | - | else ( | |
651 | + | else (cfgPoolStatus == PoolShutdown)) | |
455 | 652 | 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 | - | } | |
653 | + | else if (if ((order.assetPair.amountAsset != cfgAmountAssetId)) | |
654 | + | then true | |
655 | + | else (order.assetPair.priceAsset != cfgPriceAssetId)) | |
656 | + | then throw("Wr assets") | |
657 | + | else { | |
658 | + | let dLp = parseBigIntValue(getStringValue(this, keyDLp)) | |
659 | + | let $t02490525005 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
660 | + | let unusedActions = $t02490525005._1 | |
661 | + | let dLpNew = $t02490525005._2 | |
662 | + | let isOrderValid = (dLpNew >= dLp) | |
663 | + | isOrderValid | |
664 | + | } | |
479 | 665 | } | |
480 | 666 | ||
481 | 667 | ||
482 | 668 | func cg (i) = if ((size(i.payments) != 1)) | |
483 | 669 | then throw("1 pmnt exp") | |
484 | 670 | else { | |
485 | 671 | let pmt = value(i.payments[0]) | |
486 | 672 | let pmtAssetId = value(pmt.assetId) | |
487 | 673 | let pmtAmt = pmt.amount | |
488 | 674 | let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
489 | 675 | let outAmAmt = r._1 | |
490 | 676 | let outPrAmt = r._2 | |
491 | 677 | let sts = parseIntValue(r._9) | |
492 | 678 | let state = r._10 | |
493 | 679 | if (if (igs()) | |
494 | 680 | then true | |
495 | 681 | else (sts == PoolShutdown)) | |
496 | 682 | then throw(("Admin blocked: " + toString(sts))) | |
497 | 683 | else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state) | |
498 | 684 | } | |
499 | 685 | ||
500 | 686 | ||
501 | 687 | func cp (caller,txId,amAsPmt,prAsPmt,slippage,emitLp,isOneAsset,validateSlippage,pmtAmt,pmtId) = { | |
502 | 688 | let r = epo(txId, slippage, value(amAsPmt).amount, value(amAsPmt).assetId, value(prAsPmt).amount, value(prAsPmt).assetId, caller, (txId == ""), emitLp, isOneAsset, validateSlippage, pmtAmt, pmtId) | |
503 | 689 | let sts = parseIntValue(r._8) | |
504 | 690 | if (if (if (igs()) | |
505 | 691 | then true | |
506 | 692 | else (sts == PoolPutDis)) | |
507 | 693 | then true | |
508 | 694 | else (sts == PoolShutdown)) | |
509 | 695 | then throw(("Blocked:" + toString(sts))) | |
510 | 696 | else r | |
511 | 697 | } | |
512 | 698 | ||
513 | 699 | ||
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 | - | ||
618 | 700 | func calcPutOneTkn (pmtAmtRaw,pmtAssetId,userAddress,txId,withTakeFee) = { | |
619 | 701 | let poolConfig = gpc() | |
620 | 702 | let amId = poolConfig[idxAmAsId] | |
621 | 703 | let prId = poolConfig[idxPrAsId] | |
622 | 704 | let lpId = poolConfig[idxLPAsId] | |
623 | 705 | let amtDcm = parseIntValue(poolConfig[idxAmtAsDcm]) | |
624 | 706 | let priceDcm = parseIntValue(poolConfig[idxPriceAsDcm]) | |
625 | 707 | let lpAssetEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity) | |
626 | 708 | let chechEmission = if ((lpAssetEmission > big0)) | |
627 | 709 | then true | |
628 | 710 | else throw("initial deposit requires all coins") | |
629 | 711 | if ((chechEmission == chechEmission)) | |
630 | 712 | then { | |
631 | 713 | let amBalance = getAccBalance(amId) | |
632 | 714 | let prBalance = getAccBalance(prId) | |
633 | - | let $ | |
715 | + | let $t02732227784 = if ((txId == "")) | |
634 | 716 | then $Tuple2(amBalance, prBalance) | |
635 | 717 | else if ((pmtAssetId == amId)) | |
636 | 718 | then if ((pmtAmtRaw > amBalance)) | |
637 | 719 | then throw("invalid payment amount") | |
638 | 720 | else $Tuple2((amBalance - pmtAmtRaw), prBalance) | |
639 | 721 | else if ((pmtAssetId == prId)) | |
640 | 722 | then if ((pmtAmtRaw > prBalance)) | |
641 | 723 | then throw("invalid payment amount") | |
642 | 724 | else $Tuple2(amBalance, (prBalance - pmtAmtRaw)) | |
643 | 725 | else throw("wrong pmtAssetId") | |
644 | - | let amBalanceOld = $ | |
645 | - | let prBalanceOld = $ | |
646 | - | let $ | |
726 | + | let amBalanceOld = $t02732227784._1 | |
727 | + | let prBalanceOld = $t02732227784._2 | |
728 | + | let $t02779027966 = if ((pmtAssetId == amId)) | |
647 | 729 | then $Tuple2(pmtAmtRaw, 0) | |
648 | 730 | else if ((pmtAssetId == prId)) | |
649 | 731 | then $Tuple2(0, pmtAmtRaw) | |
650 | 732 | else throw("invalid payment") | |
651 | - | let amAmountRaw = $ | |
652 | - | let prAmountRaw = $ | |
653 | - | let $ | |
654 | - | then $Tuple3(takeFee(amAmountRaw | |
733 | + | let amAmountRaw = $t02779027966._1 | |
734 | + | let prAmountRaw = $t02779027966._2 | |
735 | + | let $t02797028209 = if (withTakeFee) | |
736 | + | then $Tuple3(takeFee(amAmountRaw)._1, takeFee(prAmountRaw)._1, takeFee(pmtAmtRaw)._2) | |
655 | 737 | else $Tuple3(amAmountRaw, prAmountRaw, 0) | |
656 | - | let amAmount = $ | |
657 | - | let prAmount = $ | |
658 | - | let feeAmount = $ | |
738 | + | let amAmount = $t02797028209._1 | |
739 | + | let prAmount = $t02797028209._2 | |
740 | + | let feeAmount = $t02797028209._3 | |
659 | 741 | let amBalanceNew = (amBalanceOld + amAmount) | |
660 | 742 | let prBalanceNew = (prBalanceOld + prAmount) | |
661 | 743 | let D0 = getD([toBigInt(amBalanceOld), toBigInt(prBalanceOld)]) | |
662 | 744 | let D1 = getD([toBigInt(amBalanceNew), toBigInt(prBalanceNew)]) | |
663 | 745 | let checkD = if ((D1 > D0)) | |
664 | 746 | then true | |
665 | 747 | else throw() | |
666 | 748 | if ((checkD == checkD)) | |
667 | 749 | then { | |
668 | - | let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0) | |
750 | + | let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0, FLOOR) | |
669 | 751 | let curPrice = f1(cpbi(t1(prBalanceNew, priceDcm), t1(amBalanceNew, amtDcm)), scale8) | |
670 | 752 | 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))] | |
671 | 753 | let poolProportion = fraction(prBalanceOld, scale8, amBalanceOld) | |
672 | 754 | let amountAssetPart = fraction(pmtAmtRaw, scale8, (poolProportion + scale8)) | |
673 | 755 | let priceAssetPart = (pmtAmtRaw - amountAssetPart) | |
674 | 756 | let lpAmtBoth = fraction(lpAssetEmission, toBigInt(priceAssetPart), toBigInt(prBalanceOld)) | |
675 | 757 | let bonus = toInt(fraction((lpAmount - lpAmtBoth), scale8BigInt, lpAmtBoth)) | |
676 | 758 | $Tuple4(toInt(lpAmount), commonState, feeAmount, bonus) | |
677 | 759 | } | |
678 | 760 | else throw("Strict value is not equal to itself.") | |
679 | 761 | } | |
680 | 762 | else throw("Strict value is not equal to itself.") | |
681 | 763 | } | |
682 | 764 | ||
683 | 765 | ||
684 | 766 | func getOneTknV2Internal (outAssetId,minOutAmount,payments,caller,originCaller,transactionId) = { | |
685 | 767 | let poolConfig = gpc() | |
686 | 768 | let lpId = poolConfig[idxLPAsId] | |
687 | 769 | let amId = poolConfig[idxAmAsId] | |
688 | 770 | let prId = poolConfig[idxPrAsId] | |
689 | 771 | let amDecimals = parseIntValue(poolConfig[idxAmtAsDcm]) | |
690 | 772 | let prDecimals = parseIntValue(poolConfig[idxPriceAsDcm]) | |
691 | 773 | let poolStatus = poolConfig[idxPoolSt] | |
692 | 774 | let userAddress = if ((caller == restContract)) | |
693 | 775 | then originCaller | |
694 | 776 | else caller | |
695 | 777 | let pmt = value(payments[0]) | |
696 | 778 | let pmtAssetId = value(pmt.assetId) | |
697 | 779 | 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)) | |
780 | + | let currentDLp = calcCurrentDLp(big0, big0, big0) | |
781 | + | if ((currentDLp == currentDLp)) | |
782 | + | then { | |
783 | + | let txId58 = toBase58String(transactionId) | |
784 | + | if ((lpId != toBase58String(pmtAssetId))) | |
785 | + | then throw("Wrong LP") | |
786 | + | else { | |
787 | + | let amBalance = getAccBalance(amId) | |
788 | + | let prBalance = getAccBalance(prId) | |
789 | + | let $t03027430385 = { | |
790 | + | let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil) | |
791 | + | if ($isInstanceOf(@, "(Int, Int)")) | |
792 | + | then @ | |
793 | + | else throw(($getType(@) + " couldn't be cast to (Int, Int)")) | |
794 | + | } | |
795 | + | if (($t03027430385 == $t03027430385)) | |
738 | 796 | then { | |
739 | - | let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
740 | - | if ((burn == burn)) | |
741 | - | then $Tuple2(state, totalAmount) | |
797 | + | let feeAmount = $t03027430385._2 | |
798 | + | let totalGet = $t03027430385._1 | |
799 | + | let totalAmount = if (if ((minOutAmount > 0)) | |
800 | + | then (minOutAmount > totalGet) | |
801 | + | else false) | |
802 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
803 | + | else totalGet | |
804 | + | let $t03057530882 = if ((outAssetId == amId)) | |
805 | + | then $Tuple4(totalAmount, 0, ((amBalance - totalAmount) - feeAmount), prBalance) | |
806 | + | else if ((outAssetId == prId)) | |
807 | + | then $Tuple4(0, totalAmount, amBalance, ((prBalance - totalAmount) - feeAmount)) | |
808 | + | else throw("invalid out asset id") | |
809 | + | let outAm = $t03057530882._1 | |
810 | + | let outPr = $t03057530882._2 | |
811 | + | let amBalanceNew = $t03057530882._3 | |
812 | + | let prBalanceNew = $t03057530882._4 | |
813 | + | let curPrX18 = cpbi(t1(prBalanceNew, prDecimals), t1(amBalanceNew, amDecimals)) | |
814 | + | let curPr = f1(curPrX18, scale8) | |
815 | + | let outAssetIdOrWaves = if ((outAssetId == "WAVES")) | |
816 | + | then unit | |
817 | + | else fromBase58String(outAssetId) | |
818 | + | let sendFeeToMatcher = if ((feeAmount > 0)) | |
819 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)] | |
820 | + | else nil | |
821 | + | let state = ([ScriptTransfer(userAddress, totalAmount, outAssetIdOrWaves), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, pmtAmt, curPr, height, lastBlock.timestamp)), IntegerEntry(pl(), curPr), IntegerEntry(ph(height, lastBlock.timestamp), curPr)] ++ sendFeeToMatcher) | |
822 | + | if ((state == state)) | |
823 | + | then { | |
824 | + | let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
825 | + | if ((burn == burn)) | |
826 | + | then { | |
827 | + | let $t03166732017 = { | |
828 | + | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
829 | + | then 0 | |
830 | + | else feeAmount | |
831 | + | let outInAmountAsset = if ((parseAssetId(outAssetId) == cfgAmountAssetId)) | |
832 | + | then true | |
833 | + | else false | |
834 | + | if (outInAmountAsset) | |
835 | + | then $Tuple2(-((totalGet + feeAmountForCalc)), 0) | |
836 | + | else $Tuple2(0, -((totalGet + feeAmountForCalc))) | |
837 | + | } | |
838 | + | let amountAssetBalanceDelta = $t03166732017._1 | |
839 | + | let priceAssetBalanceDelta = $t03166732017._2 | |
840 | + | let $t03202032128 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
841 | + | let refreshDLpActions = $t03202032128._1 | |
842 | + | let updatedDLp = $t03202032128._2 | |
843 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
844 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
845 | + | then $Tuple2((state ++ refreshDLpActions), totalAmount) | |
846 | + | else throw("Strict value is not equal to itself.") | |
847 | + | } | |
848 | + | else throw("Strict value is not equal to itself.") | |
849 | + | } | |
742 | 850 | else throw("Strict value is not equal to itself.") | |
743 | 851 | } | |
744 | 852 | else throw("Strict value is not equal to itself.") | |
745 | 853 | } | |
746 | - | else throw("Strict value is not equal to itself.") | |
747 | 854 | } | |
855 | + | else throw("Strict value is not equal to itself.") | |
748 | 856 | } | |
749 | 857 | ||
750 | 858 | ||
751 | 859 | func m () = match getString(mpk()) { | |
752 | 860 | case s: String => | |
753 | 861 | fromBase58String(s) | |
754 | 862 | case _: Unit => | |
755 | 863 | unit | |
756 | 864 | case _ => | |
757 | 865 | throw("Match error") | |
758 | 866 | } | |
759 | 867 | ||
760 | 868 | ||
761 | 869 | func pm () = match getString(pmpk()) { | |
762 | 870 | case s: String => | |
763 | 871 | fromBase58String(s) | |
764 | 872 | case _: Unit => | |
765 | 873 | unit | |
766 | 874 | case _ => | |
767 | 875 | throw("Match error") | |
768 | 876 | } | |
769 | 877 | ||
770 | 878 | ||
771 | 879 | let pd = throw("Permission denied") | |
772 | 880 | ||
773 | 881 | func isManager (i) = match m() { | |
774 | 882 | case pk: ByteVector => | |
775 | 883 | (i.callerPublicKey == pk) | |
776 | 884 | case _: Unit => | |
777 | 885 | (i.caller == this) | |
778 | 886 | case _ => | |
779 | 887 | throw("Match error") | |
780 | 888 | } | |
781 | 889 | ||
782 | 890 | ||
783 | 891 | func mm (i) = match m() { | |
784 | 892 | case pk: ByteVector => | |
785 | 893 | if ((i.callerPublicKey == pk)) | |
786 | 894 | then true | |
787 | 895 | else pd | |
788 | 896 | case _: Unit => | |
789 | 897 | if ((i.caller == this)) | |
790 | 898 | then true | |
791 | 899 | else pd | |
792 | 900 | case _ => | |
793 | 901 | throw("Match error") | |
794 | 902 | } | |
795 | 903 | ||
796 | 904 | ||
797 | 905 | @Callable(i) | |
798 | 906 | func constructor (fc) = { | |
799 | 907 | let c = mm(i) | |
800 | 908 | if ((c == c)) | |
801 | 909 | then [StringEntry(fc(), fc)] | |
802 | 910 | else throw("Strict value is not equal to itself.") | |
803 | 911 | } | |
804 | 912 | ||
805 | 913 | ||
806 | 914 | ||
807 | 915 | @Callable(i) | |
808 | 916 | func setManager (pendingManagerPublicKey) = { | |
809 | 917 | let c = mm(i) | |
810 | 918 | if ((c == c)) | |
811 | 919 | then { | |
812 | 920 | let cm = fromBase58String(pendingManagerPublicKey) | |
813 | 921 | if ((cm == cm)) | |
814 | 922 | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
815 | 923 | else throw("Strict value is not equal to itself.") | |
816 | 924 | } | |
817 | 925 | else throw("Strict value is not equal to itself.") | |
818 | 926 | } | |
819 | 927 | ||
820 | 928 | ||
821 | 929 | ||
822 | 930 | @Callable(i) | |
823 | 931 | func confirmManager () = { | |
824 | 932 | let p = pm() | |
825 | 933 | let hpm = if (isDefined(p)) | |
826 | 934 | then true | |
827 | 935 | else throw("No pending manager") | |
828 | 936 | if ((hpm == hpm)) | |
829 | 937 | then { | |
830 | 938 | let cpm = if ((i.callerPublicKey == value(p))) | |
831 | 939 | then true | |
832 | 940 | else throw("You are not pending manager") | |
833 | 941 | if ((cpm == cpm)) | |
834 | 942 | then [StringEntry(mpk(), toBase58String(value(p))), DeleteEntry(pmpk())] | |
835 | 943 | else throw("Strict value is not equal to itself.") | |
836 | 944 | } | |
837 | 945 | else throw("Strict value is not equal to itself.") | |
838 | 946 | } | |
839 | 947 | ||
840 | 948 | ||
841 | 949 | ||
842 | 950 | @Callable(i) | |
843 | 951 | func put (slip,autoStake) = { | |
844 | 952 | let factCfg = gfc() | |
845 | 953 | let stakingCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactStakCntr]), "Wr st addr") | |
846 | 954 | let slipCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactSlippCntr]), "Wr sl addr") | |
847 | 955 | if ((0 > slip)) | |
848 | 956 | then throw("Wrong slippage") | |
849 | 957 | else if ((size(i.payments) != 2)) | |
850 | 958 | then throw("2 pmnts expd") | |
851 | 959 | 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)) | |
960 | + | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
961 | + | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
962 | + | let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
963 | + | if ((currentDLp == currentDLp)) | |
862 | 964 | 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)) | |
965 | + | 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, "") | |
966 | + | let emitLpAmt = e._2 | |
967 | + | let lpAssetId = e._7 | |
968 | + | let state = e._9 | |
969 | + | let amDiff = e._10 | |
970 | + | let prDiff = e._11 | |
971 | + | let amId = e._12 | |
972 | + | let prId = e._13 | |
973 | + | let r = invoke(fca, "emit", [emitLpAmt], nil) | |
974 | + | if ((r == r)) | |
870 | 975 | then { | |
871 | - | let sa = if ((amDiff > 0)) | |
872 | - | then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)]) | |
873 | - | else nil | |
874 | - | if ((sa == sa)) | |
976 | + | let el = match r { | |
977 | + | case legacy: Address => | |
978 | + | invoke(legacy, "emit", [emitLpAmt], nil) | |
979 | + | case _ => | |
980 | + | unit | |
981 | + | } | |
982 | + | if ((el == el)) | |
875 | 983 | then { | |
876 | - | let | |
877 | - | then invoke(slipCntr, "put", nil, [AttachedPayment( | |
984 | + | let sa = if ((amDiff > 0)) | |
985 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)]) | |
878 | 986 | else nil | |
879 | - | if (( | |
987 | + | if ((sa == sa)) | |
880 | 988 | then { | |
881 | - | let lpTrnsfr = if (autoStake) | |
989 | + | let sp = if ((prDiff > 0)) | |
990 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)]) | |
991 | + | else nil | |
992 | + | if ((sp == sp)) | |
882 | 993 | then { | |
883 | - | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
884 | - | if ((ss == ss)) | |
885 | - | then nil | |
994 | + | let lpTrnsfr = if (autoStake) | |
995 | + | then { | |
996 | + | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
997 | + | if ((ss == ss)) | |
998 | + | then nil | |
999 | + | else throw("Strict value is not equal to itself.") | |
1000 | + | } | |
1001 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
1002 | + | let $t03598436049 = refreshDLpInternal(0, 0, 0) | |
1003 | + | let refreshDLpActions = $t03598436049._1 | |
1004 | + | let updatedDLp = $t03598436049._2 | |
1005 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1006 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1007 | + | then ((state ++ lpTrnsfr) ++ refreshDLpActions) | |
886 | 1008 | else throw("Strict value is not equal to itself.") | |
887 | 1009 | } | |
888 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
889 | - | (state ++ lpTrnsfr) | |
1010 | + | else throw("Strict value is not equal to itself.") | |
890 | 1011 | } | |
891 | 1012 | else throw("Strict value is not equal to itself.") | |
892 | 1013 | } | |
893 | 1014 | else throw("Strict value is not equal to itself.") | |
894 | 1015 | } | |
895 | 1016 | else throw("Strict value is not equal to itself.") | |
896 | 1017 | } | |
897 | 1018 | else throw("Strict value is not equal to itself.") | |
898 | 1019 | } | |
899 | 1020 | } | |
900 | 1021 | ||
901 | 1022 | ||
902 | 1023 | ||
903 | 1024 | @Callable(i) | |
904 | 1025 | func putOneTknV2 (minOutAmount,autoStake) = { | |
905 | 1026 | let isPoolOneTokenOperationsDisabled = { | |
906 | 1027 | let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
907 | 1028 | if ($isInstanceOf(@, "Boolean")) | |
908 | 1029 | then @ | |
909 | 1030 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
910 | 1031 | } | |
911 | 1032 | let isPutDisabled = if (if (if (igs()) | |
912 | 1033 | then true | |
913 | 1034 | else (cfgPoolStatus == PoolPutDis)) | |
914 | 1035 | then true | |
915 | 1036 | else (cfgPoolStatus == PoolShutdown)) | |
916 | 1037 | then true | |
917 | 1038 | else isPoolOneTokenOperationsDisabled | |
918 | 1039 | let checks = [if (if (!(isPutDisabled)) | |
919 | 1040 | then true | |
920 | 1041 | else isManager(i)) | |
921 | 1042 | then true | |
922 | 1043 | else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1)) | |
923 | 1044 | then true | |
924 | 1045 | else throwErr("exactly 1 payment are expected")] | |
925 | 1046 | if ((checks == checks)) | |
926 | 1047 | then { | |
927 | 1048 | let poolConfig = gpc() | |
928 | 1049 | let amId = poolConfig[idxAmAsId] | |
929 | 1050 | let prId = poolConfig[idxPrAsId] | |
930 | 1051 | let lpId = fromBase58String(poolConfig[idxLPAsId]) | |
931 | 1052 | let amDecimals = parseIntValue(poolConfig[idxAmtAsDcm]) | |
932 | 1053 | let prDecimals = parseIntValue(poolConfig[idxPriceAsDcm]) | |
933 | 1054 | let userAddress = if ((i.caller == this)) | |
934 | 1055 | then i.originCaller | |
935 | 1056 | else i.caller | |
936 | 1057 | let pmt = value(i.payments[0]) | |
937 | 1058 | let pmtAssetId = toBase58String(value(pmt.assetId)) | |
938 | 1059 | let pmtAmt = pmt.amount | |
939 | - | let $ | |
940 | - | if (($ | |
1060 | + | let $t03718637344 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true) | |
1061 | + | if (($t03718637344 == $t03718637344)) | |
941 | 1062 | then { | |
942 | - | let feeAmount = $ | |
943 | - | let state = $ | |
944 | - | let estimLP = $ | |
1063 | + | let feeAmount = $t03718637344._3 | |
1064 | + | let state = $t03718637344._2 | |
1065 | + | let estimLP = $t03718637344._1 | |
945 | 1066 | let emitLpAmt = if (if ((minOutAmount > 0)) | |
946 | 1067 | then (minOutAmount > estimLP) | |
947 | 1068 | else false) | |
948 | 1069 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
949 | 1070 | else estimLP | |
950 | 1071 | let e = invoke(fca, "emit", [emitLpAmt], nil) | |
951 | 1072 | if ((e == e)) | |
952 | 1073 | then { | |
953 | 1074 | let el = match e { | |
954 | 1075 | case legacy: Address => | |
955 | 1076 | invoke(legacy, "emit", [emitLpAmt], nil) | |
956 | 1077 | case _ => | |
957 | 1078 | unit | |
958 | 1079 | } | |
959 | 1080 | if ((el == el)) | |
960 | 1081 | then { | |
961 | 1082 | let lpTrnsfr = if (autoStake) | |
962 | 1083 | then { | |
963 | 1084 | let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)]) | |
964 | 1085 | if ((ss == ss)) | |
965 | 1086 | then nil | |
966 | 1087 | else throw("Strict value is not equal to itself.") | |
967 | 1088 | } | |
968 | 1089 | else [ScriptTransfer(i.caller, emitLpAmt, lpId)] | |
969 | 1090 | let sendFeeToMatcher = if ((feeAmount > 0)) | |
970 | 1091 | then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))] | |
971 | 1092 | else nil | |
972 | - | $Tuple2(((state ++ lpTrnsfr) ++ sendFeeToMatcher), emitLpAmt) | |
1093 | + | let $t03815938508 = if ((this == feeCollectorAddress)) | |
1094 | + | then $Tuple2(0, 0) | |
1095 | + | else { | |
1096 | + | let paymentInAmountAsset = if ((pmt.assetId == cfgAmountAssetId)) | |
1097 | + | then true | |
1098 | + | else false | |
1099 | + | if (paymentInAmountAsset) | |
1100 | + | then $Tuple2(-(feeAmount), 0) | |
1101 | + | else $Tuple2(0, -(feeAmount)) | |
1102 | + | } | |
1103 | + | let amountAssetBalanceDelta = $t03815938508._1 | |
1104 | + | let priceAssetBalanceDelta = $t03815938508._2 | |
1105 | + | let $t03851138619 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1106 | + | let refreshDLpActions = $t03851138619._1 | |
1107 | + | let updatedDLp = $t03851138619._2 | |
1108 | + | $Tuple2((((state ++ lpTrnsfr) ++ sendFeeToMatcher) ++ refreshDLpActions), emitLpAmt) | |
973 | 1109 | } | |
974 | 1110 | else throw("Strict value is not equal to itself.") | |
975 | 1111 | } | |
976 | 1112 | else throw("Strict value is not equal to itself.") | |
977 | 1113 | } | |
978 | 1114 | else throw("Strict value is not equal to itself.") | |
979 | 1115 | } | |
980 | 1116 | else throw("Strict value is not equal to itself.") | |
981 | 1117 | } | |
982 | 1118 | ||
983 | 1119 | ||
984 | 1120 | ||
985 | 1121 | @Callable(i) | |
986 | 1122 | func putForFree (maxSlpg) = if ((0 > maxSlpg)) | |
987 | 1123 | then throw("Wrong slpg") | |
988 | 1124 | else if ((size(i.payments) != 2)) | |
989 | 1125 | then throw("2 pmnts expd") | |
990 | 1126 | else { | |
991 | 1127 | 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 | |
1128 | + | let state = estPut._9 | |
1129 | + | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
1130 | + | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
1131 | + | let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
1132 | + | if ((currentDLp == currentDLp)) | |
1133 | + | then { | |
1134 | + | let $t03957839643 = refreshDLpInternal(0, 0, 0) | |
1135 | + | let refreshDLpActions = $t03957839643._1 | |
1136 | + | let updatedDLp = $t03957839643._2 | |
1137 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1138 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1139 | + | then (state ++ refreshDLpActions) | |
1140 | + | else throw("Strict value is not equal to itself.") | |
1141 | + | } | |
1142 | + | else throw("Strict value is not equal to itself.") | |
993 | 1143 | } | |
994 | 1144 | ||
995 | 1145 | ||
996 | 1146 | ||
997 | 1147 | @Callable(i) | |
998 | 1148 | func get () = { | |
999 | 1149 | let r = cg(i) | |
1000 | 1150 | let outAmtAmt = r._1 | |
1001 | 1151 | let outPrAmt = r._2 | |
1002 | 1152 | let pmtAmt = r._3 | |
1003 | 1153 | let pmtAssetId = r._4 | |
1004 | 1154 | let state = r._5 | |
1005 | 1155 | let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1006 | 1156 | if ((b == b)) | |
1007 | - | then state | |
1157 | + | then { | |
1158 | + | let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt)) | |
1159 | + | let $t04043240514 = refreshDLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1160 | + | let refreshDLpActions = $t04043240514._1 | |
1161 | + | let updatedDLp = $t04043240514._2 | |
1162 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1163 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1164 | + | then (state ++ refreshDLpActions) | |
1165 | + | else throw("Strict value is not equal to itself.") | |
1166 | + | } | |
1008 | 1167 | else throw("Strict value is not equal to itself.") | |
1009 | 1168 | } | |
1010 | 1169 | ||
1011 | 1170 | ||
1012 | 1171 | ||
1013 | 1172 | @Callable(i) | |
1014 | 1173 | func getOneTknV2 (outAssetId,minOutAmount) = { | |
1015 | 1174 | let isPoolOneTokenOperationsDisabled = { | |
1016 | 1175 | let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
1017 | 1176 | if ($isInstanceOf(@, "Boolean")) | |
1018 | 1177 | then @ | |
1019 | 1178 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
1020 | 1179 | } | |
1021 | 1180 | let isGetDisabled = if (if (igs()) | |
1022 | 1181 | then true | |
1023 | 1182 | else (cfgPoolStatus == PoolShutdown)) | |
1024 | 1183 | then true | |
1025 | 1184 | else isPoolOneTokenOperationsDisabled | |
1026 | 1185 | let checks = [if (if (!(isGetDisabled)) | |
1027 | 1186 | then true | |
1028 | 1187 | else isManager(i)) | |
1029 | 1188 | then true | |
1030 | 1189 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1)) | |
1031 | 1190 | then true | |
1032 | 1191 | else throwErr("exactly 1 payment are expected")] | |
1033 | 1192 | if ((checks == checks)) | |
1034 | 1193 | then { | |
1035 | - | let $ | |
1036 | - | let state = $ | |
1037 | - | let totalAmount = $ | |
1194 | + | let $t04113241287 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId) | |
1195 | + | let state = $t04113241287._1 | |
1196 | + | let totalAmount = $t04113241287._2 | |
1038 | 1197 | $Tuple2(state, totalAmount) | |
1198 | + | } | |
1199 | + | else throw("Strict value is not equal to itself.") | |
1200 | + | } | |
1201 | + | ||
1202 | + | ||
1203 | + | ||
1204 | + | @Callable(i) | |
1205 | + | func refreshDLp () = { | |
1206 | + | let lastRefreshedBlockHeight = valueOrElse(getInteger(keyDLpRefreshedHeight), 0) | |
1207 | + | let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= dLpRefreshDelay)) | |
1208 | + | then unit | |
1209 | + | else throwErr(makeString([toString(dLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1210 | + | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1211 | + | then { | |
1212 | + | let dLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyDLp), "0")), fmtErr("invalid dLp")) | |
1213 | + | let $t04181141875 = refreshDLpInternal(0, 0, 0) | |
1214 | + | let dLpUpdateActions = $t04181141875._1 | |
1215 | + | let updatedDLp = $t04181141875._2 | |
1216 | + | let actions = if ((dLp != updatedDLp)) | |
1217 | + | then dLpUpdateActions | |
1218 | + | else throwErr("nothing to refresh") | |
1219 | + | $Tuple2(actions, toString(updatedDLp)) | |
1039 | 1220 | } | |
1040 | 1221 | else throw("Strict value is not equal to itself.") | |
1041 | 1222 | } | |
1042 | 1223 | ||
1043 | 1224 | ||
1044 | 1225 | ||
1045 | 1226 | @Callable(i) | |
1046 | 1227 | func getOneTknV2READONLY (outAssetId,lpAssetAmount) = { | |
1047 | 1228 | let poolConfig = gpc() | |
1048 | 1229 | let amId = poolConfig[idxAmAsId] | |
1049 | 1230 | let prId = poolConfig[idxPrAsId] | |
1050 | 1231 | let lpId = poolConfig[idxLPAsId] | |
1051 | 1232 | let xp = [toBigInt(getAccBalance(amId)), toBigInt(getAccBalance(prId))] | |
1052 | 1233 | let lpEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity) | |
1053 | 1234 | let D0 = getD(xp) | |
1054 | 1235 | let D1 = (D0 - fraction(toBigInt(lpAssetAmount), D0, lpEmission)) | |
1055 | 1236 | let index = if ((outAssetId == amId)) | |
1056 | 1237 | then 0 | |
1057 | 1238 | else if ((outAssetId == prId)) | |
1058 | 1239 | then 1 | |
1059 | 1240 | else throw("invalid out asset id") | |
1060 | 1241 | let newY = getYD(xp, index, D1) | |
1061 | 1242 | let dy = (xp[index] - newY) | |
1062 | 1243 | let totalGetRaw = max([0, toInt((dy - big1))]) | |
1063 | - | let $ | |
1064 | - | let totalGet = $ | |
1065 | - | let feeAmount = $ | |
1244 | + | let $t04277542824 = takeFee(totalGetRaw) | |
1245 | + | let totalGet = $t04277542824._1 | |
1246 | + | let feeAmount = $t04277542824._2 | |
1066 | 1247 | $Tuple2(nil, $Tuple2(totalGet, feeAmount)) | |
1067 | 1248 | } | |
1068 | 1249 | ||
1069 | 1250 | ||
1070 | 1251 | ||
1071 | 1252 | @Callable(i) | |
1072 | 1253 | func getOneTknV2WithBonusREADONLY (outAssetId,lpAssetAmount) = { | |
1073 | 1254 | let poolConfig = gpc() | |
1074 | 1255 | let amId = poolConfig[idxAmAsId] | |
1075 | 1256 | let prId = poolConfig[idxPrAsId] | |
1076 | 1257 | let lpId = poolConfig[idxLPAsId] | |
1077 | 1258 | let amBalance = getAccBalance(amId) | |
1078 | 1259 | let prBalance = getAccBalance(prId) | |
1079 | - | let $ | |
1260 | + | let $t04316943284 = { | |
1080 | 1261 | let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, lpAssetAmount], nil) | |
1081 | 1262 | if ($isInstanceOf(@, "(Int, Int)")) | |
1082 | 1263 | then @ | |
1083 | 1264 | else throw(($getType(@) + " couldn't be cast to (Int, Int)")) | |
1084 | 1265 | } | |
1085 | - | let totalGet = $ | |
1086 | - | let feeAmount = $ | |
1266 | + | let totalGet = $t04316943284._1 | |
1267 | + | let feeAmount = $t04316943284._2 | |
1087 | 1268 | let r = ego("", lpId, lpAssetAmount, this) | |
1088 | 1269 | let outAmAmt = r._1 | |
1089 | 1270 | let outPrAmt = r._2 | |
1090 | 1271 | let sumOfGetAssets = (outAmAmt + outPrAmt) | |
1091 | 1272 | let bonus = if ((sumOfGetAssets == 0)) | |
1092 | 1273 | then if ((totalGet == 0)) | |
1093 | 1274 | then 0 | |
1094 | 1275 | else throw("bonus calculation error") | |
1095 | 1276 | else fraction((totalGet - sumOfGetAssets), scale8, sumOfGetAssets) | |
1096 | 1277 | $Tuple2(nil, $Tuple3(totalGet, feeAmount, bonus)) | |
1097 | 1278 | } | |
1098 | 1279 | ||
1099 | 1280 | ||
1100 | 1281 | ||
1101 | 1282 | @Callable(i) | |
1102 | 1283 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
1103 | 1284 | let r = cg(i) | |
1104 | 1285 | let outAmAmt = r._1 | |
1105 | 1286 | let outPrAmt = r._2 | |
1106 | 1287 | let pmtAmt = r._3 | |
1107 | 1288 | let pmtAssetId = r._4 | |
1108 | 1289 | let state = r._5 | |
1109 | 1290 | if ((noLessThenAmtAsset > outAmAmt)) | |
1110 | 1291 | then throw(((("Failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
1111 | 1292 | else if ((noLessThenPriceAsset > outPrAmt)) | |
1112 | 1293 | then throw(((("Failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
1113 | 1294 | else { | |
1295 | + | let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt)) | |
1114 | 1296 | let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1115 | 1297 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1116 | - | then state | |
1298 | + | then { | |
1299 | + | let $t04445244533 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1300 | + | let refreshDLpActions = $t04445244533._1 | |
1301 | + | let updatedDLp = $t04445244533._2 | |
1302 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1303 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1304 | + | then (state ++ refreshDLpActions) | |
1305 | + | else throw("Strict value is not equal to itself.") | |
1306 | + | } | |
1117 | 1307 | else throw("Strict value is not equal to itself.") | |
1118 | 1308 | } | |
1119 | 1309 | } | |
1120 | 1310 | ||
1121 | 1311 | ||
1122 | 1312 | ||
1123 | 1313 | @Callable(i) | |
1124 | 1314 | func unstakeAndGet (amount) = { | |
1125 | 1315 | let checkPayments = if ((size(i.payments) != 0)) | |
1126 | 1316 | then throw("No pmnts expd") | |
1127 | 1317 | else true | |
1128 | 1318 | if ((checkPayments == checkPayments)) | |
1129 | 1319 | then { | |
1130 | 1320 | let cfg = gpc() | |
1131 | 1321 | let factoryCfg = gfc() | |
1132 | 1322 | let lpAssetId = fromBase58String(cfg[idxLPAsId]) | |
1133 | 1323 | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr") | |
1324 | + | let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1134 | 1325 | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1135 | 1326 | if ((unstakeInv == unstakeInv)) | |
1136 | 1327 | then { | |
1137 | 1328 | let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1329 | + | let outAmAmt = r._1 | |
1330 | + | let outPrAmt = r._2 | |
1138 | 1331 | let sts = parseIntValue(r._9) | |
1139 | 1332 | let state = r._10 | |
1140 | 1333 | let v = if (if (igs()) | |
1141 | 1334 | then true | |
1142 | 1335 | else (sts == PoolShutdown)) | |
1143 | 1336 | then throw(("Blocked: " + toString(sts))) | |
1144 | 1337 | else true | |
1145 | 1338 | if ((v == v)) | |
1146 | 1339 | then { | |
1147 | 1340 | let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1148 | 1341 | if ((burnA == burnA)) | |
1149 | - | then state | |
1342 | + | then { | |
1343 | + | let $t04559645677 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1344 | + | let refreshDLpActions = $t04559645677._1 | |
1345 | + | let updatedDLp = $t04559645677._2 | |
1346 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1347 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1348 | + | then (state ++ refreshDLpActions) | |
1349 | + | else throw("Strict value is not equal to itself.") | |
1350 | + | } | |
1150 | 1351 | else throw("Strict value is not equal to itself.") | |
1151 | 1352 | } | |
1152 | 1353 | else throw("Strict value is not equal to itself.") | |
1153 | 1354 | } | |
1154 | 1355 | else throw("Strict value is not equal to itself.") | |
1155 | 1356 | } | |
1156 | 1357 | else throw("Strict value is not equal to itself.") | |
1157 | 1358 | } | |
1158 | 1359 | ||
1159 | 1360 | ||
1160 | 1361 | ||
1161 | 1362 | @Callable(i) | |
1162 | 1363 | func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = { | |
1163 | 1364 | let isGetDisabled = if (igs()) | |
1164 | 1365 | then true | |
1165 | 1366 | else (cfgPoolStatus == PoolShutdown) | |
1166 | 1367 | let checks = [if (!(isGetDisabled)) | |
1167 | 1368 | then true | |
1168 | 1369 | else throw("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1169 | 1370 | then true | |
1170 | 1371 | else throw("no payments are expected")] | |
1171 | 1372 | if ((checks == checks)) | |
1172 | 1373 | then { | |
1374 | + | let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1173 | 1375 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1174 | 1376 | if ((unstakeInv == unstakeInv)) | |
1175 | 1377 | then { | |
1176 | 1378 | let res = ego(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1177 | 1379 | let outAmAmt = res._1 | |
1178 | 1380 | let outPrAmt = res._2 | |
1179 | 1381 | let state = res._10 | |
1180 | 1382 | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1181 | 1383 | then true | |
1182 | 1384 | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1183 | 1385 | then true | |
1184 | 1386 | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1185 | 1387 | if ((checkAmounts == checkAmounts)) | |
1186 | 1388 | then { | |
1187 | 1389 | let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1188 | 1390 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1189 | - | then state | |
1391 | + | then { | |
1392 | + | let $t04692547006 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1393 | + | let refreshDLpActions = $t04692547006._1 | |
1394 | + | let updatedDLp = $t04692547006._2 | |
1395 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1396 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1397 | + | then (state ++ refreshDLpActions) | |
1398 | + | else throw("Strict value is not equal to itself.") | |
1399 | + | } | |
1190 | 1400 | else throw("Strict value is not equal to itself.") | |
1191 | 1401 | } | |
1192 | 1402 | else throw("Strict value is not equal to itself.") | |
1193 | 1403 | } | |
1194 | 1404 | else throw("Strict value is not equal to itself.") | |
1195 | 1405 | } | |
1196 | 1406 | else throw("Strict value is not equal to itself.") | |
1197 | 1407 | } | |
1198 | 1408 | ||
1199 | 1409 | ||
1200 | 1410 | ||
1201 | 1411 | @Callable(i) | |
1202 | 1412 | func unstakeAndGetOneTknV2 (unstakeAmount,outAssetId,minOutAmount) = { | |
1203 | 1413 | let isPoolOneTokenOperationsDisabled = { | |
1204 | 1414 | let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
1205 | 1415 | if ($isInstanceOf(@, "Boolean")) | |
1206 | 1416 | then @ | |
1207 | 1417 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
1208 | 1418 | } | |
1209 | 1419 | let isGetDisabled = if (if (igs()) | |
1210 | 1420 | then true | |
1211 | 1421 | else (cfgPoolStatus == PoolShutdown)) | |
1212 | 1422 | then true | |
1213 | 1423 | else isPoolOneTokenOperationsDisabled | |
1214 | 1424 | let checks = [if (if (!(isGetDisabled)) | |
1215 | 1425 | then true | |
1216 | 1426 | else isManager(i)) | |
1217 | 1427 | then true | |
1218 | 1428 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1219 | 1429 | then true | |
1220 | 1430 | else throwErr("no payments are expected")] | |
1221 | 1431 | if ((checks == checks)) | |
1222 | 1432 | then { | |
1223 | 1433 | let cfg = gpc() | |
1224 | 1434 | let factoryCfg = gfc() | |
1225 | 1435 | let lpAssetId = fromBase58String(cfg[idxLPAsId]) | |
1226 | 1436 | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr") | |
1227 | 1437 | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), unstakeAmount], nil) | |
1228 | 1438 | if ((unstakeInv == unstakeInv)) | |
1229 | 1439 | then { | |
1230 | - | let $ | |
1231 | - | let state = $ | |
1232 | - | let totalAmount = $ | |
1440 | + | let $t04794048128 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId) | |
1441 | + | let state = $t04794048128._1 | |
1442 | + | let totalAmount = $t04794048128._2 | |
1233 | 1443 | $Tuple2(state, totalAmount) | |
1234 | 1444 | } | |
1235 | 1445 | else throw("Strict value is not equal to itself.") | |
1236 | 1446 | } | |
1237 | 1447 | else throw("Strict value is not equal to itself.") | |
1238 | 1448 | } | |
1239 | 1449 | ||
1240 | 1450 | ||
1241 | 1451 | ||
1242 | 1452 | @Callable(i) | |
1243 | 1453 | func putOneTknV2WithBonusREADONLY (paymentAmountRaw,paymentAssetId) = { | |
1244 | 1454 | let poolConfig = gpc() | |
1245 | 1455 | let amId = poolConfig[idxAmAsId] | |
1246 | 1456 | let prId = poolConfig[idxPrAsId] | |
1247 | 1457 | let lpId = poolConfig[idxLPAsId] | |
1248 | - | let $ | |
1249 | - | let lpAmount = $ | |
1250 | - | let state = $ | |
1251 | - | let feeAmount = $ | |
1252 | - | let bonus = $ | |
1458 | + | let $t04838748490 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true) | |
1459 | + | let lpAmount = $t04838748490._1 | |
1460 | + | let state = $t04838748490._2 | |
1461 | + | let feeAmount = $t04838748490._3 | |
1462 | + | let bonus = $t04838748490._4 | |
1253 | 1463 | $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus)) | |
1254 | 1464 | } | |
1255 | 1465 | ||
1256 | 1466 | ||
1257 | 1467 | ||
1258 | 1468 | @Callable(i) | |
1259 | 1469 | func putOneTknV2WithoutTakeFeeREADONLY (paymentAmountRaw,paymentAssetId) = { | |
1260 | 1470 | let poolConfig = gpc() | |
1261 | 1471 | let amId = poolConfig[idxAmAsId] | |
1262 | 1472 | let prId = poolConfig[idxPrAsId] | |
1263 | 1473 | let lpId = poolConfig[idxLPAsId] | |
1264 | - | let $ | |
1265 | - | let lpAmount = $ | |
1266 | - | let state = $ | |
1267 | - | let feeAmount = $ | |
1268 | - | let bonus = $ | |
1474 | + | let $t04876948873 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false) | |
1475 | + | let lpAmount = $t04876948873._1 | |
1476 | + | let state = $t04876948873._2 | |
1477 | + | let feeAmount = $t04876948873._3 | |
1478 | + | let bonus = $t04876948873._4 | |
1269 | 1479 | $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus)) | |
1270 | 1480 | } | |
1271 | 1481 | ||
1272 | 1482 | ||
1273 | 1483 | ||
1274 | 1484 | @Callable(i) | |
1275 | 1485 | func activate (amtAsStr,prAsStr) = if ((toString(i.caller) != toString(fca))) | |
1276 | 1486 | then throw("denied") | |
1277 | 1487 | else $Tuple2([StringEntry(aa(), amtAsStr), StringEntry(pa(), prAsStr)], "success") | |
1278 | 1488 | ||
1279 | 1489 | ||
1280 | 1490 | ||
1281 | 1491 | @Callable(i) | |
1282 | 1492 | func setS (k,v) = if ((toString(i.caller) != strf(this, ada()))) | |
1283 | 1493 | then pd | |
1284 | 1494 | else [StringEntry(k, v)] | |
1285 | 1495 | ||
1286 | 1496 | ||
1287 | 1497 | ||
1288 | 1498 | @Callable(i) | |
1289 | 1499 | func setI (k,v) = if ((toString(i.caller) != strf(this, ada()))) | |
1290 | 1500 | then pd | |
1291 | 1501 | else [IntegerEntry(k, v)] | |
1292 | 1502 | ||
1293 | 1503 | ||
1294 | 1504 | ||
1295 | 1505 | @Callable(i) | |
1296 | 1506 | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, gpc()) | |
1297 | 1507 | ||
1298 | 1508 | ||
1299 | 1509 | ||
1300 | 1510 | @Callable(i) | |
1301 | 1511 | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
1302 | 1512 | ||
1303 | 1513 | ||
1304 | 1514 | ||
1305 | 1515 | @Callable(i) | |
1306 | 1516 | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
1307 | 1517 | let pr = calcPrices(amAmt, prAmt, lpAmt) | |
1308 | 1518 | $Tuple2(nil, [toString(pr[0]), toString(pr[1]), toString(pr[2])]) | |
1309 | 1519 | } | |
1310 | 1520 | ||
1311 | 1521 | ||
1312 | 1522 | ||
1313 | 1523 | @Callable(i) | |
1314 | 1524 | func fromX18WrapperREADONLY (val,resScaleMult) = $Tuple2(nil, f1(parseBigIntValue(val), resScaleMult)) | |
1315 | 1525 | ||
1316 | 1526 | ||
1317 | 1527 | ||
1318 | 1528 | @Callable(i) | |
1319 | 1529 | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(t1(origVal, origScaleMult))) | |
1320 | 1530 | ||
1321 | 1531 | ||
1322 | 1532 | ||
1323 | 1533 | @Callable(i) | |
1324 | 1534 | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(cpbi(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
1325 | 1535 | ||
1326 | 1536 | ||
1327 | 1537 | ||
1328 | 1538 | @Callable(i) | |
1329 | 1539 | 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, "")) | |
1330 | 1540 | ||
1331 | 1541 | ||
1332 | 1542 | ||
1333 | 1543 | @Callable(i) | |
1334 | 1544 | func estimateGetOperationWrapperREADONLY (txId58,pmtAsId,pmtLpAmt,usrAddr) = { | |
1335 | 1545 | let r = ego(txId58, pmtAsId, pmtLpAmt, addressFromStringValue(usrAddr)) | |
1336 | 1546 | $Tuple2(nil, $Tuple10(r._1, r._2, r._3, r._4, r._5, r._6, r._7, toString(r._8), r._9, r._10)) | |
1337 | 1547 | } | |
1338 | 1548 | ||
1339 | 1549 | ||
1550 | + | ||
1551 | + | @Callable(i) | |
1552 | + | func getFeeREADONLY () = $Tuple2(nil, fee) | |
1553 | + | ||
1554 | + | ||
1340 | 1555 | @Verifier(tx) | |
1341 | 1556 | func verify () = { | |
1342 | 1557 | let targetPublicKey = match m() { | |
1343 | 1558 | case pk: ByteVector => | |
1344 | 1559 | pk | |
1345 | 1560 | case _: Unit => | |
1346 | 1561 | tx.senderPublicKey | |
1347 | 1562 | case _ => | |
1348 | 1563 | throw("Match error") | |
1349 | 1564 | } | |
1350 | 1565 | match tx { | |
1351 | 1566 | case order: Order => | |
1352 | 1567 | let matcherPub = mp() | |
1353 | - | let orderValid = | |
1568 | + | let orderValid = validateMatcherOrderAllowed(order) | |
1354 | 1569 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1355 | 1570 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1356 | 1571 | if (if (if (orderValid) | |
1357 | 1572 | then senderValid | |
1358 | 1573 | else false) | |
1359 | 1574 | then matcherValid | |
1360 | 1575 | else false) | |
1361 | 1576 | then true | |
1362 | 1577 | else toe(orderValid, senderValid, matcherValid) | |
1363 | 1578 | case s: SetScriptTransaction => | |
1364 | 1579 | let newHash = blake2b256(value(s.script)) | |
1365 | 1580 | let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash()))) | |
1366 | 1581 | let currentHash = scriptHash(this) | |
1367 | 1582 | if (if ((allowedHash == newHash)) | |
1368 | 1583 | then (currentHash != newHash) | |
1369 | 1584 | else false) | |
1370 | 1585 | then true | |
1371 | 1586 | else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1372 | 1587 | case _ => | |
1373 | 1588 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1374 | 1589 | } | |
1375 | 1590 | } | |
1376 | 1591 |
github/deemru/w8io/169f3d6 190.20 ms ◑