tx · 5jVmg9gjwD56TZWphz3JpybMSqkPNumAxJiJb55KRijQ

3MzdAxtzyAedqJGUXgrA4TwuJy6mjzTC4xi:  -0.02500000 Waves

2023.01.23 18:57 [2417810] smart account 3MzdAxtzyAedqJGUXgrA4TwuJy6mjzTC4xi > SELF 0.00000000 Waves

{ "type": 13, "id": "5jVmg9gjwD56TZWphz3JpybMSqkPNumAxJiJb55KRijQ", "fee": 2500000, "feeAssetId": null, "timestamp": 1674489459649, "version": 2, "chainId": 84, "sender": "3MzdAxtzyAedqJGUXgrA4TwuJy6mjzTC4xi", "senderPublicKey": "3DC8m2oHTKBkLVzMrSBroidcvNHES2E8d6pCmJR3nJnD", "proofs": [ "4u8sFqPmaBy79EdAvzpCRS3QDXFwxQvkJQkX8aNVzgX3k7zSMZjPuyTpg8MXJu5yueDqGjqJ4UwZ7ED48fQe4ZkV", "3axZ5BNwGg1Ms5SpGqqTbZdjqYzfNiZKqzfzwwskoD7TEAWiJoBZDo7seozAJUewt9WcDAFnzQdicDNLV8RmDHwe" ], "script": "base64:AwQAAAAHJG1hdGNoMAUAAAACdHgGB2nb5Q==", "height": 2417810, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9ixiVvhpyps9QReykretGtFNhjBH15M3xBwb8L6zr14d Next: BCoLZa2CQ1vhxxH2QSYjKqSFbumApW45z1mG3zgNJEZ5 Full:
OldNewDifferences
1-{-# STDLIB_VERSION 6 #-}
2-{-# SCRIPT_TYPE ACCOUNT #-}
3-{-# CONTENT_TYPE DAPP #-}
4-let kActive = "active"
5-
6-let kActiveGlob = "active_all_contracts"
7-
8-let kCause = "shutdown_cause"
9-
10-let kLastInterest = "last_interest"
11-
12-let kUserLastInterest = "_last_interest"
13-
14-let kUserSWOPLocked = "_SWOP_amount"
15-
16-let kTotalSWOPLocked = "total_SWOP_amount"
17-
18-let kUserSwopUnlockHeight = "_SWOP_unlock_height"
19-
20-let kUserGSwopLocked = "_GSwop_amount"
21-
22-let kTotalGSwopLocked = "total_GSwop_amount"
23-
24-let kUserTotalVoteSWOP = "_user_total_vote_gSWOP"
25-
26-let kUserAvailableForClaim = "_user_available_for_claim"
27-
28-let kRewardPoolFractionCurrent = "_current_pool_fraction_reward"
29-
30-let kRewardPoolFractionPrevious = "_previous_pool_fraction_reward"
31-
32-let kHeightPoolFraction = "_pool_reward_update_height"
33-
34-let kRewardUpdateHeight = "reward_update_height"
35-
36-let kRewardUpdateFirstPaginationHeight = "reward_update_height_first_pagination"
37-
38-let kNoVotingForNewPool = "_vote_no"
39-
40-let kYesVotingForNewPool = "_vote_yes"
41-
42-let kStatusOfVotingForNewPool = "_status"
43-
44-let kHeightOfPoolVotingForNewPool = "_finish_height"
45-
46-let activeVoteFirst = "voting_active_cell_1"
47-
48-let activeVoteSecond = "voting_active_cell_2"
49-
50-let activeVoteThird = "voting_active_cell_3"
51-
52-let kTempCurSum = "sum_reward_current"
53-
54-let kLaunchpadBoughtTickets = "_bought_tickets"
55-
56-let kLaunchpadSwopPerTickets = "_swop_per_ticket"
57-
58-let kLaunchpadActiveId = "launchpad_active_id"
59-
60-let kLaunchpadDuration = "_duration"
61-
62-let kLaunchpadStartHeight = "_start_height"
63-
64-let kStartHeight = "start_height"
65-
66-let kBasePeriod = "base_period"
67-
68-let kPeriodLength = "period_length"
69-
70-let kUserTotalStruc = "_user_total_struc"
71-
72-let kLauchpadFreezSwopDuration = "_freeze_swop_duration"
73-
74-let kSWOPid = "SWOP_id"
75-
76-let kAirdropFee = "airdrop_fee"
77-
78-let kAdminPubKey1 = "admin_pub_1"
79-
80-let kAdminPubKey2 = "admin_pub_2"
81-
82-let kAdminPubKey3 = "admin_pub_3"
83-
84-let kMoneyBoxPubKey = "money_box_pub_key"
85-
86-let kFarmingAddr = "farming_address"
87-
88-let kVotingAddr = "voting_address"
89-
90-let kVotingNewPoolAddr = "voting_new_pool_address"
91-
92-let kLaunchpadAddr = "launchpad_address"
93-
94-let kAirdropMoneyBoxAddr = "airdrop_fee_money_box"
95-
96-let kOraclePool = "pool_"
97-
98-let oracle = Address(base58'3MvVBtsXroQpy1tsPw21TU2ET9A8WfmrNjz')
99-
100-func getBase58FromOracle (key) = match getString(oracle, key) {
101- case string: String =>
102- fromBase58String(string)
103- case nothing =>
104- throw((key + "is empty"))
1+{-# STDLIB_VERSION 3 #-}
2+{-# CONTENT_TYPE EXPRESSION #-}
3+match tx {
4+ case _ =>
5+ true
1056 }
106-
107-
108-let adminPubKey1 = getBase58FromOracle(kAdminPubKey1)
109-
110-let adminPubKey2 = getBase58FromOracle(kAdminPubKey2)
111-
112-let adminPubKey3 = getBase58FromOracle(kAdminPubKey3)
113-
114-let moneyBoxPubKey = getBase58FromOracle(kMoneyBoxPubKey)
115-
116-let farmingAddr = Address(getBase58FromOracle(kFarmingAddr))
117-
118-let votingAddr = Address(getBase58FromOracle(kVotingAddr))
119-
120-let votingNewPoolAddr = Address(getBase58FromOracle(kVotingNewPoolAddr))
121-
122-let launchpadAddr = Address(getBase58FromOracle(kLaunchpadAddr))
123-
124-let airdropMoneyBoxAddr = Address(getBase58FromOracle(kAirdropMoneyBoxAddr))
125-
126-let lockSwopBlocksAmount = (10102 * 4)
127-
128-let SWOP = fromBase58String(getStringValue(farmingAddr, kSWOPid))
129-
130-let scaleValue = 100000000
131-
132-let totalVoteShare = 10000000000
133-
134-let feeSacle6 = 1000000
135-
136-let basePeriod = valueOrErrorMessage(getInteger(votingAddr, kBasePeriod), "Empty kBasePeriod at voting contract")
137-
138-let startHeight = valueOrErrorMessage(getInteger(votingAddr, kStartHeight), "Empty kStartHeight at voting contract")
139-
140-let periodLength = valueOrErrorMessage(getInteger(votingAddr, kPeriodLength), "Empty kPeriodLength at voting contract")
141-
142-let firstActiveVote = valueOrElse(getString(votingNewPoolAddr, activeVoteFirst), "")
143-
144-let secondActiveVote = valueOrElse(getString(votingNewPoolAddr, activeVoteSecond), "")
145-
146-let thirdActiveVote = valueOrElse(getString(votingNewPoolAddr, activeVoteThird), "")
147-
148-let active = valueOrElse(getBoolean(this, kActive), true)
149-
150-let activeGlob = valueOrElse(getBoolean(oracle, kActiveGlob), true)
151-
152-let airdropFee = getIntegerValue(oracle, kAirdropFee)
153-
154-let currVotingPeriod = (basePeriod + ((height - startHeight) / periodLength))
155-
156-func suspend (cause) = [BooleanEntry(kActive, false), StringEntry(kCause, cause)]
157-
158-
159-func isActive () = if (if (active)
160- then activeGlob
161- else false)
162- then unit
163- else throw("DApp is inactive at this moment")
164-
165-
166-func isAdminCall (i) = if (containsElement([adminPubKey1, adminPubKey2, adminPubKey3], i.callerPublicKey))
167- then unit
168- else throw("Only admin can call this function")
169-
170-
171-func getLastInterestInfo () = valueOrElse(getInteger(this, kLastInterest), 0)
172-
173-
174-func getTotalLockedInfo () = {
175- let totalSwopLocked = valueOrElse(getInteger(this, kTotalSWOPLocked), 0)
176- let totalGSwopLocked = valueOrElse(getInteger(this, kTotalGSwopLocked), totalSwopLocked)
177- $Tuple2(totalSwopLocked, totalGSwopLocked)
178- }
179-
180-
181-func getUserLockedInfo (user) = {
182- let userSwopLocked = valueOrElse(getInteger(this, (user + kUserSWOPLocked)), 0)
183- let userGSwopLocked = valueOrElse(getInteger(this, (user + kUserGSwopLocked)), userSwopLocked)
184- $Tuple2(userSwopLocked, userGSwopLocked)
185- }
186-
187-
188-func getUserInterestInfo (user,lastInterest) = {
189- let $t050365099 = getUserLockedInfo(user)
190- let userSWOPAmount = $t050365099._1
191- let userGSwopAmount = $t050365099._2
192- let userLastInterest = valueOrElse(getInteger(this, (user + kUserLastInterest)), lastInterest)
193- $Tuple3(userLastInterest, userSWOPAmount, userGSwopAmount)
194- }
195-
196-
197-func getUserAvailableForClaim (user) = valueOrElse(getInteger(this, (user + kUserAvailableForClaim)), 0)
198-
199-
200-func getUserTotalVoteAmountForOnePool (pool,user) = {
201- let voting = valueOrElse(getInteger(votingNewPoolAddr, pool), -1)
202- let heightOfVoting = valueOrElse(getInteger(votingNewPoolAddr, (toString(voting) + kHeightOfPoolVotingForNewPool)), 0)
203- let statusOfVoting = valueOrElse(getBoolean(votingNewPoolAddr, (toString(voting) + kStatusOfVotingForNewPool)), true)
204- let currentHeight = height
205- if ((0 > voting))
206- then 0
207- else if (!(statusOfVoting))
208- then 0
209- else if ((heightOfVoting > currentHeight))
210- then (valueOrElse(getInteger(votingNewPoolAddr, (((toString(user) + "_") + toString(voting)) + kYesVotingForNewPool)), 0) + valueOrElse(getInteger(votingNewPoolAddr, (((toString(user) + "_") + toString(voting)) + kNoVotingForNewPool)), 0))
211- else 0
212- }
213-
214-
215-func getUserTotalVoteForNewPoolAmount (user) = {
216- let listOfVoting = [getUserTotalVoteAmountForOnePool(firstActiveVote, user), getUserTotalVoteAmountForOnePool(secondActiveVote, user), getUserTotalVoteAmountForOnePool(thirdActiveVote, user)]
217- max(listOfVoting)
218- }
219-
220-
221-func getUserBlockedInLauchpad (user) = {
222- let lauchpadId = toString(valueOrElse(getInteger(launchpadAddr, kLaunchpadActiveId), 0))
223- if ((lauchpadId == "0"))
224- then 0
225- else {
226- let lStartHeight = valueOrElse(getInteger(launchpadAddr, (lauchpadId + kLaunchpadStartHeight)), 0)
227- let lDuration = valueOrElse(getInteger(launchpadAddr, (lauchpadId + kLaunchpadDuration)), 0)
228- let lFreezeSwopDuration = valueOrElse(getInteger(launchpadAddr, (lauchpadId + kLauchpadFreezSwopDuration)), 0)
229- let blockEndHeight = ((lStartHeight + lDuration) + lFreezeSwopDuration)
230- if ((height > blockEndHeight))
231- then 0
232- else {
233- let boughtTickets = valueOrElse(getInteger(launchpadAddr, (((toString(user) + "_") + lauchpadId) + kLaunchpadBoughtTickets)), 0)
234- let swopPerTicket = valueOrElse(getInteger(launchpadAddr, (lauchpadId + kLaunchpadSwopPerTickets)), 0)
235- (boughtTickets * swopPerTicket)
236- }
237- }
238- }
239-
240-
241-func getUserTotalVote (user) = if (isDefined(getString(votingAddr, (toString(user) + kUserTotalStruc))))
242- then parseIntValue(split(valueOrErrorMessage(getString(votingAddr, (toString(user) + kUserTotalStruc)), "Empty kUserTotalStruc"), "_")[0])
243- else valueOrElse(getInteger(votingAddr, (toString(user) + kUserTotalVoteSWOP)), 0)
244-
245-
246-func getPoolUpdateHeight (pool) = valueOrElse(getInteger(this, (pool + kHeightPoolFraction)), 0)
247-
248-
249-func isDefinePoolUpdateHeight (pool) = isDefined(getInteger(this, (pool + kHeightPoolFraction)))
250-
251-
252-func getCurPoolWeight (pool) = valueOrElse(getInteger(this, (pool + kRewardPoolFractionCurrent)), 0)
253-
254-
255-func getPrevPoolWeight (pool) = valueOrElse(getInteger(this, (pool + kRewardPoolFractionPrevious)), 0)
256-
257-
258-func claimCalc (user) = {
259- let lastInterest = getLastInterestInfo()
260- let $t085248621 = getUserInterestInfo(user, lastInterest)
261- let userLastInterest = $t085248621._1
262- let userSWOPLocked = $t085248621._2
263- let userGSwopAmount = $t085248621._3
264- let claimAmount = fraction(userGSwopAmount, (lastInterest - userLastInterest), scaleValue)
265- let userNewInterest = lastInterest
266- $Tuple2(userNewInterest, claimAmount)
267- }
268-
269-
270-func isOraclePool (poolAddress) = if (isDefined(getString(oracle, (kOraclePool + poolAddress))))
271- then unit
272- else throw("DApp is not registered pool")
273-
274-
275-@Callable(i)
276-func addPool (poolAddress) = valueOrElse(isAdminCall(i), valueOrElse(isActive(), valueOrElse(isOraclePool(poolAddress), if (isDefined(getInteger(this, (poolAddress + kRewardPoolFractionCurrent))))
277- then throw("Pool already in governance")
278- else [IntegerEntry((poolAddress + kRewardPoolFractionCurrent), 0), IntegerEntry((poolAddress + kRewardPoolFractionPrevious), 0), IntegerEntry((poolAddress + kHeightPoolFraction), getIntegerValue(this, kRewardUpdateHeight))])))
279-
280-
281-
282-@Callable(i)
283-func airDrop () = valueOrElse(isActive(), {
284- let $t095209595 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
285- let pmtAmount = $t095209595._1
286- let pmtAssetId = $t095209595._2
287- if ((pmtAssetId != SWOP))
288- then throw("Incorrect pmtAssetId")
289- else {
290- let airdropFeeAmount = fraction(pmtAmount, airdropFee, feeSacle6, CEILING)
291- let $t097689830 = getTotalLockedInfo()
292- let totalSWOPLocked = $t097689830._1
293- let totalGSwopLocked = $t097689830._2
294- let lastInterest = getLastInterestInfo()
295- let interestNew = (lastInterest + fraction((pmtAmount - airdropFeeAmount), scaleValue, totalGSwopLocked))
296-[IntegerEntry(kLastInterest, interestNew), ScriptTransfer(airdropMoneyBoxAddr, airdropFeeAmount, SWOP)]
297- }
298- })
299-
300-
301-
302-@Callable(i)
303-func lockSWOP () = valueOrElse(isActive(), {
304- let $t01020810283 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
305- let pmtAmount = $t01020810283._1
306- let pmtAssetId = $t01020810283._2
307- if ((pmtAssetId != SWOP))
308- then throw("Incorrect pmtAssetId")
309- else {
310- let user = toString(i.caller)
311- let lastInterest = getLastInterestInfo()
312- let $t01043410497 = getUserLockedInfo(user)
313- let userSWOPLocked = $t01043410497._1
314- let userGSwopLocked = $t01043410497._2
315- let $t01050210563 = claimCalc(user)
316- let userNewInterest = $t01050210563._1
317- let claimAmountAvailable = $t01050210563._2
318- let availableForClaim = getUserAvailableForClaim(user)
319- let availableForClaimNew = (availableForClaim + claimAmountAvailable)
320- let userSWOPLockedNew = (userSWOPLocked + pmtAmount)
321- let userGSwopLockedNew = (userGSwopLocked + pmtAmount)
322- let $t01081110873 = getTotalLockedInfo()
323- let totalSWOPLocked = $t01081110873._1
324- let totalGSwopLocked = $t01081110873._2
325- let totalSWOPLockedNew = (totalSWOPLocked + pmtAmount)
326- let totalGSwopLockedNew = (totalGSwopLocked + pmtAmount)
327-[IntegerEntry((user + kUserSwopUnlockHeight), (height + lockSwopBlocksAmount)), IntegerEntry((user + kUserLastInterest), userNewInterest), IntegerEntry((user + kUserSWOPLocked), userSWOPLockedNew), IntegerEntry((user + kUserGSwopLocked), userGSwopLockedNew), IntegerEntry((user + kUserAvailableForClaim), availableForClaimNew), IntegerEntry(kTotalSWOPLocked, totalSWOPLockedNew), IntegerEntry(kTotalGSwopLocked, totalGSwopLockedNew)]
328- }
329- })
330-
331-
332-
333-@Callable(i)
334-func withdrawSWOP (withdrawAmount) = valueOrElse(isActive(), {
335- let user = toString(i.caller)
336- let unlockHeight = valueOrElse(getInteger(this, (user + kUserSwopUnlockHeight)), 0)
337- if ((0 >= withdrawAmount))
338- then throw("withdrawAmount <= 0")
339- else if ((unlockHeight > height))
340- then throw(("You can't withdraw till " + toString(unlockHeight)))
341- else {
342- let $t01185111913 = getTotalLockedInfo()
343- let totalSWOPLocked = $t01185111913._1
344- let totalGSwopLocked = $t01185111913._2
345- let $t01191811981 = getUserLockedInfo(user)
346- let userSWOPLocked = $t01191811981._1
347- let userGSwopLocked = $t01191811981._2
348- let $t01198612047 = claimCalc(user)
349- let userNewInterest = $t01198612047._1
350- let claimAmountAvailable = $t01198612047._2
351- let userTotalVoteAmount = getUserTotalVote(i.caller)
352- let userVoteAmountForNewPool = getUserTotalVoteForNewPoolAmount(i.caller)
353- let blockedInLaunchpad = getUserBlockedInLauchpad(i.caller)
354- if (if ((0 > userTotalVoteAmount))
355- then true
356- else (0 > userVoteAmountForNewPool))
357- then throw("userVoteAmount < 0 || userVoteAmountForNewPool < 0")
358- else {
359- let availableToUnstake = (userSWOPLocked - max([userVoteAmountForNewPool, userTotalVoteAmount, blockedInLaunchpad]))
360- if ((withdrawAmount > availableToUnstake))
361- then throw("withdrawAmount > availableToUnstake")
362- else {
363- let availableForClaim = getUserAvailableForClaim(user)
364- let availableForClaimNew = (availableForClaim + claimAmountAvailable)
365- let totalSWOPLockedNew = (totalSWOPLocked - withdrawAmount)
366- let userSWOPAmountNew = (userSWOPLocked - withdrawAmount)
367- let totalGSwopLockedNew = ((totalGSwopLocked - userGSwopLocked) + userSWOPAmountNew)
368-[IntegerEntry((user + kUserLastInterest), userNewInterest), IntegerEntry((user + kUserSWOPLocked), userSWOPAmountNew), IntegerEntry((user + kUserGSwopLocked), userSWOPAmountNew), IntegerEntry((user + kUserAvailableForClaim), availableForClaimNew), IntegerEntry(kTotalSWOPLocked, totalSWOPLockedNew), IntegerEntry(kTotalGSwopLocked, totalGSwopLockedNew), ScriptTransfer(i.caller, withdrawAmount, SWOP)]
369- }
370- }
371- }
372- })
373-
374-
375-
376-@Callable(i)
377-func claimAndWithdrawSWOP () = valueOrElse(isActive(), {
378- let user = toString(i.caller)
379- let availableForClaim = getUserAvailableForClaim(user)
380- let $t01356613618 = claimCalc(user)
381- let userNewInterest = $t01356613618._1
382- let claimAmount = $t01356613618._2
383- let userClaimAmount = (availableForClaim + claimAmount)
384- if ((userClaimAmount == 0))
385- then throw("You have 0 available SWOP")
386- else [IntegerEntry((user + kUserLastInterest), userNewInterest), IntegerEntry((user + kUserAvailableForClaim), 0), ScriptTransfer(i.caller, userClaimAmount, SWOP)]
387- })
388-
389-
390-
391-@Callable(i)
392-func claimAndStakeSWOP () = valueOrElse(isActive(), {
393- let user = toString(i.caller)
394- let $t01404814110 = getTotalLockedInfo()
395- let totalSWOPLocked = $t01404814110._1
396- let totalGSwopLocked = $t01404814110._2
397- let $t01411514178 = getUserLockedInfo(user)
398- let userSWOPLocked = $t01411514178._1
399- let userGSwopLocked = $t01411514178._2
400- let availableForClaim = getUserAvailableForClaim(user)
401- let $t01424214293 = claimCalc(user)
402- let userNewInterest = $t01424214293._1
403- let claimAmount = $t01424214293._2
404- let userClaimAmount = (availableForClaim + claimAmount)
405- let userSWOPLockedNew = (userSWOPLocked + userClaimAmount)
406- let userGSwopLockedNew = (userGSwopLocked + (userClaimAmount * 2))
407- let totalSWOPLockedNew = (totalSWOPLocked + userClaimAmount)
408- let totalGSwopLockedNew = (totalGSwopLocked + (userClaimAmount * 2))
409- if ((userClaimAmount == 0))
410- then throw("You have 0 available SWOP")
411- else [IntegerEntry((user + kUserSwopUnlockHeight), (height + lockSwopBlocksAmount)), IntegerEntry((user + kUserLastInterest), userNewInterest), IntegerEntry(kTotalSWOPLocked, totalSWOPLockedNew), IntegerEntry(kTotalGSwopLocked, totalGSwopLockedNew), IntegerEntry((user + kUserSWOPLocked), userSWOPLockedNew), IntegerEntry((user + kUserGSwopLocked), userGSwopLockedNew), IntegerEntry((user + kUserAvailableForClaim), 0)]
412- })
413-
414-
415-
416-@Callable(i)
417-func lockSWOPFromFarming () = valueOrElse(isActive(), {
418- let $t01522915304 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
419- let pmtAmount = $t01522915304._1
420- let pmtAssetId = $t01522915304._2
421- if ((i.caller != farmingAddr))
422- then throw("Only farming can call this function")
423- else if ((pmtAssetId != SWOP))
424- then throw("Incorrect pmtAssetId")
425- else {
426- let user = toString(i.originCaller)
427- let lastInterest = getLastInterestInfo()
428- let $t01554715610 = getUserLockedInfo(user)
429- let userSWOPLocked = $t01554715610._1
430- let userGSwopLocked = $t01554715610._2
431- let $t01561515676 = claimCalc(user)
432- let userNewInterest = $t01561515676._1
433- let claimAmountAvailable = $t01561515676._2
434- let availableForClaim = getUserAvailableForClaim(user)
435- let availableForClaimNew = (availableForClaim + claimAmountAvailable)
436- let userSWOPLockedNew = (userSWOPLocked + pmtAmount)
437- let userGSwopLockedNew = (userGSwopLocked + (pmtAmount * 2))
438- let $t01592815990 = getTotalLockedInfo()
439- let totalSWOPLocked = $t01592815990._1
440- let totalGSwopLocked = $t01592815990._2
441- let totalSWOPLockedNew = (totalSWOPLocked + pmtAmount)
442- let totalGSwopLockedNew = (totalGSwopLocked + (pmtAmount * 2))
443-[IntegerEntry((user + kUserSwopUnlockHeight), (height + lockSwopBlocksAmount)), IntegerEntry((user + kUserLastInterest), userNewInterest), IntegerEntry((user + kUserSWOPLocked), userSWOPLockedNew), IntegerEntry((user + kUserGSwopLocked), userGSwopLockedNew), IntegerEntry((user + kUserAvailableForClaim), availableForClaimNew), IntegerEntry(kTotalSWOPLocked, totalSWOPLockedNew), IntegerEntry(kTotalGSwopLocked, totalGSwopLockedNew)]
444- }
445- })
446-
447-
448-
449-@Callable(i)
450-func updateWeights (currentPools,currentRewards,rewardUpdateHeight,pagination) = valueOrElse(isActive(), {
451- let amountPools = 10
452- let totalRewardUpdateHeight = valueOrElse(getInteger(this, kRewardUpdateHeight), 0)
453- if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3, moneyBoxPubKey], i.callerPublicKey)))
454- then throw("Only admin can call this function")
455- else if ((size(currentPools) > amountPools))
456- then throw(("Max amount of pool is " + toString(amountPools)))
457- else if ((totalRewardUpdateHeight >= rewardUpdateHeight))
458- then throw("rewardUpdateHeight <= totalRewardUpdateHeight")
459- else if ((height >= rewardUpdateHeight))
460- then throw("height >= rewardUpdateHeight")
461- else if ((0 >= rewardUpdateHeight))
462- then throw("0 >= rewardUpdateHeight ")
463- else {
464- func sum (a,b) = (a + b)
465-
466- func changePreviousRewardEntry (accumulated,pool) = {
467- let poolRewardUpdateHeight = getPoolUpdateHeight(pool)
468- if (if (!(isDefinePoolUpdateHeight(pool)))
469- then true
470- else if ((rewardUpdateHeight != poolRewardUpdateHeight))
471- then (poolRewardUpdateHeight == totalRewardUpdateHeight)
472- else false)
473- then {
474- let poolReward = getCurPoolWeight(pool)
475-IntegerEntry((pool + kRewardPoolFractionPrevious), poolReward) :: accumulated
476- }
477- else {
478- let poolReward = getPrevPoolWeight(pool)
479-IntegerEntry((pool + kRewardPoolFractionPrevious), poolReward) :: accumulated
480- }
481- }
482-
483- func changeCurrentRewardEntry (accumulated,pool) = {
484- let poolIndex = value(indexOf(currentPools, pool))
485- let poolReward = currentRewards[poolIndex]
486- if ((0 > poolReward))
487- then throw("PoolReward < 0")
488- else IntegerEntry((pool + kRewardPoolFractionCurrent), poolReward) :: accumulated
489- }
490-
491- func changeHeightEntry (accumulated,pool) = {
492- let poolHeight = rewardUpdateHeight
493- let upUIntr = invoke(farmingAddr, "updatePoolInterest", [pool], nil)
494- if ((upUIntr == upUIntr))
495- then IntegerEntry((pool + kHeightPoolFraction), poolHeight) :: accumulated
496- else throw("Strict value is not equal to itself.")
497- }
498-
499- func getSumReward (curTempSum,pagination) = if ((pagination == 0))
500- then if ((curTempSum > totalVoteShare))
501- then throw(((("sumRewardPrevious > totalVoteShare or sumRewardCurrent > totalVoteShare - " + toString(pagination)) + " ") + toString(curTempSum)))
502- else $Tuple2([IntegerEntry(kTempCurSum, curTempSum)], [IntegerEntry(kRewardUpdateFirstPaginationHeight, rewardUpdateHeight)])
503- else if ((pagination == 1))
504- then {
505- let curTempSumFromKey = valueOrElse(getInteger(this, kTempCurSum), 0)
506- let rewardUpdateHeightFirstPaginationEntry = valueOrElse(getInteger(this, kRewardUpdateFirstPaginationHeight), 0)
507- if (((curTempSum + curTempSumFromKey) > totalVoteShare))
508- then throw(((("sumRewardPrevious > totalVoteShare or sumRewardCurrent > totalVoteShare - " + toString(pagination)) + " ") + toString((curTempSum + curTempSumFromKey))))
509- else if ((rewardUpdateHeightFirstPaginationEntry != rewardUpdateHeight))
510- then throw("current rewardUpdateHeight != rewardUpdateHeightFirstPaginationEntry")
511- else $Tuple2([IntegerEntry(kTempCurSum, (curTempSum + curTempSumFromKey))], nil)
512- }
513- else if ((pagination == 2))
514- then {
515- let curSum = (valueOrElse(getInteger(this, kTempCurSum), 0) + curTempSum)
516- let rewardUpdateHeightFirstPaginationEntry = valueOrElse(getInteger(this, kRewardUpdateFirstPaginationHeight), 0)
517- if ((curSum != totalVoteShare))
518- then throw("sumRewardPrevious != totalVoteShare or sumRewardCurrent != totalVoteShare")
519- else if ((rewardUpdateHeightFirstPaginationEntry != rewardUpdateHeight))
520- then throw("current rewardUpdateHeight != rewardUpdateHeightFirstPaginationEntry")
521- else $Tuple2([IntegerEntry(kTempCurSum, curSum)], nil)
522- }
523- else throw("Incorrect pagination")
524-
525- let previousRewardEntryNew = {
526- let $l = currentPools
527- let $s = size($l)
528- let $acc0 = nil
529- func $f0_1 ($a,$i) = if (($i >= $s))
530- then $a
531- else changePreviousRewardEntry($a, $l[$i])
532-
533- func $f0_2 ($a,$i) = if (($i >= $s))
534- then $a
535- else throw("List size exceeds 10")
536-
537- $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)
538- }
539- let currentRewardEntryNew = {
540- let $l = currentPools
541- let $s = size($l)
542- let $acc0 = nil
543- func $f1_1 ($a,$i) = if (($i >= $s))
544- then $a
545- else changeCurrentRewardEntry($a, $l[$i])
546-
547- func $f1_2 ($a,$i) = if (($i >= $s))
548- then $a
549- else throw("List size exceeds 10")
550-
551- $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)
552- }
553- let heightEntryNewCur = {
554- let $l = currentPools
555- let $s = size($l)
556- let $acc0 = nil
557- func $f2_1 ($a,$i) = if (($i >= $s))
558- then $a
559- else changeHeightEntry($a, $l[$i])
560-
561- func $f2_2 ($a,$i) = if (($i >= $s))
562- then $a
563- else throw("List size exceeds 10")
564-
565- $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)
566- }
567- let sumRewardCurrentTemp = {
568- let $l = currentRewards
569- let $s = size($l)
570- let $acc0 = 0
571- func $f3_1 ($a,$i) = if (($i >= $s))
572- then $a
573- else sum($a, $l[$i])
574-
575- func $f3_2 ($a,$i) = if (($i >= $s))
576- then $a
577- else throw("List size exceeds 10")
578-
579- $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)
580- }
581- let $t02101521126 = getSumReward(sumRewardCurrentTemp, pagination)
582- let sumRewardCurrent = $t02101521126._1
583- let rewardUpdateHeightFirstPaginationEntry = $t02101521126._2
584- let rewardUpdateHeightEntry = if ((pagination == 2))
585- then [IntegerEntry(kRewardUpdateHeight, rewardUpdateHeight)]
586- else nil
587- if ((height > rewardUpdateHeight))
588- then throw("rewardUpdateHeight < height")
589- else (((((previousRewardEntryNew ++ currentRewardEntryNew) ++ heightEntryNewCur) ++ sumRewardCurrent) ++ rewardUpdateHeightEntry) ++ rewardUpdateHeightFirstPaginationEntry)
590- }
591- })
592-
593-
594-
595-@Callable(i)
596-func shutdown () = valueOrElse(isAdminCall(i), if (!(active))
597- then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, kCause), "the cause wasn't specified")))
598- else suspend("Paused by admin"))
599-
600-
601-
602-@Callable(i)
603-func activate () = valueOrElse(isAdminCall(i), if (active)
604- then throw("DApp is already active")
605- else [BooleanEntry(kActive, true), DeleteEntry(kCause)])
606-
607-
608-@Verifier(tx)
609-func verify () = {
610- let adminPubKey1Signed = if (sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey1))
611- then 1
612- else 0
613- let adminPubKey2Signed = if (sigVerify(tx.bodyBytes, tx.proofs[1], adminPubKey2))
614- then 1
615- else 0
616- let adminPubKey3Signed = if (sigVerify(tx.bodyBytes, tx.proofs[2], adminPubKey3))
617- then 1
618- else 0
619- (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 2)
620- }
621-

github/deemru/w8io/169f3d6 
50.52 ms