1 | | - | {-# STDLIB_VERSION 5 #-} |
---|
2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let a = "__" |
---|
5 | | - | |
---|
6 | | - | let b = "WAVES" |
---|
7 | | - | |
---|
8 | | - | let c = "Invalid price asset" |
---|
9 | | - | |
---|
10 | | - | func d (e) = throw(makeString(["user_pools.ride:", e], " ")) |
---|
11 | | - | |
---|
12 | | - | |
---|
13 | | - | func f () = d("Permission denied") |
---|
14 | | - | |
---|
15 | | - | |
---|
16 | | - | func g () = d("Create is not called for assets pair") |
---|
17 | | - | |
---|
18 | | - | |
---|
19 | | - | func h () = d("You are not amountAsset issuer") |
---|
20 | | - | |
---|
21 | | - | |
---|
22 | | - | func i () = d("Pool with such assets already exists") |
---|
23 | | - | |
---|
24 | | - | |
---|
25 | | - | func j () = d("Asset is not verified") |
---|
26 | | - | |
---|
27 | | - | |
---|
28 | | - | func k () = d(c) |
---|
29 | | - | |
---|
30 | | - | |
---|
31 | | - | func l () = d("Invalid fee asset") |
---|
32 | | - | |
---|
33 | | - | |
---|
34 | | - | func m () = d("Invalid amount asset attached") |
---|
35 | | - | |
---|
36 | | - | |
---|
37 | | - | func n () = d("Invalid status") |
---|
38 | | - | |
---|
39 | | - | |
---|
40 | | - | func o () = d("Can activate pool only in 'pending' status") |
---|
41 | | - | |
---|
42 | | - | |
---|
43 | | - | func p () = d("FactoryV2 returned not string") |
---|
44 | | - | |
---|
45 | | - | |
---|
46 | | - | func q () = d("invalid price asset amount") |
---|
47 | | - | |
---|
48 | | - | |
---|
49 | | - | func r () = d("invalid fee") |
---|
50 | | - | |
---|
51 | | - | |
---|
52 | | - | func s () = makeString(["%s", "managerPublicKey"], a) |
---|
53 | | - | |
---|
54 | | - | |
---|
55 | | - | func t () = makeString(["%s", "pendingManagerPublicKey"], a) |
---|
56 | | - | |
---|
57 | | - | |
---|
58 | | - | func u () = makeString(["%s", "adminPubKeys"], a) |
---|
59 | | - | |
---|
60 | | - | |
---|
61 | | - | func v (w,x) = makeString(["%s%s%s", "status", w, x], a) |
---|
62 | | - | |
---|
63 | | - | |
---|
64 | | - | func y () = makeString(["%s", "factoryContract"], a) |
---|
65 | | - | |
---|
66 | | - | |
---|
67 | | - | func z () = makeString(["%s", "assetsStoreContract"], a) |
---|
68 | | - | |
---|
69 | | - | |
---|
70 | | - | func A () = makeString(["%s", "emissionContract"], a) |
---|
71 | | - | |
---|
72 | | - | |
---|
73 | | - | func B (w,x) = makeString(["%s%s%s", "suffix", w, x], a) |
---|
74 | | - | |
---|
75 | | - | |
---|
76 | | - | func C () = makeString(["%s", "lastIndex"], a) |
---|
77 | | - | |
---|
78 | | - | |
---|
79 | | - | let D = "u" |
---|
80 | | - | |
---|
81 | | - | let E = "pending" |
---|
82 | | - | |
---|
83 | | - | let F = "declined" |
---|
84 | | - | |
---|
85 | | - | let G = "active" |
---|
86 | | - | |
---|
87 | | - | let H = [E, F, G] |
---|
88 | | - | |
---|
89 | | - | func I (w,x) = makeString(["%s%s%s", "createCalled", w, x], a) |
---|
90 | | - | |
---|
91 | | - | |
---|
92 | | - | func J (w,x) = makeString(["%s%s%s", "createCaller", w, x], a) |
---|
93 | | - | |
---|
94 | | - | |
---|
95 | | - | func K (w,x) = makeString(["%s%s%s", "amountAssetAmount", w, x], a) |
---|
96 | | - | |
---|
97 | | - | |
---|
98 | | - | func L (w,x) = makeString(["%s%s%s", "priceAssetAmount", w, x], a) |
---|
99 | | - | |
---|
100 | | - | |
---|
101 | | - | func M (w,x) = makeString(["%s%s%s", "height", w, x], a) |
---|
102 | | - | |
---|
103 | | - | |
---|
104 | | - | func N () = makeString(["%s", "feeAssetId"], a) |
---|
105 | | - | |
---|
106 | | - | |
---|
107 | | - | func O () = makeString(["%s", "feeAmount"], a) |
---|
108 | | - | |
---|
109 | | - | |
---|
110 | | - | func P () = makeString(["%s", "amountAssetMinAmount"], a) |
---|
111 | | - | |
---|
112 | | - | |
---|
113 | | - | func Q () = makeString(["%s", "priceAssetsMinAmount"], a) |
---|
114 | | - | |
---|
115 | | - | |
---|
116 | | - | func R () = makeString(["%s", "priceAssets"], a) |
---|
117 | | - | |
---|
118 | | - | |
---|
119 | | - | func S (T) = valueOrErrorMessage(getString(this, T), (T + " is not defined")) |
---|
120 | | - | |
---|
121 | | - | |
---|
122 | | - | func U (V) = { |
---|
123 | | - | let W = V |
---|
124 | | - | if ($isInstanceOf(W, "String")) |
---|
125 | | - | then { |
---|
126 | | - | let X = W |
---|
127 | | - | if ((size(X) == 0)) |
---|
128 | | - | then nil |
---|
129 | | - | else split(X, a) |
---|
130 | | - | } |
---|
131 | | - | else if ($isInstanceOf(W, "Unit")) |
---|
132 | | - | then nil |
---|
133 | | - | else throw("Match error") |
---|
134 | | - | } |
---|
135 | | - | |
---|
136 | | - | |
---|
137 | | - | let Y = addressFromStringValue(S(y())) |
---|
138 | | - | |
---|
139 | | - | func Z (w,x) = valueOrElse(getBoolean(I(w, x)), false) |
---|
140 | | - | |
---|
141 | | - | |
---|
142 | | - | func aa (w,x) = if (Z(w, x)) |
---|
143 | | - | then true |
---|
144 | | - | else g() |
---|
145 | | - | |
---|
146 | | - | |
---|
147 | | - | func ab () = { |
---|
148 | | - | let W = getString(s()) |
---|
149 | | - | if ($isInstanceOf(W, "String")) |
---|
150 | | - | then { |
---|
151 | | - | let X = W |
---|
152 | | - | fromBase58String(X) |
---|
153 | | - | } |
---|
154 | | - | else if ($isInstanceOf(W, "Unit")) |
---|
155 | | - | then unit |
---|
156 | | - | else throw("Match error") |
---|
157 | | - | } |
---|
158 | | - | |
---|
159 | | - | |
---|
160 | | - | func ac () = { |
---|
161 | | - | let W = getString(t()) |
---|
162 | | - | if ($isInstanceOf(W, "String")) |
---|
163 | | - | then { |
---|
164 | | - | let X = W |
---|
165 | | - | fromBase58String(X) |
---|
166 | | - | } |
---|
167 | | - | else if ($isInstanceOf(W, "Unit")) |
---|
168 | | - | then unit |
---|
169 | | - | else throw("Match error") |
---|
170 | | - | } |
---|
171 | | - | |
---|
172 | | - | |
---|
173 | | - | func ad (ae) = { |
---|
174 | | - | let W = ab() |
---|
175 | | - | if ($isInstanceOf(W, "ByteVector")) |
---|
176 | | - | then { |
---|
177 | | - | let af = W |
---|
178 | | - | (ae.callerPublicKey == af) |
---|
179 | | - | } |
---|
180 | | - | else if ($isInstanceOf(W, "Unit")) |
---|
181 | | - | then (ae.caller == this) |
---|
182 | | - | else throw("Match error") |
---|
183 | | - | } |
---|
184 | | - | |
---|
185 | | - | |
---|
186 | | - | func ag (ae) = if (ad(ae)) |
---|
187 | | - | then true |
---|
188 | | - | else f() |
---|
189 | | - | |
---|
190 | | - | |
---|
191 | | - | func ah (ae) = { |
---|
192 | | - | let ai = U(getString(u())) |
---|
193 | | - | if (containsElement(ai, toBase58String(ae.callerPublicKey))) |
---|
194 | | - | then true |
---|
195 | | - | else ag(ae) |
---|
196 | | - | } |
---|
197 | | - | |
---|
198 | | - | |
---|
199 | | - | func aj (ak) = (valueOrElse(getInteger(addressFromStringValue(S(z())), (("status_<" + ak) + ">")), 0) == 2) |
---|
200 | | - | |
---|
201 | | - | |
---|
202 | | - | func al (am) = { |
---|
203 | | - | let W = am.assetId |
---|
204 | | - | if ($isInstanceOf(W, "ByteVector")) |
---|
205 | | - | then { |
---|
206 | | - | let an = W |
---|
207 | | - | let ao = value(assetInfo(an)) |
---|
208 | | - | $Tuple2(toBase58String(an), ao) |
---|
209 | | - | } |
---|
210 | | - | else if ($isInstanceOf(W, "Unit")) |
---|
211 | | - | then $Tuple2(b, unit) |
---|
212 | | - | else throw("Match error") |
---|
213 | | - | } |
---|
214 | | - | |
---|
215 | | - | |
---|
216 | | - | func ap (aq) = containsElement(H, aq) |
---|
217 | | - | |
---|
218 | | - | |
---|
219 | | - | @Callable(ae) |
---|
220 | | - | func constructor (ar,as,at,au,av,aw,ax) = { |
---|
221 | | - | let ay = ag(ae) |
---|
222 | | - | if ((ay == ay)) |
---|
223 | | - | then [StringEntry(y(), ar), StringEntry(z(), as), StringEntry(A(), at), StringEntry(Q(), makeString(au, a)), IntegerEntry(P(), av), StringEntry(N(), aw), IntegerEntry(O(), ax)] |
---|
224 | | - | else throw("Strict value is not equal to itself.") |
---|
225 | | - | } |
---|
226 | | - | |
---|
227 | | - | |
---|
228 | | - | |
---|
229 | | - | @Callable(ae) |
---|
230 | | - | func create () = { |
---|
231 | | - | let az = value(ae.payments[0]) |
---|
232 | | - | let aA = value(ae.payments[1]) |
---|
233 | | - | let aB = value(ae.payments[2]) |
---|
234 | | - | let aC = al(az) |
---|
235 | | - | let w = aC._1 |
---|
236 | | - | let aD = aC._2 |
---|
237 | | - | let aE = al(aA) |
---|
238 | | - | let x = aE._1 |
---|
239 | | - | let aF = aE._2 |
---|
240 | | - | let aG = al(aB) |
---|
241 | | - | let aw = aG._1 |
---|
242 | | - | let aH = aG._2 |
---|
243 | | - | let aI = U(getString(Y, R())) |
---|
244 | | - | let aJ = 1 |
---|
245 | | - | let aK = if (ad(ae)) |
---|
246 | | - | then aJ |
---|
247 | | - | else { |
---|
248 | | - | let aL = valueOrErrorMessage(indexOf(aI, x), c) |
---|
249 | | - | value(parseInt(U(getString(Q()))[aL])) |
---|
250 | | - | } |
---|
251 | | - | let aM = valueOrElse(getInteger(C()), 0) |
---|
252 | | - | let aN = (aM + 1) |
---|
253 | | - | let aO = addressFromStringValue(S(A())) |
---|
254 | | - | let aP = { |
---|
255 | | - | let aQ = invoke(Y, "poolExistsREADONLY", [w, x], nil) |
---|
256 | | - | if ($isInstanceOf(aQ, "Boolean")) |
---|
257 | | - | then aQ |
---|
258 | | - | else throw("Couldn't cast Any to Boolean") |
---|
259 | | - | } |
---|
260 | | - | let aR = [if (!(Z(w, x))) |
---|
261 | | - | then true |
---|
262 | | - | else i(), if (!(aP)) |
---|
263 | | - | then true |
---|
264 | | - | else i(), if (if (ad(ae)) |
---|
265 | | - | then true |
---|
266 | | - | else aj(w)) |
---|
267 | | - | then true |
---|
268 | | - | else j(), if ((getString(N()) == aw)) |
---|
269 | | - | then true |
---|
270 | | - | else l(), if (if (ad(ae)) |
---|
271 | | - | then true |
---|
272 | | - | else (az.amount >= getIntegerValue(P()))) |
---|
273 | | - | then true |
---|
274 | | - | else m(), if (if (ad(ae)) |
---|
275 | | - | then true |
---|
276 | | - | else (aA.amount >= aK)) |
---|
277 | | - | then true |
---|
278 | | - | else q(), if ((aB.amount == getInteger(O()))) |
---|
279 | | - | then true |
---|
280 | | - | else r()] |
---|
281 | | - | if ((aR == aR)) |
---|
282 | | - | then { |
---|
283 | | - | let aS = invoke(aO, "burn", nil, [AttachedPayment(fromBase58String(aw), aB.amount)]) |
---|
284 | | - | if ((aS == aS)) |
---|
285 | | - | then [BooleanEntry(I(w, x), true), StringEntry(J(w, x), toString(ae.caller)), IntegerEntry(C(), aN), StringEntry(B(w, x), (toString(aN) + D)), IntegerEntry(M(w, x), height), StringEntry(v(w, x), E), IntegerEntry(K(w, x), az.amount), IntegerEntry(L(w, x), aA.amount)] |
---|
286 | | - | else throw("Strict value is not equal to itself.") |
---|
287 | | - | } |
---|
288 | | - | else throw("Strict value is not equal to itself.") |
---|
289 | | - | } |
---|
290 | | - | |
---|
291 | | - | |
---|
292 | | - | |
---|
293 | | - | @Callable(ae) |
---|
294 | | - | func activate (aT,w,aU,x,aV,aW) = { |
---|
295 | | - | let aR = [ah(ae), if (Z(w, x)) |
---|
296 | | - | then true |
---|
297 | | - | else g(), if ((value(getString(v(w, x))) == E)) |
---|
298 | | - | then true |
---|
299 | | - | else o()] |
---|
300 | | - | if ((aR == aR)) |
---|
301 | | - | then { |
---|
302 | | - | let aX = invoke(Y, "activateNewPool", [aT, w, x, ((aU + aV) + "LP"), (((aU + "/") + aV) + " pool liquidity provider token"), 0, "VLTPOOL", aW], nil) |
---|
303 | | - | if ((aX == aX)) |
---|
304 | | - | then { |
---|
305 | | - | let aY = { |
---|
306 | | - | let W = aX |
---|
307 | | - | if ($isInstanceOf(W, "String")) |
---|
308 | | - | then { |
---|
309 | | - | let an = W |
---|
310 | | - | an |
---|
311 | | - | } |
---|
312 | | - | else p() |
---|
313 | | - | } |
---|
314 | | - | if ((aY == aY)) |
---|
315 | | - | then { |
---|
316 | | - | let aZ = assetBalance(this, fromBase58String(aY)) |
---|
317 | | - | if ((aZ == aZ)) |
---|
318 | | - | then { |
---|
319 | | - | let ba = invoke(addressFromStringValue(aT), "put", [0, false], [AttachedPayment(if ((w == "WAVES")) |
---|
320 | | - | then unit |
---|
321 | | - | else fromBase58String(w), value(getInteger(K(w, x)))), AttachedPayment(if ((x == "WAVES")) |
---|
322 | | - | then unit |
---|
323 | | - | else fromBase58String(x), value(getInteger(L(w, x))))]) |
---|
324 | | - | if ((ba == ba)) |
---|
325 | | - | then { |
---|
326 | | - | let bb = assetBalance(this, fromBase58String(aY)) |
---|
327 | | - | if ((bb == bb)) |
---|
328 | | - | then { |
---|
329 | | - | let bc = value(addressFromString(value(getString(J(w, x))))) |
---|
330 | | - | [StringEntry(v(w, x), G), ScriptTransfer(bc, (bb - aZ), fromBase58String(aY))] |
---|
331 | | - | } |
---|
332 | | - | else throw("Strict value is not equal to itself.") |
---|
333 | | - | } |
---|
334 | | - | else throw("Strict value is not equal to itself.") |
---|
335 | | - | } |
---|
336 | | - | else throw("Strict value is not equal to itself.") |
---|
337 | | - | } |
---|
338 | | - | else throw("Strict value is not equal to itself.") |
---|
339 | | - | } |
---|
340 | | - | else throw("Strict value is not equal to itself.") |
---|
341 | | - | } |
---|
342 | | - | else throw("Strict value is not equal to itself.") |
---|
343 | | - | } |
---|
344 | | - | |
---|
345 | | - | |
---|
346 | | - | |
---|
347 | | - | @Callable(ae) |
---|
348 | | - | func setAdmins (bd) = { |
---|
349 | | - | let ay = ag(ae) |
---|
350 | | - | if ((ay == ay)) |
---|
351 | | - | then [StringEntry(u(), makeString(bd, a))] |
---|
352 | | - | else throw("Strict value is not equal to itself.") |
---|
353 | | - | } |
---|
354 | | - | |
---|
355 | | - | |
---|
356 | | - | |
---|
357 | | - | @Callable(ae) |
---|
358 | | - | func setManager (be) = { |
---|
359 | | - | let ay = ag(ae) |
---|
360 | | - | if ((ay == ay)) |
---|
361 | | - | then { |
---|
362 | | - | let bf = fromBase58String(be) |
---|
363 | | - | if ((bf == bf)) |
---|
364 | | - | then [StringEntry(t(), be)] |
---|
365 | | - | else throw("Strict value is not equal to itself.") |
---|
366 | | - | } |
---|
367 | | - | else throw("Strict value is not equal to itself.") |
---|
368 | | - | } |
---|
369 | | - | |
---|
370 | | - | |
---|
371 | | - | |
---|
372 | | - | @Callable(ae) |
---|
373 | | - | func confirmManager () = { |
---|
374 | | - | let bg = ac() |
---|
375 | | - | let bh = if (isDefined(bg)) |
---|
376 | | - | then true |
---|
377 | | - | else throw("No pending manager") |
---|
378 | | - | if ((bh == bh)) |
---|
379 | | - | then { |
---|
380 | | - | let bi = if ((ae.callerPublicKey == value(bg))) |
---|
381 | | - | then true |
---|
382 | | - | else throw("You are not pending manager") |
---|
383 | | - | if ((bi == bi)) |
---|
384 | | - | then [StringEntry(s(), toBase58String(value(bg))), DeleteEntry(t())] |
---|
385 | | - | else throw("Strict value is not equal to itself.") |
---|
386 | | - | } |
---|
387 | | - | else throw("Strict value is not equal to itself.") |
---|
388 | | - | } |
---|
389 | | - | |
---|
390 | | - | |
---|
391 | | - | |
---|
392 | | - | @Callable(ae) |
---|
393 | | - | func priceAssetsREADONLY () = $Tuple2(nil, U(getString(R()))) |
---|
394 | | - | |
---|
395 | | - | |
---|
396 | | - | |
---|
397 | | - | @Callable(ae) |
---|
398 | | - | func statusREADONLY (w,x) = { |
---|
399 | | - | let aq = { |
---|
400 | | - | let W = getString(v(w, x)) |
---|
401 | | - | if ($isInstanceOf(W, "String")) |
---|
402 | | - | then { |
---|
403 | | - | let X = W |
---|
404 | | - | X |
---|
405 | | - | } |
---|
406 | | - | else unit |
---|
407 | | - | } |
---|
408 | | - | $Tuple2(nil, aq) |
---|
409 | | - | } |
---|
410 | | - | |
---|
411 | | - | |
---|
412 | | - | @Verifier(bj) |
---|
413 | | - | func bk () = { |
---|
414 | | - | let bl = { |
---|
415 | | - | let W = ab() |
---|
416 | | - | if ($isInstanceOf(W, "ByteVector")) |
---|
417 | | - | then { |
---|
418 | | - | let af = W |
---|
419 | | - | af |
---|
420 | | - | } |
---|
421 | | - | else if ($isInstanceOf(W, "Unit")) |
---|
422 | | - | then bj.senderPublicKey |
---|
423 | | - | else throw("Match error") |
---|
424 | | - | } |
---|
425 | | - | sigVerify(bj.bodyBytes, bj.proofs[0], bl) |
---|
426 | | - | } |
---|
427 | | - | |
---|
| 1 | + | # no script |
---|