1 | | - | {-# STDLIB_VERSION 4 #-} |
---|
2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let a = "__" |
---|
5 | | - | |
---|
6 | | - | func b (c) = valueOrErrorMessage(getString(this, c), ("No data for this.key=" + c)) |
---|
7 | | - | |
---|
8 | | - | |
---|
9 | | - | func d (c) = valueOrErrorMessage(getBoolean(this, c), ("No data for this.key=" + c)) |
---|
10 | | - | |
---|
11 | | - | |
---|
12 | | - | func e (f,g,h,i) = throw(((((((f + ": baseAssetStr=") + g) + " userAddressStr=") + h) + " getTxIdStr=") + i)) |
---|
13 | | - | |
---|
14 | | - | |
---|
15 | | - | func j (g) = ("%s%s%s__config__asset__" + g) |
---|
16 | | - | |
---|
17 | | - | |
---|
18 | | - | func k () = "%s__nextInternalAssetId" |
---|
19 | | - | |
---|
20 | | - | |
---|
21 | | - | func l (m) = ("%s%s%d__price__last__" + m) |
---|
22 | | - | |
---|
23 | | - | |
---|
24 | | - | func n (m,o,p) = makeString(["%s%s%d%d%d__price__history", m, toString(o), toString(p)], a) |
---|
25 | | - | |
---|
26 | | - | |
---|
27 | | - | func q (m) = ("%s%s%d__total__locked__" + m) |
---|
28 | | - | |
---|
29 | | - | |
---|
30 | | - | func r (s,h) = makeString(["%s%s%d%s__total__locked", s, h], a) |
---|
31 | | - | |
---|
32 | | - | |
---|
33 | | - | func t (u) = ("%s%s%d__mappings__internal2baseAssetId__" + toString(u)) |
---|
34 | | - | |
---|
35 | | - | |
---|
36 | | - | func v (g) = ("%s%s%s__mappings__baseAsset2internalId__" + g) |
---|
37 | | - | |
---|
38 | | - | |
---|
39 | | - | func w (x) = ("%s%s%s__mappings__share2baseAssetId__" + x) |
---|
40 | | - | |
---|
41 | | - | |
---|
42 | | - | func y (g) = ("%s%s%s__mappings__baseAsset2shareId__" + g) |
---|
43 | | - | |
---|
44 | | - | |
---|
45 | | - | func z (s) = ("%s%s%d__shutdown__put__" + s) |
---|
46 | | - | |
---|
47 | | - | |
---|
48 | | - | func A (s) = ("%s%s%d__shutdown__manager__" + s) |
---|
49 | | - | |
---|
50 | | - | |
---|
51 | | - | let B = 1 |
---|
52 | | - | |
---|
53 | | - | let C = 2 |
---|
54 | | - | |
---|
55 | | - | let D = 3 |
---|
56 | | - | |
---|
57 | | - | let E = 4 |
---|
58 | | - | |
---|
59 | | - | let F = 5 |
---|
60 | | - | |
---|
61 | | - | func G (x,s,H,I,J) = makeString(["%s%d%d%d%d", x, s, toString(H), toString(I), toString(J)], a) |
---|
62 | | - | |
---|
63 | | - | |
---|
64 | | - | let K = 1 |
---|
65 | | - | |
---|
66 | | - | let L = 2 |
---|
67 | | - | |
---|
68 | | - | func M (N,O) = makeString(["%d%d", toString(N), toString(O)], a) |
---|
69 | | - | |
---|
70 | | - | |
---|
71 | | - | func P (c) = { |
---|
72 | | - | let Q = split(valueOrElse(getString(this, c), M(0, 0)), a) |
---|
73 | | - | [-1, parseIntValue(Q[K]), parseIntValue(Q[L])] |
---|
74 | | - | } |
---|
75 | | - | |
---|
76 | | - | |
---|
77 | | - | func R (S,s,T,U) = makeString(["%s%d%s%s", S, s, T, U], a) |
---|
78 | | - | |
---|
79 | | - | |
---|
80 | | - | let V = 1 |
---|
81 | | - | |
---|
82 | | - | let W = 2 |
---|
83 | | - | |
---|
84 | | - | let X = 3 |
---|
85 | | - | |
---|
86 | | - | let Y = 4 |
---|
87 | | - | |
---|
88 | | - | let Z = 5 |
---|
89 | | - | |
---|
90 | | - | let aa = 6 |
---|
91 | | - | |
---|
92 | | - | let ab = 7 |
---|
93 | | - | |
---|
94 | | - | let ac = 8 |
---|
95 | | - | |
---|
96 | | - | func ad (ae,af,ag,ah,ai,aj,ak,al) = makeString(["%s%d%d%d%d%d%d%d", ae, af, ag, ah, ai, aj, ak, al], a) |
---|
97 | | - | |
---|
98 | | - | |
---|
99 | | - | func am (ae,af,ag,ah,ai,aj,ak,al) = ad(ae, toString(af), toString(ag), toString(ah), toString(ai), toString(aj), toString(ak), toString(al)) |
---|
100 | | - | |
---|
101 | | - | |
---|
102 | | - | func an (ao,ap,aq) = ad(ap, ao[W], ao[X], ao[Y], ao[Z], ao[aa], ao[ab], toString(aq)) |
---|
103 | | - | |
---|
104 | | - | |
---|
105 | | - | func ar (g) = { |
---|
106 | | - | let c = j(g) |
---|
107 | | - | split(b(c), a) |
---|
108 | | - | } |
---|
109 | | - | |
---|
110 | | - | |
---|
111 | | - | func as (c,N,O) = { |
---|
112 | | - | let at = P(c) |
---|
113 | | - | StringEntry(c, M((at[K] + N), (at[L] + O))) |
---|
114 | | - | } |
---|
115 | | - | |
---|
116 | | - | |
---|
117 | | - | func au (c,N,O) = { |
---|
118 | | - | let at = P(c) |
---|
119 | | - | StringEntry(c, M((at[K] - N), (at[L] - O))) |
---|
120 | | - | } |
---|
121 | | - | |
---|
122 | | - | |
---|
123 | | - | func av (s,aw,ax,ay,H,I) = { |
---|
124 | | - | let Q = P(q(s)) |
---|
125 | | - | let az = Q[L] |
---|
126 | | - | let aA = assetBalance(this, aw) |
---|
127 | | - | let aB = ((aA - az) + ax) |
---|
128 | | - | if ((0 > aB)) |
---|
129 | | - | then throw(((("baseAssetBalanceConsideringLock < 0: baseAssetBalance=" + toString(aA)) + " baseAssetBalanceConsideringLock=") + toString(aB))) |
---|
130 | | - | else { |
---|
131 | | - | let aC = value(assetInfo(ay)).quantity |
---|
132 | | - | let ag = if ((aC == 0)) |
---|
133 | | - | then (1 * I) |
---|
134 | | - | else fraction(aB, I, aC) |
---|
135 | | - | $Tuple5(ag, aA, az, aB, aC) |
---|
136 | | - | } |
---|
137 | | - | } |
---|
138 | | - | |
---|
139 | | - | |
---|
140 | | - | func aD (s,aw,ay,H,I) = av(s, aw, 0, ay, H, I) |
---|
141 | | - | |
---|
142 | | - | |
---|
143 | | - | func aE (g) = { |
---|
144 | | - | let aw = fromBase58String(g) |
---|
145 | | - | let aF = ar(g) |
---|
146 | | - | let x = aF[B] |
---|
147 | | - | let ay = fromBase58String(x) |
---|
148 | | - | let H = parseIntValue(aF[D]) |
---|
149 | | - | let I = parseIntValue(aF[E]) |
---|
150 | | - | let s = aF[C] |
---|
151 | | - | let aG = aD(s, aw, ay, H, I) |
---|
152 | | - | $Tuple6(IntegerEntry("price", aG._1), IntegerEntry("decimalsMultPrice", I), IntegerEntry("baseAssetBalance", aG._2), IntegerEntry("totalLockedBaseAmount", aG._3), IntegerEntry("baseAssetBalanceConsideringLock", aG._4), IntegerEntry("shareEmission", aG._5)) |
---|
153 | | - | } |
---|
154 | | - | |
---|
155 | | - | |
---|
156 | | - | @Callable(aH) |
---|
157 | | - | func adminRegisterAsset (g,aI,aJ,aK,aL) = { |
---|
158 | | - | let aw = fromBase58String(g) |
---|
159 | | - | let aM = value(assetInfo(aw)).decimals |
---|
160 | | - | if ((aH.caller != this)) |
---|
161 | | - | then throw("permissions denied") |
---|
162 | | - | else if ((toString(addressFromStringValue(aL)) != aL)) |
---|
163 | | - | then throw("invalid shutdownManagerAddress") |
---|
164 | | - | else if ((0 > aK)) |
---|
165 | | - | then throw(("invalid getDelayinBlocks=" + toString(aK))) |
---|
166 | | - | else { |
---|
167 | | - | let aN = Issue(aI, aJ, 1, aM, true) |
---|
168 | | - | let ay = calculateAssetId(aN) |
---|
169 | | - | let x = toBase58String(ay) |
---|
170 | | - | let I = ((100 * 1000) * 1000) |
---|
171 | | - | let H = pow(10, 0, aM, 0, 0, DOWN) |
---|
172 | | - | let aO = (1 * I) |
---|
173 | | - | let aP = valueOrElse(getInteger(this, k()), 0) |
---|
174 | | - | let s = toString(aP) |
---|
175 | | - | [StringEntry(j(g), G(x, s, H, I, aK)), StringEntry(t(aP), g), StringEntry(v(g), s), StringEntry(w(x), g), StringEntry(y(g), x), BooleanEntry(z(s), false), StringEntry(A(s), aL), IntegerEntry(k(), (aP + 1)), IntegerEntry(l(s), aO), IntegerEntry(n(s, height, lastBlock.timestamp), aO), aN, Burn(ay, 1)] |
---|
176 | | - | } |
---|
177 | | - | } |
---|
178 | | - | |
---|
179 | | - | |
---|
180 | | - | |
---|
181 | | - | @Callable(aH) |
---|
182 | | - | func shutdownPut (aQ) = { |
---|
183 | | - | let aR = toString(aQ) |
---|
184 | | - | let aS = b(t(aQ)) |
---|
185 | | - | let aL = b(A(aR)) |
---|
186 | | - | if ((1 > size(aS))) |
---|
187 | | - | then throw("invalid internalBaseAssetId") |
---|
188 | | - | else if ((toString(aH.caller) != aL)) |
---|
189 | | - | then throw("access denied") |
---|
190 | | - | else [BooleanEntry(z(toString(aQ)), true)] |
---|
191 | | - | } |
---|
192 | | - | |
---|
193 | | - | |
---|
194 | | - | |
---|
195 | | - | @Callable(aH) |
---|
196 | | - | func put () = { |
---|
197 | | - | let aT = value(aH.payments[0]) |
---|
198 | | - | let aw = value(aT.assetId) |
---|
199 | | - | let g = toBase58String(aw) |
---|
200 | | - | let h = toString(aH.caller) |
---|
201 | | - | let aF = ar(g) |
---|
202 | | - | let x = aF[B] |
---|
203 | | - | let ay = fromBase58String(x) |
---|
204 | | - | let H = parseIntValue(aF[D]) |
---|
205 | | - | let I = parseIntValue(aF[E]) |
---|
206 | | - | let s = aF[C] |
---|
207 | | - | let aU = d(z(s)) |
---|
208 | | - | if (aU) |
---|
209 | | - | then throw("put operation is blocked") |
---|
210 | | - | else { |
---|
211 | | - | let ag = aD(s, aw, ay, H, I)._1 |
---|
212 | | - | let N = fraction(aT.amount, I, ag) |
---|
213 | | - | [Reissue(ay, N, true), ScriptTransfer(aH.caller, N, ay), StringEntry(R("P", s, h, toBase58String(aH.transactionId)), am("FINISHED", aT.amount, ag, N, height, lastBlock.timestamp, height, lastBlock.timestamp))] |
---|
214 | | - | } |
---|
215 | | - | } |
---|
216 | | - | |
---|
217 | | - | |
---|
218 | | - | |
---|
219 | | - | @Callable(aH) |
---|
220 | | - | func submitGetRequest () = { |
---|
221 | | - | let aT = value(aH.payments[0]) |
---|
222 | | - | let ay = value(aT.assetId) |
---|
223 | | - | let x = toBase58String(ay) |
---|
224 | | - | let aV = toBase58String(aH.callerPublicKey) |
---|
225 | | - | let T = aH.caller |
---|
226 | | - | let h = toString(T) |
---|
227 | | - | let N = aT.amount |
---|
228 | | - | let g = b(w(x)) |
---|
229 | | - | let aw = fromBase58String(g) |
---|
230 | | - | let aF = ar(g) |
---|
231 | | - | let H = parseIntValue(aF[D]) |
---|
232 | | - | let I = parseIntValue(aF[E]) |
---|
233 | | - | let aW = parseIntValue(aF[F]) |
---|
234 | | - | let s = aF[C] |
---|
235 | | - | let ag = aD(s, aw, ay, H, I)._1 |
---|
236 | | - | let O = fraction(N, ag, I) |
---|
237 | | - | let aX = R("G", s, h, toBase58String(aH.transactionId)) |
---|
238 | | - | let aY = am("PENDING", N, ag, O, height, lastBlock.timestamp, (height + aW), 0) |
---|
239 | | - | [Burn(ay, N), StringEntry(aX, aY), as(q(s), N, O), as(r(s, h), N, O)] |
---|
240 | | - | } |
---|
241 | | - | |
---|
242 | | - | |
---|
243 | | - | |
---|
244 | | - | @Callable(aH) |
---|
245 | | - | func executeGetRequest (g,h,i) = { |
---|
246 | | - | let T = addressFromStringValue(h) |
---|
247 | | - | let aZ = ar(g) |
---|
248 | | - | let ay = fromBase58String(aZ[B]) |
---|
249 | | - | let aw = fromBase58String(g) |
---|
250 | | - | let s = aZ[C] |
---|
251 | | - | let aX = R("G", s, h, i) |
---|
252 | | - | let ba = split(b(aX), a) |
---|
253 | | - | let ae = ba[V] |
---|
254 | | - | let ak = parseIntValue(ba[ab]) |
---|
255 | | - | let bb = parseIntValue(ba[W]) |
---|
256 | | - | let bc = parseIntValue(ba[Y]) |
---|
257 | | - | if ((ae != "PENDING")) |
---|
258 | | - | then e("Status is not PENDING", g, h, i) |
---|
259 | | - | else if ((ak > height)) |
---|
260 | | - | then e(((("EndHeight[" + toString(ak)) + "] > ") + toString(height)), g, h, i) |
---|
261 | | - | else [ScriptTransfer(T, bc, aw), StringEntry(aX, an(ba, "FINISHED", lastBlock.timestamp)), au(q(s), bb, bc), au(r(s, h), bb, bc)] |
---|
262 | | - | } |
---|
263 | | - | |
---|
264 | | - | |
---|
265 | | - | |
---|
266 | | - | @Callable(aH) |
---|
267 | | - | func topUpBalance (g) = { |
---|
268 | | - | let aZ = ar(g) |
---|
269 | | - | let aT = value(aH.payments[0]) |
---|
270 | | - | let bd = value(aT.assetId) |
---|
271 | | - | let be = toBase58String(bd) |
---|
272 | | - | let ay = fromBase58String(aZ[B]) |
---|
273 | | - | let H = parseIntValue(aZ[D]) |
---|
274 | | - | let I = parseIntValue(aZ[E]) |
---|
275 | | - | let s = aZ[C] |
---|
276 | | - | if ((g != be)) |
---|
277 | | - | then throw("attached payment's asset id is NOT matched passed baseAssetStr") |
---|
278 | | - | else if ((size(aH.payments) > 1)) |
---|
279 | | - | then throw("only one payment can be attached") |
---|
280 | | - | else { |
---|
281 | | - | let ag = av(s, bd, aT.amount, ay, H, I)._1 |
---|
282 | | - | [IntegerEntry(l(s), ag), IntegerEntry(n(s, height, lastBlock.timestamp), ag)] |
---|
283 | | - | } |
---|
284 | | - | } |
---|
285 | | - | |
---|
286 | | - | |
---|
287 | | - | |
---|
288 | | - | @Callable(aH) |
---|
289 | | - | func currentSysParamsREST (g) = { |
---|
290 | | - | let bf = aE(g) |
---|
291 | | - | let ag = bf._1.value |
---|
292 | | - | let I = bf._2.value |
---|
293 | | - | let aA = bf._3.value |
---|
294 | | - | let az = bf._4.value |
---|
295 | | - | let aB = bf._5.value |
---|
296 | | - | let aC = bf._6.value |
---|
297 | | - | let bg = makeString(["startCurrentSysParamsREST", toString(ag), toString(I), toString(aA), toString(az), toString(aB), toString(aC), "endCurrentSysParamsREST"], a) |
---|
298 | | - | throw(bg) |
---|
299 | | - | } |
---|
300 | | - | |
---|
301 | | - | |
---|
302 | | - | @Verifier(bh) |
---|
303 | | - | func bi () = { |
---|
304 | | - | let bj = ["kMVLGCwXnETBo7cjirdUTSrrWXCDYFUNY56FyHEvpj1", "GidQ61btQCXZBYeuYqpJphw5hP1o9zyduRTwrEvUzPZ", "DTz4eaCd7UfVtfodw4GrVJ2bE4HQFYW6T94mpGsHMhXz"] |
---|
305 | | - | let bk = if (sigVerify(bh.bodyBytes, bh.proofs[0], fromBase58String(bj[0]))) |
---|
306 | | - | then 1 |
---|
307 | | - | else 0 |
---|
308 | | - | let bl = if (sigVerify(bh.bodyBytes, bh.proofs[1], fromBase58String(bj[1]))) |
---|
309 | | - | then 1 |
---|
310 | | - | else 0 |
---|
311 | | - | let bm = if (sigVerify(bh.bodyBytes, bh.proofs[2], fromBase58String(bj[2]))) |
---|
312 | | - | then 1 |
---|
313 | | - | else 0 |
---|
314 | | - | let bn = ((bk + bl) + bm) |
---|
315 | | - | if ((2 > bn)) |
---|
316 | | - | then throw(((((("invalid multisig: s0=" + toString(bk)) + " s1=") + toString(bl)) + " s2=") + toString(bm))) |
---|
317 | | - | else true |
---|
318 | | - | } |
---|
319 | | - | |
---|
| 1 | + | # no script |
---|