tx · HSfdGnuCToxuFZSFt8BWwPYjGpb5y5kG6uy4KZt4UeFZ 3N6wAa7PMFZJu4Zrmp3avXmMnRTrRpMM9Lh: -0.04300000 Waves 2023.04.03 15:46 [2518409] smart account 3N6wAa7PMFZJu4Zrmp3avXmMnRTrRpMM9Lh > SELF 0.00000000 Waves
{ "type": 13, "id": "HSfdGnuCToxuFZSFt8BWwPYjGpb5y5kG6uy4KZt4UeFZ", "fee": 4300000, "feeAssetId": null, "timestamp": 1680525988395, "version": 2, "chainId": 84, "sender": "3N6wAa7PMFZJu4Zrmp3avXmMnRTrRpMM9Lh", "senderPublicKey": "Cr8D7eozSzJh7XHsYTjBinPpo3SS83BrCGiBAJsjGxBo", "proofs": [ "4x9yxWpo2ST9aS1etnVqSAJsNwdbRZVkCmzHbRv4rTLjXbxGiDECBdBwZmW2JtwQansu9EJ5ftBRhdoYYkgL3wdd" ], "script": "base64:BgLsNggCEgASBQoDAQQBEgcKBQEEAQgBEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgQKAggBEgQKAggBEgQKAggBEgUKAwEIARIAEgQKAgEBEgMKAQESBQoDAQEBEgQKAggIEgASABIDCgEIEgUKAwEBARIECgIBARIECgIIARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCBIAEgMKAQESAwoBARIECgIIASIKbFBkZWNpbWFscyIGc2NhbGU4IgxzY2FsZThCaWdJbnQiB3NjYWxlMTgiCnplcm9CaWdJbnQiBGJpZzAiBGJpZzEiBGJpZzIiC3dhdmVzU3RyaW5nIgNTRVAiClBvb2xBY3RpdmUiD1Bvb2xQdXREaXNhYmxlZCITUG9vbE1hdGNoZXJEaXNhYmxlZCIMUG9vbFNodXRkb3duIg5pZHhQb29sQWRkcmVzcyINaWR4UG9vbFN0YXR1cyIQaWR4UG9vbExQQXNzZXRJZCINaWR4QW10QXNzZXRJZCIPaWR4UHJpY2VBc3NldElkIg5pZHhBbXRBc3NldERjbSIQaWR4UHJpY2VBc3NldERjbSIOaWR4SUFt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WkBAmlqAAQCaWsEAmJWCQECZlYAAwkAAQIFAmJWAgpCeXRlVmVjdG9yBAJmWgUCYlYFAmZaAwkAAQIFAmJWAgRVbml0CAUCaWkPc2VuZGVyUHVibGljS2V5CQACAQILTWF0Y2ggZXJyb3IEAmJWBQJpaQMJAAECBQJiVgIFT3JkZXIEAmV5BQJiVgQCaWwJAQJiZAAEAmltCQECZXgBBQJleQQCYUsIBQJpbQJfMQQCYUwIBQJpbQJfMgQCYU0JAPQDAwgFAmV5CWJvZHlCeXRlcwkAkQMCCAUCZXkGcHJvb2ZzAAAIBQJleQ9zZW5kZXJQdWJsaWNLZXkEAmFOCQD0AwMIBQJleQlib2R5Qnl0ZXMJAJEDAggFAmV5BnByb29mcwABBQJpbAMDAwUCYUsFAmFNBwUCYU4HBgkBAmFKBAUCYUsFAmFMBQJhTQUCYU4DCQABAgUCYlYCFFNldFNjcmlwdFRyYW5zYWN0aW9uBAJmVwUCYlYDCQD0AwMIBQJpaQlib2R5Qnl0ZXMJAJEDAggFAmlpBnByb29mcwAABQJpawYEAmluCQD2AwEJAQV2YWx1ZQEIBQJmVwZzY3JpcHQEAmlvCQDbBAEJAQV2YWx1ZQEJAJ0IAgUCYVYJAQJhSAAEAmlwCQDxBwEFBHRoaXMDCQAAAgUCaW8FAmluCQECIT0CBQJpcAUCaW4HCQD0AwMIBQJpaQlib2R5Qnl0ZXMJAJEDAggFAmlpBnByb29mcwAABQJpa8WmiLQ=", "height": 2518409, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9kcVgc9W2TN2smasocKHfHKdzLeCfb69WFd3XB4NyvVV Next: AW4YZ4n3KvY1AESN4Bn2s1bqSuz6BoA7oyMXT9XohiUK Diff:
Old | New | Differences | |
---|---|---|---|
130 | 130 | ||
131 | 131 | let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault) | |
132 | 132 | ||
133 | + | func keySWavesAssetId () = "%s__sWavesAssetId" | |
134 | + | ||
135 | + | ||
136 | + | func keySWavesProxyAddress () = "%s__sWavesProxyAddress" | |
137 | + | ||
138 | + | ||
139 | + | func keyAdditionalBalance (assetId) = makeString(["%s%s", "additionalBalance", assetId], SEP) | |
140 | + | ||
141 | + | ||
142 | + | func keyStakingAssetBalance (assetId) = makeString(["%s%s", "stakingAssetBalance", assetId], SEP) | |
143 | + | ||
144 | + | ||
145 | + | func getAdditionalBalance (assetId) = valueOrElse(getInteger(this, keyAdditionalBalance(assetId)), 0) | |
146 | + | ||
147 | + | ||
148 | + | func getStakingAssetBalance (assetId) = valueOrElse(getInteger(this, keyStakingAssetBalance(assetId)), 0) | |
149 | + | ||
150 | + | ||
133 | 151 | func keyFactoryConfig () = "%s__factoryConfig" | |
134 | 152 | ||
135 | 153 | ||
189 | 207 | else throw(($getType(@) + " couldn't be cast to Int")) | |
190 | 208 | } | |
191 | 209 | ||
210 | + | func sWavesId () = getStringOrFail(factoryContract, keySWavesAssetId()) | |
211 | + | ||
212 | + | ||
213 | + | func sWavesProxy () = getStringOrFail(factoryContract, keySWavesProxyAddress()) | |
214 | + | ||
215 | + | ||
192 | 216 | func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false) | |
193 | 217 | ||
194 | 218 | ||
219 | 243 | ||
220 | 244 | let poolConfigParsed = parsePoolConfig(getPoolConfig()) | |
221 | 245 | ||
222 | - | let $ | |
246 | + | let $t092129378 = poolConfigParsed | |
223 | 247 | ||
224 | - | let cfgPoolAddress = $ | |
248 | + | let cfgPoolAddress = $t092129378._1 | |
225 | 249 | ||
226 | - | let cfgPoolStatus = $ | |
250 | + | let cfgPoolStatus = $t092129378._2 | |
227 | 251 | ||
228 | - | let cfgLpAssetId = $ | |
252 | + | let cfgLpAssetId = $t092129378._3 | |
229 | 253 | ||
230 | - | let cfgAmountAssetId = $ | |
254 | + | let cfgAmountAssetId = $t092129378._4 | |
231 | 255 | ||
232 | - | let cfgPriceAssetId = $ | |
256 | + | let cfgPriceAssetId = $t092129378._5 | |
233 | 257 | ||
234 | - | let cfgAmountAssetDecimals = $ | |
258 | + | let cfgAmountAssetDecimals = $t092129378._6 | |
235 | 259 | ||
236 | - | let cfgPriceAssetDecimals = $ | |
260 | + | let cfgPriceAssetDecimals = $t092129378._7 | |
237 | 261 | ||
238 | 262 | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
239 | 263 | ||
249 | 273 | ||
250 | 274 | ||
251 | 275 | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
252 | - | then wavesBalance(this).available | |
253 | - | else assetBalance(this, fromBase58String(assetId)) | |
276 | + | then (wavesBalance(this).available + getAdditionalBalance(assetId)) | |
277 | + | else if ((assetId == sWavesId())) | |
278 | + | then { | |
279 | + | let amtAsset = getStringOrFail(this, aa()) | |
280 | + | let priceAsset = getStringOrFail(this, pa()) | |
281 | + | if (if (if ((amtAsset == "WAVES")) | |
282 | + | then (priceAsset == sWavesId()) | |
283 | + | else false) | |
284 | + | then true | |
285 | + | else if ((priceAsset == "WAVES")) | |
286 | + | then (amtAsset == sWavesId()) | |
287 | + | else false) | |
288 | + | then assetBalance(this, fromBase58String(assetId)) | |
289 | + | else (assetBalance(this, fromBase58String(assetId)) + getStakingAssetBalance(assetId)) | |
290 | + | } | |
291 | + | else assetBalance(this, fromBase58String(assetId)) | |
254 | 292 | ||
255 | 293 | ||
256 | 294 | func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
257 | 295 | ||
258 | 296 | ||
259 | 297 | func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round) | |
298 | + | ||
299 | + | ||
300 | + | func getRate (proxy) = { | |
301 | + | let inv = invoke(proxy, "getRate", nil, nil) | |
302 | + | if ((inv == inv)) | |
303 | + | then match inv { | |
304 | + | case r: Int => | |
305 | + | r | |
306 | + | case _ => | |
307 | + | throwErr("proxy.getRate() unexpected value") | |
308 | + | } | |
309 | + | else throw("Strict value is not equal to itself.") | |
310 | + | } | |
311 | + | ||
312 | + | ||
313 | + | func deposit (assetId,amount,stakingAssetId,proxy) = { | |
314 | + | let currentAdditionalBalance = getAdditionalBalance(assetId) | |
315 | + | if ((currentAdditionalBalance == currentAdditionalBalance)) | |
316 | + | then { | |
317 | + | let currentStakingAssetBalance = getStakingAssetBalance(stakingAssetId) | |
318 | + | if ((currentStakingAssetBalance == currentStakingAssetBalance)) | |
319 | + | then { | |
320 | + | let asset = parseAssetId(assetId) | |
321 | + | if ((amount > 0)) | |
322 | + | then { | |
323 | + | let depositInvoke = invoke(proxy, "deposit", nil, [AttachedPayment(asset, amount)]) | |
324 | + | if ((depositInvoke == depositInvoke)) | |
325 | + | then match depositInvoke { | |
326 | + | case receivedStakingAsset: Int => | |
327 | + | let newAdditionalBalance = (currentAdditionalBalance + amount) | |
328 | + | let newStakingAssetBalance = (currentStakingAssetBalance + receivedStakingAsset) | |
329 | + | [IntegerEntry(keyAdditionalBalance(assetId), newAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance)] | |
330 | + | case _ => | |
331 | + | nil | |
332 | + | } | |
333 | + | else throw("Strict value is not equal to itself.") | |
334 | + | } | |
335 | + | else nil | |
336 | + | } | |
337 | + | else throw("Strict value is not equal to itself.") | |
338 | + | } | |
339 | + | else throw("Strict value is not equal to itself.") | |
340 | + | } | |
341 | + | ||
342 | + | ||
343 | + | func withdraw (assetId,amount,stakingAssetId,proxy,proxyRateMul) = { | |
344 | + | let currentAdditionalBalance = getAdditionalBalance(assetId) | |
345 | + | if ((currentAdditionalBalance == currentAdditionalBalance)) | |
346 | + | then { | |
347 | + | let currentStakingAssetBalance = getStakingAssetBalance(stakingAssetId) | |
348 | + | if ((currentStakingAssetBalance == currentStakingAssetBalance)) | |
349 | + | then { | |
350 | + | let currentProxyRate = getRate(proxy) | |
351 | + | if ((currentProxyRate == currentProxyRate)) | |
352 | + | then { | |
353 | + | let stakingAsset = parseAssetId(stakingAssetId) | |
354 | + | let sendStakingAssetAmount = fraction(proxyRateMul, amount, currentProxyRate) | |
355 | + | if ((sendStakingAssetAmount > 0)) | |
356 | + | then { | |
357 | + | let withdrawInvoke = invoke(proxy, "withdraw", nil, [AttachedPayment(stakingAsset, sendStakingAssetAmount)]) | |
358 | + | if ((withdrawInvoke == withdrawInvoke)) | |
359 | + | then match withdrawInvoke { | |
360 | + | case receivedAssets: Int => | |
361 | + | let newAdditionalBalance = (currentAdditionalBalance - receivedAssets) | |
362 | + | let newStakingAssetBalance = (currentStakingAssetBalance - sendStakingAssetAmount) | |
363 | + | [IntegerEntry(keyAdditionalBalance(assetId), newAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance)] | |
364 | + | case _ => | |
365 | + | nil | |
366 | + | } | |
367 | + | else throw("Strict value is not equal to itself.") | |
368 | + | } | |
369 | + | else nil | |
370 | + | } | |
371 | + | else throw("Strict value is not equal to itself.") | |
372 | + | } | |
373 | + | else throw("Strict value is not equal to itself.") | |
374 | + | } | |
375 | + | else throw("Strict value is not equal to itself.") | |
376 | + | } | |
377 | + | ||
378 | + | ||
379 | + | func getLeaseProxyConfig (assetId) = invoke(factoryContract, "getPoolLeaseConfigREADONLY", [toString(this), assetId], nil) | |
380 | + | ||
381 | + | ||
382 | + | func rebalanceInternal (targetRatio,assetId,stakingAssetId,minBalance,proxy,proxyRateMul) = { | |
383 | + | let currentAdditionalBalance = getAdditionalBalance(assetId) | |
384 | + | if ((currentAdditionalBalance == currentAdditionalBalance)) | |
385 | + | then { | |
386 | + | let currentStakingAssetBalance = getStakingAssetBalance(stakingAssetId) | |
387 | + | if ((currentStakingAssetBalance == currentStakingAssetBalance)) | |
388 | + | then { | |
389 | + | let availableBalance = match parseAssetId(assetId) { | |
390 | + | case b: ByteVector => | |
391 | + | assetBalance(this, b) | |
392 | + | case u: Unit => | |
393 | + | wavesBalance(this).available | |
394 | + | case _ => | |
395 | + | throw("Match error") | |
396 | + | } | |
397 | + | if ((availableBalance == availableBalance)) | |
398 | + | then { | |
399 | + | let wholeBalance = max([0, ((availableBalance + currentAdditionalBalance) - minBalance)]) | |
400 | + | let targetAdditionalBalance = fraction(targetRatio, wholeBalance, 100) | |
401 | + | let diff = (currentAdditionalBalance - targetAdditionalBalance) | |
402 | + | if ((diff == 0)) | |
403 | + | then nil | |
404 | + | else if ((0 > diff)) | |
405 | + | then { | |
406 | + | let sendAssetAmount = -(diff) | |
407 | + | deposit(assetId, sendAssetAmount, stakingAssetId, proxy) | |
408 | + | } | |
409 | + | else { | |
410 | + | let getAssetAmount = diff | |
411 | + | withdraw(assetId, getAssetAmount, stakingAssetId, proxy, proxyRateMul) | |
412 | + | } | |
413 | + | } | |
414 | + | else throw("Strict value is not equal to itself.") | |
415 | + | } | |
416 | + | else throw("Strict value is not equal to itself.") | |
417 | + | } | |
418 | + | else throw("Strict value is not equal to itself.") | |
419 | + | } | |
420 | + | ||
421 | + | ||
422 | + | func rebalanceAsset (assetId) = match getLeaseProxyConfig(assetId) { | |
423 | + | case a: (Boolean, Int, Int, String, String, Int, String) => | |
424 | + | let $t01551515624 = a | |
425 | + | let isLeasable = $t01551515624._1 | |
426 | + | let leasedRatio = $t01551515624._2 | |
427 | + | let minBalance = $t01551515624._3 | |
428 | + | let proxyAddress = $t01551515624._4 | |
429 | + | let proxyAssetId = $t01551515624._5 | |
430 | + | let proxyRateMul = $t01551515624._6 | |
431 | + | let stakingProfitAddress = $t01551515624._7 | |
432 | + | if (isLeasable) | |
433 | + | then rebalanceInternal(leasedRatio, assetId, proxyAssetId, minBalance, addressFromStringValue(proxyAddress), proxyRateMul) | |
434 | + | else nil | |
435 | + | case _ => | |
436 | + | throwErr((("[" + assetId) + "] Rebalance error")) | |
437 | + | } | |
260 | 438 | ||
261 | 439 | ||
262 | 440 | func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
438 | 616 | let priceAssetBalance = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
439 | 617 | let amountAssetAmount = order.amount | |
440 | 618 | let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR) | |
441 | - | let $ | |
619 | + | let $t02714527357 = if ((order.orderType == Buy)) | |
442 | 620 | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
443 | 621 | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
444 | - | let amountAssetBalanceDelta = $ | |
445 | - | let priceAssetBalanceDelta = $ | |
622 | + | let amountAssetBalanceDelta = $t02714527357._1 | |
623 | + | let priceAssetBalanceDelta = $t02714527357._2 | |
446 | 624 | if (if (if (isGlobalShutdown()) | |
447 | 625 | then true | |
448 | 626 | else (cfgPoolStatus == PoolMatcherDisabled)) | |
455 | 633 | then throw("Wrong order assets.") | |
456 | 634 | else { | |
457 | 635 | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
458 | - | let $ | |
459 | - | let unusedActions = $ | |
460 | - | let kLpNew = $ | |
636 | + | let $t02779727897 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
637 | + | let unusedActions = $t02779727897._1 | |
638 | + | let kLpNew = $t02779727897._2 | |
461 | 639 | let isOrderValid = (kLpNew >= kLp) | |
462 | 640 | let info = makeString(["kLp=", toString(kLp), " kLpNew=", toString(kLpNew), " amountAssetBalance=", toString(amountAssetBalance), " priceAssetBalance=", toString(priceAssetBalance), " amountAssetBalanceDelta=", toString(amountAssetBalanceDelta), " priceAssetBalanceDelta=", toString(priceAssetBalanceDelta), " height=", toString(height)], "") | |
463 | 641 | $Tuple2(isOrderValid, info) | |
536 | 714 | else if ((paymentAssetId == cfgPriceAssetId)) | |
537 | 715 | then false | |
538 | 716 | else throwErr("invalid asset") | |
539 | - | let $ | |
717 | + | let $t03101031303 = if (isEval) | |
540 | 718 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
541 | 719 | else if (paymentInAmountAsset) | |
542 | 720 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
543 | 721 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
544 | - | let amountBalanceOld = $ | |
545 | - | let priceBalanceOld = $ | |
546 | - | let $ | |
722 | + | let amountBalanceOld = $t03101031303._1 | |
723 | + | let priceBalanceOld = $t03101031303._2 | |
724 | + | let $t03130731456 = if (paymentInAmountAsset) | |
547 | 725 | then $Tuple2(paymentAmountRaw, 0) | |
548 | 726 | else $Tuple2(0, paymentAmountRaw) | |
549 | - | let amountAssetAmountRaw = $ | |
550 | - | let priceAssetAmountRaw = $ | |
727 | + | let amountAssetAmountRaw = $t03130731456._1 | |
728 | + | let priceAssetAmountRaw = $t03130731456._2 | |
551 | 729 | let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1 | |
552 | 730 | let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1 | |
553 | - | let $ | |
554 | - | let paymentAmount = $ | |
555 | - | let feeAmount = $ | |
731 | + | let $t03158831652 = takeFee(paymentAmountRaw, inFee) | |
732 | + | let paymentAmount = $t03158831652._1 | |
733 | + | let feeAmount = $t03158831652._2 | |
556 | 734 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
557 | 735 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
558 | 736 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
575 | 753 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
576 | 754 | let priceOld = fromX18(priceOldX18, scale8) | |
577 | 755 | let loss = { | |
578 | - | let $ | |
756 | + | let $t03333333500 = if (paymentInAmountAsset) | |
579 | 757 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
580 | 758 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
581 | - | let amount = $ | |
582 | - | let balance = $ | |
759 | + | let amount = $t03333333500._1 | |
760 | + | let balance = $t03333333500._2 | |
583 | 761 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
584 | 762 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
585 | 763 | } | |
619 | 797 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
620 | 798 | let redeemedBigInt = toBigInt(paymentAmount) | |
621 | 799 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
622 | - | let $ | |
623 | - | let totalAmount = $ | |
624 | - | let feeAmount = $ | |
625 | - | let $ | |
800 | + | let $t03557835634 = takeFee(amountRaw, outFee) | |
801 | + | let totalAmount = $t03557835634._1 | |
802 | + | let feeAmount = $t03557835634._2 | |
803 | + | let $t03563835864 = if (outInAmountAsset) | |
626 | 804 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
627 | 805 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
628 | - | let outAmAmount = $ | |
629 | - | let outPrAmount = $ | |
630 | - | let amBalanceNew = $ | |
631 | - | let prBalanceNew = $ | |
806 | + | let outAmAmount = $t03563835864._1 | |
807 | + | let outPrAmount = $t03563835864._2 | |
808 | + | let amBalanceNew = $t03563835864._3 | |
809 | + | let prBalanceNew = $t03563835864._4 | |
632 | 810 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
633 | 811 | let priceNew = fromX18(priceNewX18, scale8) | |
634 | 812 | let commonState = if (isEval) | |
694 | 872 | ||
695 | 873 | ||
696 | 874 | @Callable(i) | |
875 | + | func rebalance () = (rebalanceAsset(aa()) ++ rebalanceAsset(pa())) | |
876 | + | ||
877 | + | ||
878 | + | ||
879 | + | @Callable(i) | |
697 | 880 | func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse,feePoolAmount) = { | |
698 | - | let $ | |
881 | + | let $t03770438009 = if ((isReverse == false)) | |
699 | 882 | then { | |
700 | 883 | let assetOut = getStringOrFail(this, pa()) | |
701 | 884 | let assetIn = getStringOrFail(this, aa()) | |
706 | 889 | let assetIn = getStringOrFail(this, pa()) | |
707 | 890 | $Tuple2(assetOut, assetIn) | |
708 | 891 | } | |
709 | - | let assetOut = $ | |
710 | - | let assetIn = $ | |
892 | + | let assetOut = $t03770438009._1 | |
893 | + | let assetIn = $t03770438009._2 | |
711 | 894 | let poolAssetInBalance = getAccBalance(assetIn) | |
712 | 895 | let poolAssetOutBalance = getAccBalance(assetOut) | |
713 | 896 | let amountOut = fraction(poolAssetOutBalance, cleanAmountIn, (poolAssetInBalance + cleanAmountIn)) | |
757 | 940 | then true | |
758 | 941 | else throw("Exchange result is fewer coins than expected") | |
759 | 942 | if ((checkMin == checkMin)) | |
760 | - | then $Tuple2([ScriptTransfer(addressFromStringValue(addressTo), amountOut, parseAssetId(assetOut))], amountOut) | |
943 | + | then { | |
944 | + | let lsConf = match getLeaseProxyConfig(assetOut) { | |
945 | + | case a: (Boolean, Int, Int, String, String, Int, String) => | |
946 | + | a | |
947 | + | case _ => | |
948 | + | throw("error lease config") | |
949 | + | } | |
950 | + | let $t04001540129 = lsConf | |
951 | + | let isLeasable = $t04001540129._1 | |
952 | + | let leasedRatio = $t04001540129._2 | |
953 | + | let minBalance = $t04001540129._3 | |
954 | + | let proxyAddress = $t04001540129._4 | |
955 | + | let proxyAssetId = $t04001540129._5 | |
956 | + | let proxyRateMul = $t04001540129._6 | |
957 | + | let stakingProfitAddress = $t04001540129._7 | |
958 | + | let assetOnPool = assetBalance(this, fromBase58String(assetOut)) | |
959 | + | let amountOfProfit = if (if ((assetOut == "WAVES")) | |
960 | + | then (amountOut > assetOnPool) | |
961 | + | else false) | |
962 | + | then { | |
963 | + | let amountDiff = (amountOut - assetOnPool) | |
964 | + | let oldRatio = (getAdditionalBalance(assetOut) / getStakingAssetBalance(sWavesId())) | |
965 | + | let oldWavesRoughBalane = wavesBalance(this).available | |
966 | + | let wd = invoke(this, "withdraw", [assetOut, amountDiff, sWavesId(), sWavesProxy(), proxyRateMul], nil) | |
967 | + | if ((wd == wd)) | |
968 | + | then { | |
969 | + | let newWavesRoughBalane = wavesBalance(this).available | |
970 | + | let wavesDiff = (newWavesRoughBalane - oldWavesRoughBalane) | |
971 | + | (wavesDiff - amountDiff) | |
972 | + | } | |
973 | + | else throw("Strict value is not equal to itself.") | |
974 | + | } | |
975 | + | else 0 | |
976 | + | let reb = invoke(this, "rebalance", nil, nil) | |
977 | + | if ((reb == reb)) | |
978 | + | then $Tuple2([ScriptTransfer(addressFromStringValue(stakingProfitAddress), amountOfProfit, unit), ScriptTransfer(addressFromStringValue(addressTo), amountOut, parseAssetId(assetOut))], amountOut) | |
979 | + | else throw("Strict value is not equal to itself.") | |
980 | + | } | |
761 | 981 | else throw("Strict value is not equal to itself.") | |
762 | 982 | } | |
763 | 983 | else throw("Strict value is not equal to itself.") | |
848 | 1068 | else throw("Strict value is not equal to itself.") | |
849 | 1069 | } | |
850 | 1070 | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
851 | - | let $ | |
852 | - | if (($ | |
1071 | + | let $t04394044402 = refreshKLpInternal(0, 0, 0) | |
1072 | + | if (($t04394044402 == $t04394044402)) | |
853 | 1073 | then { | |
854 | - | let updatedKLp = $ | |
855 | - | let refreshKLpActions = $ | |
1074 | + | let updatedKLp = $t04394044402._2 | |
1075 | + | let refreshKLpActions = $t04394044402._1 | |
856 | 1076 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
857 | 1077 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
858 | 1078 | then ((state ++ lpTransfer) ++ refreshKLpActions) | |
884 | 1104 | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
885 | 1105 | if ((currentKLp == currentKLp)) | |
886 | 1106 | then { | |
887 | - | let $ | |
888 | - | let refreshKLpActions = $ | |
889 | - | let updatedKLp = $ | |
1107 | + | let $t04496445029 = refreshKLpInternal(0, 0, 0) | |
1108 | + | let refreshKLpActions = $t04496445029._1 | |
1109 | + | let updatedKLp = $t04496445029._2 | |
890 | 1110 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
891 | 1111 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
892 | 1112 | then (state ++ refreshKLpActions) | |
933 | 1153 | then { | |
934 | 1154 | let userAddress = i.caller | |
935 | 1155 | let txId = i.transactionId | |
936 | - | let $ | |
937 | - | if (($ | |
1156 | + | let $t04621746369 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
1157 | + | if (($t04621746369 == $t04621746369)) | |
938 | 1158 | then { | |
939 | - | let paymentInAmountAsset = $ | |
940 | - | let bonus = $ | |
941 | - | let feeAmount = $ | |
942 | - | let commonState = $ | |
943 | - | let emitAmountEstimated = $ | |
1159 | + | let paymentInAmountAsset = $t04621746369._5 | |
1160 | + | let bonus = $t04621746369._4 | |
1161 | + | let feeAmount = $t04621746369._3 | |
1162 | + | let commonState = $t04621746369._2 | |
1163 | + | let emitAmountEstimated = $t04621746369._1 | |
944 | 1164 | let emitAmount = if (if ((minOutAmount > 0)) | |
945 | 1165 | then (minOutAmount > emitAmountEstimated) | |
946 | 1166 | else false) | |
960 | 1180 | let sendFee = if ((feeAmount > 0)) | |
961 | 1181 | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
962 | 1182 | else nil | |
963 | - | let $ | |
1183 | + | let $t04695547152 = if ((this == feeCollectorAddress)) | |
964 | 1184 | then $Tuple2(0, 0) | |
965 | 1185 | else if (paymentInAmountAsset) | |
966 | 1186 | then $Tuple2(-(feeAmount), 0) | |
967 | 1187 | else $Tuple2(0, -(feeAmount)) | |
968 | - | let amountAssetBalanceDelta = $ | |
969 | - | let priceAssetBalanceDelta = $ | |
970 | - | let $ | |
971 | - | let refreshKLpActions = $ | |
972 | - | let updatedKLp = $ | |
1188 | + | let amountAssetBalanceDelta = $t04695547152._1 | |
1189 | + | let priceAssetBalanceDelta = $t04695547152._2 | |
1190 | + | let $t04715547263 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1191 | + | let refreshKLpActions = $t04715547263._1 | |
1192 | + | let updatedKLp = $t04715547263._2 | |
973 | 1193 | let kLp = value(getString(keyKLp)) | |
974 | 1194 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
975 | 1195 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
976 | - | then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
1196 | + | then { | |
1197 | + | let reb = invoke(this, "rebalance", nil, nil) | |
1198 | + | if ((reb == reb)) | |
1199 | + | then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
1200 | + | else throw("Strict value is not equal to itself.") | |
1201 | + | } | |
977 | 1202 | else throw("Strict value is not equal to itself.") | |
978 | 1203 | } | |
979 | 1204 | else throw("Strict value is not equal to itself.") | |
989 | 1214 | ||
990 | 1215 | @Callable(i) | |
991 | 1216 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
992 | - | let $ | |
993 | - | let emitAmountEstimated = $ | |
994 | - | let commonState = $ | |
995 | - | let feeAmount = $ | |
996 | - | let bonus = $ | |
997 | - | let paymentInAmountAsset = $ | |
1217 | + | let $t04761847775 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
1218 | + | let emitAmountEstimated = $t04761847775._1 | |
1219 | + | let commonState = $t04761847775._2 | |
1220 | + | let feeAmount = $t04761847775._3 | |
1221 | + | let bonus = $t04761847775._4 | |
1222 | + | let paymentInAmountAsset = $t04761847775._5 | |
998 | 1223 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
999 | 1224 | } | |
1000 | 1225 | ||
1031 | 1256 | then { | |
1032 | 1257 | let userAddress = i.caller | |
1033 | 1258 | let txId = i.transactionId | |
1034 | - | let $ | |
1035 | - | if (($ | |
1259 | + | let $t04866048813 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
1260 | + | if (($t04866048813 == $t04866048813)) | |
1036 | 1261 | then { | |
1037 | - | let outInAmountAsset = $ | |
1038 | - | let bonus = $ | |
1039 | - | let feeAmount = $ | |
1040 | - | let commonState = $ | |
1041 | - | let amountEstimated = $ | |
1262 | + | let outInAmountAsset = $t04866048813._5 | |
1263 | + | let bonus = $t04866048813._4 | |
1264 | + | let feeAmount = $t04866048813._3 | |
1265 | + | let commonState = $t04866048813._2 | |
1266 | + | let amountEstimated = $t04866048813._1 | |
1042 | 1267 | let amount = if (if ((minOutAmount > 0)) | |
1043 | 1268 | then (minOutAmount > amountEstimated) | |
1044 | 1269 | else false) | |
1045 | 1270 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1046 | 1271 | else amountEstimated | |
1272 | + | let lsConf = match getLeaseProxyConfig(outAssetIdStr) { | |
1273 | + | case a: (Boolean, Int, Int, String, String, Int, String) => | |
1274 | + | a | |
1275 | + | case _ => | |
1276 | + | throw("error lease config") | |
1277 | + | } | |
1278 | + | let $t04919749311 = lsConf | |
1279 | + | let isLeasable = $t04919749311._1 | |
1280 | + | let leasedRatio = $t04919749311._2 | |
1281 | + | let minBalance = $t04919749311._3 | |
1282 | + | let proxyAddress = $t04919749311._4 | |
1283 | + | let proxyAssetId = $t04919749311._5 | |
1284 | + | let proxyRateMul = $t04919749311._6 | |
1285 | + | let stakingProfitAddress = $t04919749311._7 | |
1286 | + | let assetOnPool = assetBalance(this, fromBase58String(outAssetIdStr)) | |
1287 | + | let amountOfProfit = if (if ((outAssetIdStr == "WAVES")) | |
1288 | + | then (amount > assetOnPool) | |
1289 | + | else false) | |
1290 | + | then { | |
1291 | + | let amountDiff = (amount - assetOnPool) | |
1292 | + | let oldRatio = (getAdditionalBalance(outAssetIdStr) / getStakingAssetBalance(sWavesId())) | |
1293 | + | let oldWavesRoughBalane = wavesBalance(this).available | |
1294 | + | let wd = invoke(this, "withdraw", [outAssetIdStr, amountDiff, sWavesId(), sWavesProxy(), proxyRateMul], nil) | |
1295 | + | if ((wd == wd)) | |
1296 | + | then { | |
1297 | + | let newWavesRoughBalane = wavesBalance(this).available | |
1298 | + | let wavesDiff = (newWavesRoughBalane - oldWavesRoughBalane) | |
1299 | + | (wavesDiff - amountDiff) | |
1300 | + | } | |
1301 | + | else throw("Strict value is not equal to itself.") | |
1302 | + | } | |
1303 | + | else 0 | |
1304 | + | let profitTransfer = [ScriptTransfer(addressFromStringValue(stakingProfitAddress), amountOfProfit, unit)] | |
1047 | 1305 | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
1048 | 1306 | if ((burnInv == burnInv)) | |
1049 | 1307 | then { | |
1051 | 1309 | let sendFee = if ((feeAmount > 0)) | |
1052 | 1310 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1053 | 1311 | else nil | |
1054 | - | let $ | |
1312 | + | let $t05035050597 = { | |
1055 | 1313 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1056 | 1314 | then 0 | |
1057 | 1315 | else feeAmount | |
1059 | 1317 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1060 | 1318 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1061 | 1319 | } | |
1062 | - | let amountAssetBalanceDelta = $ | |
1063 | - | let priceAssetBalanceDelta = $ | |
1064 | - | let $ | |
1065 | - | let refreshKLpActions = $ | |
1066 | - | let updatedKLp = $ | |
1320 | + | let amountAssetBalanceDelta = $t05035050597._1 | |
1321 | + | let priceAssetBalanceDelta = $t05035050597._2 | |
1322 | + | let $t05060050708 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1323 | + | let refreshKLpActions = $t05060050708._1 | |
1324 | + | let updatedKLp = $t05060050708._2 | |
1067 | 1325 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1068 | 1326 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1069 | - | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1327 | + | then { | |
1328 | + | let reb = invoke(this, "rebalance", nil, nil) | |
1329 | + | if ((reb == reb)) | |
1330 | + | then $Tuple2(((((commonState ++ assetTransfer) ++ profitTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1331 | + | else throw("Strict value is not equal to itself.") | |
1332 | + | } | |
1070 | 1333 | else throw("Strict value is not equal to itself.") | |
1071 | 1334 | } | |
1072 | 1335 | else throw("Strict value is not equal to itself.") | |
1082 | 1345 | ||
1083 | 1346 | @Callable(i) | |
1084 | 1347 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
1085 | - | let $ | |
1086 | - | let amountEstimated = $ | |
1087 | - | let commonState = $ | |
1088 | - | let feeAmount = $ | |
1089 | - | let bonus = $ | |
1090 | - | let outInAmountAsset = $ | |
1348 | + | let $t05103551191 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
1349 | + | let amountEstimated = $t05103551191._1 | |
1350 | + | let commonState = $t05103551191._2 | |
1351 | + | let feeAmount = $t05103551191._3 | |
1352 | + | let bonus = $t05103551191._4 | |
1353 | + | let outInAmountAsset = $t05103551191._5 | |
1091 | 1354 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
1092 | 1355 | } | |
1093 | 1356 | ||
1124 | 1387 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1125 | 1388 | if ((unstakeInv == unstakeInv)) | |
1126 | 1389 | then { | |
1127 | - | let $ | |
1128 | - | if (($ | |
1390 | + | let $t05209652247 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
1391 | + | if (($t05209652247 == $t05209652247)) | |
1129 | 1392 | then { | |
1130 | - | let outInAmountAsset = $ | |
1131 | - | let bonus = $ | |
1132 | - | let feeAmount = $ | |
1133 | - | let commonState = $ | |
1134 | - | let amountEstimated = $ | |
1393 | + | let outInAmountAsset = $t05209652247._5 | |
1394 | + | let bonus = $t05209652247._4 | |
1395 | + | let feeAmount = $t05209652247._3 | |
1396 | + | let commonState = $t05209652247._2 | |
1397 | + | let amountEstimated = $t05209652247._1 | |
1135 | 1398 | let amount = if (if ((minOutAmount > 0)) | |
1136 | 1399 | then (minOutAmount > amountEstimated) | |
1137 | 1400 | else false) | |
1144 | 1407 | let sendFee = if ((feeAmount > 0)) | |
1145 | 1408 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1146 | 1409 | else nil | |
1147 | - | let $ | |
1410 | + | let $t05274252989 = { | |
1148 | 1411 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1149 | 1412 | then 0 | |
1150 | 1413 | else feeAmount | |
1152 | 1415 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1153 | 1416 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1154 | 1417 | } | |
1155 | - | let amountAssetBalanceDelta = $ | |
1156 | - | let priceAssetBalanceDelta = $ | |
1157 | - | let $ | |
1158 | - | let refreshKLpActions = $ | |
1159 | - | let updatedKLp = $ | |
1418 | + | let amountAssetBalanceDelta = $t05274252989._1 | |
1419 | + | let priceAssetBalanceDelta = $t05274252989._2 | |
1420 | + | let $t05299253100 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1421 | + | let refreshKLpActions = $t05299253100._1 | |
1422 | + | let updatedKLp = $t05299253100._2 | |
1160 | 1423 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1161 | 1424 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1162 | 1425 | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1189 | 1452 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1190 | 1453 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1191 | 1454 | then { | |
1192 | - | let $ | |
1193 | - | let refreshKLpActions = $ | |
1194 | - | let updatedKLp = $ | |
1455 | + | let $t05404654128 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1456 | + | let refreshKLpActions = $t05404654128._1 | |
1457 | + | let updatedKLp = $t05404654128._2 | |
1195 | 1458 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1196 | 1459 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1197 | 1460 | then (state ++ refreshKLpActions) | |
1223 | 1486 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1224 | 1487 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1225 | 1488 | then { | |
1226 | - | let $ | |
1227 | - | let refreshKLpActions = $ | |
1228 | - | let updatedKLp = $ | |
1489 | + | let $t05507755158 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1490 | + | let refreshKLpActions = $t05507755158._1 | |
1491 | + | let updatedKLp = $t05507755158._2 | |
1229 | 1492 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1230 | 1493 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1231 | 1494 | then (state ++ refreshKLpActions) | |
1269 | 1532 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1270 | 1533 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1271 | 1534 | then { | |
1272 | - | let $ | |
1273 | - | let refreshKLpActions = $ | |
1274 | - | let updatedKLp = $ | |
1535 | + | let $t05628456365 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1536 | + | let refreshKLpActions = $t05628456365._1 | |
1537 | + | let updatedKLp = $t05628456365._2 | |
1275 | 1538 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1276 | 1539 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1277 | 1540 | then (state ++ refreshKLpActions) | |
1322 | 1585 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1323 | 1586 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1324 | 1587 | then { | |
1325 | - | let $ | |
1326 | - | let refreshKLpActions = $ | |
1327 | - | let updatedKLp = $ | |
1588 | + | let $t05766057741 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1589 | + | let refreshKLpActions = $t05766057741._1 | |
1590 | + | let updatedKLp = $t05766057741._2 | |
1328 | 1591 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1329 | 1592 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1330 | 1593 | then (state ++ refreshKLpActions) | |
1359 | 1622 | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1360 | 1623 | then { | |
1361 | 1624 | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
1362 | - | let $ | |
1363 | - | let kLpUpdateActions = $ | |
1364 | - | let updatedKLp = $ | |
1625 | + | let $t05892858992 = refreshKLpInternal(0, 0, 0) | |
1626 | + | let kLpUpdateActions = $t05892858992._1 | |
1627 | + | let updatedKLp = $t05892858992._2 | |
1365 | 1628 | let actions = if ((kLp != updatedKLp)) | |
1366 | 1629 | then kLpUpdateActions | |
1367 | 1630 | else throwErr("nothing to refresh") | |
1536 | 1799 | match tx { | |
1537 | 1800 | case order: Order => | |
1538 | 1801 | let matcherPub = getMatcherPubOrFail() | |
1539 | - | let $ | |
1540 | - | let orderValid = $ | |
1541 | - | let orderValidInfo = $ | |
1802 | + | let $t06765467723 = validateMatcherOrderAllowed(order) | |
1803 | + | let orderValid = $t06765467723._1 | |
1804 | + | let orderValidInfo = $t06765467723._2 | |
1542 | 1805 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1543 | 1806 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1544 | 1807 | if (if (if (orderValid) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let lPdecimals = 8 | |
5 | 5 | ||
6 | 6 | let scale8 = 100000000 | |
7 | 7 | ||
8 | 8 | let scale8BigInt = toBigInt(100000000) | |
9 | 9 | ||
10 | 10 | let scale18 = toBigInt(1000000000000000000) | |
11 | 11 | ||
12 | 12 | let zeroBigInt = toBigInt(0) | |
13 | 13 | ||
14 | 14 | let big0 = toBigInt(0) | |
15 | 15 | ||
16 | 16 | let big1 = toBigInt(1) | |
17 | 17 | ||
18 | 18 | let big2 = toBigInt(2) | |
19 | 19 | ||
20 | 20 | let wavesString = "WAVES" | |
21 | 21 | ||
22 | 22 | let SEP = "__" | |
23 | 23 | ||
24 | 24 | let PoolActive = 1 | |
25 | 25 | ||
26 | 26 | let PoolPutDisabled = 2 | |
27 | 27 | ||
28 | 28 | let PoolMatcherDisabled = 3 | |
29 | 29 | ||
30 | 30 | let PoolShutdown = 4 | |
31 | 31 | ||
32 | 32 | let idxPoolAddress = 1 | |
33 | 33 | ||
34 | 34 | let idxPoolStatus = 2 | |
35 | 35 | ||
36 | 36 | let idxPoolLPAssetId = 3 | |
37 | 37 | ||
38 | 38 | let idxAmtAssetId = 4 | |
39 | 39 | ||
40 | 40 | let idxPriceAssetId = 5 | |
41 | 41 | ||
42 | 42 | let idxAmtAssetDcm = 6 | |
43 | 43 | ||
44 | 44 | let idxPriceAssetDcm = 7 | |
45 | 45 | ||
46 | 46 | let idxIAmtAssetId = 8 | |
47 | 47 | ||
48 | 48 | let idxIPriceAssetId = 9 | |
49 | 49 | ||
50 | 50 | let idxLPAssetDcm = 10 | |
51 | 51 | ||
52 | 52 | let idxPoolAmtAssetAmt = 1 | |
53 | 53 | ||
54 | 54 | let idxPoolPriceAssetAmt = 2 | |
55 | 55 | ||
56 | 56 | let idxPoolLPAssetAmt = 3 | |
57 | 57 | ||
58 | 58 | let idxFactoryStakingContract = 1 | |
59 | 59 | ||
60 | 60 | let idxFactorySlippageContract = 7 | |
61 | 61 | ||
62 | 62 | func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult)) | |
63 | 63 | ||
64 | 64 | ||
65 | 65 | func toX18BigInt (origVal,origScaleMult) = fraction(origVal, scale18, origScaleMult) | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18)) | |
69 | 69 | ||
70 | 70 | ||
71 | 71 | func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round)) | |
72 | 72 | ||
73 | 73 | ||
74 | 74 | func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
75 | 75 | ||
76 | 76 | ||
77 | 77 | func abs (val) = if ((0 > val)) | |
78 | 78 | then -(val) | |
79 | 79 | else val | |
80 | 80 | ||
81 | 81 | ||
82 | 82 | func absBigInt (val) = if ((zeroBigInt > val)) | |
83 | 83 | then -(val) | |
84 | 84 | else val | |
85 | 85 | ||
86 | 86 | ||
87 | 87 | func swapContract () = "%s__swapContract" | |
88 | 88 | ||
89 | 89 | ||
90 | 90 | func fc () = "%s__factoryContract" | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | func mpk () = "%s__managerPublicKey" | |
94 | 94 | ||
95 | 95 | ||
96 | 96 | func pmpk () = "%s__pendingManagerPublicKey" | |
97 | 97 | ||
98 | 98 | ||
99 | 99 | func pl () = "%s%s__price__last" | |
100 | 100 | ||
101 | 101 | ||
102 | 102 | func ph (h,timestamp) = makeString(["%s%s%d%d__price__history", toString(h), toString(timestamp)], SEP) | |
103 | 103 | ||
104 | 104 | ||
105 | 105 | func pau (userAddress,txId) = ((("%s%s%s__P__" + userAddress) + "__") + txId) | |
106 | 106 | ||
107 | 107 | ||
108 | 108 | func gau (userAddress,txId) = ((("%s%s%s__G__" + userAddress) + "__") + txId) | |
109 | 109 | ||
110 | 110 | ||
111 | 111 | func aa () = "%s__amountAsset" | |
112 | 112 | ||
113 | 113 | ||
114 | 114 | func pa () = "%s__priceAsset" | |
115 | 115 | ||
116 | 116 | ||
117 | 117 | let keyFee = "%s__fee" | |
118 | 118 | ||
119 | 119 | let feeDefault = fraction(10, scale8, 10000) | |
120 | 120 | ||
121 | 121 | let fee = valueOrElse(getInteger(this, keyFee), feeDefault) | |
122 | 122 | ||
123 | 123 | let keyKLp = makeString(["%s", "kLp"], SEP) | |
124 | 124 | ||
125 | 125 | let keyKLpRefreshedHeight = makeString(["%s", "kLpRefreshedHeight"], SEP) | |
126 | 126 | ||
127 | 127 | let keyKLpRefreshDelay = makeString(["%s", "refreshKLpDelay"], SEP) | |
128 | 128 | ||
129 | 129 | let kLpRefreshDelayDefault = 30 | |
130 | 130 | ||
131 | 131 | let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault) | |
132 | 132 | ||
133 | + | func keySWavesAssetId () = "%s__sWavesAssetId" | |
134 | + | ||
135 | + | ||
136 | + | func keySWavesProxyAddress () = "%s__sWavesProxyAddress" | |
137 | + | ||
138 | + | ||
139 | + | func keyAdditionalBalance (assetId) = makeString(["%s%s", "additionalBalance", assetId], SEP) | |
140 | + | ||
141 | + | ||
142 | + | func keyStakingAssetBalance (assetId) = makeString(["%s%s", "stakingAssetBalance", assetId], SEP) | |
143 | + | ||
144 | + | ||
145 | + | func getAdditionalBalance (assetId) = valueOrElse(getInteger(this, keyAdditionalBalance(assetId)), 0) | |
146 | + | ||
147 | + | ||
148 | + | func getStakingAssetBalance (assetId) = valueOrElse(getInteger(this, keyStakingAssetBalance(assetId)), 0) | |
149 | + | ||
150 | + | ||
133 | 151 | func keyFactoryConfig () = "%s__factoryConfig" | |
134 | 152 | ||
135 | 153 | ||
136 | 154 | func keyMatcherPub () = "%s%s__matcher__publicKey" | |
137 | 155 | ||
138 | 156 | ||
139 | 157 | func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset") | |
140 | 158 | ||
141 | 159 | ||
142 | 160 | func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config") | |
143 | 161 | ||
144 | 162 | ||
145 | 163 | func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr) | |
146 | 164 | ||
147 | 165 | ||
148 | 166 | func keyAllPoolsShutdown () = "%s__shutdown" | |
149 | 167 | ||
150 | 168 | ||
151 | 169 | func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress) | |
152 | 170 | ||
153 | 171 | ||
154 | 172 | func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash" | |
155 | 173 | ||
156 | 174 | ||
157 | 175 | let keyFeeCollectorAddress = "%s__feeCollectorAddress" | |
158 | 176 | ||
159 | 177 | func throwOrderError (orderValid,orderValidInfo,senderValid,matcherValid) = throw((((((((("order validation failed: orderValid=" + toString(orderValid)) + " (") + orderValidInfo) + ")") + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid))) | |
160 | 178 | ||
161 | 179 | ||
162 | 180 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
163 | 181 | ||
164 | 182 | ||
165 | 183 | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
166 | 184 | ||
167 | 185 | ||
168 | 186 | func throwErr (msg) = throw(makeString(["lp.ride:", msg], " ")) | |
169 | 187 | ||
170 | 188 | ||
171 | 189 | func fmtErr (msg) = makeString(["lp.ride:", msg], " ") | |
172 | 190 | ||
173 | 191 | ||
174 | 192 | let factoryContract = addressFromStringValue(getStringOrFail(this, fc())) | |
175 | 193 | ||
176 | 194 | let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress)) | |
177 | 195 | ||
178 | 196 | let inFee = { | |
179 | 197 | let @ = invoke(factoryContract, "getInFeeREADONLY", [toString(this)], nil) | |
180 | 198 | if ($isInstanceOf(@, "Int")) | |
181 | 199 | then @ | |
182 | 200 | else throw(($getType(@) + " couldn't be cast to Int")) | |
183 | 201 | } | |
184 | 202 | ||
185 | 203 | let outFee = { | |
186 | 204 | let @ = invoke(factoryContract, "getOutFeeREADONLY", [toString(this)], nil) | |
187 | 205 | if ($isInstanceOf(@, "Int")) | |
188 | 206 | then @ | |
189 | 207 | else throw(($getType(@) + " couldn't be cast to Int")) | |
190 | 208 | } | |
191 | 209 | ||
210 | + | func sWavesId () = getStringOrFail(factoryContract, keySWavesAssetId()) | |
211 | + | ||
212 | + | ||
213 | + | func sWavesProxy () = getStringOrFail(factoryContract, keySWavesProxyAddress()) | |
214 | + | ||
215 | + | ||
192 | 216 | func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false) | |
193 | 217 | ||
194 | 218 | ||
195 | 219 | func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub())) | |
196 | 220 | ||
197 | 221 | ||
198 | 222 | func getPoolConfig () = { | |
199 | 223 | let amtAsset = getStringOrFail(this, aa()) | |
200 | 224 | let priceAsset = getStringOrFail(this, pa()) | |
201 | 225 | let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset)) | |
202 | 226 | let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset)) | |
203 | 227 | split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP) | |
204 | 228 | } | |
205 | 229 | ||
206 | 230 | ||
207 | 231 | func parseAssetId (input) = if ((input == wavesString)) | |
208 | 232 | then unit | |
209 | 233 | else fromBase58String(input) | |
210 | 234 | ||
211 | 235 | ||
212 | 236 | func assetIdToString (input) = if ((input == unit)) | |
213 | 237 | then wavesString | |
214 | 238 | else toBase58String(value(input)) | |
215 | 239 | ||
216 | 240 | ||
217 | 241 | 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])) | |
218 | 242 | ||
219 | 243 | ||
220 | 244 | let poolConfigParsed = parsePoolConfig(getPoolConfig()) | |
221 | 245 | ||
222 | - | let $ | |
246 | + | let $t092129378 = poolConfigParsed | |
223 | 247 | ||
224 | - | let cfgPoolAddress = $ | |
248 | + | let cfgPoolAddress = $t092129378._1 | |
225 | 249 | ||
226 | - | let cfgPoolStatus = $ | |
250 | + | let cfgPoolStatus = $t092129378._2 | |
227 | 251 | ||
228 | - | let cfgLpAssetId = $ | |
252 | + | let cfgLpAssetId = $t092129378._3 | |
229 | 253 | ||
230 | - | let cfgAmountAssetId = $ | |
254 | + | let cfgAmountAssetId = $t092129378._4 | |
231 | 255 | ||
232 | - | let cfgPriceAssetId = $ | |
256 | + | let cfgPriceAssetId = $t092129378._5 | |
233 | 257 | ||
234 | - | let cfgAmountAssetDecimals = $ | |
258 | + | let cfgAmountAssetDecimals = $t092129378._6 | |
235 | 259 | ||
236 | - | let cfgPriceAssetDecimals = $ | |
260 | + | let cfgPriceAssetDecimals = $t092129378._7 | |
237 | 261 | ||
238 | 262 | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
239 | 263 | ||
240 | 264 | ||
241 | 265 | let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address") | |
242 | 266 | ||
243 | 267 | let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address") | |
244 | 268 | ||
245 | 269 | 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) | |
246 | 270 | ||
247 | 271 | ||
248 | 272 | 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) | |
249 | 273 | ||
250 | 274 | ||
251 | 275 | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
252 | - | then wavesBalance(this).available | |
253 | - | else assetBalance(this, fromBase58String(assetId)) | |
276 | + | then (wavesBalance(this).available + getAdditionalBalance(assetId)) | |
277 | + | else if ((assetId == sWavesId())) | |
278 | + | then { | |
279 | + | let amtAsset = getStringOrFail(this, aa()) | |
280 | + | let priceAsset = getStringOrFail(this, pa()) | |
281 | + | if (if (if ((amtAsset == "WAVES")) | |
282 | + | then (priceAsset == sWavesId()) | |
283 | + | else false) | |
284 | + | then true | |
285 | + | else if ((priceAsset == "WAVES")) | |
286 | + | then (amtAsset == sWavesId()) | |
287 | + | else false) | |
288 | + | then assetBalance(this, fromBase58String(assetId)) | |
289 | + | else (assetBalance(this, fromBase58String(assetId)) + getStakingAssetBalance(assetId)) | |
290 | + | } | |
291 | + | else assetBalance(this, fromBase58String(assetId)) | |
254 | 292 | ||
255 | 293 | ||
256 | 294 | func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
257 | 295 | ||
258 | 296 | ||
259 | 297 | func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round) | |
298 | + | ||
299 | + | ||
300 | + | func getRate (proxy) = { | |
301 | + | let inv = invoke(proxy, "getRate", nil, nil) | |
302 | + | if ((inv == inv)) | |
303 | + | then match inv { | |
304 | + | case r: Int => | |
305 | + | r | |
306 | + | case _ => | |
307 | + | throwErr("proxy.getRate() unexpected value") | |
308 | + | } | |
309 | + | else throw("Strict value is not equal to itself.") | |
310 | + | } | |
311 | + | ||
312 | + | ||
313 | + | func deposit (assetId,amount,stakingAssetId,proxy) = { | |
314 | + | let currentAdditionalBalance = getAdditionalBalance(assetId) | |
315 | + | if ((currentAdditionalBalance == currentAdditionalBalance)) | |
316 | + | then { | |
317 | + | let currentStakingAssetBalance = getStakingAssetBalance(stakingAssetId) | |
318 | + | if ((currentStakingAssetBalance == currentStakingAssetBalance)) | |
319 | + | then { | |
320 | + | let asset = parseAssetId(assetId) | |
321 | + | if ((amount > 0)) | |
322 | + | then { | |
323 | + | let depositInvoke = invoke(proxy, "deposit", nil, [AttachedPayment(asset, amount)]) | |
324 | + | if ((depositInvoke == depositInvoke)) | |
325 | + | then match depositInvoke { | |
326 | + | case receivedStakingAsset: Int => | |
327 | + | let newAdditionalBalance = (currentAdditionalBalance + amount) | |
328 | + | let newStakingAssetBalance = (currentStakingAssetBalance + receivedStakingAsset) | |
329 | + | [IntegerEntry(keyAdditionalBalance(assetId), newAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance)] | |
330 | + | case _ => | |
331 | + | nil | |
332 | + | } | |
333 | + | else throw("Strict value is not equal to itself.") | |
334 | + | } | |
335 | + | else nil | |
336 | + | } | |
337 | + | else throw("Strict value is not equal to itself.") | |
338 | + | } | |
339 | + | else throw("Strict value is not equal to itself.") | |
340 | + | } | |
341 | + | ||
342 | + | ||
343 | + | func withdraw (assetId,amount,stakingAssetId,proxy,proxyRateMul) = { | |
344 | + | let currentAdditionalBalance = getAdditionalBalance(assetId) | |
345 | + | if ((currentAdditionalBalance == currentAdditionalBalance)) | |
346 | + | then { | |
347 | + | let currentStakingAssetBalance = getStakingAssetBalance(stakingAssetId) | |
348 | + | if ((currentStakingAssetBalance == currentStakingAssetBalance)) | |
349 | + | then { | |
350 | + | let currentProxyRate = getRate(proxy) | |
351 | + | if ((currentProxyRate == currentProxyRate)) | |
352 | + | then { | |
353 | + | let stakingAsset = parseAssetId(stakingAssetId) | |
354 | + | let sendStakingAssetAmount = fraction(proxyRateMul, amount, currentProxyRate) | |
355 | + | if ((sendStakingAssetAmount > 0)) | |
356 | + | then { | |
357 | + | let withdrawInvoke = invoke(proxy, "withdraw", nil, [AttachedPayment(stakingAsset, sendStakingAssetAmount)]) | |
358 | + | if ((withdrawInvoke == withdrawInvoke)) | |
359 | + | then match withdrawInvoke { | |
360 | + | case receivedAssets: Int => | |
361 | + | let newAdditionalBalance = (currentAdditionalBalance - receivedAssets) | |
362 | + | let newStakingAssetBalance = (currentStakingAssetBalance - sendStakingAssetAmount) | |
363 | + | [IntegerEntry(keyAdditionalBalance(assetId), newAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance)] | |
364 | + | case _ => | |
365 | + | nil | |
366 | + | } | |
367 | + | else throw("Strict value is not equal to itself.") | |
368 | + | } | |
369 | + | else nil | |
370 | + | } | |
371 | + | else throw("Strict value is not equal to itself.") | |
372 | + | } | |
373 | + | else throw("Strict value is not equal to itself.") | |
374 | + | } | |
375 | + | else throw("Strict value is not equal to itself.") | |
376 | + | } | |
377 | + | ||
378 | + | ||
379 | + | func getLeaseProxyConfig (assetId) = invoke(factoryContract, "getPoolLeaseConfigREADONLY", [toString(this), assetId], nil) | |
380 | + | ||
381 | + | ||
382 | + | func rebalanceInternal (targetRatio,assetId,stakingAssetId,minBalance,proxy,proxyRateMul) = { | |
383 | + | let currentAdditionalBalance = getAdditionalBalance(assetId) | |
384 | + | if ((currentAdditionalBalance == currentAdditionalBalance)) | |
385 | + | then { | |
386 | + | let currentStakingAssetBalance = getStakingAssetBalance(stakingAssetId) | |
387 | + | if ((currentStakingAssetBalance == currentStakingAssetBalance)) | |
388 | + | then { | |
389 | + | let availableBalance = match parseAssetId(assetId) { | |
390 | + | case b: ByteVector => | |
391 | + | assetBalance(this, b) | |
392 | + | case u: Unit => | |
393 | + | wavesBalance(this).available | |
394 | + | case _ => | |
395 | + | throw("Match error") | |
396 | + | } | |
397 | + | if ((availableBalance == availableBalance)) | |
398 | + | then { | |
399 | + | let wholeBalance = max([0, ((availableBalance + currentAdditionalBalance) - minBalance)]) | |
400 | + | let targetAdditionalBalance = fraction(targetRatio, wholeBalance, 100) | |
401 | + | let diff = (currentAdditionalBalance - targetAdditionalBalance) | |
402 | + | if ((diff == 0)) | |
403 | + | then nil | |
404 | + | else if ((0 > diff)) | |
405 | + | then { | |
406 | + | let sendAssetAmount = -(diff) | |
407 | + | deposit(assetId, sendAssetAmount, stakingAssetId, proxy) | |
408 | + | } | |
409 | + | else { | |
410 | + | let getAssetAmount = diff | |
411 | + | withdraw(assetId, getAssetAmount, stakingAssetId, proxy, proxyRateMul) | |
412 | + | } | |
413 | + | } | |
414 | + | else throw("Strict value is not equal to itself.") | |
415 | + | } | |
416 | + | else throw("Strict value is not equal to itself.") | |
417 | + | } | |
418 | + | else throw("Strict value is not equal to itself.") | |
419 | + | } | |
420 | + | ||
421 | + | ||
422 | + | func rebalanceAsset (assetId) = match getLeaseProxyConfig(assetId) { | |
423 | + | case a: (Boolean, Int, Int, String, String, Int, String) => | |
424 | + | let $t01551515624 = a | |
425 | + | let isLeasable = $t01551515624._1 | |
426 | + | let leasedRatio = $t01551515624._2 | |
427 | + | let minBalance = $t01551515624._3 | |
428 | + | let proxyAddress = $t01551515624._4 | |
429 | + | let proxyAssetId = $t01551515624._5 | |
430 | + | let proxyRateMul = $t01551515624._6 | |
431 | + | let stakingProfitAddress = $t01551515624._7 | |
432 | + | if (isLeasable) | |
433 | + | then rebalanceInternal(leasedRatio, assetId, proxyAssetId, minBalance, addressFromStringValue(proxyAddress), proxyRateMul) | |
434 | + | else nil | |
435 | + | case _ => | |
436 | + | throwErr((("[" + assetId) + "] Rebalance error")) | |
437 | + | } | |
260 | 438 | ||
261 | 439 | ||
262 | 440 | func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
263 | 441 | let amtAssetAmtX18 = toX18(amAmt, amAssetDcm) | |
264 | 442 | let priceAssetAmtX18 = toX18(prAmt, prAssetDcm) | |
265 | 443 | calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
266 | 444 | } | |
267 | 445 | ||
268 | 446 | ||
269 | 447 | func calcPrices (amAmt,prAmt,lpAmt) = { | |
270 | 448 | let cfg = getPoolConfig() | |
271 | 449 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
272 | 450 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
273 | 451 | let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt) | |
274 | 452 | let amAmtX18 = toX18(amAmt, amtAssetDcm) | |
275 | 453 | let prAmtX18 = toX18(prAmt, priceAssetDcm) | |
276 | 454 | let lpAmtX18 = toX18(lpAmt, scale8) | |
277 | 455 | let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18) | |
278 | 456 | let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18) | |
279 | 457 | [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18] | |
280 | 458 | } | |
281 | 459 | ||
282 | 460 | ||
283 | 461 | func calculatePrices (amAmt,prAmt,lpAmt) = { | |
284 | 462 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
285 | 463 | [fromX18(prices[0], scale8), fromX18(prices[1], scale8), fromX18(prices[2], scale8)] | |
286 | 464 | } | |
287 | 465 | ||
288 | 466 | ||
289 | 467 | func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
290 | 468 | let cfg = getPoolConfig() | |
291 | 469 | let lpAssetId = cfg[idxPoolLPAssetId] | |
292 | 470 | let amAssetId = cfg[idxAmtAssetId] | |
293 | 471 | let prAssetId = cfg[idxPriceAssetId] | |
294 | 472 | let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
295 | 473 | let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
296 | 474 | let poolStatus = cfg[idxPoolStatus] | |
297 | 475 | let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity | |
298 | 476 | if ((lpAssetId != pmtAssetId)) | |
299 | 477 | then throw("Invalid asset passed.") | |
300 | 478 | else { | |
301 | 479 | let amBalance = getAccBalance(amAssetId) | |
302 | 480 | let amBalanceX18 = toX18(amBalance, amAssetDcm) | |
303 | 481 | let prBalance = getAccBalance(prAssetId) | |
304 | 482 | let prBalanceX18 = toX18(prBalance, prAssetDcm) | |
305 | 483 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
306 | 484 | let curPrice = fromX18(curPriceX18, scale8) | |
307 | 485 | let pmtLpAmtX18 = toX18(pmtLpAmt, scale8) | |
308 | 486 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
309 | 487 | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
310 | 488 | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
311 | 489 | let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR) | |
312 | 490 | let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR) | |
313 | 491 | let state = if ((txId58 == "")) | |
314 | 492 | then nil | |
315 | 493 | else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
316 | 494 | then unit | |
317 | 495 | else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES")) | |
318 | 496 | then unit | |
319 | 497 | 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)] | |
320 | 498 | $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state) | |
321 | 499 | } | |
322 | 500 | } | |
323 | 501 | ||
324 | 502 | ||
325 | 503 | func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = { | |
326 | 504 | let cfg = getPoolConfig() | |
327 | 505 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
328 | 506 | let amAssetIdStr = cfg[idxAmtAssetId] | |
329 | 507 | let prAssetIdStr = cfg[idxPriceAssetId] | |
330 | 508 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
331 | 509 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
332 | 510 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
333 | 511 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
334 | 512 | let poolStatus = cfg[idxPoolStatus] | |
335 | 513 | let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
336 | 514 | let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES"))) | |
337 | 515 | let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES"))) | |
338 | 516 | if (if ((amAssetIdStr != inAmAssetIdStr)) | |
339 | 517 | then true | |
340 | 518 | else (prAssetIdStr != inPrAssetIdStr)) | |
341 | 519 | then throw("Invalid amt or price asset passed.") | |
342 | 520 | else { | |
343 | 521 | let amBalance = if (isEvaluate) | |
344 | 522 | then getAccBalance(amAssetIdStr) | |
345 | 523 | else (getAccBalance(amAssetIdStr) - inAmAssetAmt) | |
346 | 524 | let prBalance = if (isEvaluate) | |
347 | 525 | then getAccBalance(prAssetIdStr) | |
348 | 526 | else (getAccBalance(prAssetIdStr) - inPrAssetAmt) | |
349 | 527 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
350 | 528 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
351 | 529 | let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18) | |
352 | 530 | let amBalanceX18 = toX18(amBalance, amtAssetDcm) | |
353 | 531 | let prBalanceX18 = toX18(prBalance, priceAssetDcm) | |
354 | 532 | let res = if ((lpEmission == 0)) | |
355 | 533 | then { | |
356 | 534 | let curPriceX18 = zeroBigInt | |
357 | 535 | let slippageX18 = zeroBigInt | |
358 | 536 | let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN) | |
359 | 537 | $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
360 | 538 | } | |
361 | 539 | else { | |
362 | 540 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
363 | 541 | let slippageX18 = fraction(absBigInt((curPriceX18 - userPriceX18)), scale18, curPriceX18) | |
364 | 542 | let slippageToleranceX18 = toX18(slippageTolerance, scale8) | |
365 | 543 | if (if ((curPriceX18 != zeroBigInt)) | |
366 | 544 | then (slippageX18 > slippageToleranceX18) | |
367 | 545 | else false) | |
368 | 546 | then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18))) | |
369 | 547 | else { | |
370 | 548 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
371 | 549 | let prViaAmX18 = fraction(inAmAssetAmtX18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING) | |
372 | 550 | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, FLOOR), CEILING) | |
373 | 551 | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
374 | 552 | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
375 | 553 | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
376 | 554 | let expAmtAssetAmtX18 = expectedAmts._1 | |
377 | 555 | let expPriceAssetAmtX18 = expectedAmts._2 | |
378 | 556 | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR) | |
379 | 557 | $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtAssetDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceAssetDcm, CEILING), curPriceX18, slippageX18) | |
380 | 558 | } | |
381 | 559 | } | |
382 | 560 | let calcLpAmt = res._1 | |
383 | 561 | let calcAmAssetPmt = res._2 | |
384 | 562 | let calcPrAssetPmt = res._3 | |
385 | 563 | let curPrice = fromX18(res._4, scale8) | |
386 | 564 | let slippageCalc = fromX18(res._5, scale8) | |
387 | 565 | if ((0 >= calcLpAmt)) | |
388 | 566 | then throw("Invalid calculations. LP calculated is less than zero.") | |
389 | 567 | else { | |
390 | 568 | let emitLpAmt = if (!(emitLp)) | |
391 | 569 | then 0 | |
392 | 570 | else calcLpAmt | |
393 | 571 | let amDiff = (inAmAssetAmt - calcAmAssetPmt) | |
394 | 572 | let prDiff = (inPrAssetAmt - calcPrAssetPmt) | |
395 | 573 | 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))] | |
396 | 574 | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId) | |
397 | 575 | } | |
398 | 576 | } | |
399 | 577 | } | |
400 | 578 | ||
401 | 579 | ||
402 | 580 | func calcKLp (amountBalance,priceBalance,lpEmission) = { | |
403 | 581 | let amountBalanceX18 = toX18BigInt(amountBalance, toBigInt(cfgAmountAssetDecimals)) | |
404 | 582 | let priceBalanceX18 = toX18BigInt(priceBalance, toBigInt(cfgPriceAssetDecimals)) | |
405 | 583 | let updatedKLp = fraction(pow((amountBalanceX18 * priceBalanceX18), 0, toBigInt(5), 1, 18, DOWN), big1, lpEmission) | |
406 | 584 | if ((lpEmission == big0)) | |
407 | 585 | then big0 | |
408 | 586 | else updatedKLp | |
409 | 587 | } | |
410 | 588 | ||
411 | 589 | ||
412 | 590 | func calcCurrentKLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = { | |
413 | 591 | let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta) | |
414 | 592 | let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta) | |
415 | 593 | let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta) | |
416 | 594 | let currentKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpAssetEmission) | |
417 | 595 | currentKLp | |
418 | 596 | } | |
419 | 597 | ||
420 | 598 | ||
421 | 599 | func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
422 | 600 | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
423 | 601 | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
424 | 602 | let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta) | |
425 | 603 | let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
426 | 604 | let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))] | |
427 | 605 | $Tuple2(actions, updatedKLp) | |
428 | 606 | } | |
429 | 607 | ||
430 | 608 | ||
431 | 609 | func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp)) | |
432 | 610 | then true | |
433 | 611 | else throwErr(makeString(["updated KLp lower than current KLp", toString(oldKLp), toString(updatedKLp)], " ")) | |
434 | 612 | ||
435 | 613 | ||
436 | 614 | func validateMatcherOrderAllowed (order) = { | |
437 | 615 | let amountAssetBalance = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
438 | 616 | let priceAssetBalance = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
439 | 617 | let amountAssetAmount = order.amount | |
440 | 618 | let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR) | |
441 | - | let $ | |
619 | + | let $t02714527357 = if ((order.orderType == Buy)) | |
442 | 620 | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
443 | 621 | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
444 | - | let amountAssetBalanceDelta = $ | |
445 | - | let priceAssetBalanceDelta = $ | |
622 | + | let amountAssetBalanceDelta = $t02714527357._1 | |
623 | + | let priceAssetBalanceDelta = $t02714527357._2 | |
446 | 624 | if (if (if (isGlobalShutdown()) | |
447 | 625 | then true | |
448 | 626 | else (cfgPoolStatus == PoolMatcherDisabled)) | |
449 | 627 | then true | |
450 | 628 | else (cfgPoolStatus == PoolShutdown)) | |
451 | 629 | then throw("Exchange operations disabled") | |
452 | 630 | else if (if ((order.assetPair.amountAsset != cfgAmountAssetId)) | |
453 | 631 | then true | |
454 | 632 | else (order.assetPair.priceAsset != cfgPriceAssetId)) | |
455 | 633 | then throw("Wrong order assets.") | |
456 | 634 | else { | |
457 | 635 | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
458 | - | let $ | |
459 | - | let unusedActions = $ | |
460 | - | let kLpNew = $ | |
636 | + | let $t02779727897 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
637 | + | let unusedActions = $t02779727897._1 | |
638 | + | let kLpNew = $t02779727897._2 | |
461 | 639 | let isOrderValid = (kLpNew >= kLp) | |
462 | 640 | let info = makeString(["kLp=", toString(kLp), " kLpNew=", toString(kLpNew), " amountAssetBalance=", toString(amountAssetBalance), " priceAssetBalance=", toString(priceAssetBalance), " amountAssetBalanceDelta=", toString(amountAssetBalanceDelta), " priceAssetBalanceDelta=", toString(priceAssetBalanceDelta), " height=", toString(height)], "") | |
463 | 641 | $Tuple2(isOrderValid, info) | |
464 | 642 | } | |
465 | 643 | } | |
466 | 644 | ||
467 | 645 | ||
468 | 646 | func commonGet (i) = if ((size(i.payments) != 1)) | |
469 | 647 | then throw("exactly 1 payment is expected") | |
470 | 648 | else { | |
471 | 649 | let pmt = value(i.payments[0]) | |
472 | 650 | let pmtAssetId = value(pmt.assetId) | |
473 | 651 | let pmtAmt = pmt.amount | |
474 | 652 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
475 | 653 | let outAmAmt = res._1 | |
476 | 654 | let outPrAmt = res._2 | |
477 | 655 | let poolStatus = parseIntValue(res._9) | |
478 | 656 | let state = res._10 | |
479 | 657 | if (if (isGlobalShutdown()) | |
480 | 658 | then true | |
481 | 659 | else (poolStatus == PoolShutdown)) | |
482 | 660 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
483 | 661 | else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state) | |
484 | 662 | } | |
485 | 663 | ||
486 | 664 | ||
487 | 665 | func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2)) | |
488 | 666 | then throw("exactly 2 payments are expected") | |
489 | 667 | else { | |
490 | 668 | let amAssetPmt = value(i.payments[0]) | |
491 | 669 | let prAssetPmt = value(i.payments[1]) | |
492 | 670 | let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp) | |
493 | 671 | let poolStatus = parseIntValue(estPut._8) | |
494 | 672 | if (if (if (isGlobalShutdown()) | |
495 | 673 | then true | |
496 | 674 | else (poolStatus == PoolPutDisabled)) | |
497 | 675 | then true | |
498 | 676 | else (poolStatus == PoolShutdown)) | |
499 | 677 | then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus))) | |
500 | 678 | else estPut | |
501 | 679 | } | |
502 | 680 | ||
503 | 681 | ||
504 | 682 | func emit (amount) = { | |
505 | 683 | let emitInv = invoke(factoryContract, "emit", [amount], nil) | |
506 | 684 | if ((emitInv == emitInv)) | |
507 | 685 | then { | |
508 | 686 | let emitInvLegacy = match emitInv { | |
509 | 687 | case legacyFactoryContract: Address => | |
510 | 688 | invoke(legacyFactoryContract, "emit", [amount], nil) | |
511 | 689 | case _ => | |
512 | 690 | unit | |
513 | 691 | } | |
514 | 692 | if ((emitInvLegacy == emitInvLegacy)) | |
515 | 693 | then amount | |
516 | 694 | else throw("Strict value is not equal to itself.") | |
517 | 695 | } | |
518 | 696 | else throw("Strict value is not equal to itself.") | |
519 | 697 | } | |
520 | 698 | ||
521 | 699 | ||
522 | 700 | func takeFee (amount,fee) = { | |
523 | 701 | let feeAmount = if ((fee == 0)) | |
524 | 702 | then 0 | |
525 | 703 | else fraction(amount, fee, scale8) | |
526 | 704 | $Tuple2((amount - feeAmount), feeAmount) | |
527 | 705 | } | |
528 | 706 | ||
529 | 707 | ||
530 | 708 | func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = { | |
531 | 709 | let isEval = (txId == unit) | |
532 | 710 | let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
533 | 711 | let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
534 | 712 | let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId)) | |
535 | 713 | then true | |
536 | 714 | else if ((paymentAssetId == cfgPriceAssetId)) | |
537 | 715 | then false | |
538 | 716 | else throwErr("invalid asset") | |
539 | - | let $ | |
717 | + | let $t03101031303 = if (isEval) | |
540 | 718 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
541 | 719 | else if (paymentInAmountAsset) | |
542 | 720 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
543 | 721 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
544 | - | let amountBalanceOld = $ | |
545 | - | let priceBalanceOld = $ | |
546 | - | let $ | |
722 | + | let amountBalanceOld = $t03101031303._1 | |
723 | + | let priceBalanceOld = $t03101031303._2 | |
724 | + | let $t03130731456 = if (paymentInAmountAsset) | |
547 | 725 | then $Tuple2(paymentAmountRaw, 0) | |
548 | 726 | else $Tuple2(0, paymentAmountRaw) | |
549 | - | let amountAssetAmountRaw = $ | |
550 | - | let priceAssetAmountRaw = $ | |
727 | + | let amountAssetAmountRaw = $t03130731456._1 | |
728 | + | let priceAssetAmountRaw = $t03130731456._2 | |
551 | 729 | let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1 | |
552 | 730 | let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1 | |
553 | - | let $ | |
554 | - | let paymentAmount = $ | |
555 | - | let feeAmount = $ | |
731 | + | let $t03158831652 = takeFee(paymentAmountRaw, inFee) | |
732 | + | let paymentAmount = $t03158831652._1 | |
733 | + | let feeAmount = $t03158831652._2 | |
556 | 734 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
557 | 735 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
558 | 736 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
559 | 737 | let priceNew = fromX18(priceNewX18, scale8) | |
560 | 738 | let paymentBalance = if (paymentInAmountAsset) | |
561 | 739 | then amountBalanceOld | |
562 | 740 | else priceBalanceOld | |
563 | 741 | let paymentBalanceBigInt = toBigInt(paymentBalance) | |
564 | 742 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
565 | 743 | let chechSupply = if ((supplyBigInt > big0)) | |
566 | 744 | then true | |
567 | 745 | else throwErr("initial deposit requires all coins") | |
568 | 746 | if ((chechSupply == chechSupply)) | |
569 | 747 | then { | |
570 | 748 | let depositBigInt = toBigInt(paymentAmount) | |
571 | 749 | let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))]) | |
572 | 750 | let commonState = if (isEval) | |
573 | 751 | then nil | |
574 | 752 | 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))] | |
575 | 753 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
576 | 754 | let priceOld = fromX18(priceOldX18, scale8) | |
577 | 755 | let loss = { | |
578 | - | let $ | |
756 | + | let $t03333333500 = if (paymentInAmountAsset) | |
579 | 757 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
580 | 758 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
581 | - | let amount = $ | |
582 | - | let balance = $ | |
759 | + | let amount = $t03333333500._1 | |
760 | + | let balance = $t03333333500._2 | |
583 | 761 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
584 | 762 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
585 | 763 | } | |
586 | 764 | $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset) | |
587 | 765 | } | |
588 | 766 | else throw("Strict value is not equal to itself.") | |
589 | 767 | } | |
590 | 768 | ||
591 | 769 | ||
592 | 770 | func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = { | |
593 | 771 | let isEval = (txId == unit) | |
594 | 772 | let cfg = getPoolConfig() | |
595 | 773 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
596 | 774 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
597 | 775 | let checks = [if ((paymentAssetId == cfgLpAssetId)) | |
598 | 776 | then true | |
599 | 777 | else throwErr("invalid lp asset")] | |
600 | 778 | if ((checks == checks)) | |
601 | 779 | then { | |
602 | 780 | let outInAmountAsset = if ((outAssetId == cfgAmountAssetId)) | |
603 | 781 | then true | |
604 | 782 | else if ((outAssetId == cfgPriceAssetId)) | |
605 | 783 | then false | |
606 | 784 | else throwErr("invalid asset") | |
607 | 785 | let balanceBigInt = if (outInAmountAsset) | |
608 | 786 | then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) | |
609 | 787 | else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) | |
610 | 788 | let outInAmountAssetDecimals = if (outInAmountAsset) | |
611 | 789 | then amtAssetDcm | |
612 | 790 | else priceAssetDcm | |
613 | 791 | let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
614 | 792 | let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
615 | 793 | let outBalance = if (outInAmountAsset) | |
616 | 794 | then amBalanceOld | |
617 | 795 | else prBalanceOld | |
618 | 796 | let outBalanceBigInt = toBigInt(outBalance) | |
619 | 797 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
620 | 798 | let redeemedBigInt = toBigInt(paymentAmount) | |
621 | 799 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
622 | - | let $ | |
623 | - | let totalAmount = $ | |
624 | - | let feeAmount = $ | |
625 | - | let $ | |
800 | + | let $t03557835634 = takeFee(amountRaw, outFee) | |
801 | + | let totalAmount = $t03557835634._1 | |
802 | + | let feeAmount = $t03557835634._2 | |
803 | + | let $t03563835864 = if (outInAmountAsset) | |
626 | 804 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
627 | 805 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
628 | - | let outAmAmount = $ | |
629 | - | let outPrAmount = $ | |
630 | - | let amBalanceNew = $ | |
631 | - | let prBalanceNew = $ | |
806 | + | let outAmAmount = $t03563835864._1 | |
807 | + | let outPrAmount = $t03563835864._2 | |
808 | + | let amBalanceNew = $t03563835864._3 | |
809 | + | let prBalanceNew = $t03563835864._4 | |
632 | 810 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
633 | 811 | let priceNew = fromX18(priceNewX18, scale8) | |
634 | 812 | let commonState = if (isEval) | |
635 | 813 | then nil | |
636 | 814 | 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)] | |
637 | 815 | let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals)) | |
638 | 816 | let priceOld = fromX18(priceOldX18, scale8) | |
639 | 817 | let loss = { | |
640 | 818 | let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2) | |
641 | 819 | fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset) | |
642 | 820 | } | |
643 | 821 | $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset) | |
644 | 822 | } | |
645 | 823 | else throw("Strict value is not equal to itself.") | |
646 | 824 | } | |
647 | 825 | ||
648 | 826 | ||
649 | 827 | func managerPublicKeyOrUnit () = match getString(mpk()) { | |
650 | 828 | case s: String => | |
651 | 829 | fromBase58String(s) | |
652 | 830 | case _: Unit => | |
653 | 831 | unit | |
654 | 832 | case _ => | |
655 | 833 | throw("Match error") | |
656 | 834 | } | |
657 | 835 | ||
658 | 836 | ||
659 | 837 | func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) { | |
660 | 838 | case s: String => | |
661 | 839 | fromBase58String(s) | |
662 | 840 | case _: Unit => | |
663 | 841 | unit | |
664 | 842 | case _ => | |
665 | 843 | throw("Match error") | |
666 | 844 | } | |
667 | 845 | ||
668 | 846 | ||
669 | 847 | func isManager (i) = match managerPublicKeyOrUnit() { | |
670 | 848 | case pk: ByteVector => | |
671 | 849 | (i.callerPublicKey == pk) | |
672 | 850 | case _: Unit => | |
673 | 851 | (i.caller == this) | |
674 | 852 | case _ => | |
675 | 853 | throw("Match error") | |
676 | 854 | } | |
677 | 855 | ||
678 | 856 | ||
679 | 857 | func mustManager (i) = { | |
680 | 858 | let pd = throw("Permission denied") | |
681 | 859 | match managerPublicKeyOrUnit() { | |
682 | 860 | case pk: ByteVector => | |
683 | 861 | if ((i.callerPublicKey == pk)) | |
684 | 862 | then true | |
685 | 863 | else pd | |
686 | 864 | case _: Unit => | |
687 | 865 | if ((i.caller == this)) | |
688 | 866 | then true | |
689 | 867 | else pd | |
690 | 868 | case _ => | |
691 | 869 | throw("Match error") | |
692 | 870 | } | |
693 | 871 | } | |
694 | 872 | ||
695 | 873 | ||
696 | 874 | @Callable(i) | |
875 | + | func rebalance () = (rebalanceAsset(aa()) ++ rebalanceAsset(pa())) | |
876 | + | ||
877 | + | ||
878 | + | ||
879 | + | @Callable(i) | |
697 | 880 | func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse,feePoolAmount) = { | |
698 | - | let $ | |
881 | + | let $t03770438009 = if ((isReverse == false)) | |
699 | 882 | then { | |
700 | 883 | let assetOut = getStringOrFail(this, pa()) | |
701 | 884 | let assetIn = getStringOrFail(this, aa()) | |
702 | 885 | $Tuple2(assetOut, assetIn) | |
703 | 886 | } | |
704 | 887 | else { | |
705 | 888 | let assetOut = getStringOrFail(this, aa()) | |
706 | 889 | let assetIn = getStringOrFail(this, pa()) | |
707 | 890 | $Tuple2(assetOut, assetIn) | |
708 | 891 | } | |
709 | - | let assetOut = $ | |
710 | - | let assetIn = $ | |
892 | + | let assetOut = $t03770438009._1 | |
893 | + | let assetIn = $t03770438009._2 | |
711 | 894 | let poolAssetInBalance = getAccBalance(assetIn) | |
712 | 895 | let poolAssetOutBalance = getAccBalance(assetOut) | |
713 | 896 | let amountOut = fraction(poolAssetOutBalance, cleanAmountIn, (poolAssetInBalance + cleanAmountIn)) | |
714 | 897 | let oldK = (toBigInt(poolAssetInBalance) * toBigInt(poolAssetOutBalance)) | |
715 | 898 | let newK = (((toBigInt(getAccBalance(assetIn)) + toBigInt(cleanAmountIn)) + toBigInt(feePoolAmount)) * (toBigInt(getAccBalance(assetOut)) - toBigInt(amountOut))) | |
716 | 899 | let checkK = if ((newK >= oldK)) | |
717 | 900 | then true | |
718 | 901 | else throw("new K is fewer error") | |
719 | 902 | if ((checkK == checkK)) | |
720 | 903 | then $Tuple2(nil, amountOut) | |
721 | 904 | else throw("Strict value is not equal to itself.") | |
722 | 905 | } | |
723 | 906 | ||
724 | 907 | ||
725 | 908 | ||
726 | 909 | @Callable(i) | |
727 | 910 | func calculateAmountOutForSwapAndSendTokens (cleanAmountIn,isReverse,amountOutMin,addressTo,feePoolAmount) = { | |
728 | 911 | let swapContact = { | |
729 | 912 | let @ = invoke(factoryContract, "getSwapContractREADONLY", nil, nil) | |
730 | 913 | if ($isInstanceOf(@, "String")) | |
731 | 914 | then @ | |
732 | 915 | else throw(($getType(@) + " couldn't be cast to String")) | |
733 | 916 | } | |
734 | 917 | let checks = [if ((value(i.payments[0]).amount >= cleanAmountIn)) | |
735 | 918 | then true | |
736 | 919 | else throwErr("Wrong amount"), if ((i.caller == addressFromStringValue(swapContact))) | |
737 | 920 | then true | |
738 | 921 | else throwErr("Permission denied")] | |
739 | 922 | if ((checks == checks)) | |
740 | 923 | then { | |
741 | 924 | let pmt = value(i.payments[0]) | |
742 | 925 | let assetIn = assetIdToString(pmt.assetId) | |
743 | 926 | let assetOut = if ((isReverse == false)) | |
744 | 927 | then getStringOrFail(this, pa()) | |
745 | 928 | else getStringOrFail(this, aa()) | |
746 | 929 | let poolAssetInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount) | |
747 | 930 | let poolAssetOutBalance = getAccBalance(assetOut) | |
748 | 931 | let amountOut = fraction(poolAssetOutBalance, cleanAmountIn, (poolAssetInBalance + cleanAmountIn)) | |
749 | 932 | let oldK = (toBigInt(poolAssetInBalance) * toBigInt(poolAssetOutBalance)) | |
750 | 933 | let newK = ((toBigInt(getAccBalance(assetIn)) + toBigInt(feePoolAmount)) * (toBigInt(getAccBalance(assetOut)) - toBigInt(amountOut))) | |
751 | 934 | let checkK = if ((newK >= oldK)) | |
752 | 935 | then true | |
753 | 936 | else throw("new K is fewer error") | |
754 | 937 | if ((checkK == checkK)) | |
755 | 938 | then { | |
756 | 939 | let checkMin = if ((amountOut >= amountOutMin)) | |
757 | 940 | then true | |
758 | 941 | else throw("Exchange result is fewer coins than expected") | |
759 | 942 | if ((checkMin == checkMin)) | |
760 | - | then $Tuple2([ScriptTransfer(addressFromStringValue(addressTo), amountOut, parseAssetId(assetOut))], amountOut) | |
943 | + | then { | |
944 | + | let lsConf = match getLeaseProxyConfig(assetOut) { | |
945 | + | case a: (Boolean, Int, Int, String, String, Int, String) => | |
946 | + | a | |
947 | + | case _ => | |
948 | + | throw("error lease config") | |
949 | + | } | |
950 | + | let $t04001540129 = lsConf | |
951 | + | let isLeasable = $t04001540129._1 | |
952 | + | let leasedRatio = $t04001540129._2 | |
953 | + | let minBalance = $t04001540129._3 | |
954 | + | let proxyAddress = $t04001540129._4 | |
955 | + | let proxyAssetId = $t04001540129._5 | |
956 | + | let proxyRateMul = $t04001540129._6 | |
957 | + | let stakingProfitAddress = $t04001540129._7 | |
958 | + | let assetOnPool = assetBalance(this, fromBase58String(assetOut)) | |
959 | + | let amountOfProfit = if (if ((assetOut == "WAVES")) | |
960 | + | then (amountOut > assetOnPool) | |
961 | + | else false) | |
962 | + | then { | |
963 | + | let amountDiff = (amountOut - assetOnPool) | |
964 | + | let oldRatio = (getAdditionalBalance(assetOut) / getStakingAssetBalance(sWavesId())) | |
965 | + | let oldWavesRoughBalane = wavesBalance(this).available | |
966 | + | let wd = invoke(this, "withdraw", [assetOut, amountDiff, sWavesId(), sWavesProxy(), proxyRateMul], nil) | |
967 | + | if ((wd == wd)) | |
968 | + | then { | |
969 | + | let newWavesRoughBalane = wavesBalance(this).available | |
970 | + | let wavesDiff = (newWavesRoughBalane - oldWavesRoughBalane) | |
971 | + | (wavesDiff - amountDiff) | |
972 | + | } | |
973 | + | else throw("Strict value is not equal to itself.") | |
974 | + | } | |
975 | + | else 0 | |
976 | + | let reb = invoke(this, "rebalance", nil, nil) | |
977 | + | if ((reb == reb)) | |
978 | + | then $Tuple2([ScriptTransfer(addressFromStringValue(stakingProfitAddress), amountOfProfit, unit), ScriptTransfer(addressFromStringValue(addressTo), amountOut, parseAssetId(assetOut))], amountOut) | |
979 | + | else throw("Strict value is not equal to itself.") | |
980 | + | } | |
761 | 981 | else throw("Strict value is not equal to itself.") | |
762 | 982 | } | |
763 | 983 | else throw("Strict value is not equal to itself.") | |
764 | 984 | } | |
765 | 985 | else throw("Strict value is not equal to itself.") | |
766 | 986 | } | |
767 | 987 | ||
768 | 988 | ||
769 | 989 | ||
770 | 990 | @Callable(i) | |
771 | 991 | func setManager (pendingManagerPublicKey) = { | |
772 | 992 | let checkCaller = mustManager(i) | |
773 | 993 | if ((checkCaller == checkCaller)) | |
774 | 994 | then { | |
775 | 995 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
776 | 996 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
777 | 997 | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
778 | 998 | else throw("Strict value is not equal to itself.") | |
779 | 999 | } | |
780 | 1000 | else throw("Strict value is not equal to itself.") | |
781 | 1001 | } | |
782 | 1002 | ||
783 | 1003 | ||
784 | 1004 | ||
785 | 1005 | @Callable(i) | |
786 | 1006 | func confirmManager () = { | |
787 | 1007 | let pm = pendingManagerPublicKeyOrUnit() | |
788 | 1008 | let hasPM = if (isDefined(pm)) | |
789 | 1009 | then true | |
790 | 1010 | else throw("No pending manager") | |
791 | 1011 | if ((hasPM == hasPM)) | |
792 | 1012 | then { | |
793 | 1013 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
794 | 1014 | then true | |
795 | 1015 | else throw("You are not pending manager") | |
796 | 1016 | if ((checkPM == checkPM)) | |
797 | 1017 | then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())] | |
798 | 1018 | else throw("Strict value is not equal to itself.") | |
799 | 1019 | } | |
800 | 1020 | else throw("Strict value is not equal to itself.") | |
801 | 1021 | } | |
802 | 1022 | ||
803 | 1023 | ||
804 | 1024 | ||
805 | 1025 | @Callable(i) | |
806 | 1026 | func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance)) | |
807 | 1027 | then throw("Invalid slippageTolerance passed") | |
808 | 1028 | else { | |
809 | 1029 | let estPut = commonPut(i, slippageTolerance, true) | |
810 | 1030 | let emitLpAmt = estPut._2 | |
811 | 1031 | let lpAssetId = estPut._7 | |
812 | 1032 | let state = estPut._9 | |
813 | 1033 | let amDiff = estPut._10 | |
814 | 1034 | let prDiff = estPut._11 | |
815 | 1035 | let amId = estPut._12 | |
816 | 1036 | let prId = estPut._13 | |
817 | 1037 | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
818 | 1038 | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
819 | 1039 | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
820 | 1040 | if ((currentKLp == currentKLp)) | |
821 | 1041 | then { | |
822 | 1042 | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
823 | 1043 | if ((emitInv == emitInv)) | |
824 | 1044 | then { | |
825 | 1045 | let emitInvLegacy = match emitInv { | |
826 | 1046 | case legacyFactoryContract: Address => | |
827 | 1047 | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
828 | 1048 | case _ => | |
829 | 1049 | unit | |
830 | 1050 | } | |
831 | 1051 | if ((emitInvLegacy == emitInvLegacy)) | |
832 | 1052 | then { | |
833 | 1053 | let slippageAInv = if ((amDiff > 0)) | |
834 | 1054 | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
835 | 1055 | else nil | |
836 | 1056 | if ((slippageAInv == slippageAInv)) | |
837 | 1057 | then { | |
838 | 1058 | let slippagePInv = if ((prDiff > 0)) | |
839 | 1059 | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
840 | 1060 | else nil | |
841 | 1061 | if ((slippagePInv == slippagePInv)) | |
842 | 1062 | then { | |
843 | 1063 | let lpTransfer = if (shouldAutoStake) | |
844 | 1064 | then { | |
845 | 1065 | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
846 | 1066 | if ((slpStakeInv == slpStakeInv)) | |
847 | 1067 | then nil | |
848 | 1068 | else throw("Strict value is not equal to itself.") | |
849 | 1069 | } | |
850 | 1070 | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
851 | - | let $ | |
852 | - | if (($ | |
1071 | + | let $t04394044402 = refreshKLpInternal(0, 0, 0) | |
1072 | + | if (($t04394044402 == $t04394044402)) | |
853 | 1073 | then { | |
854 | - | let updatedKLp = $ | |
855 | - | let refreshKLpActions = $ | |
1074 | + | let updatedKLp = $t04394044402._2 | |
1075 | + | let refreshKLpActions = $t04394044402._1 | |
856 | 1076 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
857 | 1077 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
858 | 1078 | then ((state ++ lpTransfer) ++ refreshKLpActions) | |
859 | 1079 | else throw("Strict value is not equal to itself.") | |
860 | 1080 | } | |
861 | 1081 | else throw("Strict value is not equal to itself.") | |
862 | 1082 | } | |
863 | 1083 | else throw("Strict value is not equal to itself.") | |
864 | 1084 | } | |
865 | 1085 | else throw("Strict value is not equal to itself.") | |
866 | 1086 | } | |
867 | 1087 | else throw("Strict value is not equal to itself.") | |
868 | 1088 | } | |
869 | 1089 | else throw("Strict value is not equal to itself.") | |
870 | 1090 | } | |
871 | 1091 | else throw("Strict value is not equal to itself.") | |
872 | 1092 | } | |
873 | 1093 | ||
874 | 1094 | ||
875 | 1095 | ||
876 | 1096 | @Callable(i) | |
877 | 1097 | func putForFree (maxSlippage) = if ((0 > maxSlippage)) | |
878 | 1098 | then throw("Invalid value passed") | |
879 | 1099 | else { | |
880 | 1100 | let estPut = commonPut(i, maxSlippage, false) | |
881 | 1101 | let state = estPut._9 | |
882 | 1102 | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
883 | 1103 | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
884 | 1104 | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
885 | 1105 | if ((currentKLp == currentKLp)) | |
886 | 1106 | then { | |
887 | - | let $ | |
888 | - | let refreshKLpActions = $ | |
889 | - | let updatedKLp = $ | |
1107 | + | let $t04496445029 = refreshKLpInternal(0, 0, 0) | |
1108 | + | let refreshKLpActions = $t04496445029._1 | |
1109 | + | let updatedKLp = $t04496445029._2 | |
890 | 1110 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
891 | 1111 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
892 | 1112 | then (state ++ refreshKLpActions) | |
893 | 1113 | else throw("Strict value is not equal to itself.") | |
894 | 1114 | } | |
895 | 1115 | else throw("Strict value is not equal to itself.") | |
896 | 1116 | } | |
897 | 1117 | ||
898 | 1118 | ||
899 | 1119 | ||
900 | 1120 | @Callable(i) | |
901 | 1121 | func putOneTkn (minOutAmount,autoStake) = { | |
902 | 1122 | let isPoolOneTokenOperationsDisabled = { | |
903 | 1123 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
904 | 1124 | if ($isInstanceOf(@, "Boolean")) | |
905 | 1125 | then @ | |
906 | 1126 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
907 | 1127 | } | |
908 | 1128 | let isPutDisabled = if (if (if (isGlobalShutdown()) | |
909 | 1129 | then true | |
910 | 1130 | else (cfgPoolStatus == PoolPutDisabled)) | |
911 | 1131 | then true | |
912 | 1132 | else (cfgPoolStatus == PoolShutdown)) | |
913 | 1133 | then true | |
914 | 1134 | else isPoolOneTokenOperationsDisabled | |
915 | 1135 | let checks = [if (if (!(isPutDisabled)) | |
916 | 1136 | then true | |
917 | 1137 | else isManager(i)) | |
918 | 1138 | then true | |
919 | 1139 | else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1)) | |
920 | 1140 | then true | |
921 | 1141 | else throwErr("exactly 1 payment are expected")] | |
922 | 1142 | if ((checks == checks)) | |
923 | 1143 | then { | |
924 | 1144 | let payment = i.payments[0] | |
925 | 1145 | let paymentAssetId = payment.assetId | |
926 | 1146 | let paymentAmountRaw = payment.amount | |
927 | 1147 | let currentKLp = if ((paymentAssetId == cfgAmountAssetId)) | |
928 | 1148 | then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0)) | |
929 | 1149 | else if ((paymentAssetId == cfgPriceAssetId)) | |
930 | 1150 | then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0)) | |
931 | 1151 | else throwErr("payment asset is not supported") | |
932 | 1152 | if ((currentKLp == currentKLp)) | |
933 | 1153 | then { | |
934 | 1154 | let userAddress = i.caller | |
935 | 1155 | let txId = i.transactionId | |
936 | - | let $ | |
937 | - | if (($ | |
1156 | + | let $t04621746369 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
1157 | + | if (($t04621746369 == $t04621746369)) | |
938 | 1158 | then { | |
939 | - | let paymentInAmountAsset = $ | |
940 | - | let bonus = $ | |
941 | - | let feeAmount = $ | |
942 | - | let commonState = $ | |
943 | - | let emitAmountEstimated = $ | |
1159 | + | let paymentInAmountAsset = $t04621746369._5 | |
1160 | + | let bonus = $t04621746369._4 | |
1161 | + | let feeAmount = $t04621746369._3 | |
1162 | + | let commonState = $t04621746369._2 | |
1163 | + | let emitAmountEstimated = $t04621746369._1 | |
944 | 1164 | let emitAmount = if (if ((minOutAmount > 0)) | |
945 | 1165 | then (minOutAmount > emitAmountEstimated) | |
946 | 1166 | else false) | |
947 | 1167 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
948 | 1168 | else emitAmountEstimated | |
949 | 1169 | let emitInv = emit(emitAmount) | |
950 | 1170 | if ((emitInv == emitInv)) | |
951 | 1171 | then { | |
952 | 1172 | let lpTransfer = if (autoStake) | |
953 | 1173 | then { | |
954 | 1174 | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
955 | 1175 | if ((stakeInv == stakeInv)) | |
956 | 1176 | then nil | |
957 | 1177 | else throw("Strict value is not equal to itself.") | |
958 | 1178 | } | |
959 | 1179 | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
960 | 1180 | let sendFee = if ((feeAmount > 0)) | |
961 | 1181 | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
962 | 1182 | else nil | |
963 | - | let $ | |
1183 | + | let $t04695547152 = if ((this == feeCollectorAddress)) | |
964 | 1184 | then $Tuple2(0, 0) | |
965 | 1185 | else if (paymentInAmountAsset) | |
966 | 1186 | then $Tuple2(-(feeAmount), 0) | |
967 | 1187 | else $Tuple2(0, -(feeAmount)) | |
968 | - | let amountAssetBalanceDelta = $ | |
969 | - | let priceAssetBalanceDelta = $ | |
970 | - | let $ | |
971 | - | let refreshKLpActions = $ | |
972 | - | let updatedKLp = $ | |
1188 | + | let amountAssetBalanceDelta = $t04695547152._1 | |
1189 | + | let priceAssetBalanceDelta = $t04695547152._2 | |
1190 | + | let $t04715547263 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1191 | + | let refreshKLpActions = $t04715547263._1 | |
1192 | + | let updatedKLp = $t04715547263._2 | |
973 | 1193 | let kLp = value(getString(keyKLp)) | |
974 | 1194 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
975 | 1195 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
976 | - | then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
1196 | + | then { | |
1197 | + | let reb = invoke(this, "rebalance", nil, nil) | |
1198 | + | if ((reb == reb)) | |
1199 | + | then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
1200 | + | else throw("Strict value is not equal to itself.") | |
1201 | + | } | |
977 | 1202 | else throw("Strict value is not equal to itself.") | |
978 | 1203 | } | |
979 | 1204 | else throw("Strict value is not equal to itself.") | |
980 | 1205 | } | |
981 | 1206 | else throw("Strict value is not equal to itself.") | |
982 | 1207 | } | |
983 | 1208 | else throw("Strict value is not equal to itself.") | |
984 | 1209 | } | |
985 | 1210 | else throw("Strict value is not equal to itself.") | |
986 | 1211 | } | |
987 | 1212 | ||
988 | 1213 | ||
989 | 1214 | ||
990 | 1215 | @Callable(i) | |
991 | 1216 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
992 | - | let $ | |
993 | - | let emitAmountEstimated = $ | |
994 | - | let commonState = $ | |
995 | - | let feeAmount = $ | |
996 | - | let bonus = $ | |
997 | - | let paymentInAmountAsset = $ | |
1217 | + | let $t04761847775 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
1218 | + | let emitAmountEstimated = $t04761847775._1 | |
1219 | + | let commonState = $t04761847775._2 | |
1220 | + | let feeAmount = $t04761847775._3 | |
1221 | + | let bonus = $t04761847775._4 | |
1222 | + | let paymentInAmountAsset = $t04761847775._5 | |
998 | 1223 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
999 | 1224 | } | |
1000 | 1225 | ||
1001 | 1226 | ||
1002 | 1227 | ||
1003 | 1228 | @Callable(i) | |
1004 | 1229 | func getOneTkn (outAssetIdStr,minOutAmount) = { | |
1005 | 1230 | let isPoolOneTokenOperationsDisabled = { | |
1006 | 1231 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
1007 | 1232 | if ($isInstanceOf(@, "Boolean")) | |
1008 | 1233 | then @ | |
1009 | 1234 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
1010 | 1235 | } | |
1011 | 1236 | let isGetDisabled = if (if (isGlobalShutdown()) | |
1012 | 1237 | then true | |
1013 | 1238 | else (cfgPoolStatus == PoolShutdown)) | |
1014 | 1239 | then true | |
1015 | 1240 | else isPoolOneTokenOperationsDisabled | |
1016 | 1241 | let checks = [if (if (!(isGetDisabled)) | |
1017 | 1242 | then true | |
1018 | 1243 | else isManager(i)) | |
1019 | 1244 | then true | |
1020 | 1245 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1)) | |
1021 | 1246 | then true | |
1022 | 1247 | else throwErr("exactly 1 payment are expected")] | |
1023 | 1248 | if ((checks == checks)) | |
1024 | 1249 | then { | |
1025 | 1250 | let outAssetId = parseAssetId(outAssetIdStr) | |
1026 | 1251 | let payment = i.payments[0] | |
1027 | 1252 | let paymentAssetId = payment.assetId | |
1028 | 1253 | let paymentAmount = payment.amount | |
1029 | 1254 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1030 | 1255 | if ((currentKLp == currentKLp)) | |
1031 | 1256 | then { | |
1032 | 1257 | let userAddress = i.caller | |
1033 | 1258 | let txId = i.transactionId | |
1034 | - | let $ | |
1035 | - | if (($ | |
1259 | + | let $t04866048813 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
1260 | + | if (($t04866048813 == $t04866048813)) | |
1036 | 1261 | then { | |
1037 | - | let outInAmountAsset = $ | |
1038 | - | let bonus = $ | |
1039 | - | let feeAmount = $ | |
1040 | - | let commonState = $ | |
1041 | - | let amountEstimated = $ | |
1262 | + | let outInAmountAsset = $t04866048813._5 | |
1263 | + | let bonus = $t04866048813._4 | |
1264 | + | let feeAmount = $t04866048813._3 | |
1265 | + | let commonState = $t04866048813._2 | |
1266 | + | let amountEstimated = $t04866048813._1 | |
1042 | 1267 | let amount = if (if ((minOutAmount > 0)) | |
1043 | 1268 | then (minOutAmount > amountEstimated) | |
1044 | 1269 | else false) | |
1045 | 1270 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1046 | 1271 | else amountEstimated | |
1272 | + | let lsConf = match getLeaseProxyConfig(outAssetIdStr) { | |
1273 | + | case a: (Boolean, Int, Int, String, String, Int, String) => | |
1274 | + | a | |
1275 | + | case _ => | |
1276 | + | throw("error lease config") | |
1277 | + | } | |
1278 | + | let $t04919749311 = lsConf | |
1279 | + | let isLeasable = $t04919749311._1 | |
1280 | + | let leasedRatio = $t04919749311._2 | |
1281 | + | let minBalance = $t04919749311._3 | |
1282 | + | let proxyAddress = $t04919749311._4 | |
1283 | + | let proxyAssetId = $t04919749311._5 | |
1284 | + | let proxyRateMul = $t04919749311._6 | |
1285 | + | let stakingProfitAddress = $t04919749311._7 | |
1286 | + | let assetOnPool = assetBalance(this, fromBase58String(outAssetIdStr)) | |
1287 | + | let amountOfProfit = if (if ((outAssetIdStr == "WAVES")) | |
1288 | + | then (amount > assetOnPool) | |
1289 | + | else false) | |
1290 | + | then { | |
1291 | + | let amountDiff = (amount - assetOnPool) | |
1292 | + | let oldRatio = (getAdditionalBalance(outAssetIdStr) / getStakingAssetBalance(sWavesId())) | |
1293 | + | let oldWavesRoughBalane = wavesBalance(this).available | |
1294 | + | let wd = invoke(this, "withdraw", [outAssetIdStr, amountDiff, sWavesId(), sWavesProxy(), proxyRateMul], nil) | |
1295 | + | if ((wd == wd)) | |
1296 | + | then { | |
1297 | + | let newWavesRoughBalane = wavesBalance(this).available | |
1298 | + | let wavesDiff = (newWavesRoughBalane - oldWavesRoughBalane) | |
1299 | + | (wavesDiff - amountDiff) | |
1300 | + | } | |
1301 | + | else throw("Strict value is not equal to itself.") | |
1302 | + | } | |
1303 | + | else 0 | |
1304 | + | let profitTransfer = [ScriptTransfer(addressFromStringValue(stakingProfitAddress), amountOfProfit, unit)] | |
1047 | 1305 | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
1048 | 1306 | if ((burnInv == burnInv)) | |
1049 | 1307 | then { | |
1050 | 1308 | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
1051 | 1309 | let sendFee = if ((feeAmount > 0)) | |
1052 | 1310 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1053 | 1311 | else nil | |
1054 | - | let $ | |
1312 | + | let $t05035050597 = { | |
1055 | 1313 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1056 | 1314 | then 0 | |
1057 | 1315 | else feeAmount | |
1058 | 1316 | if (outInAmountAsset) | |
1059 | 1317 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1060 | 1318 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1061 | 1319 | } | |
1062 | - | let amountAssetBalanceDelta = $ | |
1063 | - | let priceAssetBalanceDelta = $ | |
1064 | - | let $ | |
1065 | - | let refreshKLpActions = $ | |
1066 | - | let updatedKLp = $ | |
1320 | + | let amountAssetBalanceDelta = $t05035050597._1 | |
1321 | + | let priceAssetBalanceDelta = $t05035050597._2 | |
1322 | + | let $t05060050708 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1323 | + | let refreshKLpActions = $t05060050708._1 | |
1324 | + | let updatedKLp = $t05060050708._2 | |
1067 | 1325 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1068 | 1326 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1069 | - | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1327 | + | then { | |
1328 | + | let reb = invoke(this, "rebalance", nil, nil) | |
1329 | + | if ((reb == reb)) | |
1330 | + | then $Tuple2(((((commonState ++ assetTransfer) ++ profitTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1331 | + | else throw("Strict value is not equal to itself.") | |
1332 | + | } | |
1070 | 1333 | else throw("Strict value is not equal to itself.") | |
1071 | 1334 | } | |
1072 | 1335 | else throw("Strict value is not equal to itself.") | |
1073 | 1336 | } | |
1074 | 1337 | else throw("Strict value is not equal to itself.") | |
1075 | 1338 | } | |
1076 | 1339 | else throw("Strict value is not equal to itself.") | |
1077 | 1340 | } | |
1078 | 1341 | else throw("Strict value is not equal to itself.") | |
1079 | 1342 | } | |
1080 | 1343 | ||
1081 | 1344 | ||
1082 | 1345 | ||
1083 | 1346 | @Callable(i) | |
1084 | 1347 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
1085 | - | let $ | |
1086 | - | let amountEstimated = $ | |
1087 | - | let commonState = $ | |
1088 | - | let feeAmount = $ | |
1089 | - | let bonus = $ | |
1090 | - | let outInAmountAsset = $ | |
1348 | + | let $t05103551191 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
1349 | + | let amountEstimated = $t05103551191._1 | |
1350 | + | let commonState = $t05103551191._2 | |
1351 | + | let feeAmount = $t05103551191._3 | |
1352 | + | let bonus = $t05103551191._4 | |
1353 | + | let outInAmountAsset = $t05103551191._5 | |
1091 | 1354 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
1092 | 1355 | } | |
1093 | 1356 | ||
1094 | 1357 | ||
1095 | 1358 | ||
1096 | 1359 | @Callable(i) | |
1097 | 1360 | func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = { | |
1098 | 1361 | let isPoolOneTokenOperationsDisabled = { | |
1099 | 1362 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
1100 | 1363 | if ($isInstanceOf(@, "Boolean")) | |
1101 | 1364 | then @ | |
1102 | 1365 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
1103 | 1366 | } | |
1104 | 1367 | let isGetDisabled = if (if (isGlobalShutdown()) | |
1105 | 1368 | then true | |
1106 | 1369 | else (cfgPoolStatus == PoolShutdown)) | |
1107 | 1370 | then true | |
1108 | 1371 | else isPoolOneTokenOperationsDisabled | |
1109 | 1372 | let checks = [if (if (!(isGetDisabled)) | |
1110 | 1373 | then true | |
1111 | 1374 | else isManager(i)) | |
1112 | 1375 | then true | |
1113 | 1376 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1114 | 1377 | then true | |
1115 | 1378 | else throwErr("no payments are expected")] | |
1116 | 1379 | if ((checks == checks)) | |
1117 | 1380 | then { | |
1118 | 1381 | let outAssetId = parseAssetId(outAssetIdStr) | |
1119 | 1382 | let userAddress = i.caller | |
1120 | 1383 | let txId = i.transactionId | |
1121 | 1384 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1122 | 1385 | if ((currentKLp == currentKLp)) | |
1123 | 1386 | then { | |
1124 | 1387 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1125 | 1388 | if ((unstakeInv == unstakeInv)) | |
1126 | 1389 | then { | |
1127 | - | let $ | |
1128 | - | if (($ | |
1390 | + | let $t05209652247 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
1391 | + | if (($t05209652247 == $t05209652247)) | |
1129 | 1392 | then { | |
1130 | - | let outInAmountAsset = $ | |
1131 | - | let bonus = $ | |
1132 | - | let feeAmount = $ | |
1133 | - | let commonState = $ | |
1134 | - | let amountEstimated = $ | |
1393 | + | let outInAmountAsset = $t05209652247._5 | |
1394 | + | let bonus = $t05209652247._4 | |
1395 | + | let feeAmount = $t05209652247._3 | |
1396 | + | let commonState = $t05209652247._2 | |
1397 | + | let amountEstimated = $t05209652247._1 | |
1135 | 1398 | let amount = if (if ((minOutAmount > 0)) | |
1136 | 1399 | then (minOutAmount > amountEstimated) | |
1137 | 1400 | else false) | |
1138 | 1401 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1139 | 1402 | else amountEstimated | |
1140 | 1403 | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1141 | 1404 | if ((burnInv == burnInv)) | |
1142 | 1405 | then { | |
1143 | 1406 | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
1144 | 1407 | let sendFee = if ((feeAmount > 0)) | |
1145 | 1408 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1146 | 1409 | else nil | |
1147 | - | let $ | |
1410 | + | let $t05274252989 = { | |
1148 | 1411 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1149 | 1412 | then 0 | |
1150 | 1413 | else feeAmount | |
1151 | 1414 | if (outInAmountAsset) | |
1152 | 1415 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1153 | 1416 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1154 | 1417 | } | |
1155 | - | let amountAssetBalanceDelta = $ | |
1156 | - | let priceAssetBalanceDelta = $ | |
1157 | - | let $ | |
1158 | - | let refreshKLpActions = $ | |
1159 | - | let updatedKLp = $ | |
1418 | + | let amountAssetBalanceDelta = $t05274252989._1 | |
1419 | + | let priceAssetBalanceDelta = $t05274252989._2 | |
1420 | + | let $t05299253100 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1421 | + | let refreshKLpActions = $t05299253100._1 | |
1422 | + | let updatedKLp = $t05299253100._2 | |
1160 | 1423 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1161 | 1424 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1162 | 1425 | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1163 | 1426 | else throw("Strict value is not equal to itself.") | |
1164 | 1427 | } | |
1165 | 1428 | else throw("Strict value is not equal to itself.") | |
1166 | 1429 | } | |
1167 | 1430 | else throw("Strict value is not equal to itself.") | |
1168 | 1431 | } | |
1169 | 1432 | else throw("Strict value is not equal to itself.") | |
1170 | 1433 | } | |
1171 | 1434 | else throw("Strict value is not equal to itself.") | |
1172 | 1435 | } | |
1173 | 1436 | else throw("Strict value is not equal to itself.") | |
1174 | 1437 | } | |
1175 | 1438 | ||
1176 | 1439 | ||
1177 | 1440 | ||
1178 | 1441 | @Callable(i) | |
1179 | 1442 | func get () = { | |
1180 | 1443 | let res = commonGet(i) | |
1181 | 1444 | let outAmtAmt = res._1 | |
1182 | 1445 | let outPrAmt = res._2 | |
1183 | 1446 | let pmtAmt = res._3 | |
1184 | 1447 | let pmtAssetId = res._4 | |
1185 | 1448 | let state = res._5 | |
1186 | 1449 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1187 | 1450 | if ((currentKLp == currentKLp)) | |
1188 | 1451 | then { | |
1189 | 1452 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1190 | 1453 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1191 | 1454 | then { | |
1192 | - | let $ | |
1193 | - | let refreshKLpActions = $ | |
1194 | - | let updatedKLp = $ | |
1455 | + | let $t05404654128 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1456 | + | let refreshKLpActions = $t05404654128._1 | |
1457 | + | let updatedKLp = $t05404654128._2 | |
1195 | 1458 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1196 | 1459 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1197 | 1460 | then (state ++ refreshKLpActions) | |
1198 | 1461 | else throw("Strict value is not equal to itself.") | |
1199 | 1462 | } | |
1200 | 1463 | else throw("Strict value is not equal to itself.") | |
1201 | 1464 | } | |
1202 | 1465 | else throw("Strict value is not equal to itself.") | |
1203 | 1466 | } | |
1204 | 1467 | ||
1205 | 1468 | ||
1206 | 1469 | ||
1207 | 1470 | @Callable(i) | |
1208 | 1471 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
1209 | 1472 | let res = commonGet(i) | |
1210 | 1473 | let outAmAmt = res._1 | |
1211 | 1474 | let outPrAmt = res._2 | |
1212 | 1475 | let pmtAmt = res._3 | |
1213 | 1476 | let pmtAssetId = res._4 | |
1214 | 1477 | let state = res._5 | |
1215 | 1478 | if ((noLessThenAmtAsset > outAmAmt)) | |
1216 | 1479 | then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
1217 | 1480 | else if ((noLessThenPriceAsset > outPrAmt)) | |
1218 | 1481 | then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
1219 | 1482 | else { | |
1220 | 1483 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1221 | 1484 | if ((currentKLp == currentKLp)) | |
1222 | 1485 | then { | |
1223 | 1486 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1224 | 1487 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1225 | 1488 | then { | |
1226 | - | let $ | |
1227 | - | let refreshKLpActions = $ | |
1228 | - | let updatedKLp = $ | |
1489 | + | let $t05507755158 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1490 | + | let refreshKLpActions = $t05507755158._1 | |
1491 | + | let updatedKLp = $t05507755158._2 | |
1229 | 1492 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1230 | 1493 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1231 | 1494 | then (state ++ refreshKLpActions) | |
1232 | 1495 | else throw("Strict value is not equal to itself.") | |
1233 | 1496 | } | |
1234 | 1497 | else throw("Strict value is not equal to itself.") | |
1235 | 1498 | } | |
1236 | 1499 | else throw("Strict value is not equal to itself.") | |
1237 | 1500 | } | |
1238 | 1501 | } | |
1239 | 1502 | ||
1240 | 1503 | ||
1241 | 1504 | ||
1242 | 1505 | @Callable(i) | |
1243 | 1506 | func unstakeAndGet (amount) = { | |
1244 | 1507 | let checkPayments = if ((size(i.payments) != 0)) | |
1245 | 1508 | then throw("No payments are expected") | |
1246 | 1509 | else true | |
1247 | 1510 | if ((checkPayments == checkPayments)) | |
1248 | 1511 | then { | |
1249 | 1512 | let cfg = getPoolConfig() | |
1250 | 1513 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1251 | 1514 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1252 | 1515 | if ((currentKLp == currentKLp)) | |
1253 | 1516 | then { | |
1254 | 1517 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1255 | 1518 | if ((unstakeInv == unstakeInv)) | |
1256 | 1519 | then { | |
1257 | 1520 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1258 | 1521 | let outAmAmt = res._1 | |
1259 | 1522 | let outPrAmt = res._2 | |
1260 | 1523 | let poolStatus = parseIntValue(res._9) | |
1261 | 1524 | let state = res._10 | |
1262 | 1525 | let checkPoolStatus = if (if (isGlobalShutdown()) | |
1263 | 1526 | then true | |
1264 | 1527 | else (poolStatus == PoolShutdown)) | |
1265 | 1528 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
1266 | 1529 | else true | |
1267 | 1530 | if ((checkPoolStatus == checkPoolStatus)) | |
1268 | 1531 | then { | |
1269 | 1532 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1270 | 1533 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1271 | 1534 | then { | |
1272 | - | let $ | |
1273 | - | let refreshKLpActions = $ | |
1274 | - | let updatedKLp = $ | |
1535 | + | let $t05628456365 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1536 | + | let refreshKLpActions = $t05628456365._1 | |
1537 | + | let updatedKLp = $t05628456365._2 | |
1275 | 1538 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1276 | 1539 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1277 | 1540 | then (state ++ refreshKLpActions) | |
1278 | 1541 | else throw("Strict value is not equal to itself.") | |
1279 | 1542 | } | |
1280 | 1543 | else throw("Strict value is not equal to itself.") | |
1281 | 1544 | } | |
1282 | 1545 | else throw("Strict value is not equal to itself.") | |
1283 | 1546 | } | |
1284 | 1547 | else throw("Strict value is not equal to itself.") | |
1285 | 1548 | } | |
1286 | 1549 | else throw("Strict value is not equal to itself.") | |
1287 | 1550 | } | |
1288 | 1551 | else throw("Strict value is not equal to itself.") | |
1289 | 1552 | } | |
1290 | 1553 | ||
1291 | 1554 | ||
1292 | 1555 | ||
1293 | 1556 | @Callable(i) | |
1294 | 1557 | func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = { | |
1295 | 1558 | let isGetDisabled = if (isGlobalShutdown()) | |
1296 | 1559 | then true | |
1297 | 1560 | else (cfgPoolStatus == PoolShutdown) | |
1298 | 1561 | let checks = [if (!(isGetDisabled)) | |
1299 | 1562 | then true | |
1300 | 1563 | else throw("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1301 | 1564 | then true | |
1302 | 1565 | else throw("no payments are expected")] | |
1303 | 1566 | if ((checks == checks)) | |
1304 | 1567 | then { | |
1305 | 1568 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1306 | 1569 | if ((currentKLp == currentKLp)) | |
1307 | 1570 | then { | |
1308 | 1571 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1309 | 1572 | if ((unstakeInv == unstakeInv)) | |
1310 | 1573 | then { | |
1311 | 1574 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1312 | 1575 | let outAmAmt = res._1 | |
1313 | 1576 | let outPrAmt = res._2 | |
1314 | 1577 | let state = res._10 | |
1315 | 1578 | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1316 | 1579 | then true | |
1317 | 1580 | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1318 | 1581 | then true | |
1319 | 1582 | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1320 | 1583 | if ((checkAmounts == checkAmounts)) | |
1321 | 1584 | then { | |
1322 | 1585 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1323 | 1586 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1324 | 1587 | then { | |
1325 | - | let $ | |
1326 | - | let refreshKLpActions = $ | |
1327 | - | let updatedKLp = $ | |
1588 | + | let $t05766057741 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1589 | + | let refreshKLpActions = $t05766057741._1 | |
1590 | + | let updatedKLp = $t05766057741._2 | |
1328 | 1591 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1329 | 1592 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1330 | 1593 | then (state ++ refreshKLpActions) | |
1331 | 1594 | else throw("Strict value is not equal to itself.") | |
1332 | 1595 | } | |
1333 | 1596 | else throw("Strict value is not equal to itself.") | |
1334 | 1597 | } | |
1335 | 1598 | else throw("Strict value is not equal to itself.") | |
1336 | 1599 | } | |
1337 | 1600 | else throw("Strict value is not equal to itself.") | |
1338 | 1601 | } | |
1339 | 1602 | else throw("Strict value is not equal to itself.") | |
1340 | 1603 | } | |
1341 | 1604 | else throw("Strict value is not equal to itself.") | |
1342 | 1605 | } | |
1343 | 1606 | ||
1344 | 1607 | ||
1345 | 1608 | ||
1346 | 1609 | @Callable(i) | |
1347 | 1610 | func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract))) | |
1348 | 1611 | then throw("permissions denied") | |
1349 | 1612 | else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success") | |
1350 | 1613 | ||
1351 | 1614 | ||
1352 | 1615 | ||
1353 | 1616 | @Callable(i) | |
1354 | 1617 | func refreshKLp () = { | |
1355 | 1618 | let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0) | |
1356 | 1619 | let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay)) | |
1357 | 1620 | then unit | |
1358 | 1621 | else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1359 | 1622 | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1360 | 1623 | then { | |
1361 | 1624 | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
1362 | - | let $ | |
1363 | - | let kLpUpdateActions = $ | |
1364 | - | let updatedKLp = $ | |
1625 | + | let $t05892858992 = refreshKLpInternal(0, 0, 0) | |
1626 | + | let kLpUpdateActions = $t05892858992._1 | |
1627 | + | let updatedKLp = $t05892858992._2 | |
1365 | 1628 | let actions = if ((kLp != updatedKLp)) | |
1366 | 1629 | then kLpUpdateActions | |
1367 | 1630 | else throwErr("nothing to refresh") | |
1368 | 1631 | $Tuple2(actions, toString(updatedKLp)) | |
1369 | 1632 | } | |
1370 | 1633 | else throw("Strict value is not equal to itself.") | |
1371 | 1634 | } | |
1372 | 1635 | ||
1373 | 1636 | ||
1374 | 1637 | ||
1375 | 1638 | @Callable(i) | |
1376 | 1639 | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig()) | |
1377 | 1640 | ||
1378 | 1641 | ||
1379 | 1642 | ||
1380 | 1643 | @Callable(i) | |
1381 | 1644 | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
1382 | 1645 | ||
1383 | 1646 | ||
1384 | 1647 | ||
1385 | 1648 | @Callable(i) | |
1386 | 1649 | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
1387 | 1650 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
1388 | 1651 | $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])]) | |
1389 | 1652 | } | |
1390 | 1653 | ||
1391 | 1654 | ||
1392 | 1655 | ||
1393 | 1656 | @Callable(i) | |
1394 | 1657 | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult))) | |
1395 | 1658 | ||
1396 | 1659 | ||
1397 | 1660 | ||
1398 | 1661 | @Callable(i) | |
1399 | 1662 | func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult)) | |
1400 | 1663 | ||
1401 | 1664 | ||
1402 | 1665 | ||
1403 | 1666 | @Callable(i) | |
1404 | 1667 | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
1405 | 1668 | ||
1406 | 1669 | ||
1407 | 1670 | ||
1408 | 1671 | @Callable(i) | |
1409 | 1672 | func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp)) | |
1410 | 1673 | ||
1411 | 1674 | ||
1412 | 1675 | ||
1413 | 1676 | @Callable(i) | |
1414 | 1677 | func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
1415 | 1678 | let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress)) | |
1416 | 1679 | $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10)) | |
1417 | 1680 | } | |
1418 | 1681 | ||
1419 | 1682 | ||
1420 | 1683 | ||
1421 | 1684 | @Callable(i) | |
1422 | 1685 | func statsREADONLY () = { | |
1423 | 1686 | let cfg = getPoolConfig() | |
1424 | 1687 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1425 | 1688 | let amtAssetId = cfg[idxAmtAssetId] | |
1426 | 1689 | let priceAssetId = cfg[idxPriceAssetId] | |
1427 | 1690 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
1428 | 1691 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
1429 | 1692 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1430 | 1693 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1431 | 1694 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1432 | 1695 | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
1433 | 1696 | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
1434 | 1697 | let pricesList = if ((poolLPBalance == 0)) | |
1435 | 1698 | then [zeroBigInt, zeroBigInt, zeroBigInt] | |
1436 | 1699 | else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance) | |
1437 | 1700 | let curPrice = 0 | |
1438 | 1701 | let lpAmtAssetShare = fromX18(pricesList[1], scale8) | |
1439 | 1702 | let lpPriceAssetShare = fromX18(pricesList[2], scale8) | |
1440 | 1703 | let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this)))) | |
1441 | 1704 | $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)) | |
1442 | 1705 | } | |
1443 | 1706 | ||
1444 | 1707 | ||
1445 | 1708 | ||
1446 | 1709 | @Callable(i) | |
1447 | 1710 | func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = { | |
1448 | 1711 | let cfg = getPoolConfig() | |
1449 | 1712 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1450 | 1713 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1451 | 1714 | let amAssetId = fromBase58String(amAssetIdStr) | |
1452 | 1715 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1453 | 1716 | let prAssetId = fromBase58String(prAssetIdStr) | |
1454 | 1717 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1455 | 1718 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1456 | 1719 | let poolStatus = cfg[idxPoolStatus] | |
1457 | 1720 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1458 | 1721 | let accAmtAssetBalance = getAccBalance(amAssetIdStr) | |
1459 | 1722 | let accPriceAssetBalance = getAccBalance(prAssetIdStr) | |
1460 | 1723 | let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm) | |
1461 | 1724 | let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm) | |
1462 | 1725 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1463 | 1726 | then zeroBigInt | |
1464 | 1727 | else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
1465 | 1728 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
1466 | 1729 | let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
1467 | 1730 | let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm) | |
1468 | 1731 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1469 | 1732 | let calcLpAmt = estPut._1 | |
1470 | 1733 | let curPriceCalc = estPut._3 | |
1471 | 1734 | let amBalance = estPut._4 | |
1472 | 1735 | let prBalance = estPut._5 | |
1473 | 1736 | let lpEmission = estPut._6 | |
1474 | 1737 | $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)) | |
1475 | 1738 | } | |
1476 | 1739 | ||
1477 | 1740 | ||
1478 | 1741 | ||
1479 | 1742 | @Callable(i) | |
1480 | 1743 | func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = { | |
1481 | 1744 | let cfg = getPoolConfig() | |
1482 | 1745 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1483 | 1746 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1484 | 1747 | let amAssetId = fromBase58String(amAssetIdStr) | |
1485 | 1748 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1486 | 1749 | let prAssetId = fromBase58String(prAssetIdStr) | |
1487 | 1750 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1488 | 1751 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1489 | 1752 | let poolStatus = cfg[idxPoolStatus] | |
1490 | 1753 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1491 | 1754 | let amBalanceRaw = getAccBalance(amAssetIdStr) | |
1492 | 1755 | let prBalanceRaw = getAccBalance(prAssetIdStr) | |
1493 | 1756 | let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm) | |
1494 | 1757 | let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm) | |
1495 | 1758 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1496 | 1759 | then zeroBigInt | |
1497 | 1760 | else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18) | |
1498 | 1761 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
1499 | 1762 | let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
1500 | 1763 | let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm) | |
1501 | 1764 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1502 | 1765 | let calcLpAmt = estPut._1 | |
1503 | 1766 | let curPriceCalc = estPut._3 | |
1504 | 1767 | let amBalance = estPut._4 | |
1505 | 1768 | let prBalance = estPut._5 | |
1506 | 1769 | let lpEmission = estPut._6 | |
1507 | 1770 | $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)) | |
1508 | 1771 | } | |
1509 | 1772 | ||
1510 | 1773 | ||
1511 | 1774 | ||
1512 | 1775 | @Callable(i) | |
1513 | 1776 | func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = { | |
1514 | 1777 | let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this) | |
1515 | 1778 | let outAmAmt = res._1 | |
1516 | 1779 | let outPrAmt = res._2 | |
1517 | 1780 | let amBalance = res._5 | |
1518 | 1781 | let prBalance = res._6 | |
1519 | 1782 | let lpEmission = res._7 | |
1520 | 1783 | let curPrice = res._8 | |
1521 | 1784 | let poolStatus = parseIntValue(res._9) | |
1522 | 1785 | $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)) | |
1523 | 1786 | } | |
1524 | 1787 | ||
1525 | 1788 | ||
1526 | 1789 | @Verifier(tx) | |
1527 | 1790 | func verify () = { | |
1528 | 1791 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
1529 | 1792 | case pk: ByteVector => | |
1530 | 1793 | pk | |
1531 | 1794 | case _: Unit => | |
1532 | 1795 | tx.senderPublicKey | |
1533 | 1796 | case _ => | |
1534 | 1797 | throw("Match error") | |
1535 | 1798 | } | |
1536 | 1799 | match tx { | |
1537 | 1800 | case order: Order => | |
1538 | 1801 | let matcherPub = getMatcherPubOrFail() | |
1539 | - | let $ | |
1540 | - | let orderValid = $ | |
1541 | - | let orderValidInfo = $ | |
1802 | + | let $t06765467723 = validateMatcherOrderAllowed(order) | |
1803 | + | let orderValid = $t06765467723._1 | |
1804 | + | let orderValidInfo = $t06765467723._2 | |
1542 | 1805 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1543 | 1806 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1544 | 1807 | if (if (if (orderValid) | |
1545 | 1808 | then senderValid | |
1546 | 1809 | else false) | |
1547 | 1810 | then matcherValid | |
1548 | 1811 | else false) | |
1549 | 1812 | then true | |
1550 | 1813 | else throwOrderError(orderValid, orderValidInfo, senderValid, matcherValid) | |
1551 | 1814 | case s: SetScriptTransaction => | |
1552 | 1815 | if (sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)) | |
1553 | 1816 | then true | |
1554 | 1817 | else { | |
1555 | 1818 | let newHash = blake2b256(value(s.script)) | |
1556 | 1819 | let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash()))) | |
1557 | 1820 | let currentHash = scriptHash(this) | |
1558 | 1821 | if ((allowedHash == newHash)) | |
1559 | 1822 | then (currentHash != newHash) | |
1560 | 1823 | else false | |
1561 | 1824 | } | |
1562 | 1825 | case _ => | |
1563 | 1826 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1564 | 1827 | } | |
1565 | 1828 | } | |
1566 | 1829 |
github/deemru/w8io/026f985 331.84 ms ◑