tx · 4RnAu3PyDznDa5hPyFHtHwWNYyjRT19CqqLWcAaZHdc6

3P8eeDzUnoDNbQjW617pAe76cEUDQsP1m1V:  -0.02000000 Waves

2024.04.18 19:53 [4134448] smart account 3P8eeDzUnoDNbQjW617pAe76cEUDQsP1m1V > SELF 0.00000000 Waves

{ "type": 13, "id": "4RnAu3PyDznDa5hPyFHtHwWNYyjRT19CqqLWcAaZHdc6", "fee": 2000000, "feeAssetId": null, "timestamp": 1713459184843, "version": 2, "chainId": 87, "sender": "3P8eeDzUnoDNbQjW617pAe76cEUDQsP1m1V", "senderPublicKey": "Hkj3ckU9a63dXcAMBHssA9LjpfnkrpkzdoF2TvqWXst3", "proofs": [ "2CyfyEwu2beeqjfniQ4hjjSaxVMx9iSW7U78YrrdaW3doXYvc161Bx1W3NENyFsYoMwhe7XaSsTbZ2BkCvreKN9" ], "script": "base64:BgIcCAISBAoCCAESAwoBCBIDCgEIEgMKAQgSAwoBCAcABWhvdXJzABgAB21pbnV0ZXMAPAENdHJ5R2V0SW50ZWdlcgEDa2V5BAckbWF0Y2gwCQCaCAIFBHRoaXMFA2tleQMJAAECBQckbWF0Y2gwAgNJbnQEAWIFByRtYXRjaDAFAWIAAAEMdHJ5R2V0U3RyaW5nAQNrZXkEByRtYXRjaDAJAJ0IAgUEdGhpcwUDa2V5AwkAAQIFByRtYXRjaDACBlN0cmluZwQBYgUHJG1hdGNoMAUBYgIAAQ5nZXRBc3NldFN0cmluZwEHYXNzZXRJZAQHJG1hdGNoMAUHYXNzZXRJZAMJAAECBQckbWF0Y2gwAgpCeXRlVmVjdG9yBAFiBQckbWF0Y2gwCQDYBAEFAWICBVdBVkVTAQ1nZXRBc3NldEJ5dGVzAQphc3NldElkU3RyAwkAAAIFCmFzc2V0SWRTdHICBVdBVkVTBQR1bml0CQDZBAEFCmFzc2V0SWRTdHIBEXBheUJvb3N0aW5nUmVzdWx0AQpib29zdGluZ0lkBApsYXN0SGVpZ2h0CQENdHJ5R2V0SW50ZWdl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8U8QL64uvph Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let li = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "55", "56"]
5-
64 let hours = 24
75
86 let minutes = 60
4543 then {
4644 let blockReward = (tryGetInteger((("boosting_" + boostingId) + "_totalAmount")) / ((tryGetInteger((("boosting_" + boostingId) + "_days")) * hours) * minutes))
4745 let toPay = fraction((min([finishHeight, height]) - lastHeight), blockReward, 1)
48- let getFinishedPoolId = tryGetString((("boosting_" + boostingId) + "_poolId"))
49- let getPoolBoostings = tryGetString((("pool_" + getFinishedPoolId) + "_boostings"))
50- let sizeStr = size(getPoolBoostings)
51- let findIndex = value(indexOf(getPoolBoostings, boostingId))
52- let modifierLeft = if ((findIndex == 0))
53- then 0
54- else 1
55- let modifierRight = if ((findIndex == 0))
56- then 2
57- else 1
58- let leftStr = take(getPoolBoostings, (sizeStr - ((sizeStr - findIndex) + modifierLeft)))
59- let rightStr = takeRight(getPoolBoostings, (sizeStr - (findIndex + modifierRight)))
60- let openBoostingsIds = (leftStr + rightStr)
61-[IntegerEntry((("boosting_" + boostingId) + "_lastHeight"), height), ScriptTransfer(addressFromStringValue(tryGetString((("boosting_" + boostingId) + "_poolId"))), toPay, getAssetBytes(tryGetString((("boosting_" + boostingId) + "_assetId")))), StringEntry((("pool_" + getFinishedPoolId) + "_boostings"), if ((finishHeight > height))
62- then tryGetString((("pool_" + getFinishedPoolId) + "_boostings"))
63- else openBoostingsIds)]
46+[IntegerEntry((("boosting_" + boostingId) + "_lastHeight"), height), ScriptTransfer(addressFromStringValue(tryGetString((("boosting_" + boostingId) + "_poolId"))), toPay, getAssetBytes(tryGetString((("boosting_" + boostingId) + "_assetId"))))]
6447 }
6548 else nil
6649 }
6750
6851
69-func endedBoostingIds (boostingId) = {
70- let lastHeight = tryGetInteger((("boosting_" + boostingId) + "_lastHeight"))
71- let finishHeight = tryGetInteger((("boosting_" + boostingId) + "_finishHeight"))
72- if ((lastHeight >= finishHeight))
73- then [StringEntry((("list ended " + toString(height)) + " boostingIds"), ((tryGetString((("list ended " + toString(height)) + " boostingIds")) + boostingId) + ","))]
74- else [StringEntry((("list ongoing boosts " + toString(height)) + " boostingIds"), ((tryGetString((("list ongoing boosts " + toString(height)) + " boostingIds")) + boostingId) + ","))]
52+@Callable(i)
53+func addBoosting (poolId,days) = {
54+ let fullAmount = i.payments[0].amount
55+ if ((1 > days))
56+ then throw("amount of days has to be between 1 and 365")
57+ else if ((days > 365))
58+ then throw("amount of days has to be between 1 and 365")
59+ else if ((1440 > (fullAmount / days)))
60+ then throw((("boosting amount too small, minimum is " + toString((1440 * days))) + " of the smallest unit of payment asset"))
61+ else if ((addressFromString(poolId) == unit))
62+ then throw("incorrect pool address")
63+ else {
64+ let assetId = getAssetString(i.payments[0].assetId)
65+ let poolBoostings = split(tryGetString((("pool_" + poolId) + "_boostings")), ",")
66+ let boostingId = toBase58String(i.transactionId)
67+[IntegerEntry((("boosting_" + boostingId) + "_days"), days), IntegerEntry((("boosting_" + boostingId) + "_totalAmount"), fullAmount), IntegerEntry((("boosting_" + boostingId) + "_dailyAmount"), (fullAmount / days)), IntegerEntry((("boosting_" + boostingId) + "_startHeight"), height), IntegerEntry((("boosting_" + boostingId) + "_finishHeight"), (height + ((days * hours) * minutes))), IntegerEntry((("boosting_" + boostingId) + "_finishTimestamp"), (lastBlock.timestamp + ((((days * hours) * minutes) * 60) * 1000))), IntegerEntry((("boosting_" + boostingId) + "_lastHeight"), height), StringEntry((("boosting_" + boostingId) + "_assetId"), assetId), StringEntry((("boosting_" + boostingId) + "_owner"), toString(i.caller)), StringEntry((("boosting_" + boostingId) + "_poolId"), poolId), StringEntry((("pool_" + poolId) + "_boostings"), tryGetString((((("pool_" + poolId) + "_boostings") + boostingId) + ",")))]
68+ }
7569 }
7670
7771
72+
7873 @Callable(i)
79-func addBoosting (poolId,days) = if ((1 > days))
80- then throw("amount of days has to be between 1 and 365")
81- else if ((days > 365))
82- then throw("amount of days has to be between 1 and 365")
83- else if (false)
84- then throw("under maintenance until further notice")
85- else {
86- let fullAmount = i.payments[0].amount
87- if ((1440 > (fullAmount / days)))
88- then throw((("boosting amount too small, minimum is " + toString((1440 * days))) + " of the smallest unit of payment asset"))
89- else {
90- let assetId = getAssetString(i.payments[0].assetId)
91- if ((height == tryGetInteger("height")))
92- then throw("wait 1 minute")
93- else {
94- let entry = if ((size(tryGetString((("pool_" + poolId) + "_boostings"))) > 11))
95- then throw("max 5 boosts per pool")
96- else invoke(this, "entryEnded", nil, nil)
97- if ((entry == entry))
98- then {
99- let boostingId = if ((size((("list ongoing boosts " + toString(height)) + " boostingIds")) > 112))
100- then throw("wait till other boosts are finished")
101- else take(tryGetString((("list ended " + toString(height)) + " boostingIds")), 1)
102- if ((addressFromString(poolId) == unit))
103- then throw("incorrect pool address")
104- else [IntegerEntry((("boosting_" + boostingId) + "_days"), days), IntegerEntry((("boosting_" + boostingId) + "_totalAmount"), fullAmount), IntegerEntry((("boosting_" + boostingId) + "_dailyAmount"), (fullAmount / days)), IntegerEntry((("boosting_" + boostingId) + "_startHeight"), height), IntegerEntry((("boosting_" + boostingId) + "_finishHeight"), (height + ((days * hours) * minutes))), IntegerEntry((("boosting_" + boostingId) + "_finishTimestamp"), (lastBlock.timestamp + ((((days * hours) * minutes) * 60) * 1000))), IntegerEntry((("boosting_" + boostingId) + "_lastHeight"), height), StringEntry((("boosting_" + boostingId) + "_assetId"), assetId), StringEntry((("boosting_" + boostingId) + "_owner"), toString(i.caller)), StringEntry((("boosting_" + boostingId) + "_poolId"), poolId), StringEntry((("pool_" + poolId) + "_boostings"), ((tryGetString((("pool_" + poolId) + "_boostings")) + boostingId) + ","))]
105- }
106- else throw("Strict value is not equal to itself.")
107- }
108- }
109- }
74+func polishFinishedBoostings (poolId) = {
75+ func checkNextBoosting (accum,boostingId) = if ((boostingId == ""))
76+ then accum
77+ else {
78+ let finishHeight = tryGetInteger((("boosting_" + boostingId) + "_finishHeight"))
79+ if ((height > finishHeight))
80+ then ((accum + boostingId) + ",")
81+ else accum
82+ }
83+
84+ let currentBoostings = split_51C(tryGetString((("pool_" + poolId) + "_boostings")), ",")
85+ let newBoostings = {
86+ let $l = currentBoostings
87+ let $s = size($l)
88+ let $acc0 = ""
89+ func $f0_1 ($a,$i) = if (($i >= $s))
90+ then $a
91+ else checkNextBoosting($a, $l[$i])
92+
93+ func $f0_2 ($a,$i) = if (($i >= $s))
94+ then $a
95+ else throw("List size exceeds 25")
96+
97+ $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($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), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25)
98+ }
99+[if ((newBoostings == ""))
100+ then DeleteEntry((("pool_" + poolId) + "_boostings"))
101+ else StringEntry((("pool_" + poolId) + "_boostings"), newBoostings)]
102+ }
110103
111104
112105
116109
117110
118111 @Callable(i)
119-func payBoostings () = {
120- func f (accum,next) = {
121- let in = invoke(this, "payBoosting", [next], nil)
122- if ((in == in))
123- then in
124- else throw("Strict value is not equal to itself.")
125- }
112+func payPoolBoostings (poolId) = {
113+ func f (accum,boostingId) = payBoostingResult(boostingId)
126114
115+ let boostings = split_51C(tryGetString((("pool_" + poolId) + "_boostings")), ",")
127116 let payments = {
128- let $l = li
117+ let $l = boostings
129118 let $s = size($l)
130119 let $acc0 = 0
131120 func $f0_1 ($a,$i) = if (($i >= $s))
134123
135124 func $f0_2 ($a,$i) = if (($i >= $s))
136125 then $a
137- else throw("List size exceeds 56")
126+ else throw("List size exceeds 25")
138127
139- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($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), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30), 31), 32), 33), 34), 35), 36), 37), 38), 39), 40), 41), 42), 43), 44), 45), 46), 47), 48), 49), 50), 51), 52), 53), 54), 55), 56)
128+ $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($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), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25)
140129 }
141130 if ((payments == payments))
142- then nil
131+ then {
132+ let inv = invoke(this, "polishFinishedBoostings", [poolId], nil)
133+ if ((inv == inv))
134+ then nil
135+ else throw("Strict value is not equal to itself.")
136+ }
143137 else throw("Strict value is not equal to itself.")
144138 }
145139
146140
147141
148142 @Callable(i)
149-func endedBoostings (boostingId) = endedBoostingIds(boostingId)
150-
151-
152-
153-@Callable(i)
154-func entryEnded () = {
155- func f (accum,next) = {
156- let in = invoke(this, "endedBoostings", [next], nil)
143+func payBoostings (poolIds) = {
144+ func f (accum,poolId) = {
145+ let in = invoke(this, "payPoolBoostings", [poolId], nil)
157146 if ((in == in))
158- then in
147+ then 0
159148 else throw("Strict value is not equal to itself.")
160149 }
161150
162- let end = {
163- let $l = li
151+ let invokes = {
152+ let $l = split_51C(poolIds, ",")
164153 let $s = size($l)
165154 let $acc0 = 0
166155 func $f0_1 ($a,$i) = if (($i >= $s))
169158
170159 func $f0_2 ($a,$i) = if (($i >= $s))
171160 then $a
172- else throw("List size exceeds 56")
161+ else throw("List size exceeds 25")
173162
174- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($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), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30), 31), 32), 33), 34), 35), 36), 37), 38), 39), 40), 41), 42), 43), 44), 45), 46), 47), 48), 49), 50), 51), 52), 53), 54), 55), 56)
163+ $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($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), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25)
175164 }
176- if ((end == end))
177- then [IntegerEntry("height", height)]
165+ if ((invokes == invokes))
166+ then nil
178167 else throw("Strict value is not equal to itself.")
179168 }
180169
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let li = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "55", "56"]
5-
64 let hours = 24
75
86 let minutes = 60
97
108 func tryGetInteger (key) = match getInteger(this, key) {
119 case b: Int =>
1210 b
1311 case _ =>
1412 0
1513 }
1614
1715
1816 func tryGetString (key) = match getString(this, key) {
1917 case b: String =>
2018 b
2119 case _ =>
2220 ""
2321 }
2422
2523
2624 func getAssetString (assetId) = match assetId {
2725 case b: ByteVector =>
2826 toBase58String(b)
2927 case _ =>
3028 "WAVES"
3129 }
3230
3331
3432 func getAssetBytes (assetIdStr) = if ((assetIdStr == "WAVES"))
3533 then unit
3634 else fromBase58String(assetIdStr)
3735
3836
3937 func payBoostingResult (boostingId) = {
4038 let lastHeight = tryGetInteger((("boosting_" + boostingId) + "_lastHeight"))
4139 let finishHeight = tryGetInteger((("boosting_" + boostingId) + "_finishHeight"))
4240 if (if ((lastHeight != 0))
4341 then (finishHeight > lastHeight)
4442 else false)
4543 then {
4644 let blockReward = (tryGetInteger((("boosting_" + boostingId) + "_totalAmount")) / ((tryGetInteger((("boosting_" + boostingId) + "_days")) * hours) * minutes))
4745 let toPay = fraction((min([finishHeight, height]) - lastHeight), blockReward, 1)
48- let getFinishedPoolId = tryGetString((("boosting_" + boostingId) + "_poolId"))
49- let getPoolBoostings = tryGetString((("pool_" + getFinishedPoolId) + "_boostings"))
50- let sizeStr = size(getPoolBoostings)
51- let findIndex = value(indexOf(getPoolBoostings, boostingId))
52- let modifierLeft = if ((findIndex == 0))
53- then 0
54- else 1
55- let modifierRight = if ((findIndex == 0))
56- then 2
57- else 1
58- let leftStr = take(getPoolBoostings, (sizeStr - ((sizeStr - findIndex) + modifierLeft)))
59- let rightStr = takeRight(getPoolBoostings, (sizeStr - (findIndex + modifierRight)))
60- let openBoostingsIds = (leftStr + rightStr)
61-[IntegerEntry((("boosting_" + boostingId) + "_lastHeight"), height), ScriptTransfer(addressFromStringValue(tryGetString((("boosting_" + boostingId) + "_poolId"))), toPay, getAssetBytes(tryGetString((("boosting_" + boostingId) + "_assetId")))), StringEntry((("pool_" + getFinishedPoolId) + "_boostings"), if ((finishHeight > height))
62- then tryGetString((("pool_" + getFinishedPoolId) + "_boostings"))
63- else openBoostingsIds)]
46+[IntegerEntry((("boosting_" + boostingId) + "_lastHeight"), height), ScriptTransfer(addressFromStringValue(tryGetString((("boosting_" + boostingId) + "_poolId"))), toPay, getAssetBytes(tryGetString((("boosting_" + boostingId) + "_assetId"))))]
6447 }
6548 else nil
6649 }
6750
6851
69-func endedBoostingIds (boostingId) = {
70- let lastHeight = tryGetInteger((("boosting_" + boostingId) + "_lastHeight"))
71- let finishHeight = tryGetInteger((("boosting_" + boostingId) + "_finishHeight"))
72- if ((lastHeight >= finishHeight))
73- then [StringEntry((("list ended " + toString(height)) + " boostingIds"), ((tryGetString((("list ended " + toString(height)) + " boostingIds")) + boostingId) + ","))]
74- else [StringEntry((("list ongoing boosts " + toString(height)) + " boostingIds"), ((tryGetString((("list ongoing boosts " + toString(height)) + " boostingIds")) + boostingId) + ","))]
52+@Callable(i)
53+func addBoosting (poolId,days) = {
54+ let fullAmount = i.payments[0].amount
55+ if ((1 > days))
56+ then throw("amount of days has to be between 1 and 365")
57+ else if ((days > 365))
58+ then throw("amount of days has to be between 1 and 365")
59+ else if ((1440 > (fullAmount / days)))
60+ then throw((("boosting amount too small, minimum is " + toString((1440 * days))) + " of the smallest unit of payment asset"))
61+ else if ((addressFromString(poolId) == unit))
62+ then throw("incorrect pool address")
63+ else {
64+ let assetId = getAssetString(i.payments[0].assetId)
65+ let poolBoostings = split(tryGetString((("pool_" + poolId) + "_boostings")), ",")
66+ let boostingId = toBase58String(i.transactionId)
67+[IntegerEntry((("boosting_" + boostingId) + "_days"), days), IntegerEntry((("boosting_" + boostingId) + "_totalAmount"), fullAmount), IntegerEntry((("boosting_" + boostingId) + "_dailyAmount"), (fullAmount / days)), IntegerEntry((("boosting_" + boostingId) + "_startHeight"), height), IntegerEntry((("boosting_" + boostingId) + "_finishHeight"), (height + ((days * hours) * minutes))), IntegerEntry((("boosting_" + boostingId) + "_finishTimestamp"), (lastBlock.timestamp + ((((days * hours) * minutes) * 60) * 1000))), IntegerEntry((("boosting_" + boostingId) + "_lastHeight"), height), StringEntry((("boosting_" + boostingId) + "_assetId"), assetId), StringEntry((("boosting_" + boostingId) + "_owner"), toString(i.caller)), StringEntry((("boosting_" + boostingId) + "_poolId"), poolId), StringEntry((("pool_" + poolId) + "_boostings"), tryGetString((((("pool_" + poolId) + "_boostings") + boostingId) + ",")))]
68+ }
7569 }
7670
7771
72+
7873 @Callable(i)
79-func addBoosting (poolId,days) = if ((1 > days))
80- then throw("amount of days has to be between 1 and 365")
81- else if ((days > 365))
82- then throw("amount of days has to be between 1 and 365")
83- else if (false)
84- then throw("under maintenance until further notice")
85- else {
86- let fullAmount = i.payments[0].amount
87- if ((1440 > (fullAmount / days)))
88- then throw((("boosting amount too small, minimum is " + toString((1440 * days))) + " of the smallest unit of payment asset"))
89- else {
90- let assetId = getAssetString(i.payments[0].assetId)
91- if ((height == tryGetInteger("height")))
92- then throw("wait 1 minute")
93- else {
94- let entry = if ((size(tryGetString((("pool_" + poolId) + "_boostings"))) > 11))
95- then throw("max 5 boosts per pool")
96- else invoke(this, "entryEnded", nil, nil)
97- if ((entry == entry))
98- then {
99- let boostingId = if ((size((("list ongoing boosts " + toString(height)) + " boostingIds")) > 112))
100- then throw("wait till other boosts are finished")
101- else take(tryGetString((("list ended " + toString(height)) + " boostingIds")), 1)
102- if ((addressFromString(poolId) == unit))
103- then throw("incorrect pool address")
104- else [IntegerEntry((("boosting_" + boostingId) + "_days"), days), IntegerEntry((("boosting_" + boostingId) + "_totalAmount"), fullAmount), IntegerEntry((("boosting_" + boostingId) + "_dailyAmount"), (fullAmount / days)), IntegerEntry((("boosting_" + boostingId) + "_startHeight"), height), IntegerEntry((("boosting_" + boostingId) + "_finishHeight"), (height + ((days * hours) * minutes))), IntegerEntry((("boosting_" + boostingId) + "_finishTimestamp"), (lastBlock.timestamp + ((((days * hours) * minutes) * 60) * 1000))), IntegerEntry((("boosting_" + boostingId) + "_lastHeight"), height), StringEntry((("boosting_" + boostingId) + "_assetId"), assetId), StringEntry((("boosting_" + boostingId) + "_owner"), toString(i.caller)), StringEntry((("boosting_" + boostingId) + "_poolId"), poolId), StringEntry((("pool_" + poolId) + "_boostings"), ((tryGetString((("pool_" + poolId) + "_boostings")) + boostingId) + ","))]
105- }
106- else throw("Strict value is not equal to itself.")
107- }
108- }
109- }
74+func polishFinishedBoostings (poolId) = {
75+ func checkNextBoosting (accum,boostingId) = if ((boostingId == ""))
76+ then accum
77+ else {
78+ let finishHeight = tryGetInteger((("boosting_" + boostingId) + "_finishHeight"))
79+ if ((height > finishHeight))
80+ then ((accum + boostingId) + ",")
81+ else accum
82+ }
83+
84+ let currentBoostings = split_51C(tryGetString((("pool_" + poolId) + "_boostings")), ",")
85+ let newBoostings = {
86+ let $l = currentBoostings
87+ let $s = size($l)
88+ let $acc0 = ""
89+ func $f0_1 ($a,$i) = if (($i >= $s))
90+ then $a
91+ else checkNextBoosting($a, $l[$i])
92+
93+ func $f0_2 ($a,$i) = if (($i >= $s))
94+ then $a
95+ else throw("List size exceeds 25")
96+
97+ $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($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), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25)
98+ }
99+[if ((newBoostings == ""))
100+ then DeleteEntry((("pool_" + poolId) + "_boostings"))
101+ else StringEntry((("pool_" + poolId) + "_boostings"), newBoostings)]
102+ }
110103
111104
112105
113106 @Callable(i)
114107 func payBoosting (boostingId) = payBoostingResult(boostingId)
115108
116109
117110
118111 @Callable(i)
119-func payBoostings () = {
120- func f (accum,next) = {
121- let in = invoke(this, "payBoosting", [next], nil)
122- if ((in == in))
123- then in
124- else throw("Strict value is not equal to itself.")
125- }
112+func payPoolBoostings (poolId) = {
113+ func f (accum,boostingId) = payBoostingResult(boostingId)
126114
115+ let boostings = split_51C(tryGetString((("pool_" + poolId) + "_boostings")), ",")
127116 let payments = {
128- let $l = li
117+ let $l = boostings
129118 let $s = size($l)
130119 let $acc0 = 0
131120 func $f0_1 ($a,$i) = if (($i >= $s))
132121 then $a
133122 else f($a, $l[$i])
134123
135124 func $f0_2 ($a,$i) = if (($i >= $s))
136125 then $a
137- else throw("List size exceeds 56")
126+ else throw("List size exceeds 25")
138127
139- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($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), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30), 31), 32), 33), 34), 35), 36), 37), 38), 39), 40), 41), 42), 43), 44), 45), 46), 47), 48), 49), 50), 51), 52), 53), 54), 55), 56)
128+ $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($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), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25)
140129 }
141130 if ((payments == payments))
142- then nil
131+ then {
132+ let inv = invoke(this, "polishFinishedBoostings", [poolId], nil)
133+ if ((inv == inv))
134+ then nil
135+ else throw("Strict value is not equal to itself.")
136+ }
143137 else throw("Strict value is not equal to itself.")
144138 }
145139
146140
147141
148142 @Callable(i)
149-func endedBoostings (boostingId) = endedBoostingIds(boostingId)
150-
151-
152-
153-@Callable(i)
154-func entryEnded () = {
155- func f (accum,next) = {
156- let in = invoke(this, "endedBoostings", [next], nil)
143+func payBoostings (poolIds) = {
144+ func f (accum,poolId) = {
145+ let in = invoke(this, "payPoolBoostings", [poolId], nil)
157146 if ((in == in))
158- then in
147+ then 0
159148 else throw("Strict value is not equal to itself.")
160149 }
161150
162- let end = {
163- let $l = li
151+ let invokes = {
152+ let $l = split_51C(poolIds, ",")
164153 let $s = size($l)
165154 let $acc0 = 0
166155 func $f0_1 ($a,$i) = if (($i >= $s))
167156 then $a
168157 else f($a, $l[$i])
169158
170159 func $f0_2 ($a,$i) = if (($i >= $s))
171160 then $a
172- else throw("List size exceeds 56")
161+ else throw("List size exceeds 25")
173162
174- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($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), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30), 31), 32), 33), 34), 35), 36), 37), 38), 39), 40), 41), 42), 43), 44), 45), 46), 47), 48), 49), 50), 51), 52), 53), 54), 55), 56)
163+ $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($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), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25)
175164 }
176- if ((end == end))
177- then [IntegerEntry("height", height)]
165+ if ((invokes == invokes))
166+ then nil
178167 else throw("Strict value is not equal to itself.")
179168 }
180169
181170

github/deemru/w8io/6500d08 
57.00 ms