1 | | - | {-# STDLIB_VERSION 6 #-} |
---|
2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let a = "__" |
---|
5 | | - | |
---|
6 | | - | let b = 100000000 |
---|
7 | | - | |
---|
8 | | - | let c = 4 |
---|
9 | | - | |
---|
10 | | - | let d = 1 |
---|
11 | | - | |
---|
12 | | - | let e = 2 |
---|
13 | | - | |
---|
14 | | - | let f = 3 |
---|
15 | | - | |
---|
16 | | - | let g = 4 |
---|
17 | | - | |
---|
18 | | - | let h = 5 |
---|
19 | | - | |
---|
20 | | - | let i = 6 |
---|
21 | | - | |
---|
22 | | - | let j = 7 |
---|
23 | | - | |
---|
24 | | - | let k = 8 |
---|
25 | | - | |
---|
26 | | - | let l = 9 |
---|
27 | | - | |
---|
28 | | - | let m = 10 |
---|
29 | | - | |
---|
30 | | - | let n = 11 |
---|
31 | | - | |
---|
32 | | - | func o (p,q) = ((("%s%s%s__P__" + p) + "__") + q) |
---|
33 | | - | |
---|
34 | | - | |
---|
35 | | - | func r (p,q) = ((("%s%s%s__invest__" + p) + "__") + q) |
---|
36 | | - | |
---|
37 | | - | |
---|
38 | | - | func s (p,t) = ((("%s%s%s__total__" + p) + "__") + t) |
---|
39 | | - | |
---|
40 | | - | |
---|
41 | | - | func u () = "%s__factoryContract" |
---|
42 | | - | |
---|
43 | | - | |
---|
44 | | - | func v (p,t) = (((("%s%s%s__" + p) + "__") + t) + "__slippageCumulative") |
---|
45 | | - | |
---|
46 | | - | |
---|
47 | | - | func w () = "%s__factoryConfig" |
---|
48 | | - | |
---|
49 | | - | |
---|
50 | | - | func x (y) = (("%s%s%s__" + y) + "__mappings__poolContract2PoolAssets") |
---|
51 | | - | |
---|
52 | | - | |
---|
53 | | - | func z (A) = ("%s%s%d__mappings__internal2baseAssetId__" + toString(A)) |
---|
54 | | - | |
---|
55 | | - | |
---|
56 | | - | func B (C,D) = (((("%d%d%s__" + C) + "__") + D) + "__config") |
---|
57 | | - | |
---|
58 | | - | |
---|
59 | | - | func E () = "%s__shutdown" |
---|
60 | | - | |
---|
61 | | - | |
---|
62 | | - | func F (G) = ("%s%s__poolWeight__" + G) |
---|
63 | | - | |
---|
64 | | - | |
---|
65 | | - | func H () = "%s__managerPublicKey" |
---|
66 | | - | |
---|
67 | | - | |
---|
68 | | - | func I () = "%s__pendingManagerPublicKey" |
---|
69 | | - | |
---|
70 | | - | |
---|
71 | | - | let J = addressFromStringValue(valueOrErrorMessage(getString(this, u()), "No Factory Acc found.")) |
---|
72 | | - | |
---|
73 | | - | func K (t) = if (!(isDefined(t))) |
---|
74 | | - | then "WAVES" |
---|
75 | | - | else t |
---|
76 | | - | |
---|
77 | | - | |
---|
78 | | - | func L (M,N,O,P) = makeString(["%s%d%d%d", M, toString(N), toString(O), toString(P)], a) |
---|
79 | | - | |
---|
80 | | - | |
---|
81 | | - | func Q (R,S,O,P) = makeString(["%d%d%d%d", toString(R), toString(S), toString(O), toString(P)], a) |
---|
82 | | - | |
---|
83 | | - | |
---|
84 | | - | func T (U) = { |
---|
85 | | - | let V = U |
---|
86 | | - | if ($isInstanceOf(V, "String")) |
---|
87 | | - | then { |
---|
88 | | - | let W = V |
---|
89 | | - | W |
---|
90 | | - | } |
---|
91 | | - | else throw("fail to cast into String") |
---|
92 | | - | } |
---|
93 | | - | |
---|
94 | | - | |
---|
95 | | - | func X (Y,Z,aa) = fraction(Y, Z, aa) |
---|
96 | | - | |
---|
97 | | - | |
---|
98 | | - | func ab () = { |
---|
99 | | - | let V = getString(H()) |
---|
100 | | - | if ($isInstanceOf(V, "String")) |
---|
101 | | - | then { |
---|
102 | | - | let ac = V |
---|
103 | | - | fromBase58String(ac) |
---|
104 | | - | } |
---|
105 | | - | else if ($isInstanceOf(V, "Unit")) |
---|
106 | | - | then unit |
---|
107 | | - | else throw("Match error") |
---|
108 | | - | } |
---|
109 | | - | |
---|
110 | | - | |
---|
111 | | - | func ad () = { |
---|
112 | | - | let V = getString(I()) |
---|
113 | | - | if ($isInstanceOf(V, "String")) |
---|
114 | | - | then { |
---|
115 | | - | let ac = V |
---|
116 | | - | fromBase58String(ac) |
---|
117 | | - | } |
---|
118 | | - | else if ($isInstanceOf(V, "Unit")) |
---|
119 | | - | then unit |
---|
120 | | - | else throw("Match error") |
---|
121 | | - | } |
---|
122 | | - | |
---|
123 | | - | |
---|
124 | | - | func ae (af) = { |
---|
125 | | - | let ag = throw("Permission denied") |
---|
126 | | - | let V = ab() |
---|
127 | | - | if ($isInstanceOf(V, "ByteVector")) |
---|
128 | | - | then { |
---|
129 | | - | let ah = V |
---|
130 | | - | if ((af.callerPublicKey == ah)) |
---|
131 | | - | then true |
---|
132 | | - | else ag |
---|
133 | | - | } |
---|
134 | | - | else if ($isInstanceOf(V, "Unit")) |
---|
135 | | - | then if ((af.caller == this)) |
---|
136 | | - | then true |
---|
137 | | - | else ag |
---|
138 | | - | else throw("Match error") |
---|
139 | | - | } |
---|
140 | | - | |
---|
141 | | - | |
---|
142 | | - | @Callable(af) |
---|
143 | | - | func constructor (J) = { |
---|
144 | | - | let ai = ae(af) |
---|
145 | | - | if ((ai == ai)) |
---|
146 | | - | then [StringEntry(u(), J)] |
---|
147 | | - | else throw("Strict value is not equal to itself.") |
---|
148 | | - | } |
---|
149 | | - | |
---|
150 | | - | |
---|
151 | | - | |
---|
152 | | - | @Callable(af) |
---|
153 | | - | func put () = { |
---|
154 | | - | let aj = toString(af.caller) |
---|
155 | | - | let ak = value(af.payments[0]) |
---|
156 | | - | let al = if (!(isDefined(ak.assetId))) |
---|
157 | | - | then "WAVES" |
---|
158 | | - | else toBase58String(value(ak.assetId)) |
---|
159 | | - | let am = ak.amount |
---|
160 | | - | let an = split(valueOrErrorMessage(getString(J, x(aj)), "Invalid caller"), a) |
---|
161 | | - | let ao = parseIntValue(an[1]) |
---|
162 | | - | let ap = parseIntValue(an[2]) |
---|
163 | | - | let aq = valueOrErrorMessage(getString(J, z(ao)), "Cannot find asset") |
---|
164 | | - | let ar = valueOrErrorMessage(getString(J, z(ap)), "Cannot find asset") |
---|
165 | | - | let as = valueOrElse(getInteger(this, s(aj, al)), 0) |
---|
166 | | - | let at = valueOrElse(getInteger(this, v(aj, al)), 0) |
---|
167 | | - | [StringEntry(o(aj, toBase58String(af.transactionId)), L(al, am, height, lastBlock.timestamp)), IntegerEntry(s(aj, al), (as + am)), IntegerEntry(v(aj, al), (at + am))] |
---|
168 | | - | } |
---|
169 | | - | |
---|
170 | | - | |
---|
171 | | - | |
---|
172 | | - | @Callable(af) |
---|
173 | | - | func invest (au) = { |
---|
174 | | - | let p = valueOrErrorMessage(addressFromString(au), "invalid pool address") |
---|
175 | | - | let an = split(valueOrErrorMessage(getString(J, x(au)), "Invalid pool passed."), a) |
---|
176 | | - | let av = valueOrErrorMessage(getString(J, z(parseIntValue(an[1]))), "No asset mapping found") |
---|
177 | | - | let aw = valueOrErrorMessage(getString(J, z(parseIntValue(an[2]))), "No asset mapping found") |
---|
178 | | - | let ax = valueOrElse(getInteger(this, s(au, av)), 0) |
---|
179 | | - | let ay = valueOrElse(getInteger(this, s(au, aw)), 0) |
---|
180 | | - | let az = invoke(p, "evaluatePutByPriceAssetREADONLY", [ay], nil) |
---|
181 | | - | let aA = invoke(p, "evaluatePutByAmountAssetREADONLY", [ax], nil) |
---|
182 | | - | let aB = 7 |
---|
183 | | - | let aC = 8 |
---|
184 | | - | let aD = valueOrErrorMessage(parseIntValue(split(T(az), a)[aB]), "fail to parse estimated amAsset amount") |
---|
185 | | - | let aE = valueOrErrorMessage(parseIntValue(split(T(aA), a)[aC]), "fail to parse estimated prAsset amount") |
---|
186 | | - | let aF = if ((ax >= aD)) |
---|
187 | | - | then $Tuple2(aD, ay) |
---|
188 | | - | else $Tuple2(ax, aE) |
---|
189 | | - | let aG = aF._1 |
---|
190 | | - | let aH = aF._2 |
---|
191 | | - | let aI = if ((av == "WAVES")) |
---|
192 | | - | then unit |
---|
193 | | - | else fromBase58String(av) |
---|
194 | | - | let aJ = if ((aw == "WAVES")) |
---|
195 | | - | then unit |
---|
196 | | - | else fromBase58String(aw) |
---|
197 | | - | let aK = invoke(p, "putForFree", [1000], [AttachedPayment(aI, aG), AttachedPayment(aJ, aH)]) |
---|
198 | | - | if ((aK == aK)) |
---|
199 | | - | then [StringEntry(r(au, toBase58String(af.transactionId)), Q(aG, aH, height, lastBlock.timestamp)), IntegerEntry(s(au, av), (ax - aG)), IntegerEntry(s(au, aw), (ay - aH))] |
---|
200 | | - | else throw("Strict value is not equal to itself.") |
---|
201 | | - | } |
---|
202 | | - | |
---|
203 | | - | |
---|
204 | | - | |
---|
205 | | - | @Callable(af) |
---|
206 | | - | func setManager (aL) = { |
---|
207 | | - | let ai = ae(af) |
---|
208 | | - | if ((ai == ai)) |
---|
209 | | - | then { |
---|
210 | | - | let aM = fromBase58String(aL) |
---|
211 | | - | if ((aM == aM)) |
---|
212 | | - | then [StringEntry(I(), aL)] |
---|
213 | | - | else throw("Strict value is not equal to itself.") |
---|
214 | | - | } |
---|
215 | | - | else throw("Strict value is not equal to itself.") |
---|
216 | | - | } |
---|
217 | | - | |
---|
218 | | - | |
---|
219 | | - | |
---|
220 | | - | @Callable(af) |
---|
221 | | - | func confirmManager () = { |
---|
222 | | - | let aN = ad() |
---|
223 | | - | let aO = if (isDefined(aN)) |
---|
224 | | - | then true |
---|
225 | | - | else throw("No pending manager") |
---|
226 | | - | if ((aO == aO)) |
---|
227 | | - | then { |
---|
228 | | - | let aP = if ((af.callerPublicKey == value(aN))) |
---|
229 | | - | then true |
---|
230 | | - | else throw("You are not pending manager") |
---|
231 | | - | if ((aP == aP)) |
---|
232 | | - | then [StringEntry(H(), toBase58String(value(aN))), DeleteEntry(I())] |
---|
233 | | - | else throw("Strict value is not equal to itself.") |
---|
234 | | - | } |
---|
235 | | - | else throw("Strict value is not equal to itself.") |
---|
236 | | - | } |
---|
237 | | - | |
---|
238 | | - | |
---|
239 | | - | @Verifier(aQ) |
---|
240 | | - | func aR () = { |
---|
241 | | - | let aS = { |
---|
242 | | - | let V = ab() |
---|
243 | | - | if ($isInstanceOf(V, "ByteVector")) |
---|
244 | | - | then { |
---|
245 | | - | let ah = V |
---|
246 | | - | ah |
---|
247 | | - | } |
---|
248 | | - | else if ($isInstanceOf(V, "Unit")) |
---|
249 | | - | then aQ.senderPublicKey |
---|
250 | | - | else throw("Match error") |
---|
251 | | - | } |
---|
252 | | - | sigVerify(aQ.bodyBytes, aQ.proofs[0], aS) |
---|
253 | | - | } |
---|
254 | | - | |
---|
| 1 | + | # no script |
---|