tx · 8y5h7h4jri46Uv6RpTgxvj46iKWaEV7gEabD5pStNato 3N9wLKKtDBphos7U3xzsPqgvJJ5zPQEU6pV: -0.01200000 Waves 2023.07.06 11:51 [2653832] smart account 3N9wLKKtDBphos7U3xzsPqgvJJ5zPQEU6pV > SELF 0.00000000 Waves
{ "type": 13, "id": "8y5h7h4jri46Uv6RpTgxvj46iKWaEV7gEabD5pStNato", "fee": 1200000, "feeAssetId": null, "timestamp": 1688633478803, "version": 1, "sender": "3N9wLKKtDBphos7U3xzsPqgvJJ5zPQEU6pV", "senderPublicKey": "GKX7DbVJVEtTB6ak3PXWHNPUhC3jym3ozbtZ7a36rGu6", "proofs": [ "2amQKrbaLoEJHXJ8D9nH1cRGLJwXaue6acq1pM7RVFjJbuJK12yk5fCyURpHPAKEc3wBeAn69VotZzKGeaFsf68q" ], "script": "base64:BgISCAISBgoEAgEBARIGCgQCAQEBLAADU0VQAgJfXwANQ09OVFJBQ1RfTkFNRQIPY2FsY3VsYXRvci5yaWRlAAZTQ0FMRTgAgMLXLwAHUEVORElORwIHUEVORElORwAIRklOSVNIRUQCCEZJTklTSEVEAAVXQVZFUwIFV0FWRVMBB3dyYXBFcnIBAXMJAKwCAgkArAICBQ1DT05UUkFDVF9OQU1FAgI6IAUBcwEIdGhyb3dFcnIBAXMJAAIBCQEHd3JhcEVycgEFAXMBD2Fzc2V0SWRUb1N0cmluZwEHYXNzZXRJZAQHJG1hdGNoMAUHYXNzZXRJZAMJAAECBQckbWF0Y2gwAgpCeXRlVmVjdG9yBAFiBQckbWF0Y2gwCQDYBAEFAWIDCQABAgUHJG1hdGNoMAIEVW5pdAUFV0FWRVMJAAIBAgtNYXRjaCBlcnJvcgEDYWJzAQFuAwkAZgIAAAUBbgkBAS0BBQFuBQFuARFrZXlGYWN0b3J5QWRkcmVzcwAJALkJAgkAzAgCAgIlcwkAzAgCAgdmYWN0b3J5BQNuaWwFA1NFUAETa2V5TWFuYWdlclB1YmxpY0tleQAJALkJAgkAzAg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hdGlvbkNvZWYJAQEtAQUGU0NBTEU4CQBnAgUGU0NBTEU4BSB0cmVhc3VyeVZvbHVtZURpZmZBbGxvY2F0aW9uQ29lZgcGCQEIdGhyb3dFcnIBAjNpbnZhbGlkIHRyZWFzdXJ5IHZvbHVtZSBkaWZmIGFsbG9jYXRpb24gY29lZmZpY2llbnQFA25pbAMJAAACBQZjaGVja3MFBmNoZWNrcwkAlAoCBQNuaWwJARBmaW5hbGl6ZUlOVEVSTkFMAwUYbmV3VHJlYXN1cnlWb2x1bWVJbldhdmVzBRdwd3JNYW5hZ2Vyc0JvbnVzSW5XYXZlcwUgdHJlYXN1cnlWb2x1bWVEaWZmQWxsb2NhdGlvbkNvZWYJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4AoEFgUw==", "chainId": 84, "height": 2653832, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FmL5cQAV3bZMxYNPbfDPzbJGCiv9yQ9ktyTGvN34yqqc Next: none Diff:
Old | New | Differences | |
---|---|---|---|
305 | 305 | else throwErr("invalid treasury volume diff allocation coefficient")] | |
306 | 306 | if ((checks == checks)) | |
307 | 307 | then { | |
308 | - | let donatedWavesAmount = valueOrElse(getInteger(factoryAddressOrFail, keyDonated(unit)), 0) | |
309 | - | let investedWavesAmount = valueOrElse(getInteger(factoryAddressOrFail, keyInvested(unit)), 0) | |
310 | - | let currentTreasuryVolumeInWaves = (donatedWavesAmount + investedWavesAmount) | |
311 | - | let profitRaw = (newTreasuryVolumeInWaves - currentTreasuryVolumeInWaves) | |
312 | - | let pwrManagersBonusAmount = if (if ((profitRaw > 0)) | |
313 | - | then (profitRaw >= pwrManagersBonusInWaves) | |
314 | - | else false) | |
315 | - | then pwrManagersBonusInWaves | |
316 | - | else throwErr("power bonus is more than profit") | |
317 | - | let profit = (profitRaw - pwrManagersBonusAmount) | |
318 | - | let donationPart = if ((currentTreasuryVolumeInWaves > 0)) | |
319 | - | then fraction(donatedWavesAmount, SCALE8, currentTreasuryVolumeInWaves) | |
320 | - | else 0 | |
321 | - | let donationProfitPartRaw = fraction(profit, donationPart, SCALE8) | |
322 | - | let investmentProfitPartRaw = (profit - donationProfitPartRaw) | |
323 | - | let treasuryVolumeDiffAllocationCoefAbs = abs(treasuryVolumeDiffAllocationCoef) | |
324 | - | let amountToDonation = fraction(investmentProfitPartRaw, if ((0 > treasuryVolumeDiffAllocationCoef)) | |
325 | - | then treasuryVolumeDiffAllocationCoefAbs | |
326 | - | else 0, SCALE8) | |
327 | - | let amountToInvestment = fraction(donationProfitPartRaw, if ((treasuryVolumeDiffAllocationCoef > 0)) | |
328 | - | then treasuryVolumeDiffAllocationCoefAbs | |
329 | - | else 0, SCALE8) | |
330 | - | let donationProfitPart = ((donationProfitPartRaw - amountToInvestment) + amountToDonation) | |
331 | - | let investmentProfitPart = ((investmentProfitPartRaw - amountToDonation) + amountToInvestment) | |
332 | - | let donatedWavesAmountNewRaw = (donatedWavesAmount + donationProfitPart) | |
333 | - | let investedWavesAmountNewRaw = (investedWavesAmount + investmentProfitPart) | |
334 | - | let donatedPartDebt = min([0, donatedWavesAmountNewRaw]) | |
335 | - | let investedPartDebt = min([0, investedWavesAmountNewRaw]) | |
336 | - | let donatedWavesAmountNew = (max([0, donatedWavesAmountNewRaw]) + investedPartDebt) | |
337 | - | let investedWavesAmountNew = (max([0, investedWavesAmountNewRaw]) + donatedPartDebt) | |
308 | + | let $t095079768 = finalizeINTERNAL(newTreasuryVolumeInWaves, pwrManagersBonusInWaves, treasuryVolumeDiffAllocationCoef) | |
309 | + | let paymentAmountMin = $t095079768._1 | |
310 | + | let finalInvestedWavesAmount = $t095079768._2 | |
311 | + | let donatedWavesAmountNew = $t095079768._3 | |
312 | + | let newPrice = $t095079768._4 | |
313 | + | let lpAssetAmountToBurn = $t095079768._5 | |
314 | + | let lpAssetFinalQuantity = $t095079768._6 | |
338 | 315 | let newPeriod = (currentPeriodOrFail + 1) | |
339 | - | let lpAssetQuantity = valueOrErrorMessage(assetInfo(lpAssetIdOrFail), wrapErr("invalid lpAsset info")).quantity | |
340 | - | let newPrice = fraction(investedWavesAmountNew, SCALE8, lpAssetQuantity) | |
341 | - | let checkIfPriceNotZero = if ((newPrice != 0)) | |
316 | + | let paymentOption = if ((size(i.payments) > 0)) | |
317 | + | then i.payments[0] | |
318 | + | else unit | |
319 | + | let paymentAmount = value(paymentOption).amount | |
320 | + | let paymentAssetId = value(paymentOption).assetId | |
321 | + | let checkPayment = if (if ((paymentAmountMin == 0)) | |
342 | 322 | then true | |
343 | - | else throwErr("LP price cannot be 0") | |
344 | - | if ((checkIfPriceNotZero == checkIfPriceNotZero)) | |
323 | + | else if (if ((paymentOption != unit)) | |
324 | + | then (paymentAssetId == unit) | |
325 | + | else false) | |
326 | + | then (paymentAmount >= paymentAmountMin) | |
327 | + | else false) | |
328 | + | then true | |
329 | + | else throwErr(("invalid payments, payment amount min: " + toString(paymentAmountMin))) | |
330 | + | if ((checkPayment == checkPayment)) | |
345 | 331 | then { | |
346 | - | let lpAssetAmountToBurn = valueOrElse(getInteger(factoryAddressOrFail, keyWithdrawal()), 0) | |
347 | - | let paymentAmountMin = max([0, fraction(lpAssetAmountToBurn, newPrice, SCALE8)]) | |
348 | - | let paymentOption = if ((size(i.payments) > 0)) | |
349 | - | then i.payments[0] | |
350 | - | else unit | |
351 | - | let paymentAmount = value(paymentOption).amount | |
352 | - | let paymentAssetId = value(paymentOption).assetId | |
353 | - | let checkPayment = if (if ((paymentAmountMin == 0)) | |
354 | - | then true | |
355 | - | else if (if ((paymentOption != unit)) | |
356 | - | then (paymentAssetId == unit) | |
357 | - | else false) | |
358 | - | then (paymentAmount >= paymentAmountMin) | |
359 | - | else false) | |
360 | - | then true | |
361 | - | else throwErr(("invalid payments, payment amount min: " + toString(paymentAmountMin))) | |
362 | - | if ((checkPayment == checkPayment)) | |
363 | - | then { | |
364 | - | let actions = if ((paymentOption != unit)) | |
365 | - | then [ScriptTransfer(factoryAddressOrFail, paymentAmount, paymentAssetId)] | |
366 | - | else nil | |
367 | - | let factoryActions = [invoke(factoryAddressOrFail, "integerEntry", [keyPowerManagerBonus(currentPeriodOrFail), pwrManagersBonusAmount], nil), invoke(factoryAddressOrFail, "integerEntry", [keyCurrentPeriod(), newPeriod], nil), invoke(factoryAddressOrFail, "integerEntry", [keyPriceForPeriod(newPeriod), newPrice], nil), invoke(factoryAddressOrFail, "integerEntry", [keyStartHeight(newPeriod), (periodEndHeight + 1)], nil), invoke(factoryAddressOrFail, "burn", [lpAssetAmountToBurn], nil), invoke(factoryAddressOrFail, "integerEntry", [keyWithdrawal(), 0], nil), invoke(factoryAddressOrFail, "integerEntry", [keyInvested(unit), (investedWavesAmountNew - paymentAmountMin)], nil), invoke(factoryAddressOrFail, "integerEntry", [keyDonated(unit), donatedWavesAmountNew], nil)] | |
368 | - | $Tuple2(actions, factoryActions) | |
369 | - | } | |
370 | - | else throw("Strict value is not equal to itself.") | |
332 | + | let actions = if ((paymentOption != unit)) | |
333 | + | then [ScriptTransfer(factoryAddressOrFail, paymentAmount, paymentAssetId)] | |
334 | + | else nil | |
335 | + | let factoryActions = [invoke(factoryAddressOrFail, "integerEntry", [keyPowerManagerBonus(currentPeriodOrFail), pwrManagersBonusInWaves], nil), invoke(factoryAddressOrFail, "integerEntry", [keyCurrentPeriod(), newPeriod], nil), invoke(factoryAddressOrFail, "integerEntry", [keyPriceForPeriod(newPeriod), newPrice], nil), invoke(factoryAddressOrFail, "integerEntry", [keyStartHeight(newPeriod), (periodEndHeight + 1)], nil), invoke(factoryAddressOrFail, "burn", [lpAssetAmountToBurn], nil), invoke(factoryAddressOrFail, "integerEntry", [keyWithdrawal(), 0], nil), invoke(factoryAddressOrFail, "integerEntry", [keyInvested(unit), finalInvestedWavesAmount], nil), invoke(factoryAddressOrFail, "integerEntry", [keyDonated(unit), donatedWavesAmountNew], nil)] | |
336 | + | $Tuple2(actions, factoryActions) | |
371 | 337 | } | |
372 | 338 | else throw("Strict value is not equal to itself.") | |
373 | 339 | } | |
377 | 343 | } | |
378 | 344 | ||
379 | 345 | ||
346 | + | ||
347 | + | @Callable(i) | |
348 | + | func finalizeREADONLY (userAddressBytes,newTreasuryVolumeInWaves,pwrManagersBonusInWaves,treasuryVolumeDiffAllocationCoef) = { | |
349 | + | let currentPeriodOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyCurrentPeriod()), wrapErr("invalid period")) | |
350 | + | let periodLength = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyPeriodLength()), wrapErr("invalid period length")) | |
351 | + | let currentStartHeight = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyStartHeight(currentPeriodOrFail)), wrapErr("invalid start height")) | |
352 | + | let currentPriceOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyPriceForPeriod(currentPeriodOrFail)), wrapErr("invalid price")) | |
353 | + | let nextBlockToProcess = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyNextBlockToProcess()), wrapErr("invalid next block to process")) | |
354 | + | let periodEndHeight = ((currentStartHeight + periodLength) - 1) | |
355 | + | let checks = [if ((nextBlockToProcess > periodEndHeight)) | |
356 | + | then true | |
357 | + | else throwErr("unprocessed blocks"), if ((newTreasuryVolumeInWaves >= 0)) | |
358 | + | then true | |
359 | + | else throwErr("invalid new treasury volume"), if ((pwrManagersBonusInWaves >= 0)) | |
360 | + | then true | |
361 | + | else throwErr("invalid PWR managers bonus"), if (if ((treasuryVolumeDiffAllocationCoef >= -(SCALE8))) | |
362 | + | then (SCALE8 >= treasuryVolumeDiffAllocationCoef) | |
363 | + | else false) | |
364 | + | then true | |
365 | + | else throwErr("invalid treasury volume diff allocation coefficient")] | |
366 | + | if ((checks == checks)) | |
367 | + | then $Tuple2(nil, finalizeINTERNAL(newTreasuryVolumeInWaves, pwrManagersBonusInWaves, treasuryVolumeDiffAllocationCoef)) | |
368 | + | else throw("Strict value is not equal to itself.") | |
369 | + | } | |
370 | + | ||
371 | + |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
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 | let WAVES = "WAVES" | |
15 | 15 | ||
16 | 16 | func wrapErr (s) = ((CONTRACT_NAME + ": ") + s) | |
17 | 17 | ||
18 | 18 | ||
19 | 19 | func throwErr (s) = throw(wrapErr(s)) | |
20 | 20 | ||
21 | 21 | ||
22 | 22 | func assetIdToString (assetId) = match assetId { | |
23 | 23 | case b: ByteVector => | |
24 | 24 | toBase58String(b) | |
25 | 25 | case _: Unit => | |
26 | 26 | WAVES | |
27 | 27 | case _ => | |
28 | 28 | throw("Match error") | |
29 | 29 | } | |
30 | 30 | ||
31 | 31 | ||
32 | 32 | func abs (n) = if ((0 > n)) | |
33 | 33 | then -(n) | |
34 | 34 | else n | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func keyFactoryAddress () = makeString(["%s", "factory"], SEP) | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | func keyManagerPublicKey () = makeString(["%s", "managerPublicKey"], SEP) | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | func keyLpAssetId () = makeString(["%s", "lpAssetId"], SEP) | |
44 | 44 | ||
45 | 45 | ||
46 | 46 | func keyProxyTreasuryAddress () = makeString(["%s", "proxyTreasury"], SEP) | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | func keyMainTreasuryAddress () = makeString(["%s", "mainTreasury"], SEP) | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func keyInvested (assetId) = makeString(["%s%s", "invested", assetIdToString(assetId)], SEP) | |
53 | 53 | ||
54 | 54 | ||
55 | 55 | func keyDonated (assetId) = makeString(["%s%s", "donated", assetIdToString(assetId)], SEP) | |
56 | 56 | ||
57 | 57 | ||
58 | 58 | func keyAvailable (userAddress) = makeString(["%s%s", "available", toString(userAddress)], SEP) | |
59 | 59 | ||
60 | 60 | ||
61 | 61 | func keyClaimed (userAddress) = makeString(["%s%s", "claimed", toString(userAddress)], SEP) | |
62 | 62 | ||
63 | 63 | ||
64 | 64 | func keyCurrentPeriod () = makeString(["%s", "currentPeriod"], SEP) | |
65 | 65 | ||
66 | 66 | ||
67 | 67 | func keyPriceForPeriod (period) = makeString(["%s%d", "price", toString(period)], SEP) | |
68 | 68 | ||
69 | 69 | ||
70 | 70 | func keyStartHeight (period) = makeString(["%s%d", "startHeight", toString(period)], SEP) | |
71 | 71 | ||
72 | 72 | ||
73 | 73 | func keyPowerManagerBonus (period) = makeString(["%s%d", "powerManagerBonus", toString(period)], SEP) | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | func keyPeriodLength () = "%s__periodLength" | |
77 | 77 | ||
78 | 78 | ||
79 | 79 | func keyBlockProcessingReward () = "%s__blockProcessingReward" | |
80 | 80 | ||
81 | 81 | ||
82 | 82 | func keyNextBlockToProcess () = "%s__nextBlockToProcess" | |
83 | 83 | ||
84 | 84 | ||
85 | 85 | func keyBlockProcessed (height) = makeString(["%s%d", "blockProcessed", toString(height)], SEP) | |
86 | 86 | ||
87 | 87 | ||
88 | 88 | func keyWithdrawal () = "%s__withdrawal" | |
89 | 89 | ||
90 | 90 | ||
91 | 91 | func keyWithdrawalRequest (userAddress,txId) = makeString(["%s%s%s", "withdrawal", toString(userAddress), toBase58String(txId)], SEP) | |
92 | 92 | ||
93 | 93 | ||
94 | 94 | func valueWithdrawalRequest (status,lpAssetAmount,targetPeriod,claimTxId) = { | |
95 | 95 | let claimTxIdStr = match claimTxId { | |
96 | 96 | case b: ByteVector => | |
97 | 97 | toBase58String(b) | |
98 | 98 | case _: Unit => | |
99 | 99 | "SOON" | |
100 | 100 | case _ => | |
101 | 101 | throw("Match error") | |
102 | 102 | } | |
103 | 103 | makeString(["%s%d%d%s", status, toString(lpAssetAmount), toString(targetPeriod), claimTxIdStr], SEP) | |
104 | 104 | } | |
105 | 105 | ||
106 | 106 | ||
107 | 107 | func parseWithdrawalRequestValueOrFail (s) = { | |
108 | 108 | let parts = split(s, SEP) | |
109 | 109 | if ((size(parts) == 5)) | |
110 | 110 | then { | |
111 | 111 | let status = parts[1] | |
112 | 112 | let lpAssetAmount = valueOrErrorMessage(parseInt(parts[2]), wrapErr("invalid lpAssetAmount")) | |
113 | 113 | let targetPeriod = valueOrErrorMessage(parseInt(parts[3]), wrapErr("invalid targetPeriod")) | |
114 | 114 | let claimTxId = parts[4] | |
115 | 115 | $Tuple4(status, lpAssetAmount, targetPeriod, claimTxId) | |
116 | 116 | } | |
117 | 117 | else throwErr("invalid withdrawal request value") | |
118 | 118 | } | |
119 | 119 | ||
120 | 120 | ||
121 | 121 | let factoryAddressOption = match getString(this, keyFactoryAddress()) { | |
122 | 122 | case s: String => | |
123 | 123 | addressFromString(s) | |
124 | 124 | case _: Unit => | |
125 | 125 | unit | |
126 | 126 | case _ => | |
127 | 127 | throw("Match error") | |
128 | 128 | } | |
129 | 129 | ||
130 | 130 | let factoryAddressOrFail = valueOrErrorMessage(factoryAddressOption, wrapErr("invalid factory address")) | |
131 | 131 | ||
132 | 132 | let lpAssetIdOption = match factoryAddressOption { | |
133 | 133 | case a: Address => | |
134 | 134 | match getString(a, keyLpAssetId()) { | |
135 | 135 | case s: String => | |
136 | 136 | fromBase58String(s) | |
137 | 137 | case _: Unit => | |
138 | 138 | unit | |
139 | 139 | case _ => | |
140 | 140 | throw("Match error") | |
141 | 141 | } | |
142 | 142 | case _: Unit => | |
143 | 143 | unit | |
144 | 144 | case _ => | |
145 | 145 | throw("Match error") | |
146 | 146 | } | |
147 | 147 | ||
148 | 148 | let lpAssetIdOrFail = valueOrErrorMessage(lpAssetIdOption, wrapErr("invalid lpAssetId")) | |
149 | 149 | ||
150 | 150 | let proxyTreasuryAddressOption = match factoryAddressOption { | |
151 | 151 | case a: Address => | |
152 | 152 | match getString(a, keyProxyTreasuryAddress()) { | |
153 | 153 | case s: String => | |
154 | 154 | addressFromString(s) | |
155 | 155 | case _: Unit => | |
156 | 156 | unit | |
157 | 157 | case _ => | |
158 | 158 | throw("Match error") | |
159 | 159 | } | |
160 | 160 | case _: Unit => | |
161 | 161 | unit | |
162 | 162 | case _ => | |
163 | 163 | throw("Match error") | |
164 | 164 | } | |
165 | 165 | ||
166 | 166 | let proxyTreasuryAddressOrFail = valueOrErrorMessage(proxyTreasuryAddressOption, wrapErr("invalid proxy treasury address")) | |
167 | 167 | ||
168 | 168 | let mainTreasuryAddressOption = match factoryAddressOption { | |
169 | 169 | case a: Address => | |
170 | 170 | match getString(a, keyMainTreasuryAddress()) { | |
171 | 171 | case s: String => | |
172 | 172 | addressFromString(s) | |
173 | 173 | case _: Unit => | |
174 | 174 | unit | |
175 | 175 | case _ => | |
176 | 176 | throw("Match error") | |
177 | 177 | } | |
178 | 178 | case _: Unit => | |
179 | 179 | unit | |
180 | 180 | case _ => | |
181 | 181 | throw("Match error") | |
182 | 182 | } | |
183 | 183 | ||
184 | 184 | let mainTreasuryAddressOrFail = valueOrErrorMessage(mainTreasuryAddressOption, wrapErr("invalid main treasury address")) | |
185 | 185 | ||
186 | 186 | func getManagerPublicKeyOrUnit () = match factoryAddressOption { | |
187 | 187 | case fa: Address => | |
188 | 188 | match getString(fa, keyManagerPublicKey()) { | |
189 | 189 | case pub: String => | |
190 | 190 | fromBase58String(pub) | |
191 | 191 | case _ => | |
192 | 192 | unit | |
193 | 193 | } | |
194 | 194 | case _ => | |
195 | 195 | unit | |
196 | 196 | } | |
197 | 197 | ||
198 | 198 | ||
199 | 199 | func onlyAddress (i,address) = if ((i.caller == address)) | |
200 | 200 | then true | |
201 | 201 | else throwErr("permission denied") | |
202 | 202 | ||
203 | 203 | ||
204 | 204 | func onlyFactory (i) = onlyAddress(i, factoryAddressOrFail) | |
205 | 205 | ||
206 | 206 | ||
207 | 207 | func rewardForOption (rewards,target) = { | |
208 | 208 | let s = size(rewards) | |
209 | 209 | let $t047354760 = rewards[0] | |
210 | 210 | let a0 = $t047354760._1 | |
211 | 211 | let r0 = $t047354760._2 | |
212 | 212 | let $t047634788 = rewards[1] | |
213 | 213 | let a1 = $t047634788._1 | |
214 | 214 | let r1 = $t047634788._2 | |
215 | 215 | let $t047914816 = rewards[2] | |
216 | 216 | let a2 = $t047914816._1 | |
217 | 217 | let r2 = $t047914816._2 | |
218 | 218 | if (if ((s > 0)) | |
219 | 219 | then (a0 == target) | |
220 | 220 | else false) | |
221 | 221 | then r0 | |
222 | 222 | else if (if ((s > 1)) | |
223 | 223 | then (a1 == target) | |
224 | 224 | else false) | |
225 | 225 | then r1 | |
226 | 226 | else if (if ((s > 2)) | |
227 | 227 | then (a2 == target) | |
228 | 228 | else false) | |
229 | 229 | then r2 | |
230 | 230 | else unit | |
231 | 231 | } | |
232 | 232 | ||
233 | 233 | ||
234 | 234 | func finalizeINTERNAL (newTreasuryVolumeInWaves,pwrManagersBonusInWaves,treasuryVolumeDiffAllocationCoef) = { | |
235 | 235 | let donatedWavesAmount = valueOrElse(getInteger(factoryAddressOrFail, keyDonated(unit)), 0) | |
236 | 236 | let investedWavesAmount = valueOrElse(getInteger(factoryAddressOrFail, keyInvested(unit)), 0) | |
237 | 237 | let currentTreasuryVolumeInWaves = (donatedWavesAmount + investedWavesAmount) | |
238 | 238 | let profitRaw = (newTreasuryVolumeInWaves - currentTreasuryVolumeInWaves) | |
239 | 239 | let pwrManagersBonusAmount = if (if ((profitRaw >= pwrManagersBonusInWaves)) | |
240 | 240 | then true | |
241 | 241 | else (pwrManagersBonusInWaves == 0)) | |
242 | 242 | then pwrManagersBonusInWaves | |
243 | 243 | else throwErr("power bonus is more than profit") | |
244 | 244 | let profit = (profitRaw - pwrManagersBonusAmount) | |
245 | 245 | let donationPart = if ((currentTreasuryVolumeInWaves > 0)) | |
246 | 246 | then fraction(donatedWavesAmount, SCALE8, currentTreasuryVolumeInWaves) | |
247 | 247 | else 0 | |
248 | 248 | let donationProfitPartRaw = fraction(profit, donationPart, SCALE8) | |
249 | 249 | let investmentProfitPartRaw = (profit - donationProfitPartRaw) | |
250 | 250 | let treasuryVolumeDiffAllocationCoefAbs = abs(treasuryVolumeDiffAllocationCoef) | |
251 | 251 | let amountToDonation = fraction(investmentProfitPartRaw, if ((0 > treasuryVolumeDiffAllocationCoef)) | |
252 | 252 | then treasuryVolumeDiffAllocationCoefAbs | |
253 | 253 | else 0, SCALE8) | |
254 | 254 | let amountToInvestment = fraction(donationProfitPartRaw, if ((treasuryVolumeDiffAllocationCoef > 0)) | |
255 | 255 | then treasuryVolumeDiffAllocationCoefAbs | |
256 | 256 | else 0, SCALE8) | |
257 | 257 | let donationProfitPart = ((donationProfitPartRaw - amountToInvestment) + amountToDonation) | |
258 | 258 | let investmentProfitPart = ((investmentProfitPartRaw - amountToDonation) + amountToInvestment) | |
259 | 259 | let donatedWavesAmountNewRaw = (donatedWavesAmount + donationProfitPart) | |
260 | 260 | let investedWavesAmountNewRaw = (investedWavesAmount + investmentProfitPart) | |
261 | 261 | let donatedPartDebt = min([0, donatedWavesAmountNewRaw]) | |
262 | 262 | let investedPartDebt = min([0, investedWavesAmountNewRaw]) | |
263 | 263 | let donatedWavesAmountNew = (max([0, donatedWavesAmountNewRaw]) + investedPartDebt) | |
264 | 264 | let investedWavesAmountNew = (max([0, investedWavesAmountNewRaw]) + donatedPartDebt) | |
265 | 265 | let lpAssetQuantity = valueOrErrorMessage(assetInfo(lpAssetIdOrFail), wrapErr("invalid lpAsset info")).quantity | |
266 | 266 | let newPrice = fraction(investedWavesAmountNew, SCALE8, lpAssetQuantity) | |
267 | 267 | let checkIfPriceNotZero = if ((newPrice != 0)) | |
268 | 268 | then true | |
269 | 269 | else throwErr("LP price cannot be 0") | |
270 | 270 | if ((checkIfPriceNotZero == checkIfPriceNotZero)) | |
271 | 271 | then { | |
272 | 272 | let lpAssetAmountToBurn = valueOrElse(getInteger(factoryAddressOrFail, keyWithdrawal()), 0) | |
273 | 273 | let paymentAmountMin = max([0, fraction(lpAssetAmountToBurn, newPrice, SCALE8)]) | |
274 | 274 | let finalInvestedWavesAmount = (investedWavesAmountNew - paymentAmountMin) | |
275 | 275 | let lpAssetFinalQuantity = (lpAssetQuantity - lpAssetAmountToBurn) | |
276 | 276 | $Tuple6(paymentAmountMin, finalInvestedWavesAmount, donatedWavesAmountNew, newPrice, lpAssetAmountToBurn, lpAssetFinalQuantity) | |
277 | 277 | } | |
278 | 278 | else throw("Strict value is not equal to itself.") | |
279 | 279 | } | |
280 | 280 | ||
281 | 281 | ||
282 | 282 | @Callable(i) | |
283 | 283 | func finalize (userAddressBytes,newTreasuryVolumeInWaves,pwrManagersBonusInWaves,treasuryVolumeDiffAllocationCoef) = { | |
284 | 284 | let checkCaller = onlyFactory(i) | |
285 | 285 | if ((checkCaller == checkCaller)) | |
286 | 286 | then { | |
287 | 287 | let currentPeriodOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyCurrentPeriod()), wrapErr("invalid period")) | |
288 | 288 | let periodLength = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyPeriodLength()), wrapErr("invalid period length")) | |
289 | 289 | let currentStartHeight = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyStartHeight(currentPeriodOrFail)), wrapErr("invalid start height")) | |
290 | 290 | let currentPriceOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyPriceForPeriod(currentPeriodOrFail)), wrapErr("invalid price")) | |
291 | 291 | let nextBlockToProcess = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyNextBlockToProcess()), wrapErr("invalid next block to process")) | |
292 | 292 | let periodEndHeight = ((currentStartHeight + periodLength) - 1) | |
293 | 293 | let checks = [if ((i.originCaller == mainTreasuryAddressOrFail)) | |
294 | 294 | then true | |
295 | 295 | else throwErr("permission denied"), if ((nextBlockToProcess > periodEndHeight)) | |
296 | 296 | then true | |
297 | 297 | else throwErr("unprocessed blocks"), if ((newTreasuryVolumeInWaves >= 0)) | |
298 | 298 | then true | |
299 | 299 | else throwErr("invalid new treasury volume"), if ((pwrManagersBonusInWaves >= 0)) | |
300 | 300 | then true | |
301 | 301 | else throwErr("invalid PWR managers bonus"), if (if ((treasuryVolumeDiffAllocationCoef >= -(SCALE8))) | |
302 | 302 | then (SCALE8 >= treasuryVolumeDiffAllocationCoef) | |
303 | 303 | else false) | |
304 | 304 | then true | |
305 | 305 | else throwErr("invalid treasury volume diff allocation coefficient")] | |
306 | 306 | if ((checks == checks)) | |
307 | 307 | then { | |
308 | - | let donatedWavesAmount = valueOrElse(getInteger(factoryAddressOrFail, keyDonated(unit)), 0) | |
309 | - | let investedWavesAmount = valueOrElse(getInteger(factoryAddressOrFail, keyInvested(unit)), 0) | |
310 | - | let currentTreasuryVolumeInWaves = (donatedWavesAmount + investedWavesAmount) | |
311 | - | let profitRaw = (newTreasuryVolumeInWaves - currentTreasuryVolumeInWaves) | |
312 | - | let pwrManagersBonusAmount = if (if ((profitRaw > 0)) | |
313 | - | then (profitRaw >= pwrManagersBonusInWaves) | |
314 | - | else false) | |
315 | - | then pwrManagersBonusInWaves | |
316 | - | else throwErr("power bonus is more than profit") | |
317 | - | let profit = (profitRaw - pwrManagersBonusAmount) | |
318 | - | let donationPart = if ((currentTreasuryVolumeInWaves > 0)) | |
319 | - | then fraction(donatedWavesAmount, SCALE8, currentTreasuryVolumeInWaves) | |
320 | - | else 0 | |
321 | - | let donationProfitPartRaw = fraction(profit, donationPart, SCALE8) | |
322 | - | let investmentProfitPartRaw = (profit - donationProfitPartRaw) | |
323 | - | let treasuryVolumeDiffAllocationCoefAbs = abs(treasuryVolumeDiffAllocationCoef) | |
324 | - | let amountToDonation = fraction(investmentProfitPartRaw, if ((0 > treasuryVolumeDiffAllocationCoef)) | |
325 | - | then treasuryVolumeDiffAllocationCoefAbs | |
326 | - | else 0, SCALE8) | |
327 | - | let amountToInvestment = fraction(donationProfitPartRaw, if ((treasuryVolumeDiffAllocationCoef > 0)) | |
328 | - | then treasuryVolumeDiffAllocationCoefAbs | |
329 | - | else 0, SCALE8) | |
330 | - | let donationProfitPart = ((donationProfitPartRaw - amountToInvestment) + amountToDonation) | |
331 | - | let investmentProfitPart = ((investmentProfitPartRaw - amountToDonation) + amountToInvestment) | |
332 | - | let donatedWavesAmountNewRaw = (donatedWavesAmount + donationProfitPart) | |
333 | - | let investedWavesAmountNewRaw = (investedWavesAmount + investmentProfitPart) | |
334 | - | let donatedPartDebt = min([0, donatedWavesAmountNewRaw]) | |
335 | - | let investedPartDebt = min([0, investedWavesAmountNewRaw]) | |
336 | - | let donatedWavesAmountNew = (max([0, donatedWavesAmountNewRaw]) + investedPartDebt) | |
337 | - | let investedWavesAmountNew = (max([0, investedWavesAmountNewRaw]) + donatedPartDebt) | |
308 | + | let $t095079768 = finalizeINTERNAL(newTreasuryVolumeInWaves, pwrManagersBonusInWaves, treasuryVolumeDiffAllocationCoef) | |
309 | + | let paymentAmountMin = $t095079768._1 | |
310 | + | let finalInvestedWavesAmount = $t095079768._2 | |
311 | + | let donatedWavesAmountNew = $t095079768._3 | |
312 | + | let newPrice = $t095079768._4 | |
313 | + | let lpAssetAmountToBurn = $t095079768._5 | |
314 | + | let lpAssetFinalQuantity = $t095079768._6 | |
338 | 315 | let newPeriod = (currentPeriodOrFail + 1) | |
339 | - | let lpAssetQuantity = valueOrErrorMessage(assetInfo(lpAssetIdOrFail), wrapErr("invalid lpAsset info")).quantity | |
340 | - | let newPrice = fraction(investedWavesAmountNew, SCALE8, lpAssetQuantity) | |
341 | - | let checkIfPriceNotZero = if ((newPrice != 0)) | |
316 | + | let paymentOption = if ((size(i.payments) > 0)) | |
317 | + | then i.payments[0] | |
318 | + | else unit | |
319 | + | let paymentAmount = value(paymentOption).amount | |
320 | + | let paymentAssetId = value(paymentOption).assetId | |
321 | + | let checkPayment = if (if ((paymentAmountMin == 0)) | |
342 | 322 | then true | |
343 | - | else throwErr("LP price cannot be 0") | |
344 | - | if ((checkIfPriceNotZero == checkIfPriceNotZero)) | |
323 | + | else if (if ((paymentOption != unit)) | |
324 | + | then (paymentAssetId == unit) | |
325 | + | else false) | |
326 | + | then (paymentAmount >= paymentAmountMin) | |
327 | + | else false) | |
328 | + | then true | |
329 | + | else throwErr(("invalid payments, payment amount min: " + toString(paymentAmountMin))) | |
330 | + | if ((checkPayment == checkPayment)) | |
345 | 331 | then { | |
346 | - | let lpAssetAmountToBurn = valueOrElse(getInteger(factoryAddressOrFail, keyWithdrawal()), 0) | |
347 | - | let paymentAmountMin = max([0, fraction(lpAssetAmountToBurn, newPrice, SCALE8)]) | |
348 | - | let paymentOption = if ((size(i.payments) > 0)) | |
349 | - | then i.payments[0] | |
350 | - | else unit | |
351 | - | let paymentAmount = value(paymentOption).amount | |
352 | - | let paymentAssetId = value(paymentOption).assetId | |
353 | - | let checkPayment = if (if ((paymentAmountMin == 0)) | |
354 | - | then true | |
355 | - | else if (if ((paymentOption != unit)) | |
356 | - | then (paymentAssetId == unit) | |
357 | - | else false) | |
358 | - | then (paymentAmount >= paymentAmountMin) | |
359 | - | else false) | |
360 | - | then true | |
361 | - | else throwErr(("invalid payments, payment amount min: " + toString(paymentAmountMin))) | |
362 | - | if ((checkPayment == checkPayment)) | |
363 | - | then { | |
364 | - | let actions = if ((paymentOption != unit)) | |
365 | - | then [ScriptTransfer(factoryAddressOrFail, paymentAmount, paymentAssetId)] | |
366 | - | else nil | |
367 | - | let factoryActions = [invoke(factoryAddressOrFail, "integerEntry", [keyPowerManagerBonus(currentPeriodOrFail), pwrManagersBonusAmount], nil), invoke(factoryAddressOrFail, "integerEntry", [keyCurrentPeriod(), newPeriod], nil), invoke(factoryAddressOrFail, "integerEntry", [keyPriceForPeriod(newPeriod), newPrice], nil), invoke(factoryAddressOrFail, "integerEntry", [keyStartHeight(newPeriod), (periodEndHeight + 1)], nil), invoke(factoryAddressOrFail, "burn", [lpAssetAmountToBurn], nil), invoke(factoryAddressOrFail, "integerEntry", [keyWithdrawal(), 0], nil), invoke(factoryAddressOrFail, "integerEntry", [keyInvested(unit), (investedWavesAmountNew - paymentAmountMin)], nil), invoke(factoryAddressOrFail, "integerEntry", [keyDonated(unit), donatedWavesAmountNew], nil)] | |
368 | - | $Tuple2(actions, factoryActions) | |
369 | - | } | |
370 | - | else throw("Strict value is not equal to itself.") | |
332 | + | let actions = if ((paymentOption != unit)) | |
333 | + | then [ScriptTransfer(factoryAddressOrFail, paymentAmount, paymentAssetId)] | |
334 | + | else nil | |
335 | + | let factoryActions = [invoke(factoryAddressOrFail, "integerEntry", [keyPowerManagerBonus(currentPeriodOrFail), pwrManagersBonusInWaves], nil), invoke(factoryAddressOrFail, "integerEntry", [keyCurrentPeriod(), newPeriod], nil), invoke(factoryAddressOrFail, "integerEntry", [keyPriceForPeriod(newPeriod), newPrice], nil), invoke(factoryAddressOrFail, "integerEntry", [keyStartHeight(newPeriod), (periodEndHeight + 1)], nil), invoke(factoryAddressOrFail, "burn", [lpAssetAmountToBurn], nil), invoke(factoryAddressOrFail, "integerEntry", [keyWithdrawal(), 0], nil), invoke(factoryAddressOrFail, "integerEntry", [keyInvested(unit), finalInvestedWavesAmount], nil), invoke(factoryAddressOrFail, "integerEntry", [keyDonated(unit), donatedWavesAmountNew], nil)] | |
336 | + | $Tuple2(actions, factoryActions) | |
371 | 337 | } | |
372 | 338 | else throw("Strict value is not equal to itself.") | |
373 | 339 | } | |
374 | 340 | else throw("Strict value is not equal to itself.") | |
375 | 341 | } | |
376 | 342 | else throw("Strict value is not equal to itself.") | |
377 | 343 | } | |
378 | 344 | ||
379 | 345 | ||
346 | + | ||
347 | + | @Callable(i) | |
348 | + | func finalizeREADONLY (userAddressBytes,newTreasuryVolumeInWaves,pwrManagersBonusInWaves,treasuryVolumeDiffAllocationCoef) = { | |
349 | + | let currentPeriodOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyCurrentPeriod()), wrapErr("invalid period")) | |
350 | + | let periodLength = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyPeriodLength()), wrapErr("invalid period length")) | |
351 | + | let currentStartHeight = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyStartHeight(currentPeriodOrFail)), wrapErr("invalid start height")) | |
352 | + | let currentPriceOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyPriceForPeriod(currentPeriodOrFail)), wrapErr("invalid price")) | |
353 | + | let nextBlockToProcess = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyNextBlockToProcess()), wrapErr("invalid next block to process")) | |
354 | + | let periodEndHeight = ((currentStartHeight + periodLength) - 1) | |
355 | + | let checks = [if ((nextBlockToProcess > periodEndHeight)) | |
356 | + | then true | |
357 | + | else throwErr("unprocessed blocks"), if ((newTreasuryVolumeInWaves >= 0)) | |
358 | + | then true | |
359 | + | else throwErr("invalid new treasury volume"), if ((pwrManagersBonusInWaves >= 0)) | |
360 | + | then true | |
361 | + | else throwErr("invalid PWR managers bonus"), if (if ((treasuryVolumeDiffAllocationCoef >= -(SCALE8))) | |
362 | + | then (SCALE8 >= treasuryVolumeDiffAllocationCoef) | |
363 | + | else false) | |
364 | + | then true | |
365 | + | else throwErr("invalid treasury volume diff allocation coefficient")] | |
366 | + | if ((checks == checks)) | |
367 | + | then $Tuple2(nil, finalizeINTERNAL(newTreasuryVolumeInWaves, pwrManagersBonusInWaves, treasuryVolumeDiffAllocationCoef)) | |
368 | + | else throw("Strict value is not equal to itself.") | |
369 | + | } | |
370 | + | ||
371 | + |
github/deemru/w8io/169f3d6 46.20 ms ◑