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:BgISCAISBgoEAgEBARIGCgQCAQEBLAADU0VQAgJfXwANQ09OVFJBQ1RfTkFNRQIPY2FsY3VsYXRvci5yaWRlAAZTQ0FMRTgAgMLXLwAHUEVORElORwIHUEVORElORwAIRklOSVNIRUQCCEZJTklTSEVEAAVXQVZFUwIFV0FWRVMBB3dyYXBFcnIBAXMJAKwCAgkArAICBQ1DT05UUkFDVF9OQU1FAgI6IAUBcwEIdGhyb3dFcnIBAXMJAAIBCQEHd3JhcEVycgEFAXMBD2Fzc2V0SWRUb1N0cmluZwEHYXNzZXRJZAQHJG1hdGNoMAUHYXNzZXRJZAMJAAECBQckbWF0Y2gwAgpCeXRlVmVjdG9yBAFiBQckbWF0Y2gwCQDYBAEFAWIDCQABAgUHJG1hdGNoMAIEVW5pdAUFV0FWRVMJAAIBAgtNYXRjaCBlcnJvcgEDYWJzAQFuAwkAZgIAAAUBbgkBAS0BBQFuBQFuARFrZXlGYWN0b3J5QWRkcmVzcwAJALkJAgkAzAgCAgIlcwkAzAgCAgdmYWN0b3J5BQNuaWwFA1NFUAETa2V5TWFuYWdlclB1YmxpY0tleQAJALkJAgkAzA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NhdGlvbkNvZWYJAQEtAQUGU0NBTEU4CQBnAgUGU0NBTEU4BSB0cmVhc3VyeVZvbHVtZURpZmZBbGxvY2F0aW9uQ29lZgcGCQEIdGhyb3dFcnIBAjNpbnZhbGlkIHRyZWFzdXJ5IHZvbHVtZSBkaWZmIGFsbG9jYXRpb24gY29lZmZpY2llbnQFA25pbAMJAAACBQZjaGVja3MFBmNoZWNrcwkAlAoCBQNuaWwJARBmaW5hbGl6ZUlOVEVSTkFMAwUYbmV3VHJlYXN1cnlWb2x1bWVJbldhdmVzBRdwd3JNYW5hZ2Vyc0JvbnVzSW5XYXZlcwUgdHJlYXN1cnlWb2x1bWVEaWZmQWxsb2NhdGlvbkNvZWYJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4AoEFgUw==", "chainId": 84, "height": 2653832, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FmL5cQAV3bZMxYNPbfDPzbJGCiv9yQ9ktyTGvN34yqqc Next: none Diff:
OldNewDifferences
305305 else throwErr("invalid treasury volume diff allocation coefficient")]
306306 if ((checks == checks))
307307 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
338315 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))
342322 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))
345331 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)
371337 }
372338 else throw("Strict value is not equal to itself.")
373339 }
377343 }
378344
379345
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+
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let SEP = "__"
55
66 let CONTRACT_NAME = "calculator.ride"
77
88 let SCALE8 = 100000000
99
1010 let PENDING = "PENDING"
1111
1212 let FINISHED = "FINISHED"
1313
1414 let WAVES = "WAVES"
1515
1616 func wrapErr (s) = ((CONTRACT_NAME + ": ") + s)
1717
1818
1919 func throwErr (s) = throw(wrapErr(s))
2020
2121
2222 func assetIdToString (assetId) = match assetId {
2323 case b: ByteVector =>
2424 toBase58String(b)
2525 case _: Unit =>
2626 WAVES
2727 case _ =>
2828 throw("Match error")
2929 }
3030
3131
3232 func abs (n) = if ((0 > n))
3333 then -(n)
3434 else n
3535
3636
3737 func keyFactoryAddress () = makeString(["%s", "factory"], SEP)
3838
3939
4040 func keyManagerPublicKey () = makeString(["%s", "managerPublicKey"], SEP)
4141
4242
4343 func keyLpAssetId () = makeString(["%s", "lpAssetId"], SEP)
4444
4545
4646 func keyProxyTreasuryAddress () = makeString(["%s", "proxyTreasury"], SEP)
4747
4848
4949 func keyMainTreasuryAddress () = makeString(["%s", "mainTreasury"], SEP)
5050
5151
5252 func keyInvested (assetId) = makeString(["%s%s", "invested", assetIdToString(assetId)], SEP)
5353
5454
5555 func keyDonated (assetId) = makeString(["%s%s", "donated", assetIdToString(assetId)], SEP)
5656
5757
5858 func keyAvailable (userAddress) = makeString(["%s%s", "available", toString(userAddress)], SEP)
5959
6060
6161 func keyClaimed (userAddress) = makeString(["%s%s", "claimed", toString(userAddress)], SEP)
6262
6363
6464 func keyCurrentPeriod () = makeString(["%s", "currentPeriod"], SEP)
6565
6666
6767 func keyPriceForPeriod (period) = makeString(["%s%d", "price", toString(period)], SEP)
6868
6969
7070 func keyStartHeight (period) = makeString(["%s%d", "startHeight", toString(period)], SEP)
7171
7272
7373 func keyPowerManagerBonus (period) = makeString(["%s%d", "powerManagerBonus", toString(period)], SEP)
7474
7575
7676 func keyPeriodLength () = "%s__periodLength"
7777
7878
7979 func keyBlockProcessingReward () = "%s__blockProcessingReward"
8080
8181
8282 func keyNextBlockToProcess () = "%s__nextBlockToProcess"
8383
8484
8585 func keyBlockProcessed (height) = makeString(["%s%d", "blockProcessed", toString(height)], SEP)
8686
8787
8888 func keyWithdrawal () = "%s__withdrawal"
8989
9090
9191 func keyWithdrawalRequest (userAddress,txId) = makeString(["%s%s%s", "withdrawal", toString(userAddress), toBase58String(txId)], SEP)
9292
9393
9494 func valueWithdrawalRequest (status,lpAssetAmount,targetPeriod,claimTxId) = {
9595 let claimTxIdStr = match claimTxId {
9696 case b: ByteVector =>
9797 toBase58String(b)
9898 case _: Unit =>
9999 "SOON"
100100 case _ =>
101101 throw("Match error")
102102 }
103103 makeString(["%s%d%d%s", status, toString(lpAssetAmount), toString(targetPeriod), claimTxIdStr], SEP)
104104 }
105105
106106
107107 func parseWithdrawalRequestValueOrFail (s) = {
108108 let parts = split(s, SEP)
109109 if ((size(parts) == 5))
110110 then {
111111 let status = parts[1]
112112 let lpAssetAmount = valueOrErrorMessage(parseInt(parts[2]), wrapErr("invalid lpAssetAmount"))
113113 let targetPeriod = valueOrErrorMessage(parseInt(parts[3]), wrapErr("invalid targetPeriod"))
114114 let claimTxId = parts[4]
115115 $Tuple4(status, lpAssetAmount, targetPeriod, claimTxId)
116116 }
117117 else throwErr("invalid withdrawal request value")
118118 }
119119
120120
121121 let factoryAddressOption = match getString(this, keyFactoryAddress()) {
122122 case s: String =>
123123 addressFromString(s)
124124 case _: Unit =>
125125 unit
126126 case _ =>
127127 throw("Match error")
128128 }
129129
130130 let factoryAddressOrFail = valueOrErrorMessage(factoryAddressOption, wrapErr("invalid factory address"))
131131
132132 let lpAssetIdOption = match factoryAddressOption {
133133 case a: Address =>
134134 match getString(a, keyLpAssetId()) {
135135 case s: String =>
136136 fromBase58String(s)
137137 case _: Unit =>
138138 unit
139139 case _ =>
140140 throw("Match error")
141141 }
142142 case _: Unit =>
143143 unit
144144 case _ =>
145145 throw("Match error")
146146 }
147147
148148 let lpAssetIdOrFail = valueOrErrorMessage(lpAssetIdOption, wrapErr("invalid lpAssetId"))
149149
150150 let proxyTreasuryAddressOption = match factoryAddressOption {
151151 case a: Address =>
152152 match getString(a, keyProxyTreasuryAddress()) {
153153 case s: String =>
154154 addressFromString(s)
155155 case _: Unit =>
156156 unit
157157 case _ =>
158158 throw("Match error")
159159 }
160160 case _: Unit =>
161161 unit
162162 case _ =>
163163 throw("Match error")
164164 }
165165
166166 let proxyTreasuryAddressOrFail = valueOrErrorMessage(proxyTreasuryAddressOption, wrapErr("invalid proxy treasury address"))
167167
168168 let mainTreasuryAddressOption = match factoryAddressOption {
169169 case a: Address =>
170170 match getString(a, keyMainTreasuryAddress()) {
171171 case s: String =>
172172 addressFromString(s)
173173 case _: Unit =>
174174 unit
175175 case _ =>
176176 throw("Match error")
177177 }
178178 case _: Unit =>
179179 unit
180180 case _ =>
181181 throw("Match error")
182182 }
183183
184184 let mainTreasuryAddressOrFail = valueOrErrorMessage(mainTreasuryAddressOption, wrapErr("invalid main treasury address"))
185185
186186 func getManagerPublicKeyOrUnit () = match factoryAddressOption {
187187 case fa: Address =>
188188 match getString(fa, keyManagerPublicKey()) {
189189 case pub: String =>
190190 fromBase58String(pub)
191191 case _ =>
192192 unit
193193 }
194194 case _ =>
195195 unit
196196 }
197197
198198
199199 func onlyAddress (i,address) = if ((i.caller == address))
200200 then true
201201 else throwErr("permission denied")
202202
203203
204204 func onlyFactory (i) = onlyAddress(i, factoryAddressOrFail)
205205
206206
207207 func rewardForOption (rewards,target) = {
208208 let s = size(rewards)
209209 let $t047354760 = rewards[0]
210210 let a0 = $t047354760._1
211211 let r0 = $t047354760._2
212212 let $t047634788 = rewards[1]
213213 let a1 = $t047634788._1
214214 let r1 = $t047634788._2
215215 let $t047914816 = rewards[2]
216216 let a2 = $t047914816._1
217217 let r2 = $t047914816._2
218218 if (if ((s > 0))
219219 then (a0 == target)
220220 else false)
221221 then r0
222222 else if (if ((s > 1))
223223 then (a1 == target)
224224 else false)
225225 then r1
226226 else if (if ((s > 2))
227227 then (a2 == target)
228228 else false)
229229 then r2
230230 else unit
231231 }
232232
233233
234234 func finalizeINTERNAL (newTreasuryVolumeInWaves,pwrManagersBonusInWaves,treasuryVolumeDiffAllocationCoef) = {
235235 let donatedWavesAmount = valueOrElse(getInteger(factoryAddressOrFail, keyDonated(unit)), 0)
236236 let investedWavesAmount = valueOrElse(getInteger(factoryAddressOrFail, keyInvested(unit)), 0)
237237 let currentTreasuryVolumeInWaves = (donatedWavesAmount + investedWavesAmount)
238238 let profitRaw = (newTreasuryVolumeInWaves - currentTreasuryVolumeInWaves)
239239 let pwrManagersBonusAmount = if (if ((profitRaw >= pwrManagersBonusInWaves))
240240 then true
241241 else (pwrManagersBonusInWaves == 0))
242242 then pwrManagersBonusInWaves
243243 else throwErr("power bonus is more than profit")
244244 let profit = (profitRaw - pwrManagersBonusAmount)
245245 let donationPart = if ((currentTreasuryVolumeInWaves > 0))
246246 then fraction(donatedWavesAmount, SCALE8, currentTreasuryVolumeInWaves)
247247 else 0
248248 let donationProfitPartRaw = fraction(profit, donationPart, SCALE8)
249249 let investmentProfitPartRaw = (profit - donationProfitPartRaw)
250250 let treasuryVolumeDiffAllocationCoefAbs = abs(treasuryVolumeDiffAllocationCoef)
251251 let amountToDonation = fraction(investmentProfitPartRaw, if ((0 > treasuryVolumeDiffAllocationCoef))
252252 then treasuryVolumeDiffAllocationCoefAbs
253253 else 0, SCALE8)
254254 let amountToInvestment = fraction(donationProfitPartRaw, if ((treasuryVolumeDiffAllocationCoef > 0))
255255 then treasuryVolumeDiffAllocationCoefAbs
256256 else 0, SCALE8)
257257 let donationProfitPart = ((donationProfitPartRaw - amountToInvestment) + amountToDonation)
258258 let investmentProfitPart = ((investmentProfitPartRaw - amountToDonation) + amountToInvestment)
259259 let donatedWavesAmountNewRaw = (donatedWavesAmount + donationProfitPart)
260260 let investedWavesAmountNewRaw = (investedWavesAmount + investmentProfitPart)
261261 let donatedPartDebt = min([0, donatedWavesAmountNewRaw])
262262 let investedPartDebt = min([0, investedWavesAmountNewRaw])
263263 let donatedWavesAmountNew = (max([0, donatedWavesAmountNewRaw]) + investedPartDebt)
264264 let investedWavesAmountNew = (max([0, investedWavesAmountNewRaw]) + donatedPartDebt)
265265 let lpAssetQuantity = valueOrErrorMessage(assetInfo(lpAssetIdOrFail), wrapErr("invalid lpAsset info")).quantity
266266 let newPrice = fraction(investedWavesAmountNew, SCALE8, lpAssetQuantity)
267267 let checkIfPriceNotZero = if ((newPrice != 0))
268268 then true
269269 else throwErr("LP price cannot be 0")
270270 if ((checkIfPriceNotZero == checkIfPriceNotZero))
271271 then {
272272 let lpAssetAmountToBurn = valueOrElse(getInteger(factoryAddressOrFail, keyWithdrawal()), 0)
273273 let paymentAmountMin = max([0, fraction(lpAssetAmountToBurn, newPrice, SCALE8)])
274274 let finalInvestedWavesAmount = (investedWavesAmountNew - paymentAmountMin)
275275 let lpAssetFinalQuantity = (lpAssetQuantity - lpAssetAmountToBurn)
276276 $Tuple6(paymentAmountMin, finalInvestedWavesAmount, donatedWavesAmountNew, newPrice, lpAssetAmountToBurn, lpAssetFinalQuantity)
277277 }
278278 else throw("Strict value is not equal to itself.")
279279 }
280280
281281
282282 @Callable(i)
283283 func finalize (userAddressBytes,newTreasuryVolumeInWaves,pwrManagersBonusInWaves,treasuryVolumeDiffAllocationCoef) = {
284284 let checkCaller = onlyFactory(i)
285285 if ((checkCaller == checkCaller))
286286 then {
287287 let currentPeriodOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyCurrentPeriod()), wrapErr("invalid period"))
288288 let periodLength = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyPeriodLength()), wrapErr("invalid period length"))
289289 let currentStartHeight = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyStartHeight(currentPeriodOrFail)), wrapErr("invalid start height"))
290290 let currentPriceOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyPriceForPeriod(currentPeriodOrFail)), wrapErr("invalid price"))
291291 let nextBlockToProcess = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyNextBlockToProcess()), wrapErr("invalid next block to process"))
292292 let periodEndHeight = ((currentStartHeight + periodLength) - 1)
293293 let checks = [if ((i.originCaller == mainTreasuryAddressOrFail))
294294 then true
295295 else throwErr("permission denied"), if ((nextBlockToProcess > periodEndHeight))
296296 then true
297297 else throwErr("unprocessed blocks"), if ((newTreasuryVolumeInWaves >= 0))
298298 then true
299299 else throwErr("invalid new treasury volume"), if ((pwrManagersBonusInWaves >= 0))
300300 then true
301301 else throwErr("invalid PWR managers bonus"), if (if ((treasuryVolumeDiffAllocationCoef >= -(SCALE8)))
302302 then (SCALE8 >= treasuryVolumeDiffAllocationCoef)
303303 else false)
304304 then true
305305 else throwErr("invalid treasury volume diff allocation coefficient")]
306306 if ((checks == checks))
307307 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
338315 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))
342322 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))
345331 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)
371337 }
372338 else throw("Strict value is not equal to itself.")
373339 }
374340 else throw("Strict value is not equal to itself.")
375341 }
376342 else throw("Strict value is not equal to itself.")
377343 }
378344
379345
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/026f985 
40.57 ms