tx · G3AFXw36cGdNo4g61Ds1njQrrZrhGSA1VScd5uaThvJF 3N6HSS7Toat1RhyEsyqVGgVSRzH19W1FTbP: -0.01400000 Waves 2023.06.09 17:42 [2615263] smart account 3N6HSS7Toat1RhyEsyqVGgVSRzH19W1FTbP > SELF 0.00000000 Waves
{ "type": 13, "id": "G3AFXw36cGdNo4g61Ds1njQrrZrhGSA1VScd5uaThvJF", "fee": 1400000, "feeAssetId": null, "timestamp": 1686321833561, "version": 2, "chainId": 84, "sender": "3N6HSS7Toat1RhyEsyqVGgVSRzH19W1FTbP", "senderPublicKey": "AoKo4segKHU4DeJnxXQYJj2u7J6XJeux6r8KLW52cd2Q", "proofs": [ "4phFzuFJkeA6VYGRDAnFJT8zs5PPYFCi1RtPabDvL5ksZZ5b5pgk7apdFiJ9kNovNKeS9Lk62rag84KVPGZQeMbH" ], "script": "base64:BwIqCAISAwoBAhIGCgQBAQEBEgMKAQISAwoBAhIECgICAhIECgICAhIDCgECHwADU0VQAgJfXwANQ09OVFJBQ1RfTkFNRQIPY2FsY3VsYXRvci5yaWRlAAZTQ0FMRTgAgMLXLwAHUEVORElORwIHUEVORElORwAIRklOSVNIRUQCCEZJTklTSEVEAQd3cmFwRXJyAQFzCQCsAgIJAKwCAgUNQ09OVFJBQ1RfTkFNRQICOiAFAXMBCHRocm93RXJyAQFzCQACAQkBB3dyYXBFcnIBBQFzARFrZXlGYWN0b3J5QWRkcmVzcwAJALkJAgkAzAgCAgIlcwkAzAgCAgdmYWN0b3J5BQNuaWwFA1NFUAEMa2V5THBBc3NldElkAAkAuQkCCQDMCAICAiVzCQDMCAICCWxwQXNzZXRJZAUDbmlsBQNTRVABEmtleVRyZWFzdXJ5QWRkcmVzcwAJALkJAgkAzAgCAgIlcwkAzAgCAgh0cmVhc3VyeQUDbmlsBQNTRVABDGtleUF2YWlsYWJsZQELdXNlckFkZHJlc3MJALkJAgkAzAgCAgQlcyVzCQDMCAICCWF2YWlsYWJsZQkAzAgCCQClCAEFC3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Qcm9jZXNzBRlibG9ja3NQcm9jZXNzaW5nQmF0Y2hTaXplBQNuaWwFA25pbAUDbmlsAwkAAAIFB2FjdGlvbnMFB2FjdGlvbnMJAJQKAgUDbmlsBQR1bml0CQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAQJ0eAEGdmVyaWZ5AAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleRC/GPE=", "height": 2615263, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FtF2bR4vkEcAYznJEojvHBjTbdtSXf3GPcjJujzzRHMA Next: 4KCq3DJDXS3JC2Yjw5ygS9nK9YtTP3eJouE1x76vHZaM Diff:
Old | New | Differences | |
---|---|---|---|
48 | 48 | ||
49 | 49 | ||
50 | 50 | func keyNextBlockToProcess () = "%s__nextBlockToProcess" | |
51 | + | ||
52 | + | ||
53 | + | func keyBlockProcessed (height) = makeString(["%s%d", "blockProcessed", toString(height)], SEP) | |
51 | 54 | ||
52 | 55 | ||
53 | 56 | func keyWithdrawalRequest (userAddress,txId) = makeString(["%s%s%s", "withdrawal", toString(userAddress), toBase58String(txId)], SEP) | |
137 | 140 | ||
138 | 141 | func rewardForOption (rewards,target) = { | |
139 | 142 | let s = size(rewards) | |
140 | - | let $ | |
141 | - | let a0 = $ | |
142 | - | let r0 = $ | |
143 | - | let $ | |
144 | - | let a1 = $ | |
145 | - | let r1 = $ | |
146 | - | let $ | |
147 | - | let a2 = $ | |
148 | - | let r2 = $ | |
143 | + | let $t033473372 = rewards[0] | |
144 | + | let a0 = $t033473372._1 | |
145 | + | let r0 = $t033473372._2 | |
146 | + | let $t033753400 = rewards[1] | |
147 | + | let a1 = $t033753400._1 | |
148 | + | let r1 = $t033753400._2 | |
149 | + | let $t034033428 = rewards[2] | |
150 | + | let a2 = $t034033428._1 | |
151 | + | let r2 = $t034033428._2 | |
149 | 152 | if (if ((s > 0)) | |
150 | 153 | then (a0 == target) | |
151 | 154 | else false) | |
271 | 274 | then { | |
272 | 275 | let userAddress = Address(userAddressBytes) | |
273 | 276 | let withdrawalRequestOption = valueOrErrorMessage(getString(factoryAddressOrFail, keyWithdrawalRequest(userAddress, txId)), wrapErr("invalid withdrawal request")) | |
274 | - | let $ | |
275 | - | let status = $ | |
276 | - | let lpAssetAmount = $ | |
277 | - | let targetPeriod = $ | |
278 | - | let claimTxId = $ | |
277 | + | let $t087058818 = parseWithdrawalRequestValueOrFail(withdrawalRequestOption) | |
278 | + | let status = $t087058818._1 | |
279 | + | let lpAssetAmount = $t087058818._2 | |
280 | + | let targetPeriod = $t087058818._3 | |
281 | + | let claimTxId = $t087058818._4 | |
279 | 282 | if ((status == PENDING)) | |
280 | 283 | then { | |
281 | 284 | let factoryActions = [invoke(factoryAddressOrFail, "deleteEntry", [keyWithdrawalRequest(userAddress, txId)], nil), invoke(factoryAddressOrFail, "transferAsset", [userAddressBytes, lpAssetAmount, lpAssetIdOrFail], nil)] | |
298 | 301 | let userAddress = Address(userAddressBytes) | |
299 | 302 | let currentPeriodOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyCurrentPeriod()), wrapErr("invalid period")) | |
300 | 303 | let withdrawalRequestOption = valueOrErrorMessage(getString(factoryAddressOrFail, keyWithdrawalRequest(userAddress, txId)), wrapErr("invalid withdrawal request")) | |
301 | - | let $ | |
302 | - | let status = $ | |
303 | - | let lpAssetAmount = $ | |
304 | - | let targetPeriod = $ | |
305 | - | let claimTxId = $ | |
304 | + | let $t096899802 = parseWithdrawalRequestValueOrFail(withdrawalRequestOption) | |
305 | + | let status = $t096899802._1 | |
306 | + | let lpAssetAmount = $t096899802._2 | |
307 | + | let targetPeriod = $t096899802._3 | |
308 | + | let claimTxId = $t096899802._4 | |
306 | 309 | if ((status == FINISHED)) | |
307 | 310 | then throwErr("invalid withdrawal request status") | |
308 | 311 | else if ((targetPeriod > currentPeriodOrFail)) | |
332 | 335 | let currentStartHeight = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyStartHeight(currentPeriodOrFail)), wrapErr("invalid start height")) | |
333 | 336 | let currentPriceOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyPriceForPeriod(currentPeriodOrFail)), wrapErr("invalid price")) | |
334 | 337 | let nextBlockToProcess = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyNextBlockToProcess()), wrapErr("invalid next block to process")) | |
335 | - | let targetBlockInfo = if (if (if ((height >= nextBlockToProcess)) | |
338 | + | let periodEndHeight = ((currentStartHeight + periodLength) - 1) | |
339 | + | let blocksProcessingBatchSizeMax = 5 | |
340 | + | let blocksProcessingBatchSize = if (if (if ((height >= nextBlockToProcess)) | |
336 | 341 | then if ((nextBlockToProcess >= currentStartHeight)) | |
337 | 342 | then true | |
338 | 343 | else (currentPeriodOrFail == 0) | |
339 | 344 | else false) | |
340 | - | then ( | |
345 | + | then (periodEndHeight >= nextBlockToProcess) | |
341 | 346 | else false) | |
342 | - | then | |
347 | + | then min([((periodEndHeight - nextBlockToProcess) + 1), blocksProcessingBatchSizeMax]) | |
343 | 348 | else throwErr(wrapErr("invalid target block")) | |
344 | - | let treasuryRewardOrFail = valueOrErrorMessage(rewardForOption(targetBlockInfo.rewards, treasuryAddressOrFail), wrapErr("invalid treasury reward")) | |
345 | - | let generator = targetBlockInfo.generator | |
346 | - | let blockProcessingRewardOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyBlockProcessingReward()), wrapErr("invalid block processing reward")) | |
347 | - | let available = valueOrElse(getInteger(factoryAddressOrFail, keyAvailable(generator)), 0) | |
348 | - | let lpAssetAmount = if ((currentPriceOrFail > 0)) | |
349 | - | then fraction((treasuryRewardOrFail - blockProcessingRewardOrFail), SCALE8, currentPriceOrFail) | |
350 | - | else 0 | |
351 | - | let factoryActions = [invoke(factoryAddressOrFail, "integerEntry", [keyNextBlockToProcess(), (nextBlockToProcess + 1)], nil), invoke(factoryAddressOrFail, "integerEntry", [keyAvailable(generator), (available + lpAssetAmount)], nil), invoke(factoryAddressOrFail, "transferWaves", [userAddressBytes, blockProcessingRewardOrFail], nil)] | |
352 | - | $Tuple2(nil, factoryActions) | |
349 | + | let blockProcessingReward = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyBlockProcessingReward()), wrapErr("invalid block processing reward")) | |
350 | + | let blockProcessingRewardByGenerator = (blockProcessingReward / blocksProcessingBatchSize) | |
351 | + | let blockProcessingRewardByGeneratorRemainder = (blockProcessingReward - (blockProcessingRewardByGenerator * blocksProcessingBatchSize)) | |
352 | + | func map (acc,inc) = if ((inc >= blocksProcessingBatchSize)) | |
353 | + | then acc | |
354 | + | else { | |
355 | + | let targetBlockHeight = (nextBlockToProcess + inc) | |
356 | + | let targetBlockInfo = valueOrErrorMessage(blockInfoByHeight(targetBlockHeight), wrapErr("invalid block info")) | |
357 | + | let treasuryRewardOrFail = valueOrErrorMessage(rewardForOption(targetBlockInfo.rewards, treasuryAddressOrFail), wrapErr(("invalid treasury reward for height " + toString(targetBlockHeight)))) | |
358 | + | let generator = targetBlockInfo.generator | |
359 | + | let available = valueOrElse(getInteger(factoryAddressOrFail, keyAvailable(generator)), 0) | |
360 | + | let lpAssetAmount = if ((currentPriceOrFail > 0)) | |
361 | + | then fraction((treasuryRewardOrFail - blockProcessingRewardByGenerator), SCALE8, currentPriceOrFail) | |
362 | + | else 0 | |
363 | + | let factoryActionsSingle = [invoke(factoryAddressOrFail, "integerEntry", [keyBlockProcessed(targetBlockHeight), lpAssetAmount], nil), invoke(factoryAddressOrFail, "integerEntry", [keyAvailable(generator), (available + lpAssetAmount)], nil)] | |
364 | + | if ((factoryActionsSingle == factoryActionsSingle)) | |
365 | + | then { | |
366 | + | let callerReward = if ((inc == (blocksProcessingBatchSize - 1))) | |
367 | + | then (blockProcessingRewardByGenerator + blockProcessingRewardByGeneratorRemainder) | |
368 | + | else blockProcessingRewardByGenerator | |
369 | + | (acc + callerReward) | |
370 | + | } | |
371 | + | else throw("Strict value is not equal to itself.") | |
372 | + | } | |
373 | + | ||
374 | + | let callerReward = { | |
375 | + | let $l = [0, 1, 2, 3, 4] | |
376 | + | let $s = size($l) | |
377 | + | let $acc0 = 0 | |
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 5") | |
385 | + | ||
386 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
387 | + | } | |
388 | + | if ((callerReward == callerReward)) | |
389 | + | then { | |
390 | + | let actions = [invoke(factoryAddressOrFail, "transferWaves", [userAddressBytes, callerReward], nil), invoke(factoryAddressOrFail, "integerEntry", [keyNextBlockToProcess(), (nextBlockToProcess + blocksProcessingBatchSize)], nil)] | |
391 | + | if ((actions == actions)) | |
392 | + | then $Tuple2(nil, unit) | |
393 | + | else throw("Strict value is not equal to itself.") | |
394 | + | } | |
395 | + | else throw("Strict value is not equal to itself.") | |
353 | 396 | } | |
354 | 397 | else throw("Strict value is not equal to itself.") | |
355 | 398 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 7 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | 5 | ||
6 | 6 | let CONTRACT_NAME = "calculator.ride" | |
7 | 7 | ||
8 | 8 | let SCALE8 = 100000000 | |
9 | 9 | ||
10 | 10 | let PENDING = "PENDING" | |
11 | 11 | ||
12 | 12 | let FINISHED = "FINISHED" | |
13 | 13 | ||
14 | 14 | func wrapErr (s) = ((CONTRACT_NAME + ": ") + s) | |
15 | 15 | ||
16 | 16 | ||
17 | 17 | func throwErr (s) = throw(wrapErr(s)) | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func keyFactoryAddress () = makeString(["%s", "factory"], SEP) | |
21 | 21 | ||
22 | 22 | ||
23 | 23 | func keyLpAssetId () = makeString(["%s", "lpAssetId"], SEP) | |
24 | 24 | ||
25 | 25 | ||
26 | 26 | func keyTreasuryAddress () = makeString(["%s", "treasury"], SEP) | |
27 | 27 | ||
28 | 28 | ||
29 | 29 | func keyAvailable (userAddress) = makeString(["%s%s", "available", toString(userAddress)], SEP) | |
30 | 30 | ||
31 | 31 | ||
32 | 32 | func keyClaimed (userAddress) = makeString(["%s%s", "claimed", toString(userAddress)], SEP) | |
33 | 33 | ||
34 | 34 | ||
35 | 35 | func keyCurrentPeriod () = makeString(["%s", "currentPeriod"], SEP) | |
36 | 36 | ||
37 | 37 | ||
38 | 38 | func keyPriceForPeriod (period) = makeString(["%s%d", "price", toString(period)], SEP) | |
39 | 39 | ||
40 | 40 | ||
41 | 41 | func keyStartHeight (period) = makeString(["%s%d", "startHeight", toString(period)], SEP) | |
42 | 42 | ||
43 | 43 | ||
44 | 44 | func keyPeriodLength () = "%s__periodLength" | |
45 | 45 | ||
46 | 46 | ||
47 | 47 | func keyBlockProcessingReward () = "%s__blockProcessingReward" | |
48 | 48 | ||
49 | 49 | ||
50 | 50 | func keyNextBlockToProcess () = "%s__nextBlockToProcess" | |
51 | + | ||
52 | + | ||
53 | + | func keyBlockProcessed (height) = makeString(["%s%d", "blockProcessed", toString(height)], SEP) | |
51 | 54 | ||
52 | 55 | ||
53 | 56 | func keyWithdrawalRequest (userAddress,txId) = makeString(["%s%s%s", "withdrawal", toString(userAddress), toBase58String(txId)], SEP) | |
54 | 57 | ||
55 | 58 | ||
56 | 59 | func valueWithdrawalRequest (status,lpAssetAmount,targetPeriod,claimTxId) = { | |
57 | 60 | let claimTxIdStr = match claimTxId { | |
58 | 61 | case b: ByteVector => | |
59 | 62 | toBase58String(b) | |
60 | 63 | case _: Unit => | |
61 | 64 | "SOON" | |
62 | 65 | case _ => | |
63 | 66 | throw("Match error") | |
64 | 67 | } | |
65 | 68 | makeString(["%s%d%d%s", status, toString(lpAssetAmount), toString(targetPeriod), claimTxIdStr], SEP) | |
66 | 69 | } | |
67 | 70 | ||
68 | 71 | ||
69 | 72 | func parseWithdrawalRequestValueOrFail (s) = { | |
70 | 73 | let parts = split(s, SEP) | |
71 | 74 | if ((size(parts) == 5)) | |
72 | 75 | then { | |
73 | 76 | let status = parts[1] | |
74 | 77 | let lpAssetAmount = valueOrErrorMessage(parseInt(parts[2]), wrapErr("invalid lpAssetAmount")) | |
75 | 78 | let targetPeriod = valueOrErrorMessage(parseInt(parts[3]), wrapErr("invalid targetPeriod")) | |
76 | 79 | let claimTxId = parts[4] | |
77 | 80 | $Tuple4(status, lpAssetAmount, targetPeriod, claimTxId) | |
78 | 81 | } | |
79 | 82 | else throwErr("invalid withdrawal request value") | |
80 | 83 | } | |
81 | 84 | ||
82 | 85 | ||
83 | 86 | let factoryAddressOption = match getString(this, keyFactoryAddress()) { | |
84 | 87 | case s: String => | |
85 | 88 | addressFromString(s) | |
86 | 89 | case _: Unit => | |
87 | 90 | unit | |
88 | 91 | case _ => | |
89 | 92 | throw("Match error") | |
90 | 93 | } | |
91 | 94 | ||
92 | 95 | let factoryAddressOrFail = valueOrErrorMessage(factoryAddressOption, wrapErr("invalid factory address")) | |
93 | 96 | ||
94 | 97 | let lpAssetIdOption = match factoryAddressOption { | |
95 | 98 | case a: Address => | |
96 | 99 | match getString(a, keyLpAssetId()) { | |
97 | 100 | case s: String => | |
98 | 101 | fromBase58String(s) | |
99 | 102 | case _: Unit => | |
100 | 103 | unit | |
101 | 104 | case _ => | |
102 | 105 | throw("Match error") | |
103 | 106 | } | |
104 | 107 | case _: Unit => | |
105 | 108 | unit | |
106 | 109 | case _ => | |
107 | 110 | throw("Match error") | |
108 | 111 | } | |
109 | 112 | ||
110 | 113 | let lpAssetIdOrFail = valueOrErrorMessage(lpAssetIdOption, wrapErr("invalid lpAssetId")) | |
111 | 114 | ||
112 | 115 | let treasuryAddressOption = match factoryAddressOption { | |
113 | 116 | case a: Address => | |
114 | 117 | match getString(a, keyTreasuryAddress()) { | |
115 | 118 | case s: String => | |
116 | 119 | addressFromString(s) | |
117 | 120 | case _: Unit => | |
118 | 121 | unit | |
119 | 122 | case _ => | |
120 | 123 | throw("Match error") | |
121 | 124 | } | |
122 | 125 | case _: Unit => | |
123 | 126 | unit | |
124 | 127 | case _ => | |
125 | 128 | throw("Match error") | |
126 | 129 | } | |
127 | 130 | ||
128 | 131 | let treasuryAddressOrFail = valueOrErrorMessage(treasuryAddressOption, wrapErr("invalid treasury address")) | |
129 | 132 | ||
130 | 133 | func onlyAddress (i,address) = if ((i.caller == address)) | |
131 | 134 | then true | |
132 | 135 | else throwErr("permission denied") | |
133 | 136 | ||
134 | 137 | ||
135 | 138 | func onlyFactory (i) = onlyAddress(i, factoryAddressOrFail) | |
136 | 139 | ||
137 | 140 | ||
138 | 141 | func rewardForOption (rewards,target) = { | |
139 | 142 | let s = size(rewards) | |
140 | - | let $ | |
141 | - | let a0 = $ | |
142 | - | let r0 = $ | |
143 | - | let $ | |
144 | - | let a1 = $ | |
145 | - | let r1 = $ | |
146 | - | let $ | |
147 | - | let a2 = $ | |
148 | - | let r2 = $ | |
143 | + | let $t033473372 = rewards[0] | |
144 | + | let a0 = $t033473372._1 | |
145 | + | let r0 = $t033473372._2 | |
146 | + | let $t033753400 = rewards[1] | |
147 | + | let a1 = $t033753400._1 | |
148 | + | let r1 = $t033753400._2 | |
149 | + | let $t034033428 = rewards[2] | |
150 | + | let a2 = $t034033428._1 | |
151 | + | let r2 = $t034033428._2 | |
149 | 152 | if (if ((s > 0)) | |
150 | 153 | then (a0 == target) | |
151 | 154 | else false) | |
152 | 155 | then r0 | |
153 | 156 | else if (if ((s > 1)) | |
154 | 157 | then (a1 == target) | |
155 | 158 | else false) | |
156 | 159 | then r1 | |
157 | 160 | else if (if ((s > 2)) | |
158 | 161 | then (a2 == target) | |
159 | 162 | else false) | |
160 | 163 | then r2 | |
161 | 164 | else unit | |
162 | 165 | } | |
163 | 166 | ||
164 | 167 | ||
165 | 168 | @Callable(i) | |
166 | 169 | func claimLP (userAddressBytes) = { | |
167 | 170 | let checkCaller = onlyFactory(i) | |
168 | 171 | if ((checkCaller == checkCaller)) | |
169 | 172 | then { | |
170 | 173 | let userAddress = Address(userAddressBytes) | |
171 | 174 | let available = valueOrElse(getInteger(factoryAddressOrFail, keyAvailable(userAddress)), 0) | |
172 | 175 | let claimed = valueOrElse(getInteger(factoryAddressOrFail, keyClaimed(userAddress)), 0) | |
173 | 176 | let factoryActions = if ((available > 0)) | |
174 | 177 | then [invoke(factoryAddressOrFail, "transferAsset", [userAddressBytes, available, lpAssetIdOrFail], nil), invoke(factoryAddressOrFail, "integerEntry", [keyAvailable(userAddress), 0], nil), invoke(factoryAddressOrFail, "stringEntry", [keyClaimed(userAddress), (claimed + available)], nil)] | |
175 | 178 | else throwErr("nothing to claim") | |
176 | 179 | $Tuple2(nil, factoryActions) | |
177 | 180 | } | |
178 | 181 | else throw("Strict value is not equal to itself.") | |
179 | 182 | } | |
180 | 183 | ||
181 | 184 | ||
182 | 185 | ||
183 | 186 | @Callable(i) | |
184 | 187 | func finalize (newTreasuryVolumeInWaves,xtnPrice,pwrManagersBonus,treasuryVolumeDiffAllocationCoef) = { | |
185 | 188 | let checks = [if ((i.originCaller == factoryAddressOrFail)) | |
186 | 189 | then true | |
187 | 190 | else throwErr("permission denied"), if ((newTreasuryVolumeInWaves >= 0)) | |
188 | 191 | then true | |
189 | 192 | else throwErr("invalid new treasury volume"), if ((xtnPrice >= 0)) | |
190 | 193 | then true | |
191 | 194 | else throwErr("invalid XTN price"), if (if ((pwrManagersBonus >= 0)) | |
192 | 195 | then (SCALE8 >= pwrManagersBonus) | |
193 | 196 | else false) | |
194 | 197 | then true | |
195 | 198 | else throwErr("invalid PWR managers bonus"), if (if ((treasuryVolumeDiffAllocationCoef >= -(SCALE8))) | |
196 | 199 | then (SCALE8 >= treasuryVolumeDiffAllocationCoef) | |
197 | 200 | else false) | |
198 | 201 | then true | |
199 | 202 | else throwErr("invalid treasury volume diff allocation coefficient")] | |
200 | 203 | if ((checks == checks)) | |
201 | 204 | then { | |
202 | 205 | let currentPeriodOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyCurrentPeriod()), wrapErr("invalid period")) | |
203 | 206 | let newPeriod = (currentPeriodOrFail + 1) | |
204 | 207 | let newPrice = SCALE8 | |
205 | 208 | let lpAssetAmountToBurn = 0 | |
206 | 209 | let factoryActions = [invoke(factoryAddressOrFail, "integerEntry", [keyCurrentPeriod(), newPeriod], nil), invoke(factoryAddressOrFail, "integerEntry", [keyPriceForPeriod(newPeriod), newPrice], nil), invoke(factoryAddressOrFail, "burn", [lpAssetAmountToBurn], nil)] | |
207 | 210 | $Tuple2(nil, factoryActions) | |
208 | 211 | } | |
209 | 212 | else throw("Strict value is not equal to itself.") | |
210 | 213 | } | |
211 | 214 | ||
212 | 215 | ||
213 | 216 | ||
214 | 217 | @Callable(i) | |
215 | 218 | func invest (userAddressBytes) = { | |
216 | 219 | let checkCaller = onlyFactory(i) | |
217 | 220 | if ((checkCaller == checkCaller)) | |
218 | 221 | then { | |
219 | 222 | let userAddress = Address(userAddressBytes) | |
220 | 223 | let currentPeriodOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyCurrentPeriod()), wrapErr("invalid period")) | |
221 | 224 | let currentPriceOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyPriceForPeriod(currentPeriodOrFail)), wrapErr("invalid price")) | |
222 | 225 | let payment = if ((size(i.payments) == 1)) | |
223 | 226 | then i.payments[0] | |
224 | 227 | else throwErr("invalid payments") | |
225 | 228 | let paymentAmount = if (if ((payment.assetId == unit)) | |
226 | 229 | then (payment.amount > 0) | |
227 | 230 | else false) | |
228 | 231 | then payment.amount | |
229 | 232 | else throwErr("invalid payment amount") | |
230 | 233 | let lpAssetAmount = if ((currentPriceOrFail > 0)) | |
231 | 234 | then fraction(paymentAmount, SCALE8, currentPriceOrFail) | |
232 | 235 | else 0 | |
233 | 236 | let factoryActions = [invoke(factoryAddressOrFail, "integerEntry", ["invested__WAVES", 0], nil), invoke(factoryAddressOrFail, "reissue", [lpAssetAmount], nil), invoke(factoryAddressOrFail, "transferAsset", [userAddressBytes, lpAssetAmount, lpAssetIdOrFail], nil), invoke(factoryAddressOrFail, "transferWaves", [treasuryAddressOrFail.bytes, paymentAmount], [AttachedPayment(unit, paymentAmount)])] | |
234 | 237 | $Tuple2(nil, factoryActions) | |
235 | 238 | } | |
236 | 239 | else throw("Strict value is not equal to itself.") | |
237 | 240 | } | |
238 | 241 | ||
239 | 242 | ||
240 | 243 | ||
241 | 244 | @Callable(i) | |
242 | 245 | func withdraw (userAddressBytes) = { | |
243 | 246 | let checkCaller = onlyFactory(i) | |
244 | 247 | if ((checkCaller == checkCaller)) | |
245 | 248 | then { | |
246 | 249 | let userAddress = Address(userAddressBytes) | |
247 | 250 | let currentPeriodOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyCurrentPeriod()), wrapErr("invalid period")) | |
248 | 251 | let payment = if ((size(i.payments) == 1)) | |
249 | 252 | then i.payments[0] | |
250 | 253 | else throwErr(wrapErr("invalid payments")) | |
251 | 254 | let paymentAssetId = if ((payment.assetId == lpAssetIdOrFail)) | |
252 | 255 | then lpAssetIdOrFail | |
253 | 256 | else throwErr("invalid payment asset") | |
254 | 257 | let paymentAmount = if ((payment.amount > 0)) | |
255 | 258 | then payment.amount | |
256 | 259 | else throwErr("invalid payment amount") | |
257 | 260 | let factoryActions = [invoke(factoryAddressOrFail, "stringEntry", [keyWithdrawalRequest(userAddress, i.transactionId), valueWithdrawalRequest(PENDING, paymentAmount, (currentPeriodOrFail + 1), unit)], nil)] | |
258 | 261 | if ((factoryActions == factoryActions)) | |
259 | 262 | then $Tuple2([ScriptTransfer(factoryAddressOrFail, paymentAmount, paymentAssetId)], factoryActions) | |
260 | 263 | else throw("Strict value is not equal to itself.") | |
261 | 264 | } | |
262 | 265 | else throw("Strict value is not equal to itself.") | |
263 | 266 | } | |
264 | 267 | ||
265 | 268 | ||
266 | 269 | ||
267 | 270 | @Callable(i) | |
268 | 271 | func cancelWithdraw (userAddressBytes,txId) = { | |
269 | 272 | let checkCaller = onlyFactory(i) | |
270 | 273 | if ((checkCaller == checkCaller)) | |
271 | 274 | then { | |
272 | 275 | let userAddress = Address(userAddressBytes) | |
273 | 276 | let withdrawalRequestOption = valueOrErrorMessage(getString(factoryAddressOrFail, keyWithdrawalRequest(userAddress, txId)), wrapErr("invalid withdrawal request")) | |
274 | - | let $ | |
275 | - | let status = $ | |
276 | - | let lpAssetAmount = $ | |
277 | - | let targetPeriod = $ | |
278 | - | let claimTxId = $ | |
277 | + | let $t087058818 = parseWithdrawalRequestValueOrFail(withdrawalRequestOption) | |
278 | + | let status = $t087058818._1 | |
279 | + | let lpAssetAmount = $t087058818._2 | |
280 | + | let targetPeriod = $t087058818._3 | |
281 | + | let claimTxId = $t087058818._4 | |
279 | 282 | if ((status == PENDING)) | |
280 | 283 | then { | |
281 | 284 | let factoryActions = [invoke(factoryAddressOrFail, "deleteEntry", [keyWithdrawalRequest(userAddress, txId)], nil), invoke(factoryAddressOrFail, "transferAsset", [userAddressBytes, lpAssetAmount, lpAssetIdOrFail], nil)] | |
282 | 285 | if ((factoryActions == factoryActions)) | |
283 | 286 | then $Tuple2(nil, factoryActions) | |
284 | 287 | else throw("Strict value is not equal to itself.") | |
285 | 288 | } | |
286 | 289 | else throwErr("invalid withdrawal request status") | |
287 | 290 | } | |
288 | 291 | else throw("Strict value is not equal to itself.") | |
289 | 292 | } | |
290 | 293 | ||
291 | 294 | ||
292 | 295 | ||
293 | 296 | @Callable(i) | |
294 | 297 | func claimWaves (userAddressBytes,txId) = { | |
295 | 298 | let checkCaller = onlyFactory(i) | |
296 | 299 | if ((checkCaller == checkCaller)) | |
297 | 300 | then { | |
298 | 301 | let userAddress = Address(userAddressBytes) | |
299 | 302 | let currentPeriodOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyCurrentPeriod()), wrapErr("invalid period")) | |
300 | 303 | let withdrawalRequestOption = valueOrErrorMessage(getString(factoryAddressOrFail, keyWithdrawalRequest(userAddress, txId)), wrapErr("invalid withdrawal request")) | |
301 | - | let $ | |
302 | - | let status = $ | |
303 | - | let lpAssetAmount = $ | |
304 | - | let targetPeriod = $ | |
305 | - | let claimTxId = $ | |
304 | + | let $t096899802 = parseWithdrawalRequestValueOrFail(withdrawalRequestOption) | |
305 | + | let status = $t096899802._1 | |
306 | + | let lpAssetAmount = $t096899802._2 | |
307 | + | let targetPeriod = $t096899802._3 | |
308 | + | let claimTxId = $t096899802._4 | |
306 | 309 | if ((status == FINISHED)) | |
307 | 310 | then throwErr("invalid withdrawal request status") | |
308 | 311 | else if ((targetPeriod > currentPeriodOrFail)) | |
309 | 312 | then throwErr("invalid withdrawal request period") | |
310 | 313 | else { | |
311 | 314 | let currentPriceOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyPriceForPeriod(currentPeriodOrFail)), wrapErr("invalid price")) | |
312 | 315 | let amount = if ((currentPriceOrFail > 0)) | |
313 | 316 | then fraction(lpAssetAmount, currentPriceOrFail, SCALE8) | |
314 | 317 | else 0 | |
315 | 318 | let factoryActions = [invoke(factoryAddressOrFail, "stringEntry", [keyWithdrawalRequest(userAddress, txId), valueWithdrawalRequest(FINISHED, lpAssetAmount, targetPeriod, i.transactionId)], nil), invoke(factoryAddressOrFail, "burn", [lpAssetAmount], nil), invoke(factoryAddressOrFail, "transferWaves", [userAddressBytes, amount], nil)] | |
316 | 319 | $Tuple2(nil, factoryActions) | |
317 | 320 | } | |
318 | 321 | } | |
319 | 322 | else throw("Strict value is not equal to itself.") | |
320 | 323 | } | |
321 | 324 | ||
322 | 325 | ||
323 | 326 | ||
324 | 327 | @Callable(i) | |
325 | 328 | func processBlocks (userAddressBytes) = { | |
326 | 329 | let checkCaller = onlyFactory(i) | |
327 | 330 | if ((checkCaller == checkCaller)) | |
328 | 331 | then { | |
329 | 332 | let userAddress = Address(userAddressBytes) | |
330 | 333 | let currentPeriodOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyCurrentPeriod()), wrapErr("invalid period")) | |
331 | 334 | let periodLength = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyPeriodLength()), wrapErr("invalid period length")) | |
332 | 335 | let currentStartHeight = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyStartHeight(currentPeriodOrFail)), wrapErr("invalid start height")) | |
333 | 336 | let currentPriceOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyPriceForPeriod(currentPeriodOrFail)), wrapErr("invalid price")) | |
334 | 337 | let nextBlockToProcess = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyNextBlockToProcess()), wrapErr("invalid next block to process")) | |
335 | - | let targetBlockInfo = if (if (if ((height >= nextBlockToProcess)) | |
338 | + | let periodEndHeight = ((currentStartHeight + periodLength) - 1) | |
339 | + | let blocksProcessingBatchSizeMax = 5 | |
340 | + | let blocksProcessingBatchSize = if (if (if ((height >= nextBlockToProcess)) | |
336 | 341 | then if ((nextBlockToProcess >= currentStartHeight)) | |
337 | 342 | then true | |
338 | 343 | else (currentPeriodOrFail == 0) | |
339 | 344 | else false) | |
340 | - | then ( | |
345 | + | then (periodEndHeight >= nextBlockToProcess) | |
341 | 346 | else false) | |
342 | - | then | |
347 | + | then min([((periodEndHeight - nextBlockToProcess) + 1), blocksProcessingBatchSizeMax]) | |
343 | 348 | else throwErr(wrapErr("invalid target block")) | |
344 | - | let treasuryRewardOrFail = valueOrErrorMessage(rewardForOption(targetBlockInfo.rewards, treasuryAddressOrFail), wrapErr("invalid treasury reward")) | |
345 | - | let generator = targetBlockInfo.generator | |
346 | - | let blockProcessingRewardOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyBlockProcessingReward()), wrapErr("invalid block processing reward")) | |
347 | - | let available = valueOrElse(getInteger(factoryAddressOrFail, keyAvailable(generator)), 0) | |
348 | - | let lpAssetAmount = if ((currentPriceOrFail > 0)) | |
349 | - | then fraction((treasuryRewardOrFail - blockProcessingRewardOrFail), SCALE8, currentPriceOrFail) | |
350 | - | else 0 | |
351 | - | let factoryActions = [invoke(factoryAddressOrFail, "integerEntry", [keyNextBlockToProcess(), (nextBlockToProcess + 1)], nil), invoke(factoryAddressOrFail, "integerEntry", [keyAvailable(generator), (available + lpAssetAmount)], nil), invoke(factoryAddressOrFail, "transferWaves", [userAddressBytes, blockProcessingRewardOrFail], nil)] | |
352 | - | $Tuple2(nil, factoryActions) | |
349 | + | let blockProcessingReward = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyBlockProcessingReward()), wrapErr("invalid block processing reward")) | |
350 | + | let blockProcessingRewardByGenerator = (blockProcessingReward / blocksProcessingBatchSize) | |
351 | + | let blockProcessingRewardByGeneratorRemainder = (blockProcessingReward - (blockProcessingRewardByGenerator * blocksProcessingBatchSize)) | |
352 | + | func map (acc,inc) = if ((inc >= blocksProcessingBatchSize)) | |
353 | + | then acc | |
354 | + | else { | |
355 | + | let targetBlockHeight = (nextBlockToProcess + inc) | |
356 | + | let targetBlockInfo = valueOrErrorMessage(blockInfoByHeight(targetBlockHeight), wrapErr("invalid block info")) | |
357 | + | let treasuryRewardOrFail = valueOrErrorMessage(rewardForOption(targetBlockInfo.rewards, treasuryAddressOrFail), wrapErr(("invalid treasury reward for height " + toString(targetBlockHeight)))) | |
358 | + | let generator = targetBlockInfo.generator | |
359 | + | let available = valueOrElse(getInteger(factoryAddressOrFail, keyAvailable(generator)), 0) | |
360 | + | let lpAssetAmount = if ((currentPriceOrFail > 0)) | |
361 | + | then fraction((treasuryRewardOrFail - blockProcessingRewardByGenerator), SCALE8, currentPriceOrFail) | |
362 | + | else 0 | |
363 | + | let factoryActionsSingle = [invoke(factoryAddressOrFail, "integerEntry", [keyBlockProcessed(targetBlockHeight), lpAssetAmount], nil), invoke(factoryAddressOrFail, "integerEntry", [keyAvailable(generator), (available + lpAssetAmount)], nil)] | |
364 | + | if ((factoryActionsSingle == factoryActionsSingle)) | |
365 | + | then { | |
366 | + | let callerReward = if ((inc == (blocksProcessingBatchSize - 1))) | |
367 | + | then (blockProcessingRewardByGenerator + blockProcessingRewardByGeneratorRemainder) | |
368 | + | else blockProcessingRewardByGenerator | |
369 | + | (acc + callerReward) | |
370 | + | } | |
371 | + | else throw("Strict value is not equal to itself.") | |
372 | + | } | |
373 | + | ||
374 | + | let callerReward = { | |
375 | + | let $l = [0, 1, 2, 3, 4] | |
376 | + | let $s = size($l) | |
377 | + | let $acc0 = 0 | |
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 5") | |
385 | + | ||
386 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
387 | + | } | |
388 | + | if ((callerReward == callerReward)) | |
389 | + | then { | |
390 | + | let actions = [invoke(factoryAddressOrFail, "transferWaves", [userAddressBytes, callerReward], nil), invoke(factoryAddressOrFail, "integerEntry", [keyNextBlockToProcess(), (nextBlockToProcess + blocksProcessingBatchSize)], nil)] | |
391 | + | if ((actions == actions)) | |
392 | + | then $Tuple2(nil, unit) | |
393 | + | else throw("Strict value is not equal to itself.") | |
394 | + | } | |
395 | + | else throw("Strict value is not equal to itself.") | |
353 | 396 | } | |
354 | 397 | else throw("Strict value is not equal to itself.") | |
355 | 398 | } | |
356 | 399 | ||
357 | 400 | ||
358 | 401 | @Verifier(tx) | |
359 | 402 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
360 | 403 |
github/deemru/w8io/026f985 58.44 ms ◑