1 | | - | {-# STDLIB_VERSION 5 #-} |
---|
2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let a = 1000 |
---|
5 | | - | |
---|
6 | | - | let b = 10000 |
---|
7 | | - | |
---|
8 | | - | let c = 10000 |
---|
9 | | - | |
---|
10 | | - | let d = base58'68Po1k24uP6goKr7RDmXPg4QkMiKuyTMEirao14rif8s' |
---|
11 | | - | |
---|
12 | | - | let e = base58'68Po1k24uP6goKr7RDmXPg4QkMiKuyTMEirao14rif8s' |
---|
13 | | - | |
---|
14 | | - | let f = base58'ALsqwPqiUP3bVbM7grozc1Y5oHVBAGKqACRJ5J8RXceC' |
---|
15 | | - | |
---|
16 | | - | @Callable(g) |
---|
17 | | - | func addPools (h,i,j,k) = if (containsElement([d, e, f], g.callerPublicKey)) |
---|
18 | | - | then { |
---|
19 | | - | func l (m,n) = IntegerEntry((n + "_asset_balance"), 0) :: m |
---|
20 | | - | |
---|
21 | | - | func o (m,n) = { |
---|
22 | | - | let p = value(indexOf(h, n)) |
---|
23 | | - | let q = i[p] |
---|
24 | | - | StringEntry((n + "_liquidity_token"), q) :: m |
---|
25 | | - | } |
---|
26 | | - | |
---|
27 | | - | func r (m,n) = { |
---|
28 | | - | let p = value(indexOf(h, n)) |
---|
29 | | - | let q = j[p] |
---|
30 | | - | StringEntry((n + "_service_token"), q) :: m |
---|
31 | | - | } |
---|
32 | | - | |
---|
33 | | - | func s (m,n) = { |
---|
34 | | - | let p = value(indexOf(h, n)) |
---|
35 | | - | let q = k[p] |
---|
36 | | - | IntegerEntry((n + "_service_token"), q) :: m |
---|
37 | | - | } |
---|
38 | | - | |
---|
39 | | - | func t (m,n) = BooleanEntry((n + "_active"), true) :: m |
---|
40 | | - | |
---|
41 | | - | let u = { |
---|
42 | | - | let v = h |
---|
43 | | - | let w = size(v) |
---|
44 | | - | let x = nil |
---|
45 | | - | func y (z,A) = if ((A >= w)) |
---|
46 | | - | then z |
---|
47 | | - | else l(z, v[A]) |
---|
48 | | - | |
---|
49 | | - | func B (z,A) = if ((A >= w)) |
---|
50 | | - | then z |
---|
51 | | - | else throw("List size exceeds 20") |
---|
52 | | - | |
---|
53 | | - | B(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(x, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20) |
---|
54 | | - | } |
---|
55 | | - | let C = { |
---|
56 | | - | let v = h |
---|
57 | | - | let w = size(v) |
---|
58 | | - | let x = nil |
---|
59 | | - | func y (z,A) = if ((A >= w)) |
---|
60 | | - | then z |
---|
61 | | - | else o(z, v[A]) |
---|
62 | | - | |
---|
63 | | - | func B (z,A) = if ((A >= w)) |
---|
64 | | - | then z |
---|
65 | | - | else throw("List size exceeds 20") |
---|
66 | | - | |
---|
67 | | - | B(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(x, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20) |
---|
68 | | - | } |
---|
69 | | - | let D = { |
---|
70 | | - | let v = h |
---|
71 | | - | let w = size(v) |
---|
72 | | - | let x = nil |
---|
73 | | - | func y (z,A) = if ((A >= w)) |
---|
74 | | - | then z |
---|
75 | | - | else r(z, v[A]) |
---|
76 | | - | |
---|
77 | | - | func B (z,A) = if ((A >= w)) |
---|
78 | | - | then z |
---|
79 | | - | else throw("List size exceeds 20") |
---|
80 | | - | |
---|
81 | | - | B(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(x, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20) |
---|
82 | | - | } |
---|
83 | | - | let E = { |
---|
84 | | - | let v = h |
---|
85 | | - | let w = size(v) |
---|
86 | | - | let x = nil |
---|
87 | | - | func y (z,A) = if ((A >= w)) |
---|
88 | | - | then z |
---|
89 | | - | else s(z, v[A]) |
---|
90 | | - | |
---|
91 | | - | func B (z,A) = if ((A >= w)) |
---|
92 | | - | then z |
---|
93 | | - | else throw("List size exceeds 20") |
---|
94 | | - | |
---|
95 | | - | B(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(x, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20) |
---|
96 | | - | } |
---|
97 | | - | let F = { |
---|
98 | | - | let v = h |
---|
99 | | - | let w = size(v) |
---|
100 | | - | let x = nil |
---|
101 | | - | func y (z,A) = if ((A >= w)) |
---|
102 | | - | then z |
---|
103 | | - | else t(z, v[A]) |
---|
104 | | - | |
---|
105 | | - | func B (z,A) = if ((A >= w)) |
---|
106 | | - | then z |
---|
107 | | - | else throw("List size exceeds 20") |
---|
108 | | - | |
---|
109 | | - | B(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(x, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20) |
---|
110 | | - | } |
---|
111 | | - | ((((u ++ C) ++ D) ++ E) ++ F) |
---|
112 | | - | } |
---|
113 | | - | else throw("Only admin can call this function") |
---|
114 | | - | |
---|
115 | | - | |
---|
116 | | - | |
---|
117 | | - | @Callable(g) |
---|
118 | | - | func deleteDepositLockRecords (G) = if (containsElement([d, e, f], g.callerPublicKey)) |
---|
119 | | - | then { |
---|
120 | | - | func H (m,I) = DeleteEntry((I + "_locked")) :: m |
---|
121 | | - | |
---|
122 | | - | let J = { |
---|
123 | | - | let v = G |
---|
124 | | - | let w = size(v) |
---|
125 | | - | let x = nil |
---|
126 | | - | func y (z,A) = if ((A >= w)) |
---|
127 | | - | then z |
---|
128 | | - | else H(z, v[A]) |
---|
129 | | - | |
---|
130 | | - | func B (z,A) = if ((A >= w)) |
---|
131 | | - | then z |
---|
132 | | - | else throw("List size exceeds 100") |
---|
133 | | - | |
---|
134 | | - | B(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(y(x, 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), 57), 58), 59), 60), 61), 62), 63), 64), 65), 66), 67), 68), 69), 70), 71), 72), 73), 74), 75), 76), 77), 78), 79), 80), 81), 82), 83), 84), 85), 86), 87), 88), 89), 90), 91), 92), 93), 94), 95), 96), 97), 98), 99), 100) |
---|
135 | | - | } |
---|
136 | | - | J |
---|
137 | | - | } |
---|
138 | | - | else throw("Only admin can call this function") |
---|
139 | | - | |
---|
140 | | - | |
---|
141 | | - | |
---|
142 | | - | @Callable(g) |
---|
143 | | - | func issueToken (K,L,M,N) = if (containsElement([d, e, f], g.callerPublicKey)) |
---|
144 | | - | then [Issue(K, L, M, N, true, unit, 0)] |
---|
145 | | - | else throw("Only admin can call this function") |
---|
146 | | - | |
---|
147 | | - | |
---|
148 | | - | |
---|
149 | | - | @Callable(O) |
---|
150 | | - | func call () = { |
---|
151 | | - | let P = 10 |
---|
152 | | - | let Q = 1 |
---|
153 | | - | let R = 8 |
---|
154 | | - | let S = 6 |
---|
155 | | - | let T = ((R + S) / 2) |
---|
156 | | - | let U = pow(P, R, 5, 1, R, DOWN) |
---|
157 | | - | let V = pow(Q, S, 5, 1, S, DOWN) |
---|
158 | | - | let W = pow(10, 0, T, 0, 0, DOWN) |
---|
159 | | - | let X = fraction(U, V, W) |
---|
160 | | - | [IntegerEntry("fisrt", U), IntegerEntry("second", V), IntegerEntry("third", W), IntegerEntry("fouth", X)] |
---|
161 | | - | } |
---|
162 | | - | |
---|
163 | | - | |
---|
164 | | - | |
---|
165 | | - | @Callable(g) |
---|
166 | | - | func deposit (n) = if ((size(g.payments) != 1)) |
---|
167 | | - | then throw("One attached payment expected") |
---|
168 | | - | else { |
---|
169 | | - | let Y = g.payments[0].amount |
---|
170 | | - | let Z = g.payments[0].assetId |
---|
171 | | - | let aa = { |
---|
172 | | - | let ab = Z |
---|
173 | | - | if ($isInstanceOf(ab, "ByteVector")) |
---|
174 | | - | then { |
---|
175 | | - | let ac = ab |
---|
176 | | - | toBase58String(ac) |
---|
177 | | - | } |
---|
178 | | - | else throw("Match error") |
---|
179 | | - | } |
---|
180 | | - | if ((0 >= Y)) |
---|
181 | | - | then throw(("Deposit amount must be positive. Actual: " + toString(Y))) |
---|
182 | | - | else { |
---|
183 | | - | let ad = (n + "_asset_balance") |
---|
184 | | - | let ae = toString(g.caller) |
---|
185 | | - | let af = (((n + "_") + ae) + "_asset_balance") |
---|
186 | | - | let ag = { |
---|
187 | | - | let ab = getString((n + "_service_token")) |
---|
188 | | - | if ($isInstanceOf(ab, "String")) |
---|
189 | | - | then { |
---|
190 | | - | let ah = ab |
---|
191 | | - | ah |
---|
192 | | - | } |
---|
193 | | - | else { |
---|
194 | | - | let ai = ab |
---|
195 | | - | throw("You try to deposit on unsupported pool") |
---|
196 | | - | } |
---|
197 | | - | } |
---|
198 | | - | let aj = { |
---|
199 | | - | let ab = getString((n + "_liquidity_token")) |
---|
200 | | - | if ($isInstanceOf(ab, "String")) |
---|
201 | | - | then { |
---|
202 | | - | let ah = ab |
---|
203 | | - | ah |
---|
204 | | - | } |
---|
205 | | - | else { |
---|
206 | | - | let ai = ab |
---|
207 | | - | throw("You try to deposit on unsupported pool") |
---|
208 | | - | } |
---|
209 | | - | } |
---|
210 | | - | let ak = { |
---|
211 | | - | let ab = assetInfo(fromBase58String(aj)) |
---|
212 | | - | if ($isInstanceOf(ab, "Asset")) |
---|
213 | | - | then { |
---|
214 | | - | let al = ab |
---|
215 | | - | al.decimals |
---|
216 | | - | } |
---|
217 | | - | else throw("Can't find asset") |
---|
218 | | - | } |
---|
219 | | - | if ((aj != aa)) |
---|
220 | | - | then throw("You attached wrong liquidity token from Swop.fi") |
---|
221 | | - | else { |
---|
222 | | - | let am = getIntegerValue(this, ad) |
---|
223 | | - | let an = { |
---|
224 | | - | let ab = getInteger(af) |
---|
225 | | - | if ($isInstanceOf(ab, "Int")) |
---|
226 | | - | then { |
---|
227 | | - | let ao = ab |
---|
228 | | - | ao |
---|
229 | | - | } |
---|
230 | | - | else { |
---|
231 | | - | let ai = ab |
---|
232 | | - | 0 |
---|
233 | | - | } |
---|
234 | | - | } |
---|
235 | | - | let ap = (am + Y) |
---|
236 | | - | let aq = ((Y - fraction(Y, 1, a, HALFUP)) - fraction(Y, 1, b, HALFUP)) |
---|
237 | | - | let ar = (an + aq) |
---|
238 | | - | let as = (((((n + "_") + ae) + "_") + toBase58String(g.transactionId)) + "_locked") |
---|
239 | | - | [Reissue(fromBase58String(ag), aq, true), ScriptTransfer(g.caller, aq, fromBase58String(ag)), IntegerEntry(as, aq), IntegerEntry(ad, ap), IntegerEntry(af, ar)] |
---|
240 | | - | } |
---|
241 | | - | } |
---|
242 | | - | } |
---|
243 | | - | |
---|
244 | | - | |
---|
245 | | - | |
---|
246 | | - | @Callable(g) |
---|
247 | | - | func withdraw (n,Y) = if ((0 >= Y)) |
---|
248 | | - | then throw(("Deposit amount must be positive. Actual: " + toString(Y))) |
---|
249 | | - | else { |
---|
250 | | - | let ad = (n + "_asset_balance") |
---|
251 | | - | let ae = toString(g.caller) |
---|
252 | | - | let af = (((n + "_") + ae) + "_asset_balance") |
---|
253 | | - | let ag = { |
---|
254 | | - | let ab = getString((n + "_service_token")) |
---|
255 | | - | if ($isInstanceOf(ab, "String")) |
---|
256 | | - | then { |
---|
257 | | - | let ah = ab |
---|
258 | | - | ah |
---|
259 | | - | } |
---|
260 | | - | else { |
---|
261 | | - | let ai = ab |
---|
262 | | - | throw("You try to withdraw from unsupported pool") |
---|
263 | | - | } |
---|
264 | | - | } |
---|
265 | | - | let aj = { |
---|
266 | | - | let ab = getString((n + "_liquidity_token")) |
---|
267 | | - | if ($isInstanceOf(ab, "String")) |
---|
268 | | - | then { |
---|
269 | | - | let ah = ab |
---|
270 | | - | ah |
---|
271 | | - | } |
---|
272 | | - | else { |
---|
273 | | - | let ai = ab |
---|
274 | | - | throw("You try to withdraw from unsupported pool") |
---|
275 | | - | } |
---|
276 | | - | } |
---|
277 | | - | let am = getIntegerValue(this, ad) |
---|
278 | | - | let an = { |
---|
279 | | - | let ab = getInteger(af) |
---|
280 | | - | if ($isInstanceOf(ab, "Int")) |
---|
281 | | - | then { |
---|
282 | | - | let ao = ab |
---|
283 | | - | ao |
---|
284 | | - | } |
---|
285 | | - | else { |
---|
286 | | - | let ai = ab |
---|
287 | | - | 0 |
---|
288 | | - | } |
---|
289 | | - | } |
---|
290 | | - | let at = ((Y - fraction(Y, 1, c, HALFUP)) - fraction(Y, 1, b, HALFUP)) |
---|
291 | | - | let ap = (am - at) |
---|
292 | | - | if ((an >= Y)) |
---|
293 | | - | then { |
---|
294 | | - | let ar = (an - Y) |
---|
295 | | - | [Burn(fromBase58String(ag), at), ScriptTransfer(g.caller, at, fromBase58String(aj)), IntegerEntry(ad, ap), IntegerEntry(af, ar)] |
---|
296 | | - | } |
---|
297 | | - | else throw("You have not such balance for withdraw") |
---|
298 | | - | } |
---|
299 | | - | |
---|
300 | | - | |
---|
| 1 | + | # no script |
---|