2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let a = base58'3My61WhRb1HXJdhjbwkGx66hQQyQN8XZ31d' |
---|
5 | | - | |
---|
6 | | - | let b = extract(addressFromString("3MxuiJsRszpfZBJLHioGA3mhwdvMNtfjyCA")) |
---|
7 | | - | |
---|
8 | | - | let c = base58'G4TXfW45zGD3SQBq1vuhM9iw1zun3w32WquiYHkJUuMa' |
---|
9 | | - | |
---|
10 | | - | let d = 1000 |
---|
11 | | - | |
---|
12 | | - | let e = pow(10, 0, 8, 0, 0, Up()) |
---|
13 | | - | |
---|
14 | | - | let f = 1000000000000 |
---|
15 | | - | |
---|
16 | | - | let g = 10 |
---|
17 | | - | |
---|
18 | | - | let h = 10000000000000000 |
---|
19 | | - | |
---|
20 | | - | let i = 1563271860 |
---|
21 | | - | |
---|
22 | | - | let j = 1609395060 |
---|
23 | | - | |
---|
24 | | - | let k = pow(10, 0, 8, 0, 0, Up()) |
---|
25 | | - | |
---|
26 | | - | func l (m) = { |
---|
27 | | - | let n = toBase58String(m) |
---|
28 | | - | let o = toBase58String(a) |
---|
29 | | - | if ((n != o)) |
---|
30 | | - | then false |
---|
31 | | - | else true |
---|
32 | | - | } |
---|
33 | | - | |
---|
34 | | - | |
---|
35 | | - | func p () = { |
---|
36 | | - | let q = getInteger(this, "startTime") |
---|
37 | | - | let r = q |
---|
38 | | - | if ($isInstanceOf(r, "Int")) |
---|
39 | | - | then { |
---|
40 | | - | let s = r |
---|
41 | | - | s |
---|
42 | | - | } |
---|
43 | | - | else if ($isInstanceOf(r, "Unit")) |
---|
44 | | - | then { |
---|
45 | | - | let t = r |
---|
46 | | - | i |
---|
47 | | - | } |
---|
48 | | - | else throw() |
---|
49 | | - | } |
---|
50 | | - | |
---|
51 | | - | |
---|
52 | | - | func u () = { |
---|
53 | | - | let v = getInteger(this, "endTime") |
---|
54 | | - | let r = v |
---|
55 | | - | if ($isInstanceOf(r, "Int")) |
---|
56 | | - | then { |
---|
57 | | - | let w = r |
---|
58 | | - | w |
---|
59 | | - | } |
---|
60 | | - | else if ($isInstanceOf(r, "Unit")) |
---|
61 | | - | then { |
---|
62 | | - | let t = r |
---|
63 | | - | j |
---|
64 | | - | } |
---|
65 | | - | else throw() |
---|
66 | | - | } |
---|
67 | | - | |
---|
68 | | - | |
---|
69 | | - | func x () = { |
---|
70 | | - | let q = getInteger(this, "startTime") |
---|
71 | | - | let y = p() |
---|
72 | | - | let z = value(blockInfoByHeight(height)) |
---|
73 | | - | let A = z.timestamp |
---|
74 | | - | if ((A > y)) |
---|
75 | | - | then true |
---|
76 | | - | else false |
---|
77 | | - | } |
---|
78 | | - | |
---|
79 | | - | |
---|
80 | | - | func B () = { |
---|
81 | | - | let v = getInteger(this, "endTime") |
---|
82 | | - | let C = u() |
---|
83 | | - | let z = value(blockInfoByHeight(height)) |
---|
84 | | - | let A = z.timestamp |
---|
85 | | - | if ((A > C)) |
---|
86 | | - | then true |
---|
87 | | - | else false |
---|
88 | | - | } |
---|
89 | | - | |
---|
90 | | - | |
---|
91 | | - | func D () = { |
---|
92 | | - | let E = getBoolean(this, "finalized") |
---|
93 | | - | let r = E |
---|
94 | | - | if ($isInstanceOf(r, "Boolean")) |
---|
95 | | - | then { |
---|
96 | | - | let F = r |
---|
97 | | - | F |
---|
98 | | - | } |
---|
99 | | - | else if ($isInstanceOf(r, "Unit")) |
---|
100 | | - | then { |
---|
101 | | - | let G = r |
---|
102 | | - | false |
---|
103 | | - | } |
---|
104 | | - | else throw() |
---|
105 | | - | } |
---|
106 | | - | |
---|
107 | | - | |
---|
108 | | - | func H () = { |
---|
109 | | - | let I = getInteger(this, "wavesRaised") |
---|
110 | | - | let r = I |
---|
111 | | - | if ($isInstanceOf(r, "Int")) |
---|
112 | | - | then { |
---|
113 | | - | let J = r |
---|
114 | | - | J |
---|
115 | | - | } |
---|
116 | | - | else if ($isInstanceOf(r, "Unit")) |
---|
117 | | - | then { |
---|
118 | | - | let K = r |
---|
119 | | - | 0 |
---|
120 | | - | } |
---|
121 | | - | else throw() |
---|
122 | | - | } |
---|
123 | | - | |
---|
124 | | - | |
---|
125 | | - | func L (M,N) = { |
---|
126 | | - | let O = ("whitelistedInvestors-" + toString(N)) |
---|
127 | | - | let P = getString(this, O) |
---|
128 | | - | let r = P |
---|
129 | | - | if ($isInstanceOf(r, "String")) |
---|
130 | | - | then { |
---|
131 | | - | let Q = r |
---|
132 | | - | let R = indexOf(Q, M) |
---|
133 | | - | let S = R |
---|
134 | | - | if ($isInstanceOf(S, "Int")) |
---|
135 | | - | then { |
---|
136 | | - | let T = S |
---|
137 | | - | true |
---|
138 | | - | } |
---|
139 | | - | else if ($isInstanceOf(S, "Unit")) |
---|
140 | | - | then { |
---|
141 | | - | let U = S |
---|
142 | | - | false |
---|
143 | | - | } |
---|
144 | | - | else throw() |
---|
145 | | - | } |
---|
146 | | - | else if ($isInstanceOf(r, "Unit")) |
---|
147 | | - | then { |
---|
148 | | - | let V = r |
---|
149 | | - | false |
---|
150 | | - | } |
---|
151 | | - | else throw() |
---|
152 | | - | } |
---|
153 | | - | |
---|
154 | | - | |
---|
155 | | - | func W (M) = if (L(M, 0)) |
---|
156 | | - | then true |
---|
157 | | - | else if (L(M, 1)) |
---|
158 | | - | then true |
---|
159 | | - | else if (L(M, 2)) |
---|
160 | | - | then true |
---|
161 | | - | else if (L(M, 3)) |
---|
162 | | - | then true |
---|
163 | | - | else if (L(M, 4)) |
---|
164 | | - | then true |
---|
165 | | - | else if (L(M, 5)) |
---|
166 | | - | then true |
---|
167 | | - | else if (L(M, 6)) |
---|
168 | | - | then true |
---|
169 | | - | else if (L(M, 7)) |
---|
170 | | - | then true |
---|
171 | | - | else if (L(M, 8)) |
---|
172 | | - | then true |
---|
173 | | - | else if (L(M, 9)) |
---|
174 | | - | then true |
---|
175 | | - | else false |
---|
176 | | - | |
---|
177 | | - | |
---|
178 | | - | func X () = { |
---|
179 | | - | let Y = getInteger(this, "minInvestment") |
---|
180 | | - | let r = Y |
---|
181 | | - | if ($isInstanceOf(r, "Int")) |
---|
182 | | - | then { |
---|
183 | | - | let Z = r |
---|
184 | | - | Z |
---|
185 | | - | } |
---|
186 | | - | else if ($isInstanceOf(r, "Unit")) |
---|
187 | | - | then { |
---|
188 | | - | let t = r |
---|
189 | | - | g |
---|
190 | | - | } |
---|
191 | | - | else throw() |
---|
192 | | - | } |
---|
193 | | - | |
---|
194 | | - | |
---|
195 | | - | func aa () = { |
---|
196 | | - | let ab = getInteger(this, "maxInvestment") |
---|
197 | | - | let r = ab |
---|
198 | | - | if ($isInstanceOf(r, "Int")) |
---|
199 | | - | then { |
---|
200 | | - | let ac = r |
---|
201 | | - | ac |
---|
202 | | - | } |
---|
203 | | - | else if ($isInstanceOf(r, "Unit")) |
---|
204 | | - | then { |
---|
205 | | - | let t = r |
---|
206 | | - | h |
---|
207 | | - | } |
---|
208 | | - | else throw() |
---|
209 | | - | } |
---|
210 | | - | |
---|
211 | | - | |
---|
212 | | - | @Callable(ad) |
---|
213 | | - | func buyTokens () = { |
---|
214 | | - | let ae = toBase58String(ad.caller.bytes) |
---|
215 | | - | if (!(W(ae))) |
---|
216 | | - | then throw("Only for whitelisted") |
---|
217 | | - | else { |
---|
218 | | - | let af = extract(ad.payment).amount |
---|
219 | | - | if ((0 >= af)) |
---|
220 | | - | then throw("Cannot accept zero value payments") |
---|
221 | | - | else if ((X() > af)) |
---|
222 | | - | then throw("Attached payment is below minimal price") |
---|
223 | | - | else if ((af > aa())) |
---|
224 | | - | then throw("Attached payment is above maximum price") |
---|
225 | | - | else if (!(x())) |
---|
226 | | - | then throw("STO time is not started yet") |
---|
227 | | - | else if (B()) |
---|
228 | | - | then throw("STO time is already ended") |
---|
229 | | - | else if (D()) |
---|
230 | | - | then throw("STO is finalized") |
---|
231 | | - | else { |
---|
232 | | - | let I = H() |
---|
233 | | - | let ag = (k / e) |
---|
234 | | - | let ah = ((f / d) * ag) |
---|
235 | | - | let ai = (I + af) |
---|
236 | | - | if ((ai > ah)) |
---|
237 | | - | then throw("Attached payment overflows hardcap") |
---|
238 | | - | else { |
---|
239 | | - | let aj = (af * d) |
---|
240 | | - | if ((ag > aj)) |
---|
241 | | - | then throw("Attached payment is too low to buy unit of token") |
---|
242 | | - | else { |
---|
243 | | - | let ak = (aj / ag) |
---|
244 | | - | ScriptResult(WriteSet([DataEntry("wavesRaised", ai)]), TransferSet([ScriptTransfer(b, af, unit), ScriptTransfer(ad.caller, ak, c)])) |
---|
245 | | - | } |
---|
246 | | - | } |
---|
247 | | - | } |
---|
248 | | - | } |
---|
249 | | - | } |
---|
250 | | - | |
---|
251 | | - | |
---|
252 | | - | |
---|
253 | | - | @Callable(ad) |
---|
254 | | - | func finalize () = if (!(l(ad.caller.bytes))) |
---|
255 | | - | then throw("Only for administration") |
---|
256 | | - | else if (D()) |
---|
257 | | - | then throw("Already finalized") |
---|
258 | | - | else if (B()) |
---|
259 | | - | then WriteSet([DataEntry("finalized", true)]) |
---|
260 | | - | else throw("STO not finished yet") |
---|
261 | | - | |
---|
262 | | - | |
---|
263 | | - | |
---|
264 | | - | @Callable(ad) |
---|
265 | | - | func setStartTime (al) = if (!(l(ad.caller.bytes))) |
---|
266 | | - | then throw("Only for administration") |
---|
267 | | - | else { |
---|
268 | | - | let am = u() |
---|
269 | | - | if ((al > am)) |
---|
270 | | - | then throw("Start date must be lower than end date") |
---|
271 | | - | else WriteSet([DataEntry("startTime", al)]) |
---|
272 | | - | } |
---|
273 | | - | |
---|
274 | | - | |
---|
275 | | - | |
---|
276 | | - | @Callable(ad) |
---|
277 | | - | func setEndTime (an) = if (!(l(ad.caller.bytes))) |
---|
278 | | - | then throw("Only for administration") |
---|
279 | | - | else { |
---|
280 | | - | let ao = p() |
---|
281 | | - | if ((an > ao)) |
---|
282 | | - | then throw("End date must be higher than start date") |
---|
283 | | - | else WriteSet([DataEntry("endTime", an)]) |
---|
284 | | - | } |
---|
285 | | - | |
---|
286 | | - | |
---|
287 | | - | |
---|
288 | | - | @Callable(ad) |
---|
289 | | - | func setStartAndEndTimes (al,an) = if (!(l(ad.caller.bytes))) |
---|
290 | | - | then throw("Only for administration") |
---|
291 | | - | else { |
---|
292 | | - | let z = value(blockInfoByHeight(height)) |
---|
293 | | - | let A = z.timestamp |
---|
294 | | - | if ((A >= an)) |
---|
295 | | - | then throw("Cannot set time to past") |
---|
296 | | - | else WriteSet([DataEntry("startTime", al), DataEntry("endTime", an)]) |
---|
297 | | - | } |
---|
298 | | - | |
---|
299 | | - | |
---|
300 | | - | |
---|
301 | | - | @Callable(ad) |
---|
302 | | - | func setMinInvestment (ap) = if (!(l(ad.caller.bytes))) |
---|
303 | | - | then throw("Only for administration") |
---|
304 | | - | else WriteSet([DataEntry("minInvestment", ap)]) |
---|
305 | | - | |
---|
306 | | - | |
---|
307 | | - | |
---|
308 | | - | @Callable(ad) |
---|
309 | | - | func setMaxInvestment (ap) = if (!(l(ad.caller.bytes))) |
---|
310 | | - | then throw("Only for administration") |
---|
311 | | - | else WriteSet([DataEntry("maxInvestment", ap)]) |
---|
312 | | - | |
---|
313 | | - | |
---|
314 | | - | |
---|
315 | | - | @Callable(ad) |
---|
316 | | - | func setWhitelistAddresses (aq) = if (!(l(ad.caller.bytes))) |
---|
317 | | - | then throw("Only for administration") |
---|
318 | | - | else { |
---|
319 | | - | let ar = split(aq, ",") |
---|
320 | | - | let as = size(ar) |
---|
321 | | - | let at = "whitelistedInvestors" |
---|
322 | | - | let au = "totalInvestors" |
---|
323 | | - | let av = "currentWhitelistPage" |
---|
324 | | - | let aw = "currentWhitelistPageSize" |
---|
325 | | - | let ax = getInteger(this, au) |
---|
326 | | - | let r = ax |
---|
327 | | - | if ($isInstanceOf(r, "Int")) |
---|
328 | | - | then { |
---|
329 | | - | let ay = r |
---|
330 | | - | let az = getIntegerValue(this, av) |
---|
331 | | - | let aA = getIntegerValue(this, aw) |
---|
332 | | - | let aB = ((at + "-") + toString(az)) |
---|
333 | | - | let aC = getStringValue(this, aB) |
---|
334 | | - | let aD = (100 - aA) |
---|
335 | | - | if (if ((aD >= as)) |
---|
336 | | - | then (aD > 0) |
---|
337 | | - | else false) |
---|
338 | | - | then { |
---|
339 | | - | let aE = ((aC + ",") + aq) |
---|
340 | | - | let aF = (aA + as) |
---|
341 | | - | let aG = (ay + as) |
---|
342 | | - | WriteSet([DataEntry(au, aG), DataEntry(aw, aF), DataEntry(aB, aE)]) |
---|
343 | | - | } |
---|
344 | | - | else { |
---|
345 | | - | let aH = (az + 1) |
---|
346 | | - | let aG = (ay + as) |
---|
347 | | - | let aI = as |
---|
348 | | - | let aJ = ((at + "-") + toString(aH)) |
---|
349 | | - | WriteSet([DataEntry(au, aG), DataEntry(av, aH), DataEntry(aw, aI), DataEntry(aJ, aq)]) |
---|
350 | | - | } |
---|
351 | | - | } |
---|
352 | | - | else if ($isInstanceOf(r, "Unit")) |
---|
353 | | - | then { |
---|
354 | | - | let aK = r |
---|
355 | | - | let aL = 0 |
---|
356 | | - | let aM = ((at + "-") + toString(aL)) |
---|
357 | | - | WriteSet([DataEntry(au, as), DataEntry(av, aL), DataEntry(aw, as), DataEntry(aM, aq)]) |
---|
358 | | - | } |
---|
359 | | - | else throw() |
---|
360 | | - | } |
---|
361 | | - | |
---|
362 | | - | |
---|
363 | | - | @Verifier(aN) |
---|
364 | | - | func aO () = true |
---|
365 | | - | |
---|
| 2 | + | {-# CONTENT_TYPE EXPRESSION #-} |
---|
| 3 | + | let PubKey1 = base58'854p8BYzrj6yBPRPmfQur3oF1Rjc1AJ548qRp5FT5kDa' |
---|
| 4 | + | let PubKey2 = base58'DKGFPozLrsiR8NM4NJzqQaBYC8NyGYjuw2hDYicQVjco' |
---|
| 5 | + | let sig1 = if (sigVerify(tx.bodyBytes, tx.proofs[0], PubKey1)) |
---|
| 6 | + | then 1 |
---|
| 7 | + | else 0 |
---|
| 8 | + | let sig2 = if (sigVerify(tx.bodyBytes, tx.proofs[1], PubKey2)) |
---|
| 9 | + | then 1 |
---|
| 10 | + | else 0 |
---|
| 11 | + | ((sig1 + sig2) > 0) |
---|