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