4 | | - | let a = ["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 b = 1 |
---|
7 | | - | |
---|
8 | | - | let c = 10 |
---|
9 | | - | |
---|
10 | | - | func d (e) = { |
---|
11 | | - | let f = getInteger(this, e) |
---|
12 | | - | if ($isInstanceOf(f, "Int")) |
---|
13 | | - | then { |
---|
14 | | - | let g = f |
---|
15 | | - | g |
---|
16 | | - | } |
---|
17 | | - | else 0 |
---|
| 4 | + | func a (b) = { |
---|
| 5 | + | let c = { |
---|
| 6 | + | let d = getBinary(this, "lastPlay") |
---|
| 7 | + | if ($isInstanceOf(d, "ByteVector")) |
---|
| 8 | + | then { |
---|
| 9 | + | let e = d |
---|
| 10 | + | e |
---|
| 11 | + | } |
---|
| 12 | + | else if ($isInstanceOf(d, "Unit")) |
---|
| 13 | + | then base58'2ee4oFDYriWJ9EMeR' |
---|
| 14 | + | else throw("Match error") |
---|
| 15 | + | } |
---|
| 16 | + | let f = (((((c + b.transactionId) + b.callerPublicKey) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height)) |
---|
| 17 | + | sha256(f) |
---|
32 | | - | func i (j) = { |
---|
33 | | - | let f = j |
---|
34 | | - | if ($isInstanceOf(f, "ByteVector")) |
---|
35 | | - | then { |
---|
36 | | - | let g = f |
---|
37 | | - | toBase58String(g) |
---|
38 | | - | } |
---|
39 | | - | else "WAVES" |
---|
40 | | - | } |
---|
41 | | - | |
---|
42 | | - | |
---|
43 | | - | func k (l) = if ((l == "WAVES")) |
---|
44 | | - | then unit |
---|
45 | | - | else fromBase58String(l) |
---|
46 | | - | |
---|
47 | | - | |
---|
48 | | - | func m (n) = { |
---|
49 | | - | let o = d((("boosting_" + n) + "_lastHeight")) |
---|
50 | | - | let p = d((("boosting_" + n) + "_finishHeight")) |
---|
51 | | - | if (if ((o != 0)) |
---|
52 | | - | then (p > o) |
---|
53 | | - | else false) |
---|
54 | | - | then { |
---|
55 | | - | let q = (d((("boosting_" + n) + "_totalAmount")) / ((d((("boosting_" + n) + "_days")) * b) * c)) |
---|
56 | | - | let r = fraction((min([p, height]) - o), q, 1) |
---|
57 | | - | [IntegerEntry((("boosting_" + n) + "_lastHeight"), height), ScriptTransfer(addressFromStringValue(h((("boosting_" + n) + "_poolId"))), r, k(h((("boosting_" + n) + "_assetId"))))] |
---|
58 | | - | } |
---|
59 | | - | else nil |
---|
60 | | - | } |
---|
61 | | - | |
---|
62 | | - | |
---|
63 | | - | func s (n) = { |
---|
64 | | - | let o = d((("boosting_" + n) + "_lastHeight")) |
---|
65 | | - | let p = d((("boosting_" + n) + "_finishHeight")) |
---|
66 | | - | if ((o >= p)) |
---|
67 | | - | then [StringEntry((("list ended " + toString(height)) + " boostingIds"), ((h((("list ended " + toString(height)) + " boostingIds")) + n) + ","))] |
---|
68 | | - | else nil |
---|
69 | | - | } |
---|
70 | | - | |
---|
71 | | - | |
---|
72 | | - | @Callable(t) |
---|
73 | | - | func addBoosting (u,v) = if ((1 > v)) |
---|
74 | | - | then throw("amount of days has to be between 1 and 365") |
---|
75 | | - | else if ((v > 365)) |
---|
76 | | - | then throw("amount of days has to be between 1 and 365") |
---|
77 | | - | else if (if ((t.caller != this)) |
---|
78 | | - | then (t.caller != Address(base58'3N3y7nQfqDc7rBUExjKQi5ZbspWRh9q8PYH')) |
---|
79 | | - | else false) |
---|
80 | | - | then throw("under maintenance until further notice") |
---|
81 | | - | else { |
---|
82 | | - | let w = t.payments[0].amount |
---|
83 | | - | if ((1440 > (w / v))) |
---|
84 | | - | then throw((("boosting amount too small, minimum is " + toString((1440 * v))) + " of the smallest unit of payment asset")) |
---|
85 | | - | else { |
---|
86 | | - | let j = i(t.payments[0].assetId) |
---|
87 | | - | if ((height == d("height"))) |
---|
88 | | - | then throw("wait 1 minute") |
---|
89 | | - | else { |
---|
90 | | - | let x = invoke(this, "entryEnded", nil, nil) |
---|
91 | | - | if ((x == x)) |
---|
92 | | - | then { |
---|
93 | | - | let y = invoke(this, "firstEndedBoostingId", nil, nil) |
---|
94 | | - | if ((y == y)) |
---|
95 | | - | then { |
---|
96 | | - | let n = toString(d("first")) |
---|
97 | | - | if ((addressFromString(u) == unit)) |
---|
98 | | - | then throw("incorrect pool address") |
---|
99 | | - | else [IntegerEntry((("boosting_" + n) + "_days"), v), IntegerEntry((("boosting_" + n) + "_totalAmount"), w), IntegerEntry((("boosting_" + n) + "_dailyAmount"), (w / v)), IntegerEntry((("boosting_" + n) + "_startHeight"), height), IntegerEntry((("boosting_" + n) + "_finishHeight"), (height + ((v * b) * c))), IntegerEntry((("boosting_" + n) + "_finishTimestamp"), (lastBlock.timestamp + ((((v * b) * c) * 60) * 1000))), IntegerEntry((("boosting_" + n) + "_lastHeight"), height), StringEntry((("boosting_" + n) + "_assetId"), j), StringEntry((("boosting_" + n) + "_owner"), toString(t.caller)), StringEntry((("boosting_" + n) + "_poolId"), u), StringEntry((("pool_" + u) + "_boostings"), ((h((("pool_" + u) + "_boostings")) + n) + ","))] |
---|
100 | | - | } |
---|
101 | | - | else throw("Strict value is not equal to itself.") |
---|
102 | | - | } |
---|
103 | | - | else throw("Strict value is not equal to itself.") |
---|
104 | | - | } |
---|
105 | | - | } |
---|
106 | | - | } |
---|
107 | | - | |
---|
108 | | - | |
---|
109 | | - | |
---|
110 | | - | @Callable(t) |
---|
111 | | - | func payBoosting (n) = m(n) |
---|
112 | | - | |
---|
113 | | - | |
---|
114 | | - | |
---|
115 | | - | @Callable(t) |
---|
116 | | - | func payBoostings () = { |
---|
117 | | - | func z (A,B) = { |
---|
118 | | - | let C = invoke(this, "payBoosting", [B], nil) |
---|
119 | | - | if ((C == C)) |
---|
120 | | - | then C |
---|
121 | | - | else throw("Strict value is not equal to itself.") |
---|
122 | | - | } |
---|
123 | | - | |
---|
124 | | - | let D = { |
---|
125 | | - | let E = a |
---|
126 | | - | let F = size(E) |
---|
127 | | - | let G = 0 |
---|
128 | | - | func H (I,J) = if ((J >= F)) |
---|
129 | | - | then I |
---|
130 | | - | else z(I, E[J]) |
---|
131 | | - | |
---|
132 | | - | func K (I,J) = if ((J >= F)) |
---|
133 | | - | then I |
---|
134 | | - | else throw("List size exceeds 56") |
---|
135 | | - | |
---|
136 | | - | K(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(G, 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) |
---|
137 | | - | } |
---|
138 | | - | if ((D == D)) |
---|
139 | | - | then nil |
---|
140 | | - | else throw("Strict value is not equal to itself.") |
---|
141 | | - | } |
---|
142 | | - | |
---|
143 | | - | |
---|
144 | | - | |
---|
145 | | - | @Callable(t) |
---|
146 | | - | func endedBoostings (n) = s(n) |
---|
147 | | - | |
---|
148 | | - | |
---|
149 | | - | |
---|
150 | | - | @Callable(t) |
---|
151 | | - | func entryEnded () = { |
---|
152 | | - | func z (A,B) = { |
---|
153 | | - | let C = invoke(this, "endedBoostings", [B], nil) |
---|
154 | | - | if ((C == C)) |
---|
155 | | - | then C |
---|
156 | | - | else throw("Strict value is not equal to itself.") |
---|
157 | | - | } |
---|
158 | | - | |
---|
159 | | - | let L = { |
---|
160 | | - | let E = a |
---|
161 | | - | let F = size(E) |
---|
162 | | - | let G = 0 |
---|
163 | | - | func H (I,J) = if ((J >= F)) |
---|
164 | | - | then I |
---|
165 | | - | else z(I, E[J]) |
---|
166 | | - | |
---|
167 | | - | func K (I,J) = if ((J >= F)) |
---|
168 | | - | then I |
---|
169 | | - | else throw("List size exceeds 56") |
---|
170 | | - | |
---|
171 | | - | K(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(G, 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) |
---|
172 | | - | } |
---|
173 | | - | if ((L == L)) |
---|
174 | | - | then [IntegerEntry("height", height)] |
---|
175 | | - | else throw("Strict value is not equal to itself.") |
---|
176 | | - | } |
---|
177 | | - | |
---|
178 | | - | |
---|
179 | | - | |
---|
180 | | - | @Callable(t) |
---|
181 | | - | func firstEndedBoostingId () = { |
---|
182 | | - | func M (A,B) = (A :+ parseIntValue(B)) |
---|
183 | | - | |
---|
184 | | - | let N = dropRight(h((("list ended " + toString(height)) + " boostingIds")), 1) |
---|
185 | | - | let O = { |
---|
186 | | - | let E = split(N, ",") |
---|
187 | | - | let F = size(E) |
---|
188 | | - | let G = nil |
---|
189 | | - | func H (I,J) = if ((J >= F)) |
---|
190 | | - | then I |
---|
191 | | - | else M(I, E[J]) |
---|
192 | | - | |
---|
193 | | - | func K (I,J) = if ((J >= F)) |
---|
194 | | - | then I |
---|
195 | | - | else throw("List size exceeds 56") |
---|
196 | | - | |
---|
197 | | - | K(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(H(G, 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) |
---|
198 | | - | } |
---|
199 | | - | let P = O[0] |
---|
200 | | - | [IntegerEntry("first", P)] |
---|
201 | | - | } |
---|
| 41 | + | @Callable(m) |
---|
| 42 | + | func lotto () = g(m) |
---|