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 | | - | |
---|
6 | | - | let hours = 1 |
---|
7 | | - | |
---|
8 | | - | let minutes = 10 |
---|
9 | | - | |
---|
10 | | - | func tryGetInteger (key) = match getInteger(this, key) { |
---|
11 | | - | case b: Int => |
---|
12 | | - | b |
---|
13 | | - | case _ => |
---|
14 | | - | 0 |
---|
15 | | - | } |
---|
16 | | - | |
---|
17 | | - | |
---|
18 | | - | func tryGetString (key) = match getString(this, key) { |
---|
19 | | - | case b: String => |
---|
20 | | - | b |
---|
21 | | - | case _ => |
---|
22 | | - | "" |
---|
23 | | - | } |
---|
24 | | - | |
---|
25 | | - | |
---|
26 | | - | func getAssetString (assetId) = match assetId { |
---|
27 | | - | case b: ByteVector => |
---|
28 | | - | toBase58String(b) |
---|
29 | | - | case _ => |
---|
30 | | - | "WAVES" |
---|
31 | | - | } |
---|
32 | | - | |
---|
33 | | - | |
---|
34 | | - | func getAssetBytes (assetIdStr) = if ((assetIdStr == "WAVES")) |
---|
35 | | - | then unit |
---|
36 | | - | else fromBase58String(assetIdStr) |
---|
37 | | - | |
---|
38 | | - | |
---|
39 | | - | func payBoostingResult (boostingId) = { |
---|
40 | | - | let lastHeight = tryGetInteger((("boosting_" + boostingId) + "_lastHeight")) |
---|
41 | | - | let finishHeight = tryGetInteger((("boosting_" + boostingId) + "_finishHeight")) |
---|
42 | | - | if (if ((lastHeight != 0)) |
---|
43 | | - | then (finishHeight > lastHeight) |
---|
44 | | - | else false) |
---|
45 | | - | then { |
---|
46 | | - | let blockReward = tryGetInteger((("boosting_" + boostingId) + "_blockAmount")) |
---|
47 | | - | let toPay = ((min([finishHeight, height]) - lastHeight) * blockReward) |
---|
48 | | - | [IntegerEntry((("boosting_" + boostingId) + "_lastHeight"), height), ScriptTransfer(addressFromStringValue(tryGetString((("boosting_" + boostingId) + "_poolId"))), toPay, getAssetBytes(tryGetString((("boosting_" + boostingId) + "_assetId"))))] |
---|
49 | | - | } |
---|
50 | | - | else nil |
---|
51 | | - | } |
---|
52 | | - | |
---|
53 | | - | |
---|
54 | | - | func endedList (boostingId) = { |
---|
55 | | - | let lastHeight = tryGetInteger((("boosting_" + boostingId) + "_lastHeight")) |
---|
56 | | - | let finishHeight = tryGetInteger((("boosting_" + boostingId) + "_finishHeight")) |
---|
57 | | - | if ((lastHeight >= finishHeight)) |
---|
58 | | - | then [StringEntry((("list ended " + toString(height)) + " boostingIds"), ((tryGetString((("list ended " + toString(height)) + " boostingIds")) + boostingId) + ","))] |
---|
59 | | - | else nil |
---|
60 | | - | } |
---|
64 | | - | func addBoosting (poolId,days) = { |
---|
65 | | - | let fullAmount = i.payments[0].amount |
---|
66 | | - | let assetId = getAssetString(i.payments[0].assetId) |
---|
67 | | - | let newBoostingsAmount = (tryGetInteger("global_boostingsAmount") + 1) |
---|
68 | | - | let boostingId = toString(newBoostingsAmount) |
---|
69 | | - | if ((addressFromString(poolId) == unit)) |
---|
70 | | - | then throw("incorrect pool address") |
---|
71 | | - | else [IntegerEntry("global_boostingsAmount", newBoostingsAmount), IntegerEntry((("boosting_" + boostingId) + "_days"), days), IntegerEntry((("boosting_" + boostingId) + "_totalAmount"), fullAmount), IntegerEntry((("boosting_" + boostingId) + "_dailyAmount"), (fullAmount / days)), IntegerEntry((("boosting_" + boostingId) + "_blockAmount"), (fullAmount / ((days * hours) * minutes))), 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) + ","))] |
---|
72 | | - | } |
---|
73 | | - | |
---|
74 | | - | |
---|
75 | | - | |
---|
76 | | - | @Callable(i) |
---|
77 | | - | func payBoosting (boostingId) = payBoostingResult(boostingId) |
---|
78 | | - | |
---|
79 | | - | |
---|
80 | | - | |
---|
81 | | - | @Callable(i) |
---|
82 | | - | func payBoostings () = { |
---|
83 | | - | func f (accum,next) = { |
---|
84 | | - | let in = invoke(this, "payBoosting", [next], nil) |
---|
85 | | - | if ((in == in)) |
---|
86 | | - | then in |
---|
87 | | - | else throw("Strict value is not equal to itself.") |
---|
88 | | - | } |
---|
89 | | - | |
---|
90 | | - | let payments = { |
---|
91 | | - | let $l = li |
---|
92 | | - | let $s = size($l) |
---|
93 | | - | let $acc0 = 0 |
---|
94 | | - | func $f0_1 ($a,$i) = if (($i >= $s)) |
---|
95 | | - | then $a |
---|
96 | | - | else f($a, $l[$i]) |
---|
97 | | - | |
---|
98 | | - | func $f0_2 ($a,$i) = if (($i >= $s)) |
---|
99 | | - | then $a |
---|
100 | | - | else throw("List size exceeds 100") |
---|
101 | | - | |
---|
102 | | - | $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($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), 57), 58), 59), 60), 61), 62), 63), 64), 65), 66), 67), 68), 69), 70), 71), 72), 73), 74), 75), 76), 77), 78), 79), 80), 81), 82), 83), 84), 85), 86), 87), 88), 89), 90), 91), 92), 93), 94), 95), 96), 97), 98), 99), 100) |
---|
103 | | - | } |
---|
104 | | - | if ((payments == payments)) |
---|
105 | | - | then nil |
---|
106 | | - | else throw("Strict value is not equal to itself.") |
---|
107 | | - | } |
---|
108 | | - | |
---|
109 | | - | |
---|
110 | | - | |
---|
111 | | - | @Callable(i) |
---|
112 | | - | func getEndedList (boostingId) = endedList(boostingId) |
---|
113 | | - | |
---|
114 | | - | |
---|
115 | | - | |
---|
116 | | - | @Callable(i) |
---|
117 | | - | func getList () = { |
---|
118 | | - | func f (accum,next) = { |
---|
119 | | - | let in = invoke(this, "getEndedList", [next], nil) |
---|
120 | | - | if ((in == in)) |
---|
121 | | - | then in |
---|
122 | | - | else throw("Strict value is not equal to itself.") |
---|
123 | | - | } |
---|
124 | | - | |
---|
125 | | - | let end = { |
---|
126 | | - | let $l = li |
---|
127 | | - | let $s = size($l) |
---|
128 | | - | let $acc0 = 0 |
---|
129 | | - | func $f0_1 ($a,$i) = if (($i >= $s)) |
---|
130 | | - | then $a |
---|
131 | | - | else f($a, $l[$i]) |
---|
132 | | - | |
---|
133 | | - | func $f0_2 ($a,$i) = if (($i >= $s)) |
---|
134 | | - | then $a |
---|
135 | | - | else throw("List size exceeds 100") |
---|
136 | | - | |
---|
137 | | - | $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($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), 57), 58), 59), 60), 61), 62), 63), 64), 65), 66), 67), 68), 69), 70), 71), 72), 73), 74), 75), 76), 77), 78), 79), 80), 81), 82), 83), 84), 85), 86), 87), 88), 89), 90), 91), 92), 93), 94), 95), 96), 97), 98), 99), 100) |
---|
138 | | - | } |
---|
139 | | - | if ((end == end)) |
---|
140 | | - | then nil |
---|
141 | | - | else throw("Strict value is not equal to itself.") |
---|
| 7 | + | func make () = { |
---|
| 8 | + | let makeList = [getStringValue("list ended 2822531 boostingIds")] |
---|
| 9 | + | let firstOfList = makeList[0] |
---|
| 10 | + | [StringEntry("first of list", firstOfList)] |
---|