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