tx · NnwbJSWZ7Rh3mAn83BXLuyS4QoZ4Vv2XMcqiiU4UXsH 3N1xHtFLmVxy153ELFALTEt3HuVXvv4rnqb: -0.03600000 Waves 2023.01.09 17:31 [2397531] smart account 3N1xHtFLmVxy153ELFALTEt3HuVXvv4rnqb > SELF 0.00000000 Waves
{ "type": 13, "id": "NnwbJSWZ7Rh3mAn83BXLuyS4QoZ4Vv2XMcqiiU4UXsH", "fee": 3600000, "feeAssetId": null, "timestamp": 1673274702018, "version": 1, "sender": "3N1xHtFLmVxy153ELFALTEt3HuVXvv4rnqb", "senderPublicKey": "FbottDhjAqYmSxiGz2jbuu6xQEvdqZoV43vksDrkTTgb", "proofs": [ "ysXaRr9UFp5ZUo9QUDu8xzTMKgPEis2rTSApQJbQux8VV6L5ptXwaNHCgatWLFfkVfCDajY1ZHn7mtCWo4apeoa" ], "script": "base64:BgKsLQgCEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgQKAggBEgQKAggBEgQKAggBEgUKAwEIARIAEgQKAgEBEgMKAQESBQoDAQEBEgQKAggIEgASABIDCgEIEgUKAwEBARIECgIBARIECgIIARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCBIAEgMKAQESAwoBARIECgIIASIKbFBkZWNpbWFscyIGc2NhbGU4IgxzY2FsZThCaWdJbnQiB3NjYWxlMTgiCnplcm9CaWdJbnQiBGJpZzAiBGJpZzEiBGJpZzIiC3dhdmVzU3RyaW5nIgNTRVAiClBvb2xBY3RpdmUiD1Bvb2xQdXREaXNhYmxlZCITUG9vbE1hdGNoZXJEaXNhYmxlZCIMUG9vbFNodXRkb3duIg5pZHhQb29sQWRkcmVzcyINaWR4UG9vbFN0YXR1cyIQaWR4UG9vbExQQXNzZXRJZCINaWR4QW10QXNzZXRJZCIPaWR4UHJpY2VBc3NldElkIg5pZHhBbXRBc3NldERjbSIQaWR4UHJpY2VBc3NldERjbSIOaWR4SUFtdEFzc2V0SWQiEGlkeElQcmljZUFzc2V0SWQiDWlkeExQQ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ZGVyUHVibGljS2V5CQACAQILTWF0Y2ggZXJyb3IEAmRRBQJnRAMJAAECBQJkUQIFT3JkZXIEAmR2BQJkUQQCZ0cJAQJhUgAEAmFCCQECZHUBBQJkdgQCYUMJAPQDAwgFAmR2CWJvZHlCeXRlcwkAkQMCCAUCZHYGcHJvb2ZzAAAIBQJkdg9zZW5kZXJQdWJsaWNLZXkEAmFECQD0AwMIBQJkdglib2R5Qnl0ZXMJAJEDAggFAmR2BnByb29mcwABBQJnRwMDAwUCYUIFAmFDBwUCYUQHBgkBAmFBAwUCYUIFAmFDBQJhRAMJAAECBQJkUQIUU2V0U2NyaXB0VHJhbnNhY3Rpb24EAmVVBQJkUQQCZ0gJAPYDAQkBBXZhbHVlAQgFAmVVBnNjcmlwdAQCZ0kJANsEAQkBBXZhbHVlAQkAnQgCBQJhTAkBAmF5AAQCZ0oJAPEHAQUEdGhpcwMDCQAAAgUCZ0kFAmdICQECIT0CBQJnSgUCZ0gHBgkA9AMDCAUCZ0QJYm9keUJ5dGVzCQCRAwIIBQJnRAZwcm9vZnMAAAUCZ0YJAPQDAwgFAmdECWJvZHlCeXRlcwkAkQMCCAUCZ0QGcHJvb2ZzAAAFAmdGigMyEw==", "chainId": 84, "height": 2397531, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FznWmN5q1btCTr6zpf2JSZYrPSVVjTowLsutDhkeY9wr Next: HkwRDEQPqFgutCzNf8av7FVK15xVm1FKG2WG86uy1wLa Diff:
Old | New | Differences | |
---|---|---|---|
65 | 65 | func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18)) | |
66 | 66 | ||
67 | 67 | ||
68 | + | func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round)) | |
69 | + | ||
70 | + | ||
68 | 71 | func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
69 | 72 | ||
70 | 73 | ||
105 | 108 | func pa () = "%s__priceAsset" | |
106 | 109 | ||
107 | 110 | ||
111 | + | let keyFee = "%s__fee" | |
112 | + | ||
113 | + | let feeDefault = fraction(10, scale8, 10000) | |
114 | + | ||
115 | + | let fee = valueOrElse(getInteger(this, keyFee), feeDefault) | |
116 | + | ||
117 | + | let keyKLp = makeString(["%s", "kLp"], SEP) | |
118 | + | ||
119 | + | let keyKLpRefreshedHeight = makeString(["%s", "kLpRefreshedHeight"], SEP) | |
120 | + | ||
121 | + | let keyKLpRefreshDelay = makeString(["%s", "refreshKLpDelay"], SEP) | |
122 | + | ||
123 | + | let kLpRefreshDelayDefault = 30 | |
124 | + | ||
125 | + | let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault) | |
126 | + | ||
108 | 127 | func keyFactoryConfig () = "%s__factoryConfig" | |
109 | 128 | ||
110 | 129 | ||
141 | 160 | ||
142 | 161 | ||
143 | 162 | func throwErr (msg) = throw(makeString(["lp.ride:", msg], " ")) | |
163 | + | ||
164 | + | ||
165 | + | func fmtErr (msg) = makeString(["lp.ride:", msg], " ") | |
144 | 166 | ||
145 | 167 | ||
146 | 168 | let factoryContract = addressFromStringValue(getStringOrFail(this, fc())) | |
191 | 213 | ||
192 | 214 | let poolConfigParsed = parsePoolConfig(getPoolConfig()) | |
193 | 215 | ||
194 | - | let $ | |
216 | + | let $t082438409 = poolConfigParsed | |
195 | 217 | ||
196 | - | let cfgPoolAddress = $ | |
218 | + | let cfgPoolAddress = $t082438409._1 | |
197 | 219 | ||
198 | - | let cfgPoolStatus = $ | |
220 | + | let cfgPoolStatus = $t082438409._2 | |
199 | 221 | ||
200 | - | let cfgLpAssetId = $ | |
222 | + | let cfgLpAssetId = $t082438409._3 | |
201 | 223 | ||
202 | - | let cfgAmountAssetId = $ | |
224 | + | let cfgAmountAssetId = $t082438409._4 | |
203 | 225 | ||
204 | - | let cfgPriceAssetId = $ | |
226 | + | let cfgPriceAssetId = $t082438409._5 | |
205 | 227 | ||
206 | - | let cfgAmountAssetDecimals = $ | |
228 | + | let cfgAmountAssetDecimals = $t082438409._6 | |
207 | 229 | ||
208 | - | let cfgPriceAssetDecimals = $ | |
230 | + | let cfgPriceAssetDecimals = $t082438409._7 | |
209 | 231 | ||
210 | 232 | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
211 | 233 | ||
226 | 248 | ||
227 | 249 | ||
228 | 250 | func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
251 | + | ||
252 | + | ||
253 | + | func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round) | |
229 | 254 | ||
230 | 255 | ||
231 | 256 | func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
277 | 302 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
278 | 303 | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
279 | 304 | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
280 | - | let outAmAmt = | |
281 | - | let outPrAmt = | |
305 | + | let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR) | |
306 | + | let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR) | |
282 | 307 | let state = if ((txId58 == "")) | |
283 | 308 | then nil | |
284 | 309 | else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
337 | 362 | then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18))) | |
338 | 363 | else { | |
339 | 364 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
340 | - | let prViaAmX18 = fraction(inAmAssetAmtX18, | |
341 | - | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, | |
365 | + | let prViaAmX18 = fraction(inAmAssetAmtX18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING) | |
366 | + | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, FLOOR), CEILING) | |
342 | 367 | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
343 | 368 | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
344 | 369 | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
345 | 370 | let expAmtAssetAmtX18 = expectedAmts._1 | |
346 | 371 | let expPriceAssetAmtX18 = expectedAmts._2 | |
347 | - | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18) | |
348 | - | $Tuple5( | |
372 | + | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR) | |
373 | + | $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtAssetDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceAssetDcm, CEILING), curPriceX18, slippageX18) | |
349 | 374 | } | |
350 | 375 | } | |
351 | 376 | let calcLpAmt = res._1 | |
368 | 393 | } | |
369 | 394 | ||
370 | 395 | ||
396 | + | func calcKLp (amountBalance,priceBalance,lpEmission) = { | |
397 | + | let updatedKLp = fraction(pow((amountBalance * priceBalance), 0, toBigInt(5), 1, 18, DOWN), big1, lpEmission) | |
398 | + | if ((lpEmission == big0)) | |
399 | + | then big0 | |
400 | + | else updatedKLp | |
401 | + | } | |
402 | + | ||
403 | + | ||
404 | + | func calcCurrentKLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = { | |
405 | + | let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta) | |
406 | + | let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta) | |
407 | + | let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta) | |
408 | + | let currentKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpAssetEmission) | |
409 | + | currentKLp | |
410 | + | } | |
411 | + | ||
412 | + | ||
413 | + | func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
414 | + | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
415 | + | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
416 | + | let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta) | |
417 | + | let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
418 | + | let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))] | |
419 | + | $Tuple2(actions, updatedKLp) | |
420 | + | } | |
421 | + | ||
422 | + | ||
423 | + | func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp)) | |
424 | + | then true | |
425 | + | else throwErr(makeString(["updated KLp lower than current KLp", toString(oldKLp), toString(updatedKLp)], " ")) | |
426 | + | ||
427 | + | ||
371 | 428 | func validateMatcherOrderAllowed (order) = { | |
372 | - | let cfg = getPoolConfig() | |
373 | - | let amtAssetId = cfg[idxAmtAssetId] | |
374 | - | let priceAssetId = cfg[idxPriceAssetId] | |
375 | - | let poolStatus = parseIntValue(cfg[idxPoolStatus]) | |
376 | - | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
377 | - | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
378 | - | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
379 | - | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
380 | - | let curPriceX18 = if ((order.orderType == Buy)) | |
381 | - | then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance) | |
382 | - | else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance) | |
383 | - | let curPrice = fromX18(curPriceX18, scale8) | |
429 | + | let amountAssetAmount = order.amount | |
430 | + | let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR) | |
431 | + | let $t02098621198 = if ((order.orderType == Buy)) | |
432 | + | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
433 | + | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
434 | + | let amountAssetBalanceDelta = $t02098621198._1 | |
435 | + | let priceAssetBalanceDelta = $t02098621198._2 | |
384 | 436 | if (if (if (isGlobalShutdown()) | |
385 | 437 | then true | |
386 | - | else ( | |
438 | + | else (cfgPoolStatus == PoolMatcherDisabled)) | |
387 | 439 | then true | |
388 | - | else ( | |
440 | + | else (cfgPoolStatus == PoolShutdown)) | |
389 | 441 | then throw("Exchange operations disabled") | |
390 | - | else { | |
391 | - | let orderAmtAsset = order.assetPair.amountAsset | |
392 | - | let orderAmtAssetStr = if ((orderAmtAsset == unit)) | |
393 | - | then "WAVES" | |
394 | - | else toBase58String(value(orderAmtAsset)) | |
395 | - | let orderPriceAsset = order.assetPair.priceAsset | |
396 | - | let orderPriceAssetStr = if ((orderPriceAsset == unit)) | |
397 | - | then "WAVES" | |
398 | - | else toBase58String(value(orderPriceAsset)) | |
399 | - | if (if ((orderAmtAssetStr != amtAssetId)) | |
400 | - | then true | |
401 | - | else (orderPriceAssetStr != priceAssetId)) | |
402 | - | then throw("Wrong order assets.") | |
403 | - | else { | |
404 | - | let orderPrice = order.price | |
405 | - | let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm) | |
406 | - | let castedOrderPrice = toScale(orderPrice, scale8, priceDcm) | |
407 | - | let isOrderPriceValid = if ((order.orderType == Buy)) | |
408 | - | then (curPrice >= castedOrderPrice) | |
409 | - | else (castedOrderPrice >= curPrice) | |
410 | - | true | |
411 | - | } | |
412 | - | } | |
442 | + | else if (if ((order.assetPair.amountAsset != cfgAmountAssetId)) | |
443 | + | then true | |
444 | + | else (order.assetPair.priceAsset != cfgPriceAssetId)) | |
445 | + | then throw("Wrong order assets.") | |
446 | + | else { | |
447 | + | let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp")) | |
448 | + | let $t02166921769 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
449 | + | let unusedActions = $t02166921769._1 | |
450 | + | let kLpNew = $t02166921769._2 | |
451 | + | let isOrderValid = (kLpNew >= kLp) | |
452 | + | isOrderValid | |
453 | + | } | |
413 | 454 | } | |
414 | 455 | ||
415 | 456 | ||
484 | 525 | else if ((paymentAssetId == cfgPriceAssetId)) | |
485 | 526 | then false | |
486 | 527 | else throwErr("invalid asset") | |
487 | - | let $ | |
528 | + | let $t02449024783 = if (isEval) | |
488 | 529 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
489 | 530 | else if (paymentInAmountAsset) | |
490 | 531 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
491 | 532 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
492 | - | let amountBalanceOld = $ | |
493 | - | let priceBalanceOld = $ | |
494 | - | let $ | |
533 | + | let amountBalanceOld = $t02449024783._1 | |
534 | + | let priceBalanceOld = $t02449024783._2 | |
535 | + | let $t02478724936 = if (paymentInAmountAsset) | |
495 | 536 | then $Tuple2(paymentAmountRaw, 0) | |
496 | 537 | else $Tuple2(0, paymentAmountRaw) | |
497 | - | let amountAssetAmountRaw = $ | |
498 | - | let priceAssetAmountRaw = $ | |
538 | + | let amountAssetAmountRaw = $t02478724936._1 | |
539 | + | let priceAssetAmountRaw = $t02478724936._2 | |
499 | 540 | let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1 | |
500 | 541 | let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1 | |
501 | - | let $ | |
502 | - | let paymentAmount = $ | |
503 | - | let feeAmount = $ | |
542 | + | let $t02506825132 = takeFee(paymentAmountRaw, inFee) | |
543 | + | let paymentAmount = $t02506825132._1 | |
544 | + | let feeAmount = $t02506825132._2 | |
504 | 545 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
505 | 546 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
506 | 547 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
523 | 564 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
524 | 565 | let priceOld = fromX18(priceOldX18, scale8) | |
525 | 566 | let loss = { | |
526 | - | let $ | |
567 | + | let $t02681326980 = if (paymentInAmountAsset) | |
527 | 568 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
528 | 569 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
529 | - | let amount = $ | |
530 | - | let balance = $ | |
570 | + | let amount = $t02681326980._1 | |
571 | + | let balance = $t02681326980._2 | |
531 | 572 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
532 | 573 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
533 | 574 | } | |
534 | - | $ | |
575 | + | $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset) | |
535 | 576 | } | |
536 | 577 | else throw("Strict value is not equal to itself.") | |
537 | 578 | } | |
539 | 580 | ||
540 | 581 | func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = { | |
541 | 582 | let isEval = (txId == unit) | |
583 | + | let cfg = getPoolConfig() | |
584 | + | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
585 | + | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
542 | 586 | let checks = [if ((paymentAssetId == cfgLpAssetId)) | |
543 | 587 | then true | |
544 | 588 | else throwErr("invalid lp asset")] | |
552 | 596 | let balanceBigInt = if (outInAmountAsset) | |
553 | 597 | then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) | |
554 | 598 | else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) | |
599 | + | let outInAmountAssetDecimals = if (outInAmountAsset) | |
600 | + | then amtAssetDcm | |
601 | + | else priceAssetDcm | |
555 | 602 | let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
556 | 603 | let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
557 | 604 | let outBalance = if (outInAmountAsset) | |
561 | 608 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
562 | 609 | let redeemedBigInt = toBigInt(paymentAmount) | |
563 | 610 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
564 | - | let $ | |
565 | - | let totalAmount = $ | |
566 | - | let feeAmount = $ | |
567 | - | let $ | |
611 | + | let $t02905829114 = takeFee(amountRaw, outFee) | |
612 | + | let totalAmount = $t02905829114._1 | |
613 | + | let feeAmount = $t02905829114._2 | |
614 | + | let $t02911829344 = if (outInAmountAsset) | |
568 | 615 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
569 | 616 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
570 | - | let outAmAmount = $ | |
571 | - | let outPrAmount = $ | |
572 | - | let amBalanceNew = $ | |
573 | - | let prBalanceNew = $ | |
617 | + | let outAmAmount = $t02911829344._1 | |
618 | + | let outPrAmount = $t02911829344._2 | |
619 | + | let amBalanceNew = $t02911829344._3 | |
620 | + | let prBalanceNew = $t02911829344._4 | |
574 | 621 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
575 | 622 | let priceNew = fromX18(priceNewX18, scale8) | |
576 | 623 | let commonState = if (isEval) | |
582 | 629 | let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2) | |
583 | 630 | fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset) | |
584 | 631 | } | |
585 | - | $ | |
632 | + | $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset) | |
586 | 633 | } | |
587 | 634 | else throw("Strict value is not equal to itself.") | |
588 | 635 | } | |
682 | 729 | let prDiff = estPut._11 | |
683 | 730 | let amId = estPut._12 | |
684 | 731 | let prId = estPut._13 | |
685 | - | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
686 | - | if ((emitInv == emitInv)) | |
732 | + | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
733 | + | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
734 | + | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
735 | + | if ((currentKLp == currentKLp)) | |
687 | 736 | then { | |
688 | - | let emitInvLegacy = match emitInv { | |
689 | - | case legacyFactoryContract: Address => | |
690 | - | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
691 | - | case _ => | |
692 | - | unit | |
693 | - | } | |
694 | - | if ((emitInvLegacy == emitInvLegacy)) | |
737 | + | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
738 | + | if ((emitInv == emitInv)) | |
695 | 739 | then { | |
696 | - | let slippageAInv = if ((amDiff > 0)) | |
697 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
698 | - | else nil | |
699 | - | if ((slippageAInv == slippageAInv)) | |
740 | + | let emitInvLegacy = match emitInv { | |
741 | + | case legacyFactoryContract: Address => | |
742 | + | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
743 | + | case _ => | |
744 | + | unit | |
745 | + | } | |
746 | + | if ((emitInvLegacy == emitInvLegacy)) | |
700 | 747 | then { | |
701 | - | let | |
702 | - | then invoke(slippageContract, "put", nil, [AttachedPayment( | |
748 | + | let slippageAInv = if ((amDiff > 0)) | |
749 | + | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
703 | 750 | else nil | |
704 | - | if (( | |
751 | + | if ((slippageAInv == slippageAInv)) | |
705 | 752 | then { | |
706 | - | let lpTransfer = if (shouldAutoStake) | |
753 | + | let slippagePInv = if ((prDiff > 0)) | |
754 | + | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
755 | + | else nil | |
756 | + | if ((slippagePInv == slippagePInv)) | |
707 | 757 | then { | |
708 | - | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
709 | - | if ((slpStakeInv == slpStakeInv)) | |
710 | - | then nil | |
758 | + | let lpTransfer = if (shouldAutoStake) | |
759 | + | then { | |
760 | + | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
761 | + | if ((slpStakeInv == slpStakeInv)) | |
762 | + | then nil | |
763 | + | else throw("Strict value is not equal to itself.") | |
764 | + | } | |
765 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
766 | + | let $t03387234334 = refreshKLpInternal(0, 0, 0) | |
767 | + | if (($t03387234334 == $t03387234334)) | |
768 | + | then { | |
769 | + | let updatedKLp = $t03387234334._2 | |
770 | + | let refreshKLpActions = $t03387234334._1 | |
771 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
772 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
773 | + | then ((state ++ lpTransfer) ++ refreshKLpActions) | |
774 | + | else throw("Strict value is not equal to itself.") | |
775 | + | } | |
711 | 776 | else throw("Strict value is not equal to itself.") | |
712 | 777 | } | |
713 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
714 | - | (state ++ lpTransfer) | |
778 | + | else throw("Strict value is not equal to itself.") | |
715 | 779 | } | |
716 | 780 | else throw("Strict value is not equal to itself.") | |
717 | 781 | } | |
729 | 793 | then throw("Invalid value passed") | |
730 | 794 | else { | |
731 | 795 | let estPut = commonPut(i, maxSlippage, false) | |
732 | - | estPut._9 | |
796 | + | let state = estPut._9 | |
797 | + | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
798 | + | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
799 | + | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
800 | + | if ((currentKLp == currentKLp)) | |
801 | + | then { | |
802 | + | let $t03489634961 = refreshKLpInternal(0, 0, 0) | |
803 | + | let refreshKLpActions = $t03489634961._1 | |
804 | + | let updatedKLp = $t03489634961._2 | |
805 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
806 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
807 | + | then (state ++ refreshKLpActions) | |
808 | + | else throw("Strict value is not equal to itself.") | |
809 | + | } | |
810 | + | else throw("Strict value is not equal to itself.") | |
733 | 811 | } | |
734 | 812 | ||
735 | 813 | ||
761 | 839 | let payment = i.payments[0] | |
762 | 840 | let paymentAssetId = payment.assetId | |
763 | 841 | let paymentAmountRaw = payment.amount | |
764 | - | let userAddress = i.caller | |
765 | - | let txId = i.transactionId | |
766 | - | let $t03172331853 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
767 | - | if (($t03172331853 == $t03172331853)) | |
842 | + | let currentKLp = if ((paymentAssetId == cfgAmountAssetId)) | |
843 | + | then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0)) | |
844 | + | else if ((paymentAssetId == cfgPriceAssetId)) | |
845 | + | then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0)) | |
846 | + | else throwErr("payment asset is not supported") | |
847 | + | if ((currentKLp == currentKLp)) | |
768 | 848 | then { | |
769 | - | let bonus = $t03172331853._4 | |
770 | - | let feeAmount = $t03172331853._3 | |
771 | - | let commonState = $t03172331853._2 | |
772 | - | let emitAmountEstimated = $t03172331853._1 | |
773 | - | let emitAmount = if (if ((minOutAmount > 0)) | |
774 | - | then (minOutAmount > emitAmountEstimated) | |
775 | - | else false) | |
776 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
777 | - | else emitAmountEstimated | |
778 | - | let emitInv = emit(emitAmount) | |
779 | - | if ((emitInv == emitInv)) | |
849 | + | let userAddress = i.caller | |
850 | + | let txId = i.transactionId | |
851 | + | let $t03614936301 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
852 | + | if (($t03614936301 == $t03614936301)) | |
780 | 853 | then { | |
781 | - | let lpTransfer = if (autoStake) | |
854 | + | let paymentInAmountAsset = $t03614936301._5 | |
855 | + | let bonus = $t03614936301._4 | |
856 | + | let feeAmount = $t03614936301._3 | |
857 | + | let commonState = $t03614936301._2 | |
858 | + | let emitAmountEstimated = $t03614936301._1 | |
859 | + | let emitAmount = if (if ((minOutAmount > 0)) | |
860 | + | then (minOutAmount > emitAmountEstimated) | |
861 | + | else false) | |
862 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
863 | + | else emitAmountEstimated | |
864 | + | let emitInv = emit(emitAmount) | |
865 | + | if ((emitInv == emitInv)) | |
782 | 866 | then { | |
783 | - | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
784 | - | if ((stakeInv == stakeInv)) | |
785 | - | then nil | |
867 | + | let lpTransfer = if (autoStake) | |
868 | + | then { | |
869 | + | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
870 | + | if ((stakeInv == stakeInv)) | |
871 | + | then nil | |
872 | + | else throw("Strict value is not equal to itself.") | |
873 | + | } | |
874 | + | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
875 | + | let sendFee = if ((feeAmount > 0)) | |
876 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
877 | + | else nil | |
878 | + | let $t03688737084 = if ((this == feeCollectorAddress)) | |
879 | + | then $Tuple2(0, 0) | |
880 | + | else if (paymentInAmountAsset) | |
881 | + | then $Tuple2(-(feeAmount), 0) | |
882 | + | else $Tuple2(0, -(feeAmount)) | |
883 | + | let amountAssetBalanceDelta = $t03688737084._1 | |
884 | + | let priceAssetBalanceDelta = $t03688737084._2 | |
885 | + | let $t03708737195 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
886 | + | let refreshKLpActions = $t03708737195._1 | |
887 | + | let updatedKLp = $t03708737195._2 | |
888 | + | let kLp = value(getString(keyKLp)) | |
889 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
890 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
891 | + | then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
786 | 892 | else throw("Strict value is not equal to itself.") | |
787 | 893 | } | |
788 | - | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
789 | - | let sendFee = if ((feeAmount > 0)) | |
790 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
791 | - | else nil | |
792 | - | $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount) | |
894 | + | else throw("Strict value is not equal to itself.") | |
793 | 895 | } | |
794 | 896 | else throw("Strict value is not equal to itself.") | |
795 | 897 | } | |
802 | 904 | ||
803 | 905 | @Callable(i) | |
804 | 906 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
805 | - | let $t03258232717 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
806 | - | let emitAmountEstimated = $t03258232717._1 | |
807 | - | let commonState = $t03258232717._2 | |
808 | - | let feeAmount = $t03258232717._3 | |
809 | - | let bonus = $t03258232717._4 | |
907 | + | let $t03750137658 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
908 | + | let emitAmountEstimated = $t03750137658._1 | |
909 | + | let commonState = $t03750137658._2 | |
910 | + | let feeAmount = $t03750137658._3 | |
911 | + | let bonus = $t03750137658._4 | |
912 | + | let paymentInAmountAsset = $t03750137658._5 | |
810 | 913 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
811 | 914 | } | |
812 | 915 | ||
838 | 941 | let payment = i.payments[0] | |
839 | 942 | let paymentAssetId = payment.assetId | |
840 | 943 | let paymentAmount = payment.amount | |
841 | - | let userAddress = i.caller | |
842 | - | let txId = i.transactionId | |
843 | - | let $t03352233657 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
844 | - | if (($t03352233657 == $t03352233657)) | |
944 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
945 | + | if ((currentKLp == currentKLp)) | |
845 | 946 | then { | |
846 | - | let bonus = $t03352233657._4 | |
847 | - | let feeAmount = $t03352233657._3 | |
848 | - | let commonState = $t03352233657._2 | |
849 | - | let amountEstimated = $t03352233657._1 | |
850 | - | let amount = if (if ((minOutAmount > 0)) | |
851 | - | then (minOutAmount > amountEstimated) | |
852 | - | else false) | |
853 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
854 | - | else amountEstimated | |
855 | - | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
856 | - | if ((burnInv == burnInv)) | |
947 | + | let userAddress = i.caller | |
948 | + | let txId = i.transactionId | |
949 | + | let $t03854338696 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
950 | + | if (($t03854338696 == $t03854338696)) | |
857 | 951 | then { | |
858 | - | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
859 | - | let sendFee = if ((feeAmount > 0)) | |
860 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
861 | - | else nil | |
862 | - | $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount) | |
952 | + | let outInAmountAsset = $t03854338696._5 | |
953 | + | let bonus = $t03854338696._4 | |
954 | + | let feeAmount = $t03854338696._3 | |
955 | + | let commonState = $t03854338696._2 | |
956 | + | let amountEstimated = $t03854338696._1 | |
957 | + | let amount = if (if ((minOutAmount > 0)) | |
958 | + | then (minOutAmount > amountEstimated) | |
959 | + | else false) | |
960 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
961 | + | else amountEstimated | |
962 | + | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
963 | + | if ((burnInv == burnInv)) | |
964 | + | then { | |
965 | + | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
966 | + | let sendFee = if ((feeAmount > 0)) | |
967 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
968 | + | else nil | |
969 | + | let $t03919639443 = { | |
970 | + | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
971 | + | then 0 | |
972 | + | else feeAmount | |
973 | + | if (outInAmountAsset) | |
974 | + | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
975 | + | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
976 | + | } | |
977 | + | let amountAssetBalanceDelta = $t03919639443._1 | |
978 | + | let priceAssetBalanceDelta = $t03919639443._2 | |
979 | + | let $t03944639554 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
980 | + | let refreshKLpActions = $t03944639554._1 | |
981 | + | let updatedKLp = $t03944639554._2 | |
982 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
983 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
984 | + | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
985 | + | else throw("Strict value is not equal to itself.") | |
986 | + | } | |
987 | + | else throw("Strict value is not equal to itself.") | |
863 | 988 | } | |
864 | 989 | else throw("Strict value is not equal to itself.") | |
865 | 990 | } | |
872 | 997 | ||
873 | 998 | @Callable(i) | |
874 | 999 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
875 | - | let $t03429234430 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
876 | - | let amountEstimated = $t03429234430._1 | |
877 | - | let commonState = $t03429234430._2 | |
878 | - | let feeAmount = $t03429234430._3 | |
879 | - | let bonus = $t03429234430._4 | |
1000 | + | let $t03981139967 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
1001 | + | let amountEstimated = $t03981139967._1 | |
1002 | + | let commonState = $t03981139967._2 | |
1003 | + | let feeAmount = $t03981139967._3 | |
1004 | + | let bonus = $t03981139967._4 | |
1005 | + | let outInAmountAsset = $t03981139967._5 | |
880 | 1006 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
881 | 1007 | } | |
882 | 1008 | ||
907 | 1033 | let outAssetId = parseAssetId(outAssetIdStr) | |
908 | 1034 | let userAddress = i.caller | |
909 | 1035 | let txId = i.transactionId | |
910 | - | let | |
911 | - | if (( | |
1036 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1037 | + | if ((currentKLp == currentKLp)) | |
912 | 1038 | then { | |
913 | - | let | |
914 | - | if (( | |
1039 | + | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1040 | + | if ((unstakeInv == unstakeInv)) | |
915 | 1041 | then { | |
916 | - | let bonus = $t03525535388._4 | |
917 | - | let feeAmount = $t03525535388._3 | |
918 | - | let commonState = $t03525535388._2 | |
919 | - | let amountEstimated = $t03525535388._1 | |
920 | - | let amount = if (if ((minOutAmount > 0)) | |
921 | - | then (minOutAmount > amountEstimated) | |
922 | - | else false) | |
923 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
924 | - | else amountEstimated | |
925 | - | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
926 | - | if ((burnInv == burnInv)) | |
1042 | + | let $t04087241023 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
1043 | + | if (($t04087241023 == $t04087241023)) | |
927 | 1044 | then { | |
928 | - | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
929 | - | let sendFee = if ((feeAmount > 0)) | |
930 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
931 | - | else nil | |
932 | - | $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount) | |
1045 | + | let outInAmountAsset = $t04087241023._5 | |
1046 | + | let bonus = $t04087241023._4 | |
1047 | + | let feeAmount = $t04087241023._3 | |
1048 | + | let commonState = $t04087241023._2 | |
1049 | + | let amountEstimated = $t04087241023._1 | |
1050 | + | let amount = if (if ((minOutAmount > 0)) | |
1051 | + | then (minOutAmount > amountEstimated) | |
1052 | + | else false) | |
1053 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1054 | + | else amountEstimated | |
1055 | + | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1056 | + | if ((burnInv == burnInv)) | |
1057 | + | then { | |
1058 | + | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
1059 | + | let sendFee = if ((feeAmount > 0)) | |
1060 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1061 | + | else nil | |
1062 | + | let $t04151841765 = { | |
1063 | + | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1064 | + | then 0 | |
1065 | + | else feeAmount | |
1066 | + | if (outInAmountAsset) | |
1067 | + | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1068 | + | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1069 | + | } | |
1070 | + | let amountAssetBalanceDelta = $t04151841765._1 | |
1071 | + | let priceAssetBalanceDelta = $t04151841765._2 | |
1072 | + | let $t04176841876 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1073 | + | let refreshKLpActions = $t04176841876._1 | |
1074 | + | let updatedKLp = $t04176841876._2 | |
1075 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1076 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1077 | + | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1078 | + | else throw("Strict value is not equal to itself.") | |
1079 | + | } | |
1080 | + | else throw("Strict value is not equal to itself.") | |
933 | 1081 | } | |
934 | 1082 | else throw("Strict value is not equal to itself.") | |
935 | 1083 | } | |
950 | 1098 | let pmtAmt = res._3 | |
951 | 1099 | let pmtAssetId = res._4 | |
952 | 1100 | let state = res._5 | |
953 | - | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
954 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
955 | - | then state | |
1101 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1102 | + | if ((currentKLp == currentKLp)) | |
1103 | + | then { | |
1104 | + | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1105 | + | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1106 | + | then { | |
1107 | + | let $t04282242904 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1108 | + | let refreshKLpActions = $t04282242904._1 | |
1109 | + | let updatedKLp = $t04282242904._2 | |
1110 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1111 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1112 | + | then (state ++ refreshKLpActions) | |
1113 | + | else throw("Strict value is not equal to itself.") | |
1114 | + | } | |
1115 | + | else throw("Strict value is not equal to itself.") | |
1116 | + | } | |
956 | 1117 | else throw("Strict value is not equal to itself.") | |
957 | 1118 | } | |
958 | 1119 | ||
971 | 1132 | else if ((noLessThenPriceAsset > outPrAmt)) | |
972 | 1133 | then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
973 | 1134 | else { | |
974 | - | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
975 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
976 | - | then state | |
1135 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1136 | + | if ((currentKLp == currentKLp)) | |
1137 | + | then { | |
1138 | + | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1139 | + | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1140 | + | then { | |
1141 | + | let $t04385343934 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1142 | + | let refreshKLpActions = $t04385343934._1 | |
1143 | + | let updatedKLp = $t04385343934._2 | |
1144 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1145 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1146 | + | then (state ++ refreshKLpActions) | |
1147 | + | else throw("Strict value is not equal to itself.") | |
1148 | + | } | |
1149 | + | else throw("Strict value is not equal to itself.") | |
1150 | + | } | |
977 | 1151 | else throw("Strict value is not equal to itself.") | |
978 | 1152 | } | |
979 | 1153 | } | |
989 | 1163 | then { | |
990 | 1164 | let cfg = getPoolConfig() | |
991 | 1165 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
992 | - | let | |
993 | - | if (( | |
1166 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1167 | + | if ((currentKLp == currentKLp)) | |
994 | 1168 | then { | |
995 | - | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
996 | - | let poolStatus = parseIntValue(res._9) | |
997 | - | let state = res._10 | |
998 | - | let checkPoolStatus = if (if (isGlobalShutdown()) | |
999 | - | then true | |
1000 | - | else (poolStatus == PoolShutdown)) | |
1001 | - | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
1002 | - | else true | |
1003 | - | if ((checkPoolStatus == checkPoolStatus)) | |
1169 | + | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1170 | + | if ((unstakeInv == unstakeInv)) | |
1004 | 1171 | then { | |
1005 | - | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1006 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1007 | - | then state | |
1172 | + | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1173 | + | let outAmAmt = res._1 | |
1174 | + | let outPrAmt = res._2 | |
1175 | + | let poolStatus = parseIntValue(res._9) | |
1176 | + | let state = res._10 | |
1177 | + | let checkPoolStatus = if (if (isGlobalShutdown()) | |
1178 | + | then true | |
1179 | + | else (poolStatus == PoolShutdown)) | |
1180 | + | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
1181 | + | else true | |
1182 | + | if ((checkPoolStatus == checkPoolStatus)) | |
1183 | + | then { | |
1184 | + | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1185 | + | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1186 | + | then { | |
1187 | + | let $t04506045141 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1188 | + | let refreshKLpActions = $t04506045141._1 | |
1189 | + | let updatedKLp = $t04506045141._2 | |
1190 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1191 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1192 | + | then (state ++ refreshKLpActions) | |
1193 | + | else throw("Strict value is not equal to itself.") | |
1194 | + | } | |
1195 | + | else throw("Strict value is not equal to itself.") | |
1196 | + | } | |
1008 | 1197 | else throw("Strict value is not equal to itself.") | |
1009 | 1198 | } | |
1010 | 1199 | else throw("Strict value is not equal to itself.") | |
1028 | 1217 | else throw("no payments are expected")] | |
1029 | 1218 | if ((checks == checks)) | |
1030 | 1219 | then { | |
1031 | - | let | |
1032 | - | if (( | |
1220 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1221 | + | if ((currentKLp == currentKLp)) | |
1033 | 1222 | then { | |
1034 | - | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1035 | - | let outAmAmt = res._1 | |
1036 | - | let outPrAmt = res._2 | |
1037 | - | let state = res._10 | |
1038 | - | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1039 | - | then true | |
1040 | - | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1041 | - | then true | |
1042 | - | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1043 | - | if ((checkAmounts == checkAmounts)) | |
1223 | + | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1224 | + | if ((unstakeInv == unstakeInv)) | |
1044 | 1225 | then { | |
1045 | - | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1046 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1047 | - | then state | |
1226 | + | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1227 | + | let outAmAmt = res._1 | |
1228 | + | let outPrAmt = res._2 | |
1229 | + | let state = res._10 | |
1230 | + | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1231 | + | then true | |
1232 | + | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1233 | + | then true | |
1234 | + | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1235 | + | if ((checkAmounts == checkAmounts)) | |
1236 | + | then { | |
1237 | + | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1238 | + | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1239 | + | then { | |
1240 | + | let $t04643646517 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1241 | + | let refreshKLpActions = $t04643646517._1 | |
1242 | + | let updatedKLp = $t04643646517._2 | |
1243 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1244 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1245 | + | then (state ++ refreshKLpActions) | |
1246 | + | else throw("Strict value is not equal to itself.") | |
1247 | + | } | |
1248 | + | else throw("Strict value is not equal to itself.") | |
1249 | + | } | |
1048 | 1250 | else throw("Strict value is not equal to itself.") | |
1049 | 1251 | } | |
1050 | 1252 | else throw("Strict value is not equal to itself.") | |
1060 | 1262 | func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract))) | |
1061 | 1263 | then throw("permissions denied") | |
1062 | 1264 | else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success") | |
1265 | + | ||
1266 | + | ||
1267 | + | ||
1268 | + | @Callable(i) | |
1269 | + | func refreshKLp () = { | |
1270 | + | let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0) | |
1271 | + | let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay)) | |
1272 | + | then unit | |
1273 | + | else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1274 | + | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1275 | + | then { | |
1276 | + | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
1277 | + | let $t04770447768 = refreshKLpInternal(0, 0, 0) | |
1278 | + | let kLpUpdateActions = $t04770447768._1 | |
1279 | + | let updatedKLp = $t04770447768._2 | |
1280 | + | let actions = if ((kLp != updatedKLp)) | |
1281 | + | then kLpUpdateActions | |
1282 | + | else throwErr("nothing to refresh") | |
1283 | + | $Tuple2(actions, toString(updatedKLp)) | |
1284 | + | } | |
1285 | + | else throw("Strict value is not equal to itself.") | |
1286 | + | } | |
1063 | 1287 | ||
1064 | 1288 | ||
1065 | 1289 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let lPdecimals = 8 | |
5 | 5 | ||
6 | 6 | let scale8 = 100000000 | |
7 | 7 | ||
8 | 8 | let scale8BigInt = toBigInt(100000000) | |
9 | 9 | ||
10 | 10 | let scale18 = toBigInt(1000000000000000000) | |
11 | 11 | ||
12 | 12 | let zeroBigInt = toBigInt(0) | |
13 | 13 | ||
14 | 14 | let big0 = toBigInt(0) | |
15 | 15 | ||
16 | 16 | let big1 = toBigInt(1) | |
17 | 17 | ||
18 | 18 | let big2 = toBigInt(2) | |
19 | 19 | ||
20 | 20 | let wavesString = "WAVES" | |
21 | 21 | ||
22 | 22 | let SEP = "__" | |
23 | 23 | ||
24 | 24 | let PoolActive = 1 | |
25 | 25 | ||
26 | 26 | let PoolPutDisabled = 2 | |
27 | 27 | ||
28 | 28 | let PoolMatcherDisabled = 3 | |
29 | 29 | ||
30 | 30 | let PoolShutdown = 4 | |
31 | 31 | ||
32 | 32 | let idxPoolAddress = 1 | |
33 | 33 | ||
34 | 34 | let idxPoolStatus = 2 | |
35 | 35 | ||
36 | 36 | let idxPoolLPAssetId = 3 | |
37 | 37 | ||
38 | 38 | let idxAmtAssetId = 4 | |
39 | 39 | ||
40 | 40 | let idxPriceAssetId = 5 | |
41 | 41 | ||
42 | 42 | let idxAmtAssetDcm = 6 | |
43 | 43 | ||
44 | 44 | let idxPriceAssetDcm = 7 | |
45 | 45 | ||
46 | 46 | let idxIAmtAssetId = 8 | |
47 | 47 | ||
48 | 48 | let idxIPriceAssetId = 9 | |
49 | 49 | ||
50 | 50 | let idxLPAssetDcm = 10 | |
51 | 51 | ||
52 | 52 | let idxPoolAmtAssetAmt = 1 | |
53 | 53 | ||
54 | 54 | let idxPoolPriceAssetAmt = 2 | |
55 | 55 | ||
56 | 56 | let idxPoolLPAssetAmt = 3 | |
57 | 57 | ||
58 | 58 | let idxFactoryStakingContract = 1 | |
59 | 59 | ||
60 | 60 | let idxFactorySlippageContract = 7 | |
61 | 61 | ||
62 | 62 | func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult)) | |
63 | 63 | ||
64 | 64 | ||
65 | 65 | func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18)) | |
66 | 66 | ||
67 | 67 | ||
68 | + | func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round)) | |
69 | + | ||
70 | + | ||
68 | 71 | func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
69 | 72 | ||
70 | 73 | ||
71 | 74 | func abs (val) = if ((0 > val)) | |
72 | 75 | then -(val) | |
73 | 76 | else val | |
74 | 77 | ||
75 | 78 | ||
76 | 79 | func absBigInt (val) = if ((zeroBigInt > val)) | |
77 | 80 | then -(val) | |
78 | 81 | else val | |
79 | 82 | ||
80 | 83 | ||
81 | 84 | func fc () = "%s__factoryContract" | |
82 | 85 | ||
83 | 86 | ||
84 | 87 | func mpk () = "%s__managerPublicKey" | |
85 | 88 | ||
86 | 89 | ||
87 | 90 | func pmpk () = "%s__pendingManagerPublicKey" | |
88 | 91 | ||
89 | 92 | ||
90 | 93 | func pl () = "%s%s__price__last" | |
91 | 94 | ||
92 | 95 | ||
93 | 96 | func ph (h,timestamp) = makeString(["%s%s%d%d__price__history", toString(h), toString(timestamp)], SEP) | |
94 | 97 | ||
95 | 98 | ||
96 | 99 | func pau (userAddress,txId) = ((("%s%s%s__P__" + userAddress) + "__") + txId) | |
97 | 100 | ||
98 | 101 | ||
99 | 102 | func gau (userAddress,txId) = ((("%s%s%s__G__" + userAddress) + "__") + txId) | |
100 | 103 | ||
101 | 104 | ||
102 | 105 | func aa () = "%s__amountAsset" | |
103 | 106 | ||
104 | 107 | ||
105 | 108 | func pa () = "%s__priceAsset" | |
106 | 109 | ||
107 | 110 | ||
111 | + | let keyFee = "%s__fee" | |
112 | + | ||
113 | + | let feeDefault = fraction(10, scale8, 10000) | |
114 | + | ||
115 | + | let fee = valueOrElse(getInteger(this, keyFee), feeDefault) | |
116 | + | ||
117 | + | let keyKLp = makeString(["%s", "kLp"], SEP) | |
118 | + | ||
119 | + | let keyKLpRefreshedHeight = makeString(["%s", "kLpRefreshedHeight"], SEP) | |
120 | + | ||
121 | + | let keyKLpRefreshDelay = makeString(["%s", "refreshKLpDelay"], SEP) | |
122 | + | ||
123 | + | let kLpRefreshDelayDefault = 30 | |
124 | + | ||
125 | + | let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault) | |
126 | + | ||
108 | 127 | func keyFactoryConfig () = "%s__factoryConfig" | |
109 | 128 | ||
110 | 129 | ||
111 | 130 | func keyMatcherPub () = "%s%s__matcher__publicKey" | |
112 | 131 | ||
113 | 132 | ||
114 | 133 | func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset") | |
115 | 134 | ||
116 | 135 | ||
117 | 136 | func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config") | |
118 | 137 | ||
119 | 138 | ||
120 | 139 | func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr) | |
121 | 140 | ||
122 | 141 | ||
123 | 142 | func keyAllPoolsShutdown () = "%s__shutdown" | |
124 | 143 | ||
125 | 144 | ||
126 | 145 | func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress) | |
127 | 146 | ||
128 | 147 | ||
129 | 148 | func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash" | |
130 | 149 | ||
131 | 150 | ||
132 | 151 | let keyFeeCollectorAddress = "%s__feeCollectorAddress" | |
133 | 152 | ||
134 | 153 | func throwOrderError (orderValid,senderValid,matcherValid) = throw(((((("order validation failed: orderValid=" + toString(orderValid)) + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid))) | |
135 | 154 | ||
136 | 155 | ||
137 | 156 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
138 | 157 | ||
139 | 158 | ||
140 | 159 | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
141 | 160 | ||
142 | 161 | ||
143 | 162 | func throwErr (msg) = throw(makeString(["lp.ride:", msg], " ")) | |
163 | + | ||
164 | + | ||
165 | + | func fmtErr (msg) = makeString(["lp.ride:", msg], " ") | |
144 | 166 | ||
145 | 167 | ||
146 | 168 | let factoryContract = addressFromStringValue(getStringOrFail(this, fc())) | |
147 | 169 | ||
148 | 170 | let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress)) | |
149 | 171 | ||
150 | 172 | let inFee = { | |
151 | 173 | let @ = invoke(factoryContract, "getInFeeREADONLY", [toString(this)], nil) | |
152 | 174 | if ($isInstanceOf(@, "Int")) | |
153 | 175 | then @ | |
154 | 176 | else throw(($getType(@) + " couldn't be cast to Int")) | |
155 | 177 | } | |
156 | 178 | ||
157 | 179 | let outFee = { | |
158 | 180 | let @ = invoke(factoryContract, "getOutFeeREADONLY", [toString(this)], nil) | |
159 | 181 | if ($isInstanceOf(@, "Int")) | |
160 | 182 | then @ | |
161 | 183 | else throw(($getType(@) + " couldn't be cast to Int")) | |
162 | 184 | } | |
163 | 185 | ||
164 | 186 | func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false) | |
165 | 187 | ||
166 | 188 | ||
167 | 189 | func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub())) | |
168 | 190 | ||
169 | 191 | ||
170 | 192 | func getPoolConfig () = { | |
171 | 193 | let amtAsset = getStringOrFail(this, aa()) | |
172 | 194 | let priceAsset = getStringOrFail(this, pa()) | |
173 | 195 | let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset)) | |
174 | 196 | let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset)) | |
175 | 197 | split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP) | |
176 | 198 | } | |
177 | 199 | ||
178 | 200 | ||
179 | 201 | func parseAssetId (input) = if ((input == wavesString)) | |
180 | 202 | then unit | |
181 | 203 | else fromBase58String(input) | |
182 | 204 | ||
183 | 205 | ||
184 | 206 | func assetIdToString (input) = if ((input == unit)) | |
185 | 207 | then wavesString | |
186 | 208 | else toBase58String(value(input)) | |
187 | 209 | ||
188 | 210 | ||
189 | 211 | func parsePoolConfig (poolConfig) = $Tuple7(addressFromStringValue(poolConfig[idxPoolAddress]), parseIntValue(poolConfig[idxPoolStatus]), fromBase58String(poolConfig[idxPoolLPAssetId]), parseAssetId(poolConfig[idxAmtAssetId]), parseAssetId(poolConfig[idxPriceAssetId]), parseIntValue(poolConfig[idxAmtAssetDcm]), parseIntValue(poolConfig[idxPriceAssetDcm])) | |
190 | 212 | ||
191 | 213 | ||
192 | 214 | let poolConfigParsed = parsePoolConfig(getPoolConfig()) | |
193 | 215 | ||
194 | - | let $ | |
216 | + | let $t082438409 = poolConfigParsed | |
195 | 217 | ||
196 | - | let cfgPoolAddress = $ | |
218 | + | let cfgPoolAddress = $t082438409._1 | |
197 | 219 | ||
198 | - | let cfgPoolStatus = $ | |
220 | + | let cfgPoolStatus = $t082438409._2 | |
199 | 221 | ||
200 | - | let cfgLpAssetId = $ | |
222 | + | let cfgLpAssetId = $t082438409._3 | |
201 | 223 | ||
202 | - | let cfgAmountAssetId = $ | |
224 | + | let cfgAmountAssetId = $t082438409._4 | |
203 | 225 | ||
204 | - | let cfgPriceAssetId = $ | |
226 | + | let cfgPriceAssetId = $t082438409._5 | |
205 | 227 | ||
206 | - | let cfgAmountAssetDecimals = $ | |
228 | + | let cfgAmountAssetDecimals = $t082438409._6 | |
207 | 229 | ||
208 | - | let cfgPriceAssetDecimals = $ | |
230 | + | let cfgPriceAssetDecimals = $t082438409._7 | |
209 | 231 | ||
210 | 232 | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
211 | 233 | ||
212 | 234 | ||
213 | 235 | let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address") | |
214 | 236 | ||
215 | 237 | let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address") | |
216 | 238 | ||
217 | 239 | func dataPutActionInfo (inAmtAssetAmt,inPriceAssetAmt,outLpAmt,price,slippageTolerancePassedByUser,slippageToleranceReal,txHeight,txTimestamp,slipageAmtAssetAmt,slipagePriceAssetAmt) = makeString(["%d%d%d%d%d%d%d%d%d%d", toString(inAmtAssetAmt), toString(inPriceAssetAmt), toString(outLpAmt), toString(price), toString(slippageTolerancePassedByUser), toString(slippageToleranceReal), toString(txHeight), toString(txTimestamp), toString(slipageAmtAssetAmt), toString(slipagePriceAssetAmt)], SEP) | |
218 | 240 | ||
219 | 241 | ||
220 | 242 | 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) | |
221 | 243 | ||
222 | 244 | ||
223 | 245 | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
224 | 246 | then wavesBalance(this).available | |
225 | 247 | else assetBalance(this, fromBase58String(assetId)) | |
226 | 248 | ||
227 | 249 | ||
228 | 250 | func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
251 | + | ||
252 | + | ||
253 | + | func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round) | |
229 | 254 | ||
230 | 255 | ||
231 | 256 | func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
232 | 257 | let amtAssetAmtX18 = toX18(amAmt, amAssetDcm) | |
233 | 258 | let priceAssetAmtX18 = toX18(prAmt, prAssetDcm) | |
234 | 259 | calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
235 | 260 | } | |
236 | 261 | ||
237 | 262 | ||
238 | 263 | func calcPrices (amAmt,prAmt,lpAmt) = { | |
239 | 264 | let cfg = getPoolConfig() | |
240 | 265 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
241 | 266 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
242 | 267 | let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt) | |
243 | 268 | let amAmtX18 = toX18(amAmt, amtAssetDcm) | |
244 | 269 | let prAmtX18 = toX18(prAmt, priceAssetDcm) | |
245 | 270 | let lpAmtX18 = toX18(lpAmt, scale8) | |
246 | 271 | let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18) | |
247 | 272 | let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18) | |
248 | 273 | [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18] | |
249 | 274 | } | |
250 | 275 | ||
251 | 276 | ||
252 | 277 | func calculatePrices (amAmt,prAmt,lpAmt) = { | |
253 | 278 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
254 | 279 | [fromX18(prices[0], scale8), fromX18(prices[1], scale8), fromX18(prices[2], scale8)] | |
255 | 280 | } | |
256 | 281 | ||
257 | 282 | ||
258 | 283 | func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
259 | 284 | let cfg = getPoolConfig() | |
260 | 285 | let lpAssetId = cfg[idxPoolLPAssetId] | |
261 | 286 | let amAssetId = cfg[idxAmtAssetId] | |
262 | 287 | let prAssetId = cfg[idxPriceAssetId] | |
263 | 288 | let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
264 | 289 | let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
265 | 290 | let poolStatus = cfg[idxPoolStatus] | |
266 | 291 | let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity | |
267 | 292 | if ((lpAssetId != pmtAssetId)) | |
268 | 293 | then throw("Invalid asset passed.") | |
269 | 294 | else { | |
270 | 295 | let amBalance = getAccBalance(amAssetId) | |
271 | 296 | let amBalanceX18 = toX18(amBalance, amAssetDcm) | |
272 | 297 | let prBalance = getAccBalance(prAssetId) | |
273 | 298 | let prBalanceX18 = toX18(prBalance, prAssetDcm) | |
274 | 299 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
275 | 300 | let curPrice = fromX18(curPriceX18, scale8) | |
276 | 301 | let pmtLpAmtX18 = toX18(pmtLpAmt, scale8) | |
277 | 302 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
278 | 303 | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
279 | 304 | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
280 | - | let outAmAmt = | |
281 | - | let outPrAmt = | |
305 | + | let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR) | |
306 | + | let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR) | |
282 | 307 | let state = if ((txId58 == "")) | |
283 | 308 | then nil | |
284 | 309 | else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
285 | 310 | then unit | |
286 | 311 | else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES")) | |
287 | 312 | then unit | |
288 | 313 | else fromBase58String(prAssetId)), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAmAmt, outPrAmt, pmtLpAmt, curPrice, height, lastBlock.timestamp)), IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice)] | |
289 | 314 | $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state) | |
290 | 315 | } | |
291 | 316 | } | |
292 | 317 | ||
293 | 318 | ||
294 | 319 | func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = { | |
295 | 320 | let cfg = getPoolConfig() | |
296 | 321 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
297 | 322 | let amAssetIdStr = cfg[idxAmtAssetId] | |
298 | 323 | let prAssetIdStr = cfg[idxPriceAssetId] | |
299 | 324 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
300 | 325 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
301 | 326 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
302 | 327 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
303 | 328 | let poolStatus = cfg[idxPoolStatus] | |
304 | 329 | let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
305 | 330 | let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES"))) | |
306 | 331 | let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES"))) | |
307 | 332 | if (if ((amAssetIdStr != inAmAssetIdStr)) | |
308 | 333 | then true | |
309 | 334 | else (prAssetIdStr != inPrAssetIdStr)) | |
310 | 335 | then throw("Invalid amt or price asset passed.") | |
311 | 336 | else { | |
312 | 337 | let amBalance = if (isEvaluate) | |
313 | 338 | then getAccBalance(amAssetIdStr) | |
314 | 339 | else (getAccBalance(amAssetIdStr) - inAmAssetAmt) | |
315 | 340 | let prBalance = if (isEvaluate) | |
316 | 341 | then getAccBalance(prAssetIdStr) | |
317 | 342 | else (getAccBalance(prAssetIdStr) - inPrAssetAmt) | |
318 | 343 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
319 | 344 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
320 | 345 | let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18) | |
321 | 346 | let amBalanceX18 = toX18(amBalance, amtAssetDcm) | |
322 | 347 | let prBalanceX18 = toX18(prBalance, priceAssetDcm) | |
323 | 348 | let res = if ((lpEmission == 0)) | |
324 | 349 | then { | |
325 | 350 | let curPriceX18 = zeroBigInt | |
326 | 351 | let slippageX18 = zeroBigInt | |
327 | 352 | let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN) | |
328 | 353 | $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
329 | 354 | } | |
330 | 355 | else { | |
331 | 356 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
332 | 357 | let slippageX18 = fraction(absBigInt((curPriceX18 - userPriceX18)), scale18, curPriceX18) | |
333 | 358 | let slippageToleranceX18 = toX18(slippageTolerance, scale8) | |
334 | 359 | if (if ((curPriceX18 != zeroBigInt)) | |
335 | 360 | then (slippageX18 > slippageToleranceX18) | |
336 | 361 | else false) | |
337 | 362 | then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18))) | |
338 | 363 | else { | |
339 | 364 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
340 | - | let prViaAmX18 = fraction(inAmAssetAmtX18, | |
341 | - | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, | |
365 | + | let prViaAmX18 = fraction(inAmAssetAmtX18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING) | |
366 | + | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, FLOOR), CEILING) | |
342 | 367 | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
343 | 368 | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
344 | 369 | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
345 | 370 | let expAmtAssetAmtX18 = expectedAmts._1 | |
346 | 371 | let expPriceAssetAmtX18 = expectedAmts._2 | |
347 | - | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18) | |
348 | - | $Tuple5( | |
372 | + | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR) | |
373 | + | $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtAssetDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceAssetDcm, CEILING), curPriceX18, slippageX18) | |
349 | 374 | } | |
350 | 375 | } | |
351 | 376 | let calcLpAmt = res._1 | |
352 | 377 | let calcAmAssetPmt = res._2 | |
353 | 378 | let calcPrAssetPmt = res._3 | |
354 | 379 | let curPrice = fromX18(res._4, scale8) | |
355 | 380 | let slippageCalc = fromX18(res._5, scale8) | |
356 | 381 | if ((0 >= calcLpAmt)) | |
357 | 382 | then throw("Invalid calculations. LP calculated is less than zero.") | |
358 | 383 | else { | |
359 | 384 | let emitLpAmt = if (!(emitLp)) | |
360 | 385 | then 0 | |
361 | 386 | else calcLpAmt | |
362 | 387 | let amDiff = (inAmAssetAmt - calcAmAssetPmt) | |
363 | 388 | let prDiff = (inPrAssetAmt - calcPrAssetPmt) | |
364 | 389 | let commonState = [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(userAddress, txId58), dataPutActionInfo(calcAmAssetPmt, calcPrAssetPmt, emitLpAmt, curPrice, slippageTolerance, slippageCalc, height, lastBlock.timestamp, amDiff, prDiff))] | |
365 | 390 | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId) | |
366 | 391 | } | |
367 | 392 | } | |
368 | 393 | } | |
369 | 394 | ||
370 | 395 | ||
396 | + | func calcKLp (amountBalance,priceBalance,lpEmission) = { | |
397 | + | let updatedKLp = fraction(pow((amountBalance * priceBalance), 0, toBigInt(5), 1, 18, DOWN), big1, lpEmission) | |
398 | + | if ((lpEmission == big0)) | |
399 | + | then big0 | |
400 | + | else updatedKLp | |
401 | + | } | |
402 | + | ||
403 | + | ||
404 | + | func calcCurrentKLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = { | |
405 | + | let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta) | |
406 | + | let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta) | |
407 | + | let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta) | |
408 | + | let currentKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpAssetEmission) | |
409 | + | currentKLp | |
410 | + | } | |
411 | + | ||
412 | + | ||
413 | + | func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
414 | + | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
415 | + | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
416 | + | let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta) | |
417 | + | let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
418 | + | let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))] | |
419 | + | $Tuple2(actions, updatedKLp) | |
420 | + | } | |
421 | + | ||
422 | + | ||
423 | + | func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp)) | |
424 | + | then true | |
425 | + | else throwErr(makeString(["updated KLp lower than current KLp", toString(oldKLp), toString(updatedKLp)], " ")) | |
426 | + | ||
427 | + | ||
371 | 428 | func validateMatcherOrderAllowed (order) = { | |
372 | - | let cfg = getPoolConfig() | |
373 | - | let amtAssetId = cfg[idxAmtAssetId] | |
374 | - | let priceAssetId = cfg[idxPriceAssetId] | |
375 | - | let poolStatus = parseIntValue(cfg[idxPoolStatus]) | |
376 | - | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
377 | - | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
378 | - | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
379 | - | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
380 | - | let curPriceX18 = if ((order.orderType == Buy)) | |
381 | - | then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance) | |
382 | - | else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance) | |
383 | - | let curPrice = fromX18(curPriceX18, scale8) | |
429 | + | let amountAssetAmount = order.amount | |
430 | + | let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR) | |
431 | + | let $t02098621198 = if ((order.orderType == Buy)) | |
432 | + | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
433 | + | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
434 | + | let amountAssetBalanceDelta = $t02098621198._1 | |
435 | + | let priceAssetBalanceDelta = $t02098621198._2 | |
384 | 436 | if (if (if (isGlobalShutdown()) | |
385 | 437 | then true | |
386 | - | else ( | |
438 | + | else (cfgPoolStatus == PoolMatcherDisabled)) | |
387 | 439 | then true | |
388 | - | else ( | |
440 | + | else (cfgPoolStatus == PoolShutdown)) | |
389 | 441 | then throw("Exchange operations disabled") | |
390 | - | else { | |
391 | - | let orderAmtAsset = order.assetPair.amountAsset | |
392 | - | let orderAmtAssetStr = if ((orderAmtAsset == unit)) | |
393 | - | then "WAVES" | |
394 | - | else toBase58String(value(orderAmtAsset)) | |
395 | - | let orderPriceAsset = order.assetPair.priceAsset | |
396 | - | let orderPriceAssetStr = if ((orderPriceAsset == unit)) | |
397 | - | then "WAVES" | |
398 | - | else toBase58String(value(orderPriceAsset)) | |
399 | - | if (if ((orderAmtAssetStr != amtAssetId)) | |
400 | - | then true | |
401 | - | else (orderPriceAssetStr != priceAssetId)) | |
402 | - | then throw("Wrong order assets.") | |
403 | - | else { | |
404 | - | let orderPrice = order.price | |
405 | - | let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm) | |
406 | - | let castedOrderPrice = toScale(orderPrice, scale8, priceDcm) | |
407 | - | let isOrderPriceValid = if ((order.orderType == Buy)) | |
408 | - | then (curPrice >= castedOrderPrice) | |
409 | - | else (castedOrderPrice >= curPrice) | |
410 | - | true | |
411 | - | } | |
412 | - | } | |
442 | + | else if (if ((order.assetPair.amountAsset != cfgAmountAssetId)) | |
443 | + | then true | |
444 | + | else (order.assetPair.priceAsset != cfgPriceAssetId)) | |
445 | + | then throw("Wrong order assets.") | |
446 | + | else { | |
447 | + | let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp")) | |
448 | + | let $t02166921769 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
449 | + | let unusedActions = $t02166921769._1 | |
450 | + | let kLpNew = $t02166921769._2 | |
451 | + | let isOrderValid = (kLpNew >= kLp) | |
452 | + | isOrderValid | |
453 | + | } | |
413 | 454 | } | |
414 | 455 | ||
415 | 456 | ||
416 | 457 | func commonGet (i) = if ((size(i.payments) != 1)) | |
417 | 458 | then throw("exactly 1 payment is expected") | |
418 | 459 | else { | |
419 | 460 | let pmt = value(i.payments[0]) | |
420 | 461 | let pmtAssetId = value(pmt.assetId) | |
421 | 462 | let pmtAmt = pmt.amount | |
422 | 463 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
423 | 464 | let outAmAmt = res._1 | |
424 | 465 | let outPrAmt = res._2 | |
425 | 466 | let poolStatus = parseIntValue(res._9) | |
426 | 467 | let state = res._10 | |
427 | 468 | if (if (isGlobalShutdown()) | |
428 | 469 | then true | |
429 | 470 | else (poolStatus == PoolShutdown)) | |
430 | 471 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
431 | 472 | else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state) | |
432 | 473 | } | |
433 | 474 | ||
434 | 475 | ||
435 | 476 | func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2)) | |
436 | 477 | then throw("exactly 2 payments are expected") | |
437 | 478 | else { | |
438 | 479 | let amAssetPmt = value(i.payments[0]) | |
439 | 480 | let prAssetPmt = value(i.payments[1]) | |
440 | 481 | let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp) | |
441 | 482 | let poolStatus = parseIntValue(estPut._8) | |
442 | 483 | if (if (if (isGlobalShutdown()) | |
443 | 484 | then true | |
444 | 485 | else (poolStatus == PoolPutDisabled)) | |
445 | 486 | then true | |
446 | 487 | else (poolStatus == PoolShutdown)) | |
447 | 488 | then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus))) | |
448 | 489 | else estPut | |
449 | 490 | } | |
450 | 491 | ||
451 | 492 | ||
452 | 493 | func emit (amount) = { | |
453 | 494 | let emitInv = invoke(factoryContract, "emit", [amount], nil) | |
454 | 495 | if ((emitInv == emitInv)) | |
455 | 496 | then { | |
456 | 497 | let emitInvLegacy = match emitInv { | |
457 | 498 | case legacyFactoryContract: Address => | |
458 | 499 | invoke(legacyFactoryContract, "emit", [amount], nil) | |
459 | 500 | case _ => | |
460 | 501 | unit | |
461 | 502 | } | |
462 | 503 | if ((emitInvLegacy == emitInvLegacy)) | |
463 | 504 | then amount | |
464 | 505 | else throw("Strict value is not equal to itself.") | |
465 | 506 | } | |
466 | 507 | else throw("Strict value is not equal to itself.") | |
467 | 508 | } | |
468 | 509 | ||
469 | 510 | ||
470 | 511 | func takeFee (amount,fee) = { | |
471 | 512 | let feeAmount = if ((fee == 0)) | |
472 | 513 | then 0 | |
473 | 514 | else fraction(amount, fee, scale8) | |
474 | 515 | $Tuple2((amount - feeAmount), feeAmount) | |
475 | 516 | } | |
476 | 517 | ||
477 | 518 | ||
478 | 519 | func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = { | |
479 | 520 | let isEval = (txId == unit) | |
480 | 521 | let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
481 | 522 | let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
482 | 523 | let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId)) | |
483 | 524 | then true | |
484 | 525 | else if ((paymentAssetId == cfgPriceAssetId)) | |
485 | 526 | then false | |
486 | 527 | else throwErr("invalid asset") | |
487 | - | let $ | |
528 | + | let $t02449024783 = if (isEval) | |
488 | 529 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
489 | 530 | else if (paymentInAmountAsset) | |
490 | 531 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
491 | 532 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
492 | - | let amountBalanceOld = $ | |
493 | - | let priceBalanceOld = $ | |
494 | - | let $ | |
533 | + | let amountBalanceOld = $t02449024783._1 | |
534 | + | let priceBalanceOld = $t02449024783._2 | |
535 | + | let $t02478724936 = if (paymentInAmountAsset) | |
495 | 536 | then $Tuple2(paymentAmountRaw, 0) | |
496 | 537 | else $Tuple2(0, paymentAmountRaw) | |
497 | - | let amountAssetAmountRaw = $ | |
498 | - | let priceAssetAmountRaw = $ | |
538 | + | let amountAssetAmountRaw = $t02478724936._1 | |
539 | + | let priceAssetAmountRaw = $t02478724936._2 | |
499 | 540 | let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1 | |
500 | 541 | let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1 | |
501 | - | let $ | |
502 | - | let paymentAmount = $ | |
503 | - | let feeAmount = $ | |
542 | + | let $t02506825132 = takeFee(paymentAmountRaw, inFee) | |
543 | + | let paymentAmount = $t02506825132._1 | |
544 | + | let feeAmount = $t02506825132._2 | |
504 | 545 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
505 | 546 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
506 | 547 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
507 | 548 | let priceNew = fromX18(priceNewX18, scale8) | |
508 | 549 | let paymentBalance = if (paymentInAmountAsset) | |
509 | 550 | then amountBalanceOld | |
510 | 551 | else priceBalanceOld | |
511 | 552 | let paymentBalanceBigInt = toBigInt(paymentBalance) | |
512 | 553 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
513 | 554 | let chechSupply = if ((supplyBigInt > big0)) | |
514 | 555 | then true | |
515 | 556 | else throwErr("initial deposit requires all coins") | |
516 | 557 | if ((chechSupply == chechSupply)) | |
517 | 558 | then { | |
518 | 559 | let depositBigInt = toBigInt(paymentAmount) | |
519 | 560 | let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))]) | |
520 | 561 | let commonState = if (isEval) | |
521 | 562 | then nil | |
522 | 563 | else [IntegerEntry(pl(), priceNew), IntegerEntry(ph(height, lastBlock.timestamp), priceNew), StringEntry(pau(toString(value(userAddress)), toBase58String(value(txId))), dataPutActionInfo(amountAssetAmountRaw, priceAssetAmountRaw, issueAmount, priceNew, 0, 0, height, lastBlock.timestamp, 0, 0))] | |
523 | 564 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
524 | 565 | let priceOld = fromX18(priceOldX18, scale8) | |
525 | 566 | let loss = { | |
526 | - | let $ | |
567 | + | let $t02681326980 = if (paymentInAmountAsset) | |
527 | 568 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
528 | 569 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
529 | - | let amount = $ | |
530 | - | let balance = $ | |
570 | + | let amount = $t02681326980._1 | |
571 | + | let balance = $t02681326980._2 | |
531 | 572 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
532 | 573 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
533 | 574 | } | |
534 | - | $ | |
575 | + | $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset) | |
535 | 576 | } | |
536 | 577 | else throw("Strict value is not equal to itself.") | |
537 | 578 | } | |
538 | 579 | ||
539 | 580 | ||
540 | 581 | func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = { | |
541 | 582 | let isEval = (txId == unit) | |
583 | + | let cfg = getPoolConfig() | |
584 | + | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
585 | + | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
542 | 586 | let checks = [if ((paymentAssetId == cfgLpAssetId)) | |
543 | 587 | then true | |
544 | 588 | else throwErr("invalid lp asset")] | |
545 | 589 | if ((checks == checks)) | |
546 | 590 | then { | |
547 | 591 | let outInAmountAsset = if ((outAssetId == cfgAmountAssetId)) | |
548 | 592 | then true | |
549 | 593 | else if ((outAssetId == cfgPriceAssetId)) | |
550 | 594 | then false | |
551 | 595 | else throwErr("invalid asset") | |
552 | 596 | let balanceBigInt = if (outInAmountAsset) | |
553 | 597 | then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) | |
554 | 598 | else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) | |
599 | + | let outInAmountAssetDecimals = if (outInAmountAsset) | |
600 | + | then amtAssetDcm | |
601 | + | else priceAssetDcm | |
555 | 602 | let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
556 | 603 | let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
557 | 604 | let outBalance = if (outInAmountAsset) | |
558 | 605 | then amBalanceOld | |
559 | 606 | else prBalanceOld | |
560 | 607 | let outBalanceBigInt = toBigInt(outBalance) | |
561 | 608 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
562 | 609 | let redeemedBigInt = toBigInt(paymentAmount) | |
563 | 610 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
564 | - | let $ | |
565 | - | let totalAmount = $ | |
566 | - | let feeAmount = $ | |
567 | - | let $ | |
611 | + | let $t02905829114 = takeFee(amountRaw, outFee) | |
612 | + | let totalAmount = $t02905829114._1 | |
613 | + | let feeAmount = $t02905829114._2 | |
614 | + | let $t02911829344 = if (outInAmountAsset) | |
568 | 615 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
569 | 616 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
570 | - | let outAmAmount = $ | |
571 | - | let outPrAmount = $ | |
572 | - | let amBalanceNew = $ | |
573 | - | let prBalanceNew = $ | |
617 | + | let outAmAmount = $t02911829344._1 | |
618 | + | let outPrAmount = $t02911829344._2 | |
619 | + | let amBalanceNew = $t02911829344._3 | |
620 | + | let prBalanceNew = $t02911829344._4 | |
574 | 621 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
575 | 622 | let priceNew = fromX18(priceNewX18, scale8) | |
576 | 623 | let commonState = if (isEval) | |
577 | 624 | then nil | |
578 | 625 | else [StringEntry(gau(toString(value(userAddress)), toBase58String(value(txId))), dataGetActionInfo(outAmAmount, outPrAmount, paymentAmount, priceNew, height, lastBlock.timestamp)), IntegerEntry(pl(), priceNew), IntegerEntry(ph(height, lastBlock.timestamp), priceNew)] | |
579 | 626 | let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals)) | |
580 | 627 | let priceOld = fromX18(priceOldX18, scale8) | |
581 | 628 | let loss = { | |
582 | 629 | let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2) | |
583 | 630 | fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset) | |
584 | 631 | } | |
585 | - | $ | |
632 | + | $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset) | |
586 | 633 | } | |
587 | 634 | else throw("Strict value is not equal to itself.") | |
588 | 635 | } | |
589 | 636 | ||
590 | 637 | ||
591 | 638 | func managerPublicKeyOrUnit () = match getString(mpk()) { | |
592 | 639 | case s: String => | |
593 | 640 | fromBase58String(s) | |
594 | 641 | case _: Unit => | |
595 | 642 | unit | |
596 | 643 | case _ => | |
597 | 644 | throw("Match error") | |
598 | 645 | } | |
599 | 646 | ||
600 | 647 | ||
601 | 648 | func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) { | |
602 | 649 | case s: String => | |
603 | 650 | fromBase58String(s) | |
604 | 651 | case _: Unit => | |
605 | 652 | unit | |
606 | 653 | case _ => | |
607 | 654 | throw("Match error") | |
608 | 655 | } | |
609 | 656 | ||
610 | 657 | ||
611 | 658 | func isManager (i) = match managerPublicKeyOrUnit() { | |
612 | 659 | case pk: ByteVector => | |
613 | 660 | (i.callerPublicKey == pk) | |
614 | 661 | case _: Unit => | |
615 | 662 | (i.caller == this) | |
616 | 663 | case _ => | |
617 | 664 | throw("Match error") | |
618 | 665 | } | |
619 | 666 | ||
620 | 667 | ||
621 | 668 | func mustManager (i) = { | |
622 | 669 | let pd = throw("Permission denied") | |
623 | 670 | match managerPublicKeyOrUnit() { | |
624 | 671 | case pk: ByteVector => | |
625 | 672 | if ((i.callerPublicKey == pk)) | |
626 | 673 | then true | |
627 | 674 | else pd | |
628 | 675 | case _: Unit => | |
629 | 676 | if ((i.caller == this)) | |
630 | 677 | then true | |
631 | 678 | else pd | |
632 | 679 | case _ => | |
633 | 680 | throw("Match error") | |
634 | 681 | } | |
635 | 682 | } | |
636 | 683 | ||
637 | 684 | ||
638 | 685 | @Callable(i) | |
639 | 686 | func setManager (pendingManagerPublicKey) = { | |
640 | 687 | let checkCaller = mustManager(i) | |
641 | 688 | if ((checkCaller == checkCaller)) | |
642 | 689 | then { | |
643 | 690 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
644 | 691 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
645 | 692 | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
646 | 693 | else throw("Strict value is not equal to itself.") | |
647 | 694 | } | |
648 | 695 | else throw("Strict value is not equal to itself.") | |
649 | 696 | } | |
650 | 697 | ||
651 | 698 | ||
652 | 699 | ||
653 | 700 | @Callable(i) | |
654 | 701 | func confirmManager () = { | |
655 | 702 | let pm = pendingManagerPublicKeyOrUnit() | |
656 | 703 | let hasPM = if (isDefined(pm)) | |
657 | 704 | then true | |
658 | 705 | else throw("No pending manager") | |
659 | 706 | if ((hasPM == hasPM)) | |
660 | 707 | then { | |
661 | 708 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
662 | 709 | then true | |
663 | 710 | else throw("You are not pending manager") | |
664 | 711 | if ((checkPM == checkPM)) | |
665 | 712 | then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())] | |
666 | 713 | else throw("Strict value is not equal to itself.") | |
667 | 714 | } | |
668 | 715 | else throw("Strict value is not equal to itself.") | |
669 | 716 | } | |
670 | 717 | ||
671 | 718 | ||
672 | 719 | ||
673 | 720 | @Callable(i) | |
674 | 721 | func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance)) | |
675 | 722 | then throw("Invalid slippageTolerance passed") | |
676 | 723 | else { | |
677 | 724 | let estPut = commonPut(i, slippageTolerance, true) | |
678 | 725 | let emitLpAmt = estPut._2 | |
679 | 726 | let lpAssetId = estPut._7 | |
680 | 727 | let state = estPut._9 | |
681 | 728 | let amDiff = estPut._10 | |
682 | 729 | let prDiff = estPut._11 | |
683 | 730 | let amId = estPut._12 | |
684 | 731 | let prId = estPut._13 | |
685 | - | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
686 | - | if ((emitInv == emitInv)) | |
732 | + | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
733 | + | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
734 | + | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
735 | + | if ((currentKLp == currentKLp)) | |
687 | 736 | then { | |
688 | - | let emitInvLegacy = match emitInv { | |
689 | - | case legacyFactoryContract: Address => | |
690 | - | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
691 | - | case _ => | |
692 | - | unit | |
693 | - | } | |
694 | - | if ((emitInvLegacy == emitInvLegacy)) | |
737 | + | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
738 | + | if ((emitInv == emitInv)) | |
695 | 739 | then { | |
696 | - | let slippageAInv = if ((amDiff > 0)) | |
697 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
698 | - | else nil | |
699 | - | if ((slippageAInv == slippageAInv)) | |
740 | + | let emitInvLegacy = match emitInv { | |
741 | + | case legacyFactoryContract: Address => | |
742 | + | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
743 | + | case _ => | |
744 | + | unit | |
745 | + | } | |
746 | + | if ((emitInvLegacy == emitInvLegacy)) | |
700 | 747 | then { | |
701 | - | let | |
702 | - | then invoke(slippageContract, "put", nil, [AttachedPayment( | |
748 | + | let slippageAInv = if ((amDiff > 0)) | |
749 | + | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
703 | 750 | else nil | |
704 | - | if (( | |
751 | + | if ((slippageAInv == slippageAInv)) | |
705 | 752 | then { | |
706 | - | let lpTransfer = if (shouldAutoStake) | |
753 | + | let slippagePInv = if ((prDiff > 0)) | |
754 | + | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
755 | + | else nil | |
756 | + | if ((slippagePInv == slippagePInv)) | |
707 | 757 | then { | |
708 | - | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
709 | - | if ((slpStakeInv == slpStakeInv)) | |
710 | - | then nil | |
758 | + | let lpTransfer = if (shouldAutoStake) | |
759 | + | then { | |
760 | + | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
761 | + | if ((slpStakeInv == slpStakeInv)) | |
762 | + | then nil | |
763 | + | else throw("Strict value is not equal to itself.") | |
764 | + | } | |
765 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
766 | + | let $t03387234334 = refreshKLpInternal(0, 0, 0) | |
767 | + | if (($t03387234334 == $t03387234334)) | |
768 | + | then { | |
769 | + | let updatedKLp = $t03387234334._2 | |
770 | + | let refreshKLpActions = $t03387234334._1 | |
771 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
772 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
773 | + | then ((state ++ lpTransfer) ++ refreshKLpActions) | |
774 | + | else throw("Strict value is not equal to itself.") | |
775 | + | } | |
711 | 776 | else throw("Strict value is not equal to itself.") | |
712 | 777 | } | |
713 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
714 | - | (state ++ lpTransfer) | |
778 | + | else throw("Strict value is not equal to itself.") | |
715 | 779 | } | |
716 | 780 | else throw("Strict value is not equal to itself.") | |
717 | 781 | } | |
718 | 782 | else throw("Strict value is not equal to itself.") | |
719 | 783 | } | |
720 | 784 | else throw("Strict value is not equal to itself.") | |
721 | 785 | } | |
722 | 786 | else throw("Strict value is not equal to itself.") | |
723 | 787 | } | |
724 | 788 | ||
725 | 789 | ||
726 | 790 | ||
727 | 791 | @Callable(i) | |
728 | 792 | func putForFree (maxSlippage) = if ((0 > maxSlippage)) | |
729 | 793 | then throw("Invalid value passed") | |
730 | 794 | else { | |
731 | 795 | let estPut = commonPut(i, maxSlippage, false) | |
732 | - | estPut._9 | |
796 | + | let state = estPut._9 | |
797 | + | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
798 | + | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
799 | + | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
800 | + | if ((currentKLp == currentKLp)) | |
801 | + | then { | |
802 | + | let $t03489634961 = refreshKLpInternal(0, 0, 0) | |
803 | + | let refreshKLpActions = $t03489634961._1 | |
804 | + | let updatedKLp = $t03489634961._2 | |
805 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
806 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
807 | + | then (state ++ refreshKLpActions) | |
808 | + | else throw("Strict value is not equal to itself.") | |
809 | + | } | |
810 | + | else throw("Strict value is not equal to itself.") | |
733 | 811 | } | |
734 | 812 | ||
735 | 813 | ||
736 | 814 | ||
737 | 815 | @Callable(i) | |
738 | 816 | func putOneTkn (minOutAmount,autoStake) = { | |
739 | 817 | let isPoolOneTokenOperationsDisabled = { | |
740 | 818 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
741 | 819 | if ($isInstanceOf(@, "Boolean")) | |
742 | 820 | then @ | |
743 | 821 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
744 | 822 | } | |
745 | 823 | let isPutDisabled = if (if (if (isGlobalShutdown()) | |
746 | 824 | then true | |
747 | 825 | else (cfgPoolStatus == PoolPutDisabled)) | |
748 | 826 | then true | |
749 | 827 | else (cfgPoolStatus == PoolShutdown)) | |
750 | 828 | then true | |
751 | 829 | else isPoolOneTokenOperationsDisabled | |
752 | 830 | let checks = [if (if (!(isPutDisabled)) | |
753 | 831 | then true | |
754 | 832 | else isManager(i)) | |
755 | 833 | then true | |
756 | 834 | else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1)) | |
757 | 835 | then true | |
758 | 836 | else throwErr("exactly 1 payment are expected")] | |
759 | 837 | if ((checks == checks)) | |
760 | 838 | then { | |
761 | 839 | let payment = i.payments[0] | |
762 | 840 | let paymentAssetId = payment.assetId | |
763 | 841 | let paymentAmountRaw = payment.amount | |
764 | - | let userAddress = i.caller | |
765 | - | let txId = i.transactionId | |
766 | - | let $t03172331853 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
767 | - | if (($t03172331853 == $t03172331853)) | |
842 | + | let currentKLp = if ((paymentAssetId == cfgAmountAssetId)) | |
843 | + | then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0)) | |
844 | + | else if ((paymentAssetId == cfgPriceAssetId)) | |
845 | + | then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0)) | |
846 | + | else throwErr("payment asset is not supported") | |
847 | + | if ((currentKLp == currentKLp)) | |
768 | 848 | then { | |
769 | - | let bonus = $t03172331853._4 | |
770 | - | let feeAmount = $t03172331853._3 | |
771 | - | let commonState = $t03172331853._2 | |
772 | - | let emitAmountEstimated = $t03172331853._1 | |
773 | - | let emitAmount = if (if ((minOutAmount > 0)) | |
774 | - | then (minOutAmount > emitAmountEstimated) | |
775 | - | else false) | |
776 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
777 | - | else emitAmountEstimated | |
778 | - | let emitInv = emit(emitAmount) | |
779 | - | if ((emitInv == emitInv)) | |
849 | + | let userAddress = i.caller | |
850 | + | let txId = i.transactionId | |
851 | + | let $t03614936301 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
852 | + | if (($t03614936301 == $t03614936301)) | |
780 | 853 | then { | |
781 | - | let lpTransfer = if (autoStake) | |
854 | + | let paymentInAmountAsset = $t03614936301._5 | |
855 | + | let bonus = $t03614936301._4 | |
856 | + | let feeAmount = $t03614936301._3 | |
857 | + | let commonState = $t03614936301._2 | |
858 | + | let emitAmountEstimated = $t03614936301._1 | |
859 | + | let emitAmount = if (if ((minOutAmount > 0)) | |
860 | + | then (minOutAmount > emitAmountEstimated) | |
861 | + | else false) | |
862 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
863 | + | else emitAmountEstimated | |
864 | + | let emitInv = emit(emitAmount) | |
865 | + | if ((emitInv == emitInv)) | |
782 | 866 | then { | |
783 | - | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
784 | - | if ((stakeInv == stakeInv)) | |
785 | - | then nil | |
867 | + | let lpTransfer = if (autoStake) | |
868 | + | then { | |
869 | + | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
870 | + | if ((stakeInv == stakeInv)) | |
871 | + | then nil | |
872 | + | else throw("Strict value is not equal to itself.") | |
873 | + | } | |
874 | + | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
875 | + | let sendFee = if ((feeAmount > 0)) | |
876 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
877 | + | else nil | |
878 | + | let $t03688737084 = if ((this == feeCollectorAddress)) | |
879 | + | then $Tuple2(0, 0) | |
880 | + | else if (paymentInAmountAsset) | |
881 | + | then $Tuple2(-(feeAmount), 0) | |
882 | + | else $Tuple2(0, -(feeAmount)) | |
883 | + | let amountAssetBalanceDelta = $t03688737084._1 | |
884 | + | let priceAssetBalanceDelta = $t03688737084._2 | |
885 | + | let $t03708737195 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
886 | + | let refreshKLpActions = $t03708737195._1 | |
887 | + | let updatedKLp = $t03708737195._2 | |
888 | + | let kLp = value(getString(keyKLp)) | |
889 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
890 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
891 | + | then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
786 | 892 | else throw("Strict value is not equal to itself.") | |
787 | 893 | } | |
788 | - | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
789 | - | let sendFee = if ((feeAmount > 0)) | |
790 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
791 | - | else nil | |
792 | - | $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount) | |
894 | + | else throw("Strict value is not equal to itself.") | |
793 | 895 | } | |
794 | 896 | else throw("Strict value is not equal to itself.") | |
795 | 897 | } | |
796 | 898 | else throw("Strict value is not equal to itself.") | |
797 | 899 | } | |
798 | 900 | else throw("Strict value is not equal to itself.") | |
799 | 901 | } | |
800 | 902 | ||
801 | 903 | ||
802 | 904 | ||
803 | 905 | @Callable(i) | |
804 | 906 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
805 | - | let $t03258232717 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
806 | - | let emitAmountEstimated = $t03258232717._1 | |
807 | - | let commonState = $t03258232717._2 | |
808 | - | let feeAmount = $t03258232717._3 | |
809 | - | let bonus = $t03258232717._4 | |
907 | + | let $t03750137658 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
908 | + | let emitAmountEstimated = $t03750137658._1 | |
909 | + | let commonState = $t03750137658._2 | |
910 | + | let feeAmount = $t03750137658._3 | |
911 | + | let bonus = $t03750137658._4 | |
912 | + | let paymentInAmountAsset = $t03750137658._5 | |
810 | 913 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
811 | 914 | } | |
812 | 915 | ||
813 | 916 | ||
814 | 917 | ||
815 | 918 | @Callable(i) | |
816 | 919 | func getOneTkn (outAssetIdStr,minOutAmount) = { | |
817 | 920 | let isPoolOneTokenOperationsDisabled = { | |
818 | 921 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
819 | 922 | if ($isInstanceOf(@, "Boolean")) | |
820 | 923 | then @ | |
821 | 924 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
822 | 925 | } | |
823 | 926 | let isGetDisabled = if (if (isGlobalShutdown()) | |
824 | 927 | then true | |
825 | 928 | else (cfgPoolStatus == PoolShutdown)) | |
826 | 929 | then true | |
827 | 930 | else isPoolOneTokenOperationsDisabled | |
828 | 931 | let checks = [if (if (!(isGetDisabled)) | |
829 | 932 | then true | |
830 | 933 | else isManager(i)) | |
831 | 934 | then true | |
832 | 935 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1)) | |
833 | 936 | then true | |
834 | 937 | else throwErr("exactly 1 payment are expected")] | |
835 | 938 | if ((checks == checks)) | |
836 | 939 | then { | |
837 | 940 | let outAssetId = parseAssetId(outAssetIdStr) | |
838 | 941 | let payment = i.payments[0] | |
839 | 942 | let paymentAssetId = payment.assetId | |
840 | 943 | let paymentAmount = payment.amount | |
841 | - | let userAddress = i.caller | |
842 | - | let txId = i.transactionId | |
843 | - | let $t03352233657 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
844 | - | if (($t03352233657 == $t03352233657)) | |
944 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
945 | + | if ((currentKLp == currentKLp)) | |
845 | 946 | then { | |
846 | - | let bonus = $t03352233657._4 | |
847 | - | let feeAmount = $t03352233657._3 | |
848 | - | let commonState = $t03352233657._2 | |
849 | - | let amountEstimated = $t03352233657._1 | |
850 | - | let amount = if (if ((minOutAmount > 0)) | |
851 | - | then (minOutAmount > amountEstimated) | |
852 | - | else false) | |
853 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
854 | - | else amountEstimated | |
855 | - | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
856 | - | if ((burnInv == burnInv)) | |
947 | + | let userAddress = i.caller | |
948 | + | let txId = i.transactionId | |
949 | + | let $t03854338696 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
950 | + | if (($t03854338696 == $t03854338696)) | |
857 | 951 | then { | |
858 | - | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
859 | - | let sendFee = if ((feeAmount > 0)) | |
860 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
861 | - | else nil | |
862 | - | $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount) | |
952 | + | let outInAmountAsset = $t03854338696._5 | |
953 | + | let bonus = $t03854338696._4 | |
954 | + | let feeAmount = $t03854338696._3 | |
955 | + | let commonState = $t03854338696._2 | |
956 | + | let amountEstimated = $t03854338696._1 | |
957 | + | let amount = if (if ((minOutAmount > 0)) | |
958 | + | then (minOutAmount > amountEstimated) | |
959 | + | else false) | |
960 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
961 | + | else amountEstimated | |
962 | + | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
963 | + | if ((burnInv == burnInv)) | |
964 | + | then { | |
965 | + | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
966 | + | let sendFee = if ((feeAmount > 0)) | |
967 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
968 | + | else nil | |
969 | + | let $t03919639443 = { | |
970 | + | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
971 | + | then 0 | |
972 | + | else feeAmount | |
973 | + | if (outInAmountAsset) | |
974 | + | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
975 | + | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
976 | + | } | |
977 | + | let amountAssetBalanceDelta = $t03919639443._1 | |
978 | + | let priceAssetBalanceDelta = $t03919639443._2 | |
979 | + | let $t03944639554 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
980 | + | let refreshKLpActions = $t03944639554._1 | |
981 | + | let updatedKLp = $t03944639554._2 | |
982 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
983 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
984 | + | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
985 | + | else throw("Strict value is not equal to itself.") | |
986 | + | } | |
987 | + | else throw("Strict value is not equal to itself.") | |
863 | 988 | } | |
864 | 989 | else throw("Strict value is not equal to itself.") | |
865 | 990 | } | |
866 | 991 | else throw("Strict value is not equal to itself.") | |
867 | 992 | } | |
868 | 993 | else throw("Strict value is not equal to itself.") | |
869 | 994 | } | |
870 | 995 | ||
871 | 996 | ||
872 | 997 | ||
873 | 998 | @Callable(i) | |
874 | 999 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
875 | - | let $t03429234430 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
876 | - | let amountEstimated = $t03429234430._1 | |
877 | - | let commonState = $t03429234430._2 | |
878 | - | let feeAmount = $t03429234430._3 | |
879 | - | let bonus = $t03429234430._4 | |
1000 | + | let $t03981139967 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
1001 | + | let amountEstimated = $t03981139967._1 | |
1002 | + | let commonState = $t03981139967._2 | |
1003 | + | let feeAmount = $t03981139967._3 | |
1004 | + | let bonus = $t03981139967._4 | |
1005 | + | let outInAmountAsset = $t03981139967._5 | |
880 | 1006 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
881 | 1007 | } | |
882 | 1008 | ||
883 | 1009 | ||
884 | 1010 | ||
885 | 1011 | @Callable(i) | |
886 | 1012 | func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = { | |
887 | 1013 | let isPoolOneTokenOperationsDisabled = { | |
888 | 1014 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
889 | 1015 | if ($isInstanceOf(@, "Boolean")) | |
890 | 1016 | then @ | |
891 | 1017 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
892 | 1018 | } | |
893 | 1019 | let isGetDisabled = if (if (isGlobalShutdown()) | |
894 | 1020 | then true | |
895 | 1021 | else (cfgPoolStatus == PoolShutdown)) | |
896 | 1022 | then true | |
897 | 1023 | else isPoolOneTokenOperationsDisabled | |
898 | 1024 | let checks = [if (if (!(isGetDisabled)) | |
899 | 1025 | then true | |
900 | 1026 | else isManager(i)) | |
901 | 1027 | then true | |
902 | 1028 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
903 | 1029 | then true | |
904 | 1030 | else throwErr("no payments are expected")] | |
905 | 1031 | if ((checks == checks)) | |
906 | 1032 | then { | |
907 | 1033 | let outAssetId = parseAssetId(outAssetIdStr) | |
908 | 1034 | let userAddress = i.caller | |
909 | 1035 | let txId = i.transactionId | |
910 | - | let | |
911 | - | if (( | |
1036 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1037 | + | if ((currentKLp == currentKLp)) | |
912 | 1038 | then { | |
913 | - | let | |
914 | - | if (( | |
1039 | + | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1040 | + | if ((unstakeInv == unstakeInv)) | |
915 | 1041 | then { | |
916 | - | let bonus = $t03525535388._4 | |
917 | - | let feeAmount = $t03525535388._3 | |
918 | - | let commonState = $t03525535388._2 | |
919 | - | let amountEstimated = $t03525535388._1 | |
920 | - | let amount = if (if ((minOutAmount > 0)) | |
921 | - | then (minOutAmount > amountEstimated) | |
922 | - | else false) | |
923 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
924 | - | else amountEstimated | |
925 | - | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
926 | - | if ((burnInv == burnInv)) | |
1042 | + | let $t04087241023 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
1043 | + | if (($t04087241023 == $t04087241023)) | |
927 | 1044 | then { | |
928 | - | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
929 | - | let sendFee = if ((feeAmount > 0)) | |
930 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
931 | - | else nil | |
932 | - | $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount) | |
1045 | + | let outInAmountAsset = $t04087241023._5 | |
1046 | + | let bonus = $t04087241023._4 | |
1047 | + | let feeAmount = $t04087241023._3 | |
1048 | + | let commonState = $t04087241023._2 | |
1049 | + | let amountEstimated = $t04087241023._1 | |
1050 | + | let amount = if (if ((minOutAmount > 0)) | |
1051 | + | then (minOutAmount > amountEstimated) | |
1052 | + | else false) | |
1053 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1054 | + | else amountEstimated | |
1055 | + | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1056 | + | if ((burnInv == burnInv)) | |
1057 | + | then { | |
1058 | + | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
1059 | + | let sendFee = if ((feeAmount > 0)) | |
1060 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1061 | + | else nil | |
1062 | + | let $t04151841765 = { | |
1063 | + | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1064 | + | then 0 | |
1065 | + | else feeAmount | |
1066 | + | if (outInAmountAsset) | |
1067 | + | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1068 | + | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1069 | + | } | |
1070 | + | let amountAssetBalanceDelta = $t04151841765._1 | |
1071 | + | let priceAssetBalanceDelta = $t04151841765._2 | |
1072 | + | let $t04176841876 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1073 | + | let refreshKLpActions = $t04176841876._1 | |
1074 | + | let updatedKLp = $t04176841876._2 | |
1075 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1076 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1077 | + | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1078 | + | else throw("Strict value is not equal to itself.") | |
1079 | + | } | |
1080 | + | else throw("Strict value is not equal to itself.") | |
933 | 1081 | } | |
934 | 1082 | else throw("Strict value is not equal to itself.") | |
935 | 1083 | } | |
936 | 1084 | else throw("Strict value is not equal to itself.") | |
937 | 1085 | } | |
938 | 1086 | else throw("Strict value is not equal to itself.") | |
939 | 1087 | } | |
940 | 1088 | else throw("Strict value is not equal to itself.") | |
941 | 1089 | } | |
942 | 1090 | ||
943 | 1091 | ||
944 | 1092 | ||
945 | 1093 | @Callable(i) | |
946 | 1094 | func get () = { | |
947 | 1095 | let res = commonGet(i) | |
948 | 1096 | let outAmtAmt = res._1 | |
949 | 1097 | let outPrAmt = res._2 | |
950 | 1098 | let pmtAmt = res._3 | |
951 | 1099 | let pmtAssetId = res._4 | |
952 | 1100 | let state = res._5 | |
953 | - | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
954 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
955 | - | then state | |
1101 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1102 | + | if ((currentKLp == currentKLp)) | |
1103 | + | then { | |
1104 | + | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1105 | + | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1106 | + | then { | |
1107 | + | let $t04282242904 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1108 | + | let refreshKLpActions = $t04282242904._1 | |
1109 | + | let updatedKLp = $t04282242904._2 | |
1110 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1111 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1112 | + | then (state ++ refreshKLpActions) | |
1113 | + | else throw("Strict value is not equal to itself.") | |
1114 | + | } | |
1115 | + | else throw("Strict value is not equal to itself.") | |
1116 | + | } | |
956 | 1117 | else throw("Strict value is not equal to itself.") | |
957 | 1118 | } | |
958 | 1119 | ||
959 | 1120 | ||
960 | 1121 | ||
961 | 1122 | @Callable(i) | |
962 | 1123 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
963 | 1124 | let res = commonGet(i) | |
964 | 1125 | let outAmAmt = res._1 | |
965 | 1126 | let outPrAmt = res._2 | |
966 | 1127 | let pmtAmt = res._3 | |
967 | 1128 | let pmtAssetId = res._4 | |
968 | 1129 | let state = res._5 | |
969 | 1130 | if ((noLessThenAmtAsset > outAmAmt)) | |
970 | 1131 | then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
971 | 1132 | else if ((noLessThenPriceAsset > outPrAmt)) | |
972 | 1133 | then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
973 | 1134 | else { | |
974 | - | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
975 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
976 | - | then state | |
1135 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1136 | + | if ((currentKLp == currentKLp)) | |
1137 | + | then { | |
1138 | + | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1139 | + | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1140 | + | then { | |
1141 | + | let $t04385343934 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1142 | + | let refreshKLpActions = $t04385343934._1 | |
1143 | + | let updatedKLp = $t04385343934._2 | |
1144 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1145 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1146 | + | then (state ++ refreshKLpActions) | |
1147 | + | else throw("Strict value is not equal to itself.") | |
1148 | + | } | |
1149 | + | else throw("Strict value is not equal to itself.") | |
1150 | + | } | |
977 | 1151 | else throw("Strict value is not equal to itself.") | |
978 | 1152 | } | |
979 | 1153 | } | |
980 | 1154 | ||
981 | 1155 | ||
982 | 1156 | ||
983 | 1157 | @Callable(i) | |
984 | 1158 | func unstakeAndGet (amount) = { | |
985 | 1159 | let checkPayments = if ((size(i.payments) != 0)) | |
986 | 1160 | then throw("No payments are expected") | |
987 | 1161 | else true | |
988 | 1162 | if ((checkPayments == checkPayments)) | |
989 | 1163 | then { | |
990 | 1164 | let cfg = getPoolConfig() | |
991 | 1165 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
992 | - | let | |
993 | - | if (( | |
1166 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1167 | + | if ((currentKLp == currentKLp)) | |
994 | 1168 | then { | |
995 | - | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
996 | - | let poolStatus = parseIntValue(res._9) | |
997 | - | let state = res._10 | |
998 | - | let checkPoolStatus = if (if (isGlobalShutdown()) | |
999 | - | then true | |
1000 | - | else (poolStatus == PoolShutdown)) | |
1001 | - | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
1002 | - | else true | |
1003 | - | if ((checkPoolStatus == checkPoolStatus)) | |
1169 | + | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1170 | + | if ((unstakeInv == unstakeInv)) | |
1004 | 1171 | then { | |
1005 | - | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1006 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1007 | - | then state | |
1172 | + | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1173 | + | let outAmAmt = res._1 | |
1174 | + | let outPrAmt = res._2 | |
1175 | + | let poolStatus = parseIntValue(res._9) | |
1176 | + | let state = res._10 | |
1177 | + | let checkPoolStatus = if (if (isGlobalShutdown()) | |
1178 | + | then true | |
1179 | + | else (poolStatus == PoolShutdown)) | |
1180 | + | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
1181 | + | else true | |
1182 | + | if ((checkPoolStatus == checkPoolStatus)) | |
1183 | + | then { | |
1184 | + | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1185 | + | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1186 | + | then { | |
1187 | + | let $t04506045141 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1188 | + | let refreshKLpActions = $t04506045141._1 | |
1189 | + | let updatedKLp = $t04506045141._2 | |
1190 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1191 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1192 | + | then (state ++ refreshKLpActions) | |
1193 | + | else throw("Strict value is not equal to itself.") | |
1194 | + | } | |
1195 | + | else throw("Strict value is not equal to itself.") | |
1196 | + | } | |
1008 | 1197 | else throw("Strict value is not equal to itself.") | |
1009 | 1198 | } | |
1010 | 1199 | else throw("Strict value is not equal to itself.") | |
1011 | 1200 | } | |
1012 | 1201 | else throw("Strict value is not equal to itself.") | |
1013 | 1202 | } | |
1014 | 1203 | else throw("Strict value is not equal to itself.") | |
1015 | 1204 | } | |
1016 | 1205 | ||
1017 | 1206 | ||
1018 | 1207 | ||
1019 | 1208 | @Callable(i) | |
1020 | 1209 | func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = { | |
1021 | 1210 | let isGetDisabled = if (isGlobalShutdown()) | |
1022 | 1211 | then true | |
1023 | 1212 | else (cfgPoolStatus == PoolShutdown) | |
1024 | 1213 | let checks = [if (!(isGetDisabled)) | |
1025 | 1214 | then true | |
1026 | 1215 | else throw("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1027 | 1216 | then true | |
1028 | 1217 | else throw("no payments are expected")] | |
1029 | 1218 | if ((checks == checks)) | |
1030 | 1219 | then { | |
1031 | - | let | |
1032 | - | if (( | |
1220 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1221 | + | if ((currentKLp == currentKLp)) | |
1033 | 1222 | then { | |
1034 | - | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1035 | - | let outAmAmt = res._1 | |
1036 | - | let outPrAmt = res._2 | |
1037 | - | let state = res._10 | |
1038 | - | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1039 | - | then true | |
1040 | - | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1041 | - | then true | |
1042 | - | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1043 | - | if ((checkAmounts == checkAmounts)) | |
1223 | + | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1224 | + | if ((unstakeInv == unstakeInv)) | |
1044 | 1225 | then { | |
1045 | - | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1046 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1047 | - | then state | |
1226 | + | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1227 | + | let outAmAmt = res._1 | |
1228 | + | let outPrAmt = res._2 | |
1229 | + | let state = res._10 | |
1230 | + | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1231 | + | then true | |
1232 | + | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1233 | + | then true | |
1234 | + | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1235 | + | if ((checkAmounts == checkAmounts)) | |
1236 | + | then { | |
1237 | + | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1238 | + | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1239 | + | then { | |
1240 | + | let $t04643646517 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1241 | + | let refreshKLpActions = $t04643646517._1 | |
1242 | + | let updatedKLp = $t04643646517._2 | |
1243 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1244 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1245 | + | then (state ++ refreshKLpActions) | |
1246 | + | else throw("Strict value is not equal to itself.") | |
1247 | + | } | |
1248 | + | else throw("Strict value is not equal to itself.") | |
1249 | + | } | |
1048 | 1250 | else throw("Strict value is not equal to itself.") | |
1049 | 1251 | } | |
1050 | 1252 | else throw("Strict value is not equal to itself.") | |
1051 | 1253 | } | |
1052 | 1254 | else throw("Strict value is not equal to itself.") | |
1053 | 1255 | } | |
1054 | 1256 | else throw("Strict value is not equal to itself.") | |
1055 | 1257 | } | |
1056 | 1258 | ||
1057 | 1259 | ||
1058 | 1260 | ||
1059 | 1261 | @Callable(i) | |
1060 | 1262 | func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract))) | |
1061 | 1263 | then throw("permissions denied") | |
1062 | 1264 | else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success") | |
1265 | + | ||
1266 | + | ||
1267 | + | ||
1268 | + | @Callable(i) | |
1269 | + | func refreshKLp () = { | |
1270 | + | let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0) | |
1271 | + | let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay)) | |
1272 | + | then unit | |
1273 | + | else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1274 | + | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1275 | + | then { | |
1276 | + | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
1277 | + | let $t04770447768 = refreshKLpInternal(0, 0, 0) | |
1278 | + | let kLpUpdateActions = $t04770447768._1 | |
1279 | + | let updatedKLp = $t04770447768._2 | |
1280 | + | let actions = if ((kLp != updatedKLp)) | |
1281 | + | then kLpUpdateActions | |
1282 | + | else throwErr("nothing to refresh") | |
1283 | + | $Tuple2(actions, toString(updatedKLp)) | |
1284 | + | } | |
1285 | + | else throw("Strict value is not equal to itself.") | |
1286 | + | } | |
1063 | 1287 | ||
1064 | 1288 | ||
1065 | 1289 | ||
1066 | 1290 | @Callable(i) | |
1067 | 1291 | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig()) | |
1068 | 1292 | ||
1069 | 1293 | ||
1070 | 1294 | ||
1071 | 1295 | @Callable(i) | |
1072 | 1296 | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
1073 | 1297 | ||
1074 | 1298 | ||
1075 | 1299 | ||
1076 | 1300 | @Callable(i) | |
1077 | 1301 | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
1078 | 1302 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
1079 | 1303 | $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])]) | |
1080 | 1304 | } | |
1081 | 1305 | ||
1082 | 1306 | ||
1083 | 1307 | ||
1084 | 1308 | @Callable(i) | |
1085 | 1309 | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult))) | |
1086 | 1310 | ||
1087 | 1311 | ||
1088 | 1312 | ||
1089 | 1313 | @Callable(i) | |
1090 | 1314 | func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult)) | |
1091 | 1315 | ||
1092 | 1316 | ||
1093 | 1317 | ||
1094 | 1318 | @Callable(i) | |
1095 | 1319 | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
1096 | 1320 | ||
1097 | 1321 | ||
1098 | 1322 | ||
1099 | 1323 | @Callable(i) | |
1100 | 1324 | func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp)) | |
1101 | 1325 | ||
1102 | 1326 | ||
1103 | 1327 | ||
1104 | 1328 | @Callable(i) | |
1105 | 1329 | func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
1106 | 1330 | let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress)) | |
1107 | 1331 | $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10)) | |
1108 | 1332 | } | |
1109 | 1333 | ||
1110 | 1334 | ||
1111 | 1335 | ||
1112 | 1336 | @Callable(i) | |
1113 | 1337 | func statsREADONLY () = { | |
1114 | 1338 | let cfg = getPoolConfig() | |
1115 | 1339 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1116 | 1340 | let amtAssetId = cfg[idxAmtAssetId] | |
1117 | 1341 | let priceAssetId = cfg[idxPriceAssetId] | |
1118 | 1342 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
1119 | 1343 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
1120 | 1344 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1121 | 1345 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1122 | 1346 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1123 | 1347 | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
1124 | 1348 | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
1125 | 1349 | let pricesList = if ((poolLPBalance == 0)) | |
1126 | 1350 | then [zeroBigInt, zeroBigInt, zeroBigInt] | |
1127 | 1351 | else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance) | |
1128 | 1352 | let curPrice = 0 | |
1129 | 1353 | let lpAmtAssetShare = fromX18(pricesList[1], scale8) | |
1130 | 1354 | let lpPriceAssetShare = fromX18(pricesList[2], scale8) | |
1131 | 1355 | let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this)))) | |
1132 | 1356 | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d", toString(accAmtAssetBalance), toString(accPriceAssetBalance), toString(poolLPBalance), toString(curPrice), toString(lpAmtAssetShare), toString(lpPriceAssetShare), toString(poolWeight)], SEP)) | |
1133 | 1357 | } | |
1134 | 1358 | ||
1135 | 1359 | ||
1136 | 1360 | ||
1137 | 1361 | @Callable(i) | |
1138 | 1362 | func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = { | |
1139 | 1363 | let cfg = getPoolConfig() | |
1140 | 1364 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1141 | 1365 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1142 | 1366 | let amAssetId = fromBase58String(amAssetIdStr) | |
1143 | 1367 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1144 | 1368 | let prAssetId = fromBase58String(prAssetIdStr) | |
1145 | 1369 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1146 | 1370 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1147 | 1371 | let poolStatus = cfg[idxPoolStatus] | |
1148 | 1372 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1149 | 1373 | let accAmtAssetBalance = getAccBalance(amAssetIdStr) | |
1150 | 1374 | let accPriceAssetBalance = getAccBalance(prAssetIdStr) | |
1151 | 1375 | let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm) | |
1152 | 1376 | let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm) | |
1153 | 1377 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1154 | 1378 | then zeroBigInt | |
1155 | 1379 | else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
1156 | 1380 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
1157 | 1381 | let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
1158 | 1382 | let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm) | |
1159 | 1383 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1160 | 1384 | let calcLpAmt = estPut._1 | |
1161 | 1385 | let curPriceCalc = estPut._3 | |
1162 | 1386 | let amBalance = estPut._4 | |
1163 | 1387 | let prBalance = estPut._5 | |
1164 | 1388 | let lpEmission = estPut._6 | |
1165 | 1389 | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d%d", toString(calcLpAmt), toString(fromX18(curPriceX18, scale8)), toString(amBalance), toString(prBalance), toString(lpEmission), poolStatus, toString(inAmAssetAmt), toString(inPrAssetAmt)], SEP)) | |
1166 | 1390 | } | |
1167 | 1391 | ||
1168 | 1392 | ||
1169 | 1393 | ||
1170 | 1394 | @Callable(i) | |
1171 | 1395 | func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = { | |
1172 | 1396 | let cfg = getPoolConfig() | |
1173 | 1397 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1174 | 1398 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1175 | 1399 | let amAssetId = fromBase58String(amAssetIdStr) | |
1176 | 1400 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1177 | 1401 | let prAssetId = fromBase58String(prAssetIdStr) | |
1178 | 1402 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1179 | 1403 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1180 | 1404 | let poolStatus = cfg[idxPoolStatus] | |
1181 | 1405 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1182 | 1406 | let amBalanceRaw = getAccBalance(amAssetIdStr) | |
1183 | 1407 | let prBalanceRaw = getAccBalance(prAssetIdStr) | |
1184 | 1408 | let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm) | |
1185 | 1409 | let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm) | |
1186 | 1410 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1187 | 1411 | then zeroBigInt | |
1188 | 1412 | else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18) | |
1189 | 1413 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
1190 | 1414 | let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
1191 | 1415 | let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm) | |
1192 | 1416 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1193 | 1417 | let calcLpAmt = estPut._1 | |
1194 | 1418 | let curPriceCalc = estPut._3 | |
1195 | 1419 | let amBalance = estPut._4 | |
1196 | 1420 | let prBalance = estPut._5 | |
1197 | 1421 | let lpEmission = estPut._6 | |
1198 | 1422 | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d%d", toString(calcLpAmt), toString(fromX18(curPriceX18, scale8)), toString(amBalance), toString(prBalance), toString(lpEmission), poolStatus, toString(inAmAssetAmt), toString(inPrAssetAmt)], SEP)) | |
1199 | 1423 | } | |
1200 | 1424 | ||
1201 | 1425 | ||
1202 | 1426 | ||
1203 | 1427 | @Callable(i) | |
1204 | 1428 | func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = { | |
1205 | 1429 | let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this) | |
1206 | 1430 | let outAmAmt = res._1 | |
1207 | 1431 | let outPrAmt = res._2 | |
1208 | 1432 | let amBalance = res._5 | |
1209 | 1433 | let prBalance = res._6 | |
1210 | 1434 | let lpEmission = res._7 | |
1211 | 1435 | let curPrice = res._8 | |
1212 | 1436 | let poolStatus = parseIntValue(res._9) | |
1213 | 1437 | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d", toString(outAmAmt), toString(outPrAmt), toString(amBalance), toString(prBalance), toString(lpEmission), toString(curPrice), toString(poolStatus)], SEP)) | |
1214 | 1438 | } | |
1215 | 1439 | ||
1216 | 1440 | ||
1217 | 1441 | @Verifier(tx) | |
1218 | 1442 | func verify () = { | |
1219 | 1443 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
1220 | 1444 | case pk: ByteVector => | |
1221 | 1445 | pk | |
1222 | 1446 | case _: Unit => | |
1223 | 1447 | tx.senderPublicKey | |
1224 | 1448 | case _ => | |
1225 | 1449 | throw("Match error") | |
1226 | 1450 | } | |
1227 | 1451 | match tx { | |
1228 | 1452 | case order: Order => | |
1229 | 1453 | let matcherPub = getMatcherPubOrFail() | |
1230 | 1454 | let orderValid = validateMatcherOrderAllowed(order) | |
1231 | 1455 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1232 | 1456 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1233 | 1457 | if (if (if (orderValid) | |
1234 | 1458 | then senderValid | |
1235 | 1459 | else false) | |
1236 | 1460 | then matcherValid | |
1237 | 1461 | else false) | |
1238 | 1462 | then true | |
1239 | 1463 | else throwOrderError(orderValid, senderValid, matcherValid) | |
1240 | 1464 | case s: SetScriptTransaction => | |
1241 | 1465 | let newHash = blake2b256(value(s.script)) | |
1242 | 1466 | let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash()))) | |
1243 | 1467 | let currentHash = scriptHash(this) | |
1244 | 1468 | if (if ((allowedHash == newHash)) | |
1245 | 1469 | then (currentHash != newHash) | |
1246 | 1470 | else false) | |
1247 | 1471 | then true | |
1248 | 1472 | else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1249 | 1473 | case _ => | |
1250 | 1474 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1251 | 1475 | } | |
1252 | 1476 | } | |
1253 | 1477 |
github/deemru/w8io/026f985 179.20 ms ◑