tx · 9Vi6dShqRBrogqSX8vt3DTNWaJHRG6yctKmES5BLEdaU

3MyLDDChFqiZMV8At2rmymVkQzrrPbSE7EK:  -0.01400000 Waves

2022.03.16 16:47 [1966578] smart account 3MyLDDChFqiZMV8At2rmymVkQzrrPbSE7EK > SELF 0.00000000 Waves

{ "type": 13, "id": "9Vi6dShqRBrogqSX8vt3DTNWaJHRG6yctKmES5BLEdaU", "fee": 1400000, "feeAssetId": null, "timestamp": 1647438099671, "version": 2, "chainId": 84, "sender": "3MyLDDChFqiZMV8At2rmymVkQzrrPbSE7EK", "senderPublicKey": "GFmKZ2naZFRoCvNbwKAQVGmLb1uBeWGDgFabdGBuZiuy", "proofs": [ "4Nt4fUMPPVbTKSCFx7vztpHpHKDTW3oSFbhGjLmmH9NNzfixcDT1j1TW5iPSPe4wC18wDcjWW1xbFa4Ftzibp2eo", "J7H5jZcyv1kch4AUPF6Jgf5Jsm3v929TobJsd7Q6iwXYVBq5JvnYhtqgFra57RbcxNxe2j77HiDPkNLRR69PBeu" ], "script": null, "height": 1966578, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BwZV2GJFMC4zUXeX5uQvaGYH4yqKKRA6x9LkENbjo8Sx Next: HmxLUPaMZ4Perz1JyEbV5epXuQ6Umuy5VPiJ8e6H4oP8 Full:
OldNewDifferences
1-{-# STDLIB_VERSION 5 #-}
2-{-# SCRIPT_TYPE ACCOUNT #-}
3-{-# CONTENT_TYPE DAPP #-}
4-let adminPubKey1 = base58'GFmKZ2naZFRoCvNbwKAQVGmLb1uBeWGDgFabdGBuZiuy'
5-
6-let adminPubKey2 = base58'GmJXRyhRA79g8yUGgKBAVdnFfQFDMjQG98b1MmLDh5kk'
7-
8-let adminPubKey3 = base58'CFhbV6h41hVjbGHudGtS3fYUv7QAKRxFQzKNtx4B5PqP'
9-
10-let adminPubKeyStartStop = base58'GFmKZ2naZFRoCvNbwKAQVGmLb1uBeWGDgFabdGBuZiuy'
11-
12-let adminPubKeyWallet = base58'4FKEh3tmKwAdBv7cr6iMhVN9wDx7FiM6u62eKY3M4uBg'
13-
14-let keyActive = "active"
15-
16-let keyCause = "shutdown_cause"
17-
18-let keyLastInterest = "last_interest"
19-
20-let keyUserLastInterest = "_last_interest"
21-
22-let keyUserSWOPLocked = "_SWOP_amount"
23-
24-let keyUserGetBackHeight = "_getBackHeight"
25-
26-let keyTotalSWOPLocked = "total_SWOP_amount"
27-
28-let kUserTotalVoteSWOP = "_user_total_SWOP_vote"
29-
30-let keyUserVoteOptionAmount = "_SWOP_option_amount"
31-
32-let keyTotalVoteOptionAmount = "total_SWOP_option_amount"
33-
34-let keyUserSWOPClaimedAmount = "_SWOP_claimed_amount"
35-
36-let keyUserSWOPLastClaimedAmount = "_SWOP_last_claimed_amount"
37-
38-let keyVoteName = "vote_name"
39-
40-let keyOptionName = "_option_name"
41-
42-let keyVotingStartHeight = "_startHeight"
43-
44-let keyVoteDuration = "_vote_duration"
45-
46-let keyRewardPoolFractionCurrent = "_current_pool_fraction_reward"
47-
48-let keyRewardPoolFractionPrevious = "_previous_pool_fraction_reward"
49-
50-let keyHeightPoolFraction = "_pool_reward_update_height"
51-
52-let keyTotalRewardPerBlockCurrent = "total_reward_per_block_current"
53-
54-let keyTotalRewardPerBlockPrevious = "total_reward_per_block_previous"
55-
56-let keyRewardUpdateHeight = "reward_update_height"
57-
58-let keyRewardUpdateFirstPaginationHeight = "reward_update_height_first_pagination"
59-
60-let keyNoVotingForNewPool = "_vote_no"
61-
62-let keyYesVotingForNewPool = "_vote_yes"
63-
64-let keyAmountOfVotingForNewPool = "max_amount_voting"
65-
66-let keyStatusOfVotingForNewPool = "_status"
67-
68-let keyHeightOfPoolVotingForNewPool = "_finish_height"
69-
70-let activeVoteFirst = "voting_active_cell_1"
71-
72-let activeVoteSecond = "voting_active_cell_2"
73-
74-let activeVoteThird = "voting_active_cell_3"
75-
76-let keyTempCurSum = "sum_reward_current"
77-
78-let keyLaunchpadBoughtTickets = "_bought_tickets"
79-
80-let keyLaunchpadSwopPerTickets = "_swop_per_ticket"
81-
82-let keyLaunchpadActiveId = "launchpad_active_id"
83-
84-let keyLaunchpadDuration = "_duration"
85-
86-let keyLaunchpadStartHeight = "_start_height"
87-
88-let keyLauchpadFreezSwopDuration = "_freeze_swop_duration"
89-
90-let isActive = valueOrElse(getBoolean(this, keyActive), true)
91-
92-let farmingSWOPAddress = Address(base58'3P73HDkPqG15nLXevjCbmXtazHYTZbpPoPw')
93-
94-let votingLiteContract = Address(base58'3PQZWxShKGRgBN1qoJw6B4s9YWS9FneZTPg')
95-
96-let votingForNewPool = Address(base58'3PHgHf5C4WvHJucSHrjoVnMFsP1EhWffVLt')
97-
98-let launchpad = Address(base58'3P6YGPihPiF81VELikoV1myU55iwTvmcQaQ')
99-
100-let keySWOPid = "SWOP_id"
101-
102-let SWOP = fromBase58String(getStringValue(farmingSWOPAddress, keySWOPid))
103-
104-let scaleValue = 100000000
105-
106-let totalVoteShare = 10000000000
107-
108-let kStartHeight = "start_height"
109-
110-let kBasePeriod = "base_period"
111-
112-let kPeriodLength = "period_length"
113-
114-let kUserTotalStruc = "_user_total_struc"
115-
116-let basePeriod = valueOrErrorMessage(getInteger(votingLiteContract, kBasePeriod), "Empty kBasePeriod at voting contract")
117-
118-let startHeight = valueOrErrorMessage(getInteger(votingLiteContract, kStartHeight), "Empty kStartHeight at voting contract")
119-
120-let periodLength = valueOrErrorMessage(getInteger(votingLiteContract, kPeriodLength), "Empty kPeriodLength at voting contract")
121-
122-let firstActiveVote = valueOrElse(getString(votingForNewPool, activeVoteFirst), "")
123-
124-let secondActiveVote = valueOrElse(getString(votingForNewPool, activeVoteSecond), "")
125-
126-let thirdActiveVote = valueOrElse(getString(votingForNewPool, activeVoteThird), "")
127-
128-let currVotingPeriod = (basePeriod + ((height - startHeight) / periodLength))
129-
130-func suspend (cause) = [BooleanEntry(keyActive, false), StringEntry(keyCause, cause)]
131-
132-
133-func throwNotEnoughSWOP () = throw("Not enough SWOP: userSWOPLocked - userTotalVoteAmount < voteSWOPAmount")
134-
135-
136-func getLastInterestInfo () = {
137- let lastInterest = valueOrElse(getInteger(this, keyLastInterest), 0)
138- lastInterest
139- }
140-
141-
142-func getUserSWOPLocked (user) = valueOrElse(getInteger(this, (toString(user) + keyUserSWOPLocked)), 0)
143-
144-
145-func getUserSWOPClaimedAmount (user) = valueOrElse(getInteger(this, (toString(user) + keyUserSWOPClaimedAmount)), 0)
146-
147-
148-func getUserTotalVoteAmount (user) = valueOrElse(getInteger(votingLiteContract, (toString(user) + kUserTotalVoteSWOP)), 0)
149-
150-
151-func getUserInterestInfo (user,lastInterest) = {
152- let userSWOPAmount = getUserSWOPLocked(user)
153- let userLastInterest = getInteger(this, (toString(user) + keyUserLastInterest))
154- let userLastInterestValue = match userLastInterest {
155- case userLastInterest: Int =>
156- userLastInterest
157- case _ =>
158- lastInterest
159- }
160- $Tuple2(userLastInterestValue, userSWOPAmount)
161- }
162-
163-
164-func getUserTotalVoteAmountForOnePool (pool,user) = {
165- let voting = valueOrElse(getInteger(votingForNewPool, pool), -1)
166- let heightOfVoting = valueOrElse(getInteger(votingForNewPool, (toString(voting) + keyHeightOfPoolVotingForNewPool)), 0)
167- let statusOfVoting = valueOrElse(getBoolean(votingForNewPool, (toString(voting) + keyStatusOfVotingForNewPool)), true)
168- let currentHeight = height
169- if ((0 > voting))
170- then 0
171- else if (!(statusOfVoting))
172- then 0
173- else if ((heightOfVoting > currentHeight))
174- then (valueOrElse(getInteger(votingForNewPool, (((toString(user) + "_") + toString(voting)) + keyYesVotingForNewPool)), 0) + valueOrElse(getInteger(votingForNewPool, (((toString(user) + "_") + toString(voting)) + keyNoVotingForNewPool)), 0))
175- else 0
176- }
177-
178-
179-func getUserTotalVoteForNewPoolAmount (user) = {
180- let listOfVoting = [getUserTotalVoteAmountForOnePool(firstActiveVote, user), getUserTotalVoteAmountForOnePool(secondActiveVote, user), getUserTotalVoteAmountForOnePool(thirdActiveVote, user)]
181- max(listOfVoting)
182- }
183-
184-
185-func getUserBlockedInLauchpad (user) = {
186- let lauchpadId = toString(valueOrElse(getInteger(launchpad, keyLaunchpadActiveId), 0))
187- if ((lauchpadId == "0"))
188- then 0
189- else {
190- let lStartHeight = valueOrElse(getInteger(launchpad, (lauchpadId + keyLaunchpadStartHeight)), 0)
191- let lDuration = valueOrElse(getInteger(launchpad, (lauchpadId + keyLaunchpadDuration)), 0)
192- let lFreezeSwopDuration = valueOrElse(getInteger(launchpad, (lauchpadId + keyLauchpadFreezSwopDuration)), 0)
193- let blockEndHeight = ((lStartHeight + lDuration) + lFreezeSwopDuration)
194- if ((height > blockEndHeight))
195- then 0
196- else {
197- let boughtTickets = valueOrElse(getInteger(launchpad, (((toString(user) + "_") + lauchpadId) + keyLaunchpadBoughtTickets)), 0)
198- let swopPerTicket = valueOrElse(getInteger(launchpad, (lauchpadId + keyLaunchpadSwopPerTickets)), 0)
199- (boughtTickets * swopPerTicket)
200- }
201- }
202- }
203-
204-
205-func getTotalSWOPLocked () = valueOrElse(getInteger(this, keyTotalSWOPLocked), 0)
206-
207-
208-func getUserVoteInfo (user) = {
209- let $t072067757 = if (isDefined(getString(votingLiteContract, (toString(user) + kUserTotalStruc))))
210- then {
211- let data = split(valueOrErrorMessage(getString(votingLiteContract, (toString(user) + kUserTotalStruc)), "Empty kUserTotalStruc"), "_")
212- $Tuple3(parseIntValue(data[0]), parseIntValue(data[1]), parseIntValue(data[2]))
213- }
214- else {
215- let uPoolTotalSWOP = valueOrElse(getInteger(votingLiteContract, (toString(user) + kUserTotalVoteSWOP)), 0)
216- $Tuple3(uPoolTotalSWOP, 0, currVotingPeriod)
217- }
218- let userTotalVoteSWOP = $t072067757._1
219- let userUnvoted = $t072067757._2
220- let userUnvotedPeriod = $t072067757._3
221- let userUnvotedActual = if ((userUnvotedPeriod == currVotingPeriod))
222- then userUnvoted
223- else 0
224- $Tuple2(userTotalVoteSWOP, userUnvotedActual)
225- }
226-
227-
228-func getUserVoteOptionAmount (user) = valueOrElse(getInteger(this, (toString(user) + keyUserVoteOptionAmount)), 0)
229-
230-
231-func getVotingStartHeight (voteName) = valueOrElse(getInteger(this, (voteName + keyVotingStartHeight)), 0)
232-
233-
234-func getPoolUpdateHeight (pool) = valueOrElse(getInteger(this, (pool + keyHeightPoolFraction)), 0)
235-
236-
237-func isDefinePoolUpdateHeight (pool) = isDefined(getInteger(this, (pool + keyHeightPoolFraction)))
238-
239-
240-func getCurPoolWeight (pool) = valueOrElse(getInteger(this, (pool + keyRewardPoolFractionCurrent)), 0)
241-
242-
243-func getPrevPoolWeight (pool) = valueOrElse(getInteger(this, (pool + keyRewardPoolFractionPrevious)), 0)
244-
245-
246-func getVoteOptionAmount (user,voteName,option) = {
247- let userVoteOptionAmount = getInteger(this, (((voteName + option) + toString(user)) + keyUserVoteOptionAmount))
248- let uvoa = match userVoteOptionAmount {
249- case uvoa: Int =>
250- uvoa
251- case uvoa: Unit =>
252- 0
253- case _ =>
254- throw("Match error")
255- }
256- valueOrErrorMessage(uvoa, (((("No data on the key: " + voteName) + option) + toString(user)) + keyUserVoteOptionAmount))
257- }
258-
259-
260-func getVoteDuration (voteName) = valueOrErrorMessage(getInteger(this, (voteName + keyVoteDuration)), (("No data on the key: " + voteName) + keyVoteDuration))
261-
262-
263-func getTotalVoteOptionAmount (voteName,option) = {
264- let totalVoteOptionAmount = getInteger(this, ((voteName + option) + keyTotalVoteOptionAmount))
265- let tvoa = match totalVoteOptionAmount {
266- case tvoa: Int =>
267- tvoa
268- case tvoa: Unit =>
269- 0
270- case _ =>
271- throw("Match error")
272- }
273- tvoa
274- }
275-
276-
277-func getUserGetBackAmount (voteName,option,user,getBackSWOPHeight) = {
278- let key = ((((((voteName + "_") + option) + "_") + toString(user)) + "_") + toString(getBackSWOPHeight))
279- valueOrErrorMessage(getInteger(this, key), ("No data on the key: " + key))
280- }
281-
282-
283-func claimCalc (caller) = {
284- let lastInterest = getLastInterestInfo()
285- let $t01016110241 = getUserInterestInfo(caller, lastInterest)
286- let userLastInterest = $t01016110241._1
287- let userSWOPLocked = $t01016110241._2
288- let claimAmount = fraction(userSWOPLocked, (lastInterest - userLastInterest), scaleValue)
289- let userNewInterest = lastInterest
290- $Tuple2(userNewInterest, claimAmount)
291- }
292-
293-
294-@Callable(i)
295-func airDrop () = if (!(isActive))
296- then throw("DApp is inactive at this moment")
297- else {
298- let $t01050610581 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
299- let pmtAmount = $t01050610581._1
300- let pmtAssetId = $t01050610581._2
301- if ((pmtAssetId != SWOP))
302- then throw("Incorrect pmtAssetId")
303- else {
304- let totalSWOPLocked = getTotalSWOPLocked()
305- let lastInterest = getLastInterestInfo()
306- let interestNew = (lastInterest + fraction(pmtAmount, scaleValue, totalSWOPLocked))
307-[IntegerEntry(keyLastInterest, interestNew)]
308- }
309- }
310-
311-
312-
313-@Callable(i)
314-func lockSWOP () = if (!(isActive))
315- then throw("DApp is inactive at this moment")
316- else {
317- let $t01101911094 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
318- let pmtAmount = $t01101911094._1
319- let pmtAssetId = $t01101911094._2
320- if ((pmtAssetId != SWOP))
321- then throw("Incorrect pmtAssetId")
322- else {
323- let lastInterest = getLastInterestInfo()
324- let $t01121011292 = getUserInterestInfo(i.caller, lastInterest)
325- let userLastInterest = $t01121011292._1
326- let userSWOPLocked = $t01121011292._2
327- let claimAmount = fraction(userSWOPLocked, (lastInterest - userLastInterest), scaleValue)
328- let userSWOPLockedNew = ((userSWOPLocked + pmtAmount) + claimAmount)
329- let userNewInterest = lastInterest
330- let totalSWOPLocked = getTotalSWOPLocked()
331- let totalSWOPLockedNew = ((totalSWOPLocked + pmtAmount) + claimAmount)
332- let userClaimedAmount = getUserSWOPClaimedAmount(i.caller)
333- let userClaimedAmountNew = (userClaimedAmount + claimAmount)
334-[IntegerEntry((toString(i.caller) + keyUserLastInterest), userNewInterest), IntegerEntry((toString(i.caller) + keyUserSWOPLocked), userSWOPLockedNew), IntegerEntry(keyTotalSWOPLocked, totalSWOPLockedNew), IntegerEntry((toString(i.caller) + keyUserSWOPClaimedAmount), userClaimedAmountNew), IntegerEntry((toString(i.caller) + keyUserSWOPLastClaimedAmount), claimAmount)]
335- }
336- }
337-
338-
339-
340-@Callable(i)
341-func withdrawSWOP (withdrawAmount) = if (!(isActive))
342- then throw("DApp is inactive at this moment")
343- else if ((0 >= withdrawAmount))
344- then throw("withdrawAmount <= 0")
345- else {
346- let totalSWOPLocked = getTotalSWOPLocked()
347- let userSWOPLocked = getUserSWOPLocked(i.caller)
348- let $t01244212497 = claimCalc(i.caller)
349- let userNewInterest = $t01244212497._1
350- let claimAmount = $t01244212497._2
351- let $t01250212567 = getUserVoteInfo(i.caller)
352- let userVoteAmount = $t01250212567._1
353- let userUnvoteAmount = $t01250212567._2
354- let userVoteAmountForNewPool = getUserTotalVoteForNewPoolAmount(i.caller)
355- let blockedInLaunchpad = getUserBlockedInLauchpad(i.caller)
356- if (if (if ((0 > userUnvoteAmount))
357- then true
358- else (0 > userVoteAmount))
359- then true
360- else (0 > userVoteAmountForNewPool))
361- then throw("userUnvoteAmount < 0 || userVoteAmount < 0 || userVoteAmountForNewPool < 0")
362- else {
363- let availableToUnstake = (userSWOPLocked - max([userVoteAmountForNewPool, (userVoteAmount + userUnvoteAmount), blockedInLaunchpad]))
364- if ((withdrawAmount > availableToUnstake))
365- then throw("withdrawAmount > availableToUnstake")
366- else {
367- let totalSWOPLockedNew = ((totalSWOPLocked + claimAmount) - withdrawAmount)
368- let userSWOPamountNew = ((userSWOPLocked + claimAmount) - withdrawAmount)
369- let userClaimedAmount = getUserSWOPClaimedAmount(i.caller)
370- let userClaimedAmountNew = (userClaimedAmount + claimAmount)
371-[IntegerEntry((toString(i.caller) + keyUserLastInterest), userNewInterest), IntegerEntry((toString(i.caller) + keyUserSWOPLocked), userSWOPamountNew), IntegerEntry(keyTotalSWOPLocked, totalSWOPLockedNew), ScriptTransfer(i.caller, withdrawAmount, SWOP), IntegerEntry((toString(i.caller) + keyUserSWOPClaimedAmount), userClaimedAmountNew), IntegerEntry((toString(i.caller) + keyUserSWOPLastClaimedAmount), claimAmount)]
372- }
373- }
374- }
375-
376-
377-
378-@Callable(i)
379-func claimAndWithdrawSWOP () = if (!(isActive))
380- then throw("DApp is inactive at this moment")
381- else {
382- let lastInterest = getLastInterestInfo()
383- let $t01402614081 = claimCalc(i.caller)
384- let userNewInterest = $t01402614081._1
385- let claimAmount = $t01402614081._2
386- let userClaimedAmount = getUserSWOPClaimedAmount(i.caller)
387- let userClaimedAmountNew = (userClaimedAmount + claimAmount)
388- if ((claimAmount == 0))
389- then throw("You have 0 available SWOP")
390- else [IntegerEntry((toString(i.caller) + keyUserLastInterest), userNewInterest), IntegerEntry((toString(i.caller) + keyUserSWOPClaimedAmount), userClaimedAmountNew), IntegerEntry((toString(i.caller) + keyUserSWOPLastClaimedAmount), claimAmount), ScriptTransfer(i.caller, claimAmount, SWOP)]
391- }
392-
393-
394-
395-@Callable(i)
396-func claimAndStakeSWOP () = if (!(isActive))
397- then throw("DApp is inactive at this moment")
398- else {
399- let totalSWOPLocked = getTotalSWOPLocked()
400- let userSWOPLocked = getUserSWOPLocked(i.caller)
401- let lastInterest = getLastInterestInfo()
402- let $t01486014915 = claimCalc(i.caller)
403- let userNewInterest = $t01486014915._1
404- let claimAmount = $t01486014915._2
405- let userSWOPLockedNew = (userSWOPLocked + claimAmount)
406- let totalSWOPLockedNew = (totalSWOPLocked + claimAmount)
407- let userClaimedAmount = getUserSWOPClaimedAmount(i.caller)
408- let userClaimedAmountNew = (userClaimedAmount + claimAmount)
409- if ((claimAmount == 0))
410- then throw("You have 0 available SWOP")
411- else [IntegerEntry((toString(i.caller) + keyUserLastInterest), userNewInterest), IntegerEntry(keyTotalSWOPLocked, totalSWOPLockedNew), IntegerEntry((toString(i.caller) + keyUserSWOPLocked), userSWOPLockedNew), IntegerEntry((toString(i.caller) + keyUserSWOPClaimedAmount), userClaimedAmountNew), IntegerEntry((toString(i.caller) + keyUserSWOPLastClaimedAmount), claimAmount)]
412- }
413-
414-
415-
416-@Callable(i)
417-func updateWeights (currentPools,currentRewards,rewardUpdateHeight,pagination) = if (!(isActive))
418- then throw("DApp is inactive at this moment")
419- else {
420- let amountPools = 10
421- let totalRewardUpdateHeight = valueOrElse(getInteger(this, keyRewardUpdateHeight), 0)
422- if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3, adminPubKeyStartStop, adminPubKeyWallet], i.callerPublicKey)))
423- then throw("Only admin can call this function")
424- else if ((size(currentPools) > amountPools))
425- then throw(("Max amount of pool is " + toString(amountPools)))
426- else if ((totalRewardUpdateHeight >= rewardUpdateHeight))
427- then throw("rewardUpdateHeight <= totalRewardUpdateHeight")
428- else if ((height >= rewardUpdateHeight))
429- then throw("height >= rewardUpdateHeight")
430- else if ((0 >= rewardUpdateHeight))
431- then throw("0 >= rewardUpdateHeight ")
432- else {
433- func sum (a,b) = (a + b)
434-
435- func changePreviousRewardEntry (accumulated,pool) = {
436- let poolRewardUpdateHeight = getPoolUpdateHeight(pool)
437- if (if (!(isDefinePoolUpdateHeight(pool)))
438- then true
439- else if ((rewardUpdateHeight != poolRewardUpdateHeight))
440- then (poolRewardUpdateHeight == totalRewardUpdateHeight)
441- else false)
442- then {
443- let poolReward = getCurPoolWeight(pool)
444-IntegerEntry((pool + keyRewardPoolFractionPrevious), poolReward) :: accumulated
445- }
446- else {
447- let poolReward = getPrevPoolWeight(pool)
448-IntegerEntry((pool + keyRewardPoolFractionPrevious), poolReward) :: accumulated
449- }
450- }
451-
452- func changeCurrentRewardEntry (accumulated,pool) = {
453- let poolIndex = value(indexOf(currentPools, pool))
454- let poolReward = currentRewards[poolIndex]
455- if ((0 > poolReward))
456- then throw("PoolReward < 0")
457- else IntegerEntry((pool + keyRewardPoolFractionCurrent), poolReward) :: accumulated
458- }
459-
460- func changeHeightEntry (accumulated,pool) = {
461- let poolHeight = rewardUpdateHeight
462-IntegerEntry((pool + keyHeightPoolFraction), poolHeight) :: accumulated
463- }
464-
465- func getSumReward (curTempSum,pagination) = if ((pagination == 0))
466- then if ((curTempSum > totalVoteShare))
467- then throw(((("sumRewardPrevious > totalVoteShare or sumRewardCurrent > totalVoteShare - " + toString(pagination)) + " ") + toString(curTempSum)))
468- else $Tuple2([IntegerEntry(keyTempCurSum, curTempSum)], [IntegerEntry(keyRewardUpdateFirstPaginationHeight, rewardUpdateHeight)])
469- else if ((pagination == 1))
470- then {
471- let curTempSumFromKey = valueOrElse(getInteger(this, keyTempCurSum), 0)
472- let rewardUpdateHeightFirstPaginationEntry = valueOrElse(getInteger(this, keyRewardUpdateFirstPaginationHeight), 0)
473- if (((curTempSum + curTempSumFromKey) > totalVoteShare))
474- then throw(((("sumRewardPrevious > totalVoteShare or sumRewardCurrent > totalVoteShare - " + toString(pagination)) + " ") + toString((curTempSum + curTempSumFromKey))))
475- else if ((rewardUpdateHeightFirstPaginationEntry != rewardUpdateHeight))
476- then throw("current rewardUpdateHeight != rewardUpdateHeightFirstPaginationEntry")
477- else $Tuple2([IntegerEntry(keyTempCurSum, (curTempSum + curTempSumFromKey))], nil)
478- }
479- else if ((pagination == 2))
480- then {
481- let curSum = (valueOrElse(getInteger(this, keyTempCurSum), 0) + curTempSum)
482- let rewardUpdateHeightFirstPaginationEntry = valueOrElse(getInteger(this, keyRewardUpdateFirstPaginationHeight), 0)
483- if ((curSum != totalVoteShare))
484- then throw("sumRewardPrevious != totalVoteShare or sumRewardCurrent != totalVoteShare")
485- else if ((rewardUpdateHeightFirstPaginationEntry != rewardUpdateHeight))
486- then throw("current rewardUpdateHeight != rewardUpdateHeightFirstPaginationEntry")
487- else $Tuple2([IntegerEntry(keyTempCurSum, curSum)], nil)
488- }
489- else throw("Incorrect pagination")
490-
491- let previousRewardEntryNew = {
492- let $l = currentPools
493- let $s = size($l)
494- let $acc0 = nil
495- func $f0_1 ($a,$i) = if (($i >= $s))
496- then $a
497- else changePreviousRewardEntry($a, $l[$i])
498-
499- func $f0_2 ($a,$i) = if (($i >= $s))
500- then $a
501- else throw("List size exceeds 10")
502-
503- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10)
504- }
505- let currentRewardEntryNew = {
506- let $l = currentPools
507- let $s = size($l)
508- let $acc0 = nil
509- func $f1_1 ($a,$i) = if (($i >= $s))
510- then $a
511- else changeCurrentRewardEntry($a, $l[$i])
512-
513- func $f1_2 ($a,$i) = if (($i >= $s))
514- then $a
515- else throw("List size exceeds 10")
516-
517- $f1_2($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10)
518- }
519- let heightEntryNewCur = {
520- let $l = currentPools
521- let $s = size($l)
522- let $acc0 = nil
523- func $f2_1 ($a,$i) = if (($i >= $s))
524- then $a
525- else changeHeightEntry($a, $l[$i])
526-
527- func $f2_2 ($a,$i) = if (($i >= $s))
528- then $a
529- else throw("List size exceeds 10")
530-
531- $f2_2($f2_1($f2_1($f2_1($f2_1($f2_1($f2_1($f2_1($f2_1($f2_1($f2_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10)
532- }
533- let sumRewardCurrentTemp = {
534- let $l = currentRewards
535- let $s = size($l)
536- let $acc0 = 0
537- func $f3_1 ($a,$i) = if (($i >= $s))
538- then $a
539- else sum($a, $l[$i])
540-
541- func $f3_2 ($a,$i) = if (($i >= $s))
542- then $a
543- else throw("List size exceeds 10")
544-
545- $f3_2($f3_1($f3_1($f3_1($f3_1($f3_1($f3_1($f3_1($f3_1($f3_1($f3_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10)
546- }
547- let $t02005920170 = getSumReward(sumRewardCurrentTemp, pagination)
548- let sumRewardCurrent = $t02005920170._1
549- let rewardUpdateHeightFirstPaginationEntry = $t02005920170._2
550- let rewardUpdateHeightEntry = if ((pagination == 2))
551- then [IntegerEntry(keyRewardUpdateHeight, rewardUpdateHeight)]
552- else nil
553- if ((height > rewardUpdateHeight))
554- then throw("rewardUpdateHeight < height")
555- else (((((previousRewardEntryNew ++ currentRewardEntryNew) ++ heightEntryNewCur) ++ sumRewardCurrent) ++ rewardUpdateHeightEntry) ++ rewardUpdateHeightFirstPaginationEntry)
556- }
557- }
558-
559-
560-
561-@Callable(i)
562-func shutdown () = if (!(isActive))
563- then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, keyCause), "the cause wasn't specified")))
564- else if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3, adminPubKeyStartStop], i.callerPublicKey)))
565- then throw("Only admin can call this function")
566- else suspend("Paused by admin")
567-
568-
569-
570-@Callable(i)
571-func activate () = if (isActive)
572- then throw("DApp is already active")
573- else if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3, adminPubKeyStartStop], i.callerPublicKey)))
574- then throw("Only admin can call this function")
575- else [BooleanEntry(keyActive, true), DeleteEntry(keyCause)]
576-
577-
578-@Verifier(tx)
579-func verify () = {
580- let adminPubKey1Signed = if (sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey1))
581- then 1
582- else 0
583- let adminPubKey2Signed = if (sigVerify(tx.bodyBytes, tx.proofs[1], adminPubKey2))
584- then 1
585- else 0
586- let adminPubKey3Signed = if (sigVerify(tx.bodyBytes, tx.proofs[2], adminPubKey3))
587- then 1
588- else 0
589- (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 2)
590- }
591-
1+# no script

github/deemru/w8io/026f985 
50.11 ms