tx · 39vgKtpBYiPeCfEuRJCMUJ2MnrG4Z75NhSZScURj9HeE 3Mzep1R5kHeC1ecKFkWjuhU3Gw4LAdCib9N: -0.01500000 Waves 2024.02.06 09:59 [2964060] smart account 3Mzep1R5kHeC1ecKFkWjuhU3Gw4LAdCib9N > SELF 0.00000000 Waves
{ "type": 13, "id": "39vgKtpBYiPeCfEuRJCMUJ2MnrG4Z75NhSZScURj9HeE", "fee": 1500000, "feeAssetId": null, "timestamp": 1707202806384, "version": 2, "chainId": 84, "sender": "3Mzep1R5kHeC1ecKFkWjuhU3Gw4LAdCib9N", "senderPublicKey": "41THq9VrFxHEvVGJyz2oMpJQErnSkkqJXpBypSDxa5Mv", "proofs": [ "Vo9Q8etihaiT7EyVf9yZhuxDiKAKZGyqMnW37CjjXyS53gneoYHHJ9vvHLf173vu7QHRedbRdksbEsuZZgWZ2y1" ], "script": "base64:BwIaCAISBAoCAhgSBAoCAhgSBAoCAhgSBAoCAhgoAAdjaGFpbklkCQDJAQIJAMoBAggFBHRoaXMFYnl0ZXMAAQABAAhjaGFpbklkVAEBVAAIY2hhaW5JZFcBAVcAA1NFUAICX18ABVdBVkVTAgVXQVZFUwAQY29udHJhY3RGaWxlbmFtZQIVd3hkYW9fY2FsY3VsYXRvci5yaWRlAAVtdWx0OACAwtcvAAZtdWx0MTgJALYCAQCAgJC7utat8A0ADXdhdmVzRGVjaW1hbHMACAAMdXNkdERlY2ltYWxzAAYBBXRvWDE4AgdvcmlnVmFsDW9yaWdTY2FsZU11bHQJALwCAwkAtgIBBQdvcmlnVmFsBQZtdWx0MTgJALYCAQUNb3JpZ1NjYWxlTXVsdAEHZnJvbVgxOAIDdmFsD3Jlc3VsdFNjYWxlTXVsdAkAoAMBCQC8AgMFA3ZhbAkAtgIBBQ9yZXN1bHRTY2FsZU11bHQFBm11bHQxOAEHd3JhcEVycgEBcwkArAICCQCsAgIFEGNvbnRyYWN0RmlsZW5hbWUCAjogBQFzAQh0aHJvd0VycgEBcwkAAgE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WNpxEUHKt Diff:
Old | New | Differences | |
---|---|---|---|
355 | 355 | } | |
356 | 356 | ||
357 | 357 | ||
358 | + | func calcRewards (factoryAddress,paymentAmount) = { | |
359 | + | let assetsStr = split(getAssetsStr(factoryAddress), SEP) | |
360 | + | let wxdaoQuantity = getAssetInfoOrFail(getLpAssetId(factoryAddress)).quantity | |
361 | + | if ((wxdaoQuantity == wxdaoQuantity)) | |
362 | + | then { | |
363 | + | let assetsBalances = getAssetsBalances(factoryAddress, assetsStr) | |
364 | + | func map (acc,nextAssetIdStr) = { | |
365 | + | let assetId = fromBase58String(nextAssetIdStr) | |
366 | + | let index = valueOrErrorMessage(indexOf(assetsStr, nextAssetIdStr), wrapErr("invalid asset balance")) | |
367 | + | let assetDecimals = getAssetInfoOrFail(assetId).decimals | |
368 | + | let balance = fromX18(assetsBalances[index], pow(10, 0, assetDecimals, 0, 0, DOWN)) | |
369 | + | let amount = fraction(balance, paymentAmount, wxdaoQuantity) | |
370 | + | if ((amount > 0)) | |
371 | + | then $Tuple2((acc._1 :+ assetId), (acc._2 :+ amount)) | |
372 | + | else acc | |
373 | + | } | |
374 | + | ||
375 | + | let $l = assetsStr | |
376 | + | let $s = size($l) | |
377 | + | let $acc0 = $Tuple2(nil, nil) | |
378 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
379 | + | then $a | |
380 | + | else map($a, $l[$i]) | |
381 | + | ||
382 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
383 | + | then $a | |
384 | + | else throw("List size exceeds 6") | |
385 | + | ||
386 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6) | |
387 | + | } | |
388 | + | else throw("Strict value is not equal to itself.") | |
389 | + | } | |
390 | + | ||
391 | + | ||
358 | 392 | func calcPrice (factoryAddress) = { | |
359 | 393 | let poolsFactoryAddress = getPoolsFactoryAddress(factoryAddress) | |
360 | 394 | let currentPeriod = valueOrErrorMessage(getInteger(factoryAddress, keyCurrentPeriod()), wrapErr("invalid current period")) | |
363 | 397 | let treasuryValueDiff = (treasuryValue - startTreasuryValue) | |
364 | 398 | let treasuryValueDiffRaw = toX18(treasuryValueDiff, pow(10, 0, usdtDecimals, 0, 0, DOWN)) | |
365 | 399 | let pwrAssetId = getPowerAssetId(factoryAddress) | |
400 | + | let pwrInfo = getAssetInfoOrFail(pwrAssetId) | |
366 | 401 | let pwrPriceRaw = getAssetsPrices(poolsFactoryAddress, [toBase58String(pwrAssetId)])[0] | |
367 | 402 | let pwrPrice = if ((pwrPriceRaw > toBigInt(0))) | |
368 | 403 | then fromX18(pwrPriceRaw, pow(10, 0, usdtDecimals, 0, 0, DOWN)) | |
369 | 404 | else throwErr("invalid PWR price") | |
370 | 405 | let treasuryAddress = getTreasuryAddress(factoryAddress) | |
371 | 406 | let skinTotal = valueOrElse(getInteger(powerContractAddress(factoryAddress), keySkinTotal(treasuryAddress)), 0) | |
372 | - | let pwrRemaining = (getAssetInfoOrFail(getLpAssetId(factoryAddress)).quantity / 100) | |
407 | + | let wxdaoInfo = getAssetInfoOrFail(getLpAssetId(factoryAddress)) | |
408 | + | let pwrRemaining = (wxdaoInfo.quantity / 100) | |
373 | 409 | let pwrAmount = (skinTotal + pwrRemaining) | |
374 | - | let pwrAmountRaw = toX18(pwrAmount, pow(10, 0, | |
410 | + | let pwrAmountRaw = toX18(pwrAmount, pow(10, 0, pwrInfo.decimals, 0, 0, DOWN)) | |
375 | 411 | let factoryAddressWxBalanceRaw = getAssetsBalances(factoryAddress, [toBase58String(wxAssetId)])[0] | |
376 | 412 | let factoryAddressWxBalance = fromX18(factoryAddressWxBalanceRaw, pow(10, 0, usdtDecimals, 0, 0, DOWN)) | |
377 | 413 | let wxPriceRaw = getAssetsPrices(poolsFactoryAddress, [toBase58String(wxAssetId)])[0] | |
378 | 414 | let wxPrice = if ((wxPriceRaw > toBigInt(0))) | |
379 | 415 | then fromX18(wxPriceRaw, pow(10, 0, usdtDecimals, 0, 0, DOWN)) | |
380 | 416 | else throwErr("invalid wx price") | |
381 | - | let wxdaoQuantity = | |
382 | - | let wxdaoQuantityRaw = toX18(wxdaoQuantity, pow(10, 0, | |
417 | + | let wxdaoQuantity = wxdaoInfo.quantity | |
418 | + | let wxdaoQuantityRaw = toX18(wxdaoQuantity, pow(10, 0, wxdaoInfo.decimals, 0, 0, DOWN)) | |
383 | 419 | let wxDaoPriceRaw = (((pwrPriceRaw + fraction((factoryAddressWxBalanceRaw * toBigInt(100)), wxPriceRaw, wxdaoQuantityRaw)) + fraction(max([treasuryValueDiffRaw, toBigInt(0)]), (toBigInt(2) * mult18), (toBigInt(10) * pwrAmountRaw))) / toBigInt(100)) | |
384 | 420 | let wxDaoPrice = fromX18(wxDaoPriceRaw, pow(10, 0, usdtDecimals, 0, 0, DOWN)) | |
385 | - | $Tuple2(wxDaoPrice, [["wxDaoPrice", wxDaoPrice], ["pwrPrice", pwrPrice], ["factoryAddressWxBalance", factoryAddressWxBalance], ["wxPrice", wxPrice], ["wxdaoQuantity", wxdaoQuantity], ["treasuryValueDiff", treasuryValueDiff], ["pwrAmount", pwrAmount], ["skinTotal", skinTotal], ["pwrRemaining", pwrRemaining]]) | |
421 | + | let rewardsPrices = calcRewards(factoryAddress, pow(10, 0, wxdaoInfo.decimals, 0, 0, DOWN)) | |
422 | + | $Tuple2([wxDaoPrice, rewardsPrices], [["wxDaoPrice", wxDaoPrice], ["pwrPrice", pwrPrice], ["factoryAddressWxBalance", factoryAddressWxBalance], ["wxPrice", wxPrice], ["wxdaoQuantity", wxdaoQuantity], ["treasuryValueDiff", treasuryValueDiff], ["pwrAmount", pwrAmount], ["skinTotal", skinTotal], ["pwrRemaining", pwrRemaining]]) | |
386 | 423 | } | |
387 | - | ||
388 | - | ||
389 | - | @Callable(i) | |
390 | - | func withdraw (args) = { | |
391 | - | let recipient = addressFromStringValue(args[0]) | |
392 | - | let amount = parseIntValue(args[1]) | |
393 | - | let result = invoke(i.caller, "transferWaves", [recipient.bytes, amount], nil) | |
394 | - | $Tuple2(nil, result) | |
395 | - | } | |
396 | - | ||
397 | - | ||
398 | - | ||
399 | - | @Callable(i) | |
400 | - | func setIntParam (args) = { | |
401 | - | let key = args[0] | |
402 | - | let val = parseIntValue(args[1]) | |
403 | - | let result = invoke(i.caller, "integerEntry", [key, val], nil) | |
404 | - | $Tuple2(nil, result) | |
405 | - | } | |
406 | - | ||
407 | 424 | ||
408 | 425 | ||
409 | 426 | @Callable(i) | |
419 | 436 | else throwErr(err) | |
420 | 437 | let pwrPrice = 100 | |
421 | 438 | let pwrAmount = (payment.amount / pwrPrice) | |
422 | - | let assetsStr = split(getAssetsStr(factoryAddress), SEP) | |
423 | - | let pwrBalance = assetBalance(factoryAddress, getPowerAssetId(factoryAddress)) | |
424 | - | if ((pwrBalance == pwrBalance)) | |
439 | + | let transfers = calcRewards(factoryAddress, payment.amount) | |
440 | + | if ((transfers == transfers)) | |
425 | 441 | then { | |
426 | - | let wxdaoQuantity = getAssetInfoOrFail(getLpAssetId(factoryAddress)).quantity | |
427 | - | if ((wxdaoQuantity == wxdaoQuantity)) | |
428 | - | then { | |
429 | - | let assetsBalances = getAssetsBalances(factoryAddress, assetsStr) | |
430 | - | func map (acc,nextAssetIdStr) = { | |
431 | - | let assetId = fromBase58String(nextAssetIdStr) | |
432 | - | let index = valueOrErrorMessage(indexOf(assetsStr, nextAssetIdStr), wrapErr("invalid asset balance")) | |
433 | - | let assetDecimals = getAssetInfoOrFail(assetId).decimals | |
434 | - | let balance = fromX18(assetsBalances[index], pow(10, 0, assetDecimals, 0, 0, DOWN)) | |
435 | - | let amount = fraction(balance, payment.amount, wxdaoQuantity) | |
436 | - | if ((amount > 0)) | |
437 | - | then $Tuple2((acc._1 :+ assetId), (acc._2 :+ amount)) | |
438 | - | else acc | |
439 | - | } | |
440 | - | ||
441 | - | let transfers = { | |
442 | - | let $l = assetsStr | |
443 | - | let $s = size($l) | |
444 | - | let $acc0 = $Tuple2(nil, nil) | |
445 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
446 | - | then $a | |
447 | - | else map($a, $l[$i]) | |
448 | - | ||
449 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
450 | - | then $a | |
451 | - | else throw("List size exceeds 6") | |
452 | - | ||
453 | - | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6) | |
454 | - | } | |
455 | - | if ((transfers == transfers)) | |
456 | - | then { | |
457 | - | let additionalLockRounds = 0 | |
458 | - | let factoryActions = ([invoke(factoryAddress, "commitAfterStartWithLockRoundFor", [toString(powerContractAddress(factoryAddress)), toString(factoryAddress), toString(userAddress), additionalLockRounds, getPowerAssetId(factoryAddress), pwrAmount], nil)] ++ (if ((size(transfers._1) == 0)) | |
459 | - | then nil | |
460 | - | else [invoke(factoryAddress, "transferAssets", [userAddress.bytes, transfers._1, transfers._2], nil)])) | |
461 | - | $Tuple2([Burn(paymentAssetId, payment.amount)], factoryActions) | |
462 | - | } | |
463 | - | else throw("Strict value is not equal to itself.") | |
464 | - | } | |
465 | - | else throw("Strict value is not equal to itself.") | |
442 | + | let additionalLockRounds = 0 | |
443 | + | let factoryActions = ([invoke(factoryAddress, "commitAfterStartWithLockRoundFor", [toString(powerContractAddress(factoryAddress)), toString(getTreasuryAddress(factoryAddress)), toString(userAddress), additionalLockRounds, getPowerAssetId(factoryAddress), pwrAmount], nil)] ++ (if ((size(transfers._1) == 0)) | |
444 | + | then nil | |
445 | + | else [invoke(factoryAddress, "transferAssets", [userAddress.bytes, transfers._1, transfers._2], nil)])) | |
446 | + | $Tuple2([Burn(paymentAssetId, payment.amount)], factoryActions) | |
466 | 447 | } | |
467 | 448 | else throw("Strict value is not equal to itself.") | |
468 | 449 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 7 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let chainId = take(drop(this.bytes, 1), 1) | |
5 | 5 | ||
6 | 6 | let chainIdT = base58'2T' | |
7 | 7 | ||
8 | 8 | let chainIdW = base58'2W' | |
9 | 9 | ||
10 | 10 | let SEP = "__" | |
11 | 11 | ||
12 | 12 | let WAVES = "WAVES" | |
13 | 13 | ||
14 | 14 | let contractFilename = "wxdao_calculator.ride" | |
15 | 15 | ||
16 | 16 | let mult8 = 100000000 | |
17 | 17 | ||
18 | 18 | let mult18 = toBigInt(1000000000000000000) | |
19 | 19 | ||
20 | 20 | let wavesDecimals = 8 | |
21 | 21 | ||
22 | 22 | let usdtDecimals = 6 | |
23 | 23 | ||
24 | 24 | func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), mult18, toBigInt(origScaleMult)) | |
25 | 25 | ||
26 | 26 | ||
27 | 27 | func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), mult18)) | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | func wrapErr (s) = ((contractFilename + ": ") + s) | |
31 | 31 | ||
32 | 32 | ||
33 | 33 | func throwErr (s) = throw(wrapErr(s)) | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | let wxAssetId = if ((chainId == chainIdW)) | |
37 | 37 | then base58'Atqv59EYzjFGuitKVnMRk6H8FukjoV3ktPorbEys25on' | |
38 | 38 | else if ((chainId == chainIdT)) | |
39 | 39 | then base58'EMAMLxDnv3xiz8RXg8Btj33jcEw3wLczL3JKYYmuubpc' | |
40 | 40 | else throwErr("invalid chain id") | |
41 | 41 | ||
42 | 42 | func keyCurrentPeriod () = makeString(["%s", "currentPeriod"], SEP) | |
43 | 43 | ||
44 | 44 | ||
45 | 45 | func keyStartHeightByPeriod (period) = makeString(["%s%d", "startHeight", toString(period)], SEP) | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | func keyPeriodLength () = makeString(["%s", "periodLength"], SEP) | |
49 | 49 | ||
50 | 50 | ||
51 | 51 | func keyTreasuryValueByPeriod (period) = makeString(["%s%d", "treasuryValue", toString(period)], SEP) | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | func keySkinTotal (treasuryAddress) = ("skin_total_" + toString(treasuryAddress)) | |
55 | 55 | ||
56 | 56 | ||
57 | 57 | func keyPowerConfigAddress () = "%s__powerConfigAddress" | |
58 | 58 | ||
59 | 59 | ||
60 | 60 | func powerConfigAddress (factoryAddress) = valueOrErrorMessage(match getString(factoryAddress, keyPowerConfigAddress()) { | |
61 | 61 | case s: String => | |
62 | 62 | addressFromString(s) | |
63 | 63 | case _: Unit => | |
64 | 64 | unit | |
65 | 65 | case _ => | |
66 | 66 | throw("Match error") | |
67 | 67 | }, wrapErr("invalid power config address")) | |
68 | 68 | ||
69 | 69 | ||
70 | 70 | func keyPowerAssetId () = "powerAssetId" | |
71 | 71 | ||
72 | 72 | ||
73 | 73 | func getPowerAssetId (factoryAddress) = fromBase58String(valueOrErrorMessage(getString(powerConfigAddress(factoryAddress), keyPowerAssetId()), wrapErr("invalid power asset id"))) | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | func keyPowerContractAddress () = "%s__powerContractAddress" | |
77 | 77 | ||
78 | 78 | ||
79 | 79 | func powerContractAddress (factoryAddress) = valueOrErrorMessage(match getString(factoryAddress, keyPowerContractAddress()) { | |
80 | 80 | case s: String => | |
81 | 81 | addressFromString(s) | |
82 | 82 | case _: Unit => | |
83 | 83 | unit | |
84 | 84 | case _ => | |
85 | 85 | throw("Match error") | |
86 | 86 | }, wrapErr("invalid power contract address")) | |
87 | 87 | ||
88 | 88 | ||
89 | 89 | func keyPoolsFactoryAddress () = "%s__poolsFactoryAddress" | |
90 | 90 | ||
91 | 91 | ||
92 | 92 | func getPoolsFactoryAddress (factoryAddress) = valueOrErrorMessage(match getString(factoryAddress, keyPoolsFactoryAddress()) { | |
93 | 93 | case s: String => | |
94 | 94 | addressFromString(s) | |
95 | 95 | case _: Unit => | |
96 | 96 | unit | |
97 | 97 | case _ => | |
98 | 98 | throw("Match error") | |
99 | 99 | }, wrapErr("invalid pools factory address")) | |
100 | 100 | ||
101 | 101 | ||
102 | 102 | func keyTreasuryAddress () = "%s__treasuryAddress" | |
103 | 103 | ||
104 | 104 | ||
105 | 105 | func getTreasuryAddress (factoryAddress) = valueOrErrorMessage(match getString(factoryAddress, keyTreasuryAddress()) { | |
106 | 106 | case s: String => | |
107 | 107 | addressFromString(s) | |
108 | 108 | case _: Unit => | |
109 | 109 | unit | |
110 | 110 | case _ => | |
111 | 111 | throw("Match error") | |
112 | 112 | }, wrapErr("invalid treasury address")) | |
113 | 113 | ||
114 | 114 | ||
115 | 115 | func keyAssets () = "%s__assets" | |
116 | 116 | ||
117 | 117 | ||
118 | 118 | func getAssetsStr (factoryAddress) = valueOrErrorMessage(getString(factoryAddress, keyAssets()), wrapErr("invalid assets")) | |
119 | 119 | ||
120 | 120 | ||
121 | 121 | func keyLpAssetId () = "%s__lpAssetId" | |
122 | 122 | ||
123 | 123 | ||
124 | 124 | func getLpAssetId (factoryAddress) = fromBase58String(valueOrErrorMessage(getString(factoryAddress, keyLpAssetId()), wrapErr("invalid lp asset id"))) | |
125 | 125 | ||
126 | 126 | ||
127 | 127 | func getAssetInfoOrFail (assetId) = valueOrErrorMessage(assetInfo(assetId), wrapErr("invalid asset info")) | |
128 | 128 | ||
129 | 129 | ||
130 | 130 | func getAssetsBalances (targetAddress,assetIdList) = { | |
131 | 131 | func map (acc,nextAssetIdStr) = { | |
132 | 132 | let balance = if ((nextAssetIdStr == WAVES)) | |
133 | 133 | then toX18(wavesBalance(targetAddress).available, pow(10, 0, wavesDecimals, 0, 0, DOWN)) | |
134 | 134 | else { | |
135 | 135 | let assetId = fromBase58String(nextAssetIdStr) | |
136 | 136 | let assetDecimals = getAssetInfoOrFail(assetId).decimals | |
137 | 137 | toX18(assetBalance(targetAddress, assetId), pow(10, 0, assetDecimals, 0, 0, DOWN)) | |
138 | 138 | } | |
139 | 139 | (acc :+ balance) | |
140 | 140 | } | |
141 | 141 | ||
142 | 142 | let $l = assetIdList | |
143 | 143 | let $s = size($l) | |
144 | 144 | let $acc0 = nil | |
145 | 145 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
146 | 146 | then $a | |
147 | 147 | else map($a, $l[$i]) | |
148 | 148 | ||
149 | 149 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
150 | 150 | then $a | |
151 | 151 | else throw("List size exceeds 10") | |
152 | 152 | ||
153 | 153 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
154 | 154 | } | |
155 | 155 | ||
156 | 156 | ||
157 | 157 | func getAssetsPrices (poolsFactoryAddress,assetIdList) = if ((chainId == chainIdW)) | |
158 | 158 | then { | |
159 | 159 | let wavesUsdtAddressStr = "3PKfrupEydU2nZAghVjZAfvCwMBkzuR1F52" | |
160 | 160 | let wavesUsdtPrice = parseBigIntValue({ | |
161 | 161 | let @ = invoke(poolsFactoryAddress, "getPrice", [wavesUsdtAddressStr], nil) | |
162 | 162 | if ($isInstanceOf(@, "String")) | |
163 | 163 | then @ | |
164 | 164 | else throw(($getType(@) + " couldn't be cast to String")) | |
165 | 165 | }) | |
166 | 166 | let wavesXtnAddressStr = "3PPZWgFNRKHLvM51pwS934C8VZ7d2F4Z58g" | |
167 | 167 | let wavesXtnPrice = parseBigIntValue({ | |
168 | 168 | let @ = invoke(poolsFactoryAddress, "getPrice", [wavesXtnAddressStr], nil) | |
169 | 169 | if ($isInstanceOf(@, "String")) | |
170 | 170 | then @ | |
171 | 171 | else throw(($getType(@) + " couldn't be cast to String")) | |
172 | 172 | }) | |
173 | 173 | let xtnUsdtPrice = fraction(wavesUsdtPrice, mult18, wavesXtnPrice) | |
174 | 174 | func map (acc,nextAssetId) = { | |
175 | 175 | let price = match nextAssetId { | |
176 | 176 | case _ => | |
177 | 177 | if (("2thsACuHmzDMuNezPM32wg9a3BwUzBWDeSKakgz3cw21" == $match0)) | |
178 | 178 | then { | |
179 | 179 | let pwrWavesAddressStr = "3PDi7Qq8pLQYvtKyTfQuqqPUWyhoYbU957t" | |
180 | 180 | let pwrWavesPrice = parseBigIntValue({ | |
181 | 181 | let @ = invoke(poolsFactoryAddress, "getPrice", [pwrWavesAddressStr], nil) | |
182 | 182 | if ($isInstanceOf(@, "String")) | |
183 | 183 | then @ | |
184 | 184 | else throw(($getType(@) + " couldn't be cast to String")) | |
185 | 185 | }) | |
186 | 186 | fraction(pwrWavesPrice, wavesUsdtPrice, mult18) | |
187 | 187 | } | |
188 | 188 | else if (("Atqv59EYzjFGuitKVnMRk6H8FukjoV3ktPorbEys25on" == $match0)) | |
189 | 189 | then { | |
190 | 190 | let wxWavesAddressStr = "3PFzaH2ghpwANHFgjeva83N1yxzErELx2eh" | |
191 | 191 | let wxWavesPrice = parseBigIntValue({ | |
192 | 192 | let @ = invoke(poolsFactoryAddress, "getPrice", [wxWavesAddressStr], nil) | |
193 | 193 | if ($isInstanceOf(@, "String")) | |
194 | 194 | then @ | |
195 | 195 | else throw(($getType(@) + " couldn't be cast to String")) | |
196 | 196 | }) | |
197 | 197 | fraction(wxWavesPrice, wavesUsdtPrice, mult18) | |
198 | 198 | } | |
199 | 199 | else if (("34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ" == $match0)) | |
200 | 200 | then { | |
201 | 201 | let wavesUsdtwxgAddressStr = "3PKMVZ7kQeaREajYi8Yc25Ro6mcNw5D6QSa" | |
202 | 202 | let wavesUsdtwxgPrice = parseBigIntValue({ | |
203 | 203 | let @ = invoke(poolsFactoryAddress, "getPrice", [wavesUsdtwxgAddressStr], nil) | |
204 | 204 | if ($isInstanceOf(@, "String")) | |
205 | 205 | then @ | |
206 | 206 | else throw(($getType(@) + " couldn't be cast to String")) | |
207 | 207 | }) | |
208 | 208 | fraction(wavesUsdtPrice, mult18, wavesUsdtwxgPrice) | |
209 | 209 | } | |
210 | 210 | else if (("6XtHjpXbs9RRJP2Sr9GUyVqzACcby9TkThHXnjVC5CDJ" == $match0)) | |
211 | 211 | then { | |
212 | 212 | let wavesUsdcwxgAddressStr = "3P3g3eipfG2NZKKQE8DZXt2E9tRJqii9jcX" | |
213 | 213 | let wavesUsdcwxgPrice = parseBigIntValue({ | |
214 | 214 | let @ = invoke(poolsFactoryAddress, "getPrice", [wavesUsdcwxgAddressStr], nil) | |
215 | 215 | if ($isInstanceOf(@, "String")) | |
216 | 216 | then @ | |
217 | 217 | else throw(($getType(@) + " couldn't be cast to String")) | |
218 | 218 | }) | |
219 | 219 | fraction(wavesUsdtPrice, mult18, wavesUsdcwxgPrice) | |
220 | 220 | } | |
221 | 221 | else if (("HZk1mbfuJpmxU1Fs4AX5MWLVYtctsNcg6e2C6VKqK8zk" == $match0)) | |
222 | 222 | then { | |
223 | 223 | let ltcwxgXtnAddressStr = "3P94wvu5gA7VhjPgAB3twaeqdwHCwNK2vsn" | |
224 | 224 | let ltcwxgXtnPrice = parseBigIntValue({ | |
225 | 225 | let @ = invoke(poolsFactoryAddress, "getPrice", [ltcwxgXtnAddressStr], nil) | |
226 | 226 | if ($isInstanceOf(@, "String")) | |
227 | 227 | then @ | |
228 | 228 | else throw(($getType(@) + " couldn't be cast to String")) | |
229 | 229 | }) | |
230 | 230 | fraction(ltcwxgXtnPrice, xtnUsdtPrice, mult18) | |
231 | 231 | } | |
232 | 232 | else if (("474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu" == $match0)) | |
233 | 233 | then { | |
234 | 234 | let ethwxgWavesAddressStr = "3P3XGTN6s292g9iwYhs3TEqJqHiffQYojuE" | |
235 | 235 | let ethwxgWavesPrice = parseBigIntValue({ | |
236 | 236 | let @ = invoke(poolsFactoryAddress, "getPrice", [ethwxgWavesAddressStr], nil) | |
237 | 237 | if ($isInstanceOf(@, "String")) | |
238 | 238 | then @ | |
239 | 239 | else throw(($getType(@) + " couldn't be cast to String")) | |
240 | 240 | }) | |
241 | 241 | fraction(ethwxgWavesPrice, wavesUsdtPrice, mult18) | |
242 | 242 | } | |
243 | 243 | else if (("8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS" == $match0)) | |
244 | 244 | then { | |
245 | 245 | let btcwxgXtnAddressStr = "3PCBWDTA6jrFswd7gQgaE3Xk7gLM5RKofvp" | |
246 | 246 | let btcwxgXtnPrice = parseBigIntValue({ | |
247 | 247 | let @ = invoke(poolsFactoryAddress, "getPrice", [btcwxgXtnAddressStr], nil) | |
248 | 248 | if ($isInstanceOf(@, "String")) | |
249 | 249 | then @ | |
250 | 250 | else throw(($getType(@) + " couldn't be cast to String")) | |
251 | 251 | }) | |
252 | 252 | fraction(btcwxgXtnPrice, xtnUsdtPrice, mult18) | |
253 | 253 | } | |
254 | 254 | else throwErr("invalid asset id") | |
255 | 255 | } | |
256 | 256 | (acc :+ price) | |
257 | 257 | } | |
258 | 258 | ||
259 | 259 | let $l = assetIdList | |
260 | 260 | let $s = size($l) | |
261 | 261 | let $acc0 = nil | |
262 | 262 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
263 | 263 | then $a | |
264 | 264 | else map($a, $l[$i]) | |
265 | 265 | ||
266 | 266 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
267 | 267 | then $a | |
268 | 268 | else throw("List size exceeds 10") | |
269 | 269 | ||
270 | 270 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
271 | 271 | } | |
272 | 272 | else if ((chainId == chainIdT)) | |
273 | 273 | then { | |
274 | 274 | func map (acc,nextAssetId) = { | |
275 | 275 | let price = match nextAssetId { | |
276 | 276 | case _ => | |
277 | 277 | if (("EMAMLxDnv3xiz8RXg8Btj33jcEw3wLczL3JKYYmuubpc" == $match0)) | |
278 | 278 | then { | |
279 | 279 | let wxUsdtAddressStr = "3MrULQRLc52GWrJF1tMcAm4M78fPe57o9Kt" | |
280 | 280 | let wxUsdtPrice = parseBigIntValue({ | |
281 | 281 | let @ = invoke(poolsFactoryAddress, "getPrice", [wxUsdtAddressStr], nil) | |
282 | 282 | if ($isInstanceOf(@, "String")) | |
283 | 283 | then @ | |
284 | 284 | else throw(($getType(@) + " couldn't be cast to String")) | |
285 | 285 | }) | |
286 | 286 | wxUsdtPrice | |
287 | 287 | } | |
288 | 288 | else if (("A7Ksh7fXyqm1KhKAiK3bAB2aiPSitQQF6v1pyu9SS3FR" == $match0)) | |
289 | 289 | then { | |
290 | 290 | let usdcUsdtAddressStr = "3MzKSdTH2jFbypLsoNfrH7QgkzSbx3EYwCA" | |
291 | 291 | let usdcUsdtPrice = parseBigIntValue({ | |
292 | 292 | let @ = invoke(poolsFactoryAddress, "getPrice", [usdcUsdtAddressStr], nil) | |
293 | 293 | if ($isInstanceOf(@, "String")) | |
294 | 294 | then @ | |
295 | 295 | else throw(($getType(@) + " couldn't be cast to String")) | |
296 | 296 | }) | |
297 | 297 | usdcUsdtPrice | |
298 | 298 | } | |
299 | 299 | else if (("8Q6SE2ANebufw8JuPjJVRjZD6drD8ihjNjM8xaGUSfdR" == $match0)) | |
300 | 300 | then { | |
301 | 301 | let price = toX18(150000000, pow(10, 0, usdtDecimals, 0, 0, DOWN)) | |
302 | 302 | price | |
303 | 303 | } | |
304 | 304 | else throwErr("invalid asset id") | |
305 | 305 | } | |
306 | 306 | (acc :+ price) | |
307 | 307 | } | |
308 | 308 | ||
309 | 309 | let $l = assetIdList | |
310 | 310 | let $s = size($l) | |
311 | 311 | let $acc0 = nil | |
312 | 312 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
313 | 313 | then $a | |
314 | 314 | else map($a, $l[$i]) | |
315 | 315 | ||
316 | 316 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
317 | 317 | then $a | |
318 | 318 | else throw("List size exceeds 10") | |
319 | 319 | ||
320 | 320 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
321 | 321 | } | |
322 | 322 | else throwErr("invalid chain id") | |
323 | 323 | ||
324 | 324 | ||
325 | 325 | func calcTreasuryValue (factoryAddress) = { | |
326 | 326 | let treasuryAddress = getTreasuryAddress(factoryAddress) | |
327 | 327 | let poolsFactoryAddress = getPoolsFactoryAddress(factoryAddress) | |
328 | 328 | let assetsStr = split(getAssetsStr(factoryAddress), SEP) | |
329 | 329 | let assetsBalances = getAssetsBalances(treasuryAddress, assetsStr) | |
330 | 330 | let assetsPrices = getAssetsPrices(poolsFactoryAddress, assetsStr) | |
331 | 331 | func reduce (acc,nextAssetIdStr) = { | |
332 | 332 | let assetId = fromBase58String(nextAssetIdStr) | |
333 | 333 | let index = valueOrErrorMessage(indexOf(assetsStr, nextAssetIdStr), wrapErr("invalid asset id")) | |
334 | 334 | let balance = assetsBalances[index] | |
335 | 335 | let price = assetsPrices[index] | |
336 | 336 | let assetValue = fraction(balance, price, mult18) | |
337 | 337 | (acc + assetValue) | |
338 | 338 | } | |
339 | 339 | ||
340 | 340 | let treasuryValue = { | |
341 | 341 | let $l = assetsStr | |
342 | 342 | let $s = size($l) | |
343 | 343 | let $acc0 = toBigInt(0) | |
344 | 344 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
345 | 345 | then $a | |
346 | 346 | else reduce($a, $l[$i]) | |
347 | 347 | ||
348 | 348 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
349 | 349 | then $a | |
350 | 350 | else throw("List size exceeds 10") | |
351 | 351 | ||
352 | 352 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
353 | 353 | } | |
354 | 354 | treasuryValue | |
355 | 355 | } | |
356 | 356 | ||
357 | 357 | ||
358 | + | func calcRewards (factoryAddress,paymentAmount) = { | |
359 | + | let assetsStr = split(getAssetsStr(factoryAddress), SEP) | |
360 | + | let wxdaoQuantity = getAssetInfoOrFail(getLpAssetId(factoryAddress)).quantity | |
361 | + | if ((wxdaoQuantity == wxdaoQuantity)) | |
362 | + | then { | |
363 | + | let assetsBalances = getAssetsBalances(factoryAddress, assetsStr) | |
364 | + | func map (acc,nextAssetIdStr) = { | |
365 | + | let assetId = fromBase58String(nextAssetIdStr) | |
366 | + | let index = valueOrErrorMessage(indexOf(assetsStr, nextAssetIdStr), wrapErr("invalid asset balance")) | |
367 | + | let assetDecimals = getAssetInfoOrFail(assetId).decimals | |
368 | + | let balance = fromX18(assetsBalances[index], pow(10, 0, assetDecimals, 0, 0, DOWN)) | |
369 | + | let amount = fraction(balance, paymentAmount, wxdaoQuantity) | |
370 | + | if ((amount > 0)) | |
371 | + | then $Tuple2((acc._1 :+ assetId), (acc._2 :+ amount)) | |
372 | + | else acc | |
373 | + | } | |
374 | + | ||
375 | + | let $l = assetsStr | |
376 | + | let $s = size($l) | |
377 | + | let $acc0 = $Tuple2(nil, nil) | |
378 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
379 | + | then $a | |
380 | + | else map($a, $l[$i]) | |
381 | + | ||
382 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
383 | + | then $a | |
384 | + | else throw("List size exceeds 6") | |
385 | + | ||
386 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6) | |
387 | + | } | |
388 | + | else throw("Strict value is not equal to itself.") | |
389 | + | } | |
390 | + | ||
391 | + | ||
358 | 392 | func calcPrice (factoryAddress) = { | |
359 | 393 | let poolsFactoryAddress = getPoolsFactoryAddress(factoryAddress) | |
360 | 394 | let currentPeriod = valueOrErrorMessage(getInteger(factoryAddress, keyCurrentPeriod()), wrapErr("invalid current period")) | |
361 | 395 | let startTreasuryValue = valueOrErrorMessage(getInteger(factoryAddress, keyTreasuryValueByPeriod(currentPeriod)), wrapErr(("invalid treasury value for period " + toString(currentPeriod)))) | |
362 | 396 | let treasuryValue = fromX18(calcTreasuryValue(factoryAddress), pow(10, 0, usdtDecimals, 0, 0, DOWN)) | |
363 | 397 | let treasuryValueDiff = (treasuryValue - startTreasuryValue) | |
364 | 398 | let treasuryValueDiffRaw = toX18(treasuryValueDiff, pow(10, 0, usdtDecimals, 0, 0, DOWN)) | |
365 | 399 | let pwrAssetId = getPowerAssetId(factoryAddress) | |
400 | + | let pwrInfo = getAssetInfoOrFail(pwrAssetId) | |
366 | 401 | let pwrPriceRaw = getAssetsPrices(poolsFactoryAddress, [toBase58String(pwrAssetId)])[0] | |
367 | 402 | let pwrPrice = if ((pwrPriceRaw > toBigInt(0))) | |
368 | 403 | then fromX18(pwrPriceRaw, pow(10, 0, usdtDecimals, 0, 0, DOWN)) | |
369 | 404 | else throwErr("invalid PWR price") | |
370 | 405 | let treasuryAddress = getTreasuryAddress(factoryAddress) | |
371 | 406 | let skinTotal = valueOrElse(getInteger(powerContractAddress(factoryAddress), keySkinTotal(treasuryAddress)), 0) | |
372 | - | let pwrRemaining = (getAssetInfoOrFail(getLpAssetId(factoryAddress)).quantity / 100) | |
407 | + | let wxdaoInfo = getAssetInfoOrFail(getLpAssetId(factoryAddress)) | |
408 | + | let pwrRemaining = (wxdaoInfo.quantity / 100) | |
373 | 409 | let pwrAmount = (skinTotal + pwrRemaining) | |
374 | - | let pwrAmountRaw = toX18(pwrAmount, pow(10, 0, | |
410 | + | let pwrAmountRaw = toX18(pwrAmount, pow(10, 0, pwrInfo.decimals, 0, 0, DOWN)) | |
375 | 411 | let factoryAddressWxBalanceRaw = getAssetsBalances(factoryAddress, [toBase58String(wxAssetId)])[0] | |
376 | 412 | let factoryAddressWxBalance = fromX18(factoryAddressWxBalanceRaw, pow(10, 0, usdtDecimals, 0, 0, DOWN)) | |
377 | 413 | let wxPriceRaw = getAssetsPrices(poolsFactoryAddress, [toBase58String(wxAssetId)])[0] | |
378 | 414 | let wxPrice = if ((wxPriceRaw > toBigInt(0))) | |
379 | 415 | then fromX18(wxPriceRaw, pow(10, 0, usdtDecimals, 0, 0, DOWN)) | |
380 | 416 | else throwErr("invalid wx price") | |
381 | - | let wxdaoQuantity = | |
382 | - | let wxdaoQuantityRaw = toX18(wxdaoQuantity, pow(10, 0, | |
417 | + | let wxdaoQuantity = wxdaoInfo.quantity | |
418 | + | let wxdaoQuantityRaw = toX18(wxdaoQuantity, pow(10, 0, wxdaoInfo.decimals, 0, 0, DOWN)) | |
383 | 419 | let wxDaoPriceRaw = (((pwrPriceRaw + fraction((factoryAddressWxBalanceRaw * toBigInt(100)), wxPriceRaw, wxdaoQuantityRaw)) + fraction(max([treasuryValueDiffRaw, toBigInt(0)]), (toBigInt(2) * mult18), (toBigInt(10) * pwrAmountRaw))) / toBigInt(100)) | |
384 | 420 | let wxDaoPrice = fromX18(wxDaoPriceRaw, pow(10, 0, usdtDecimals, 0, 0, DOWN)) | |
385 | - | $Tuple2(wxDaoPrice, [["wxDaoPrice", wxDaoPrice], ["pwrPrice", pwrPrice], ["factoryAddressWxBalance", factoryAddressWxBalance], ["wxPrice", wxPrice], ["wxdaoQuantity", wxdaoQuantity], ["treasuryValueDiff", treasuryValueDiff], ["pwrAmount", pwrAmount], ["skinTotal", skinTotal], ["pwrRemaining", pwrRemaining]]) | |
421 | + | let rewardsPrices = calcRewards(factoryAddress, pow(10, 0, wxdaoInfo.decimals, 0, 0, DOWN)) | |
422 | + | $Tuple2([wxDaoPrice, rewardsPrices], [["wxDaoPrice", wxDaoPrice], ["pwrPrice", pwrPrice], ["factoryAddressWxBalance", factoryAddressWxBalance], ["wxPrice", wxPrice], ["wxdaoQuantity", wxdaoQuantity], ["treasuryValueDiff", treasuryValueDiff], ["pwrAmount", pwrAmount], ["skinTotal", skinTotal], ["pwrRemaining", pwrRemaining]]) | |
386 | 423 | } | |
387 | - | ||
388 | - | ||
389 | - | @Callable(i) | |
390 | - | func withdraw (args) = { | |
391 | - | let recipient = addressFromStringValue(args[0]) | |
392 | - | let amount = parseIntValue(args[1]) | |
393 | - | let result = invoke(i.caller, "transferWaves", [recipient.bytes, amount], nil) | |
394 | - | $Tuple2(nil, result) | |
395 | - | } | |
396 | - | ||
397 | - | ||
398 | - | ||
399 | - | @Callable(i) | |
400 | - | func setIntParam (args) = { | |
401 | - | let key = args[0] | |
402 | - | let val = parseIntValue(args[1]) | |
403 | - | let result = invoke(i.caller, "integerEntry", [key, val], nil) | |
404 | - | $Tuple2(nil, result) | |
405 | - | } | |
406 | - | ||
407 | 424 | ||
408 | 425 | ||
409 | 426 | @Callable(i) | |
410 | 427 | func swap (callerPublicKey,args) = { | |
411 | 428 | let factoryAddress = i.caller | |
412 | 429 | let userAddress = addressFromPublicKey(callerPublicKey) | |
413 | 430 | let payment = if ((size(i.payments) == 1)) | |
414 | 431 | then i.payments[0] | |
415 | 432 | else throwErr("1 payment is required") | |
416 | 433 | let err = wrapErr("invalid payment asset id") | |
417 | 434 | let paymentAssetId = if ((valueOrErrorMessage(payment.assetId, err) == getLpAssetId(factoryAddress))) | |
418 | 435 | then value(payment.assetId) | |
419 | 436 | else throwErr(err) | |
420 | 437 | let pwrPrice = 100 | |
421 | 438 | let pwrAmount = (payment.amount / pwrPrice) | |
422 | - | let assetsStr = split(getAssetsStr(factoryAddress), SEP) | |
423 | - | let pwrBalance = assetBalance(factoryAddress, getPowerAssetId(factoryAddress)) | |
424 | - | if ((pwrBalance == pwrBalance)) | |
439 | + | let transfers = calcRewards(factoryAddress, payment.amount) | |
440 | + | if ((transfers == transfers)) | |
425 | 441 | then { | |
426 | - | let wxdaoQuantity = getAssetInfoOrFail(getLpAssetId(factoryAddress)).quantity | |
427 | - | if ((wxdaoQuantity == wxdaoQuantity)) | |
428 | - | then { | |
429 | - | let assetsBalances = getAssetsBalances(factoryAddress, assetsStr) | |
430 | - | func map (acc,nextAssetIdStr) = { | |
431 | - | let assetId = fromBase58String(nextAssetIdStr) | |
432 | - | let index = valueOrErrorMessage(indexOf(assetsStr, nextAssetIdStr), wrapErr("invalid asset balance")) | |
433 | - | let assetDecimals = getAssetInfoOrFail(assetId).decimals | |
434 | - | let balance = fromX18(assetsBalances[index], pow(10, 0, assetDecimals, 0, 0, DOWN)) | |
435 | - | let amount = fraction(balance, payment.amount, wxdaoQuantity) | |
436 | - | if ((amount > 0)) | |
437 | - | then $Tuple2((acc._1 :+ assetId), (acc._2 :+ amount)) | |
438 | - | else acc | |
439 | - | } | |
440 | - | ||
441 | - | let transfers = { | |
442 | - | let $l = assetsStr | |
443 | - | let $s = size($l) | |
444 | - | let $acc0 = $Tuple2(nil, nil) | |
445 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
446 | - | then $a | |
447 | - | else map($a, $l[$i]) | |
448 | - | ||
449 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
450 | - | then $a | |
451 | - | else throw("List size exceeds 6") | |
452 | - | ||
453 | - | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6) | |
454 | - | } | |
455 | - | if ((transfers == transfers)) | |
456 | - | then { | |
457 | - | let additionalLockRounds = 0 | |
458 | - | let factoryActions = ([invoke(factoryAddress, "commitAfterStartWithLockRoundFor", [toString(powerContractAddress(factoryAddress)), toString(factoryAddress), toString(userAddress), additionalLockRounds, getPowerAssetId(factoryAddress), pwrAmount], nil)] ++ (if ((size(transfers._1) == 0)) | |
459 | - | then nil | |
460 | - | else [invoke(factoryAddress, "transferAssets", [userAddress.bytes, transfers._1, transfers._2], nil)])) | |
461 | - | $Tuple2([Burn(paymentAssetId, payment.amount)], factoryActions) | |
462 | - | } | |
463 | - | else throw("Strict value is not equal to itself.") | |
464 | - | } | |
465 | - | else throw("Strict value is not equal to itself.") | |
442 | + | let additionalLockRounds = 0 | |
443 | + | let factoryActions = ([invoke(factoryAddress, "commitAfterStartWithLockRoundFor", [toString(powerContractAddress(factoryAddress)), toString(getTreasuryAddress(factoryAddress)), toString(userAddress), additionalLockRounds, getPowerAssetId(factoryAddress), pwrAmount], nil)] ++ (if ((size(transfers._1) == 0)) | |
444 | + | then nil | |
445 | + | else [invoke(factoryAddress, "transferAssets", [userAddress.bytes, transfers._1, transfers._2], nil)])) | |
446 | + | $Tuple2([Burn(paymentAssetId, payment.amount)], factoryActions) | |
466 | 447 | } | |
467 | 448 | else throw("Strict value is not equal to itself.") | |
468 | 449 | } | |
469 | 450 | ||
470 | 451 | ||
471 | 452 | ||
472 | 453 | @Callable(i) | |
473 | 454 | func price (callerPublicKey,args) = { | |
474 | 455 | let factoryAddress = i.caller | |
475 | 456 | $Tuple2(nil, calcPrice(factoryAddress)._1) | |
476 | 457 | } | |
477 | 458 | ||
478 | 459 | ||
479 | 460 | ||
480 | 461 | @Callable(i) | |
481 | 462 | func priceDebug (callerPublicKey,args) = { | |
482 | 463 | let factoryAddress = i.caller | |
483 | 464 | $Tuple2(nil, calcPrice(factoryAddress)._2) | |
484 | 465 | } | |
485 | 466 | ||
486 | 467 | ||
487 | 468 | ||
488 | 469 | @Callable(i) | |
489 | 470 | func getTreasuryValue (callerPublicKey,args) = { | |
490 | 471 | let factoryAddress = i.caller | |
491 | 472 | let treasuryValue = fromX18(calcTreasuryValue(factoryAddress), pow(10, 0, usdtDecimals, 0, 0, DOWN)) | |
492 | 473 | $Tuple2(nil, treasuryValue) | |
493 | 474 | } | |
494 | 475 | ||
495 | 476 | ||
496 | 477 | @Verifier(tx) | |
497 | 478 | func verify () = (chainId == chainIdT) | |
498 | 479 |
github/deemru/w8io/169f3d6 65.26 ms ◑