15 | | - | func e (b) = { |
---|
16 | | - | let c = getString(this, b) |
---|
17 | | - | if ($isInstanceOf(c, "String")) |
---|
18 | | - | then { |
---|
19 | | - | let d = c |
---|
20 | | - | d |
---|
| 22 | + | @Callable(h) |
---|
| 23 | + | func voteOnSplit (i,j,k) = if ((((i + j) + k) > 10)) |
---|
| 24 | + | then throw("Please disperse max 10 points") |
---|
| 25 | + | else if ((c((toString(h.caller) + "_voted")) != 0)) |
---|
| 26 | + | then throw("You have already voted") |
---|
| 27 | + | else { |
---|
| 28 | + | let l = (c("group1_share") + i) |
---|
| 29 | + | let m = (c("group2_share") + j) |
---|
| 30 | + | let n = (c("group3_share") + k) |
---|
| 31 | + | WriteSet([DataEntry("group1_share", l), DataEntry("group2_share", m), DataEntry("group3_share", n), DataEntry((toString(h.caller) + "_voted"), ((i + j) + k))]) |
---|
26 | | - | func f (b) = { |
---|
27 | | - | let c = getBoolean(this, b) |
---|
28 | | - | if ($isInstanceOf(c, "Boolean")) |
---|
29 | | - | then { |
---|
30 | | - | let d = c |
---|
31 | | - | d |
---|
| 35 | + | |
---|
| 36 | + | @Callable(h) |
---|
| 37 | + | func addTips (o,i,j,k) = { |
---|
| 38 | + | let p = extract(h.payment) |
---|
| 39 | + | if ((p.assetId != b)) |
---|
| 40 | + | then throw("Tips accepted only in USDN") |
---|
| 41 | + | else { |
---|
| 42 | + | let q = c("group1_share") |
---|
| 43 | + | let r = c("group2_share") |
---|
| 44 | + | let s = c("group3_share") |
---|
| 45 | + | ScriptResult(WriteSet([DataEntry(("tips_amount_" + o), p.amount)]), TransferSet([ScriptTransfer(addressFromStringValue(i), ((p.amount * q) / ((q + r) + s)), b), ScriptTransfer(addressFromStringValue(j), ((p.amount * r) / ((q + r) + s)), b), ScriptTransfer(addressFromStringValue(k), ((p.amount * s) / ((q + r) + s)), b)])) |
---|
33 | | - | else false |
---|
34 | | - | } |
---|
35 | | - | |
---|
36 | | - | |
---|
37 | | - | func g (h,b) = { |
---|
38 | | - | let c = getInteger(addressFromStringValue(h), b) |
---|
39 | | - | if ($isInstanceOf(c, "Int")) |
---|
40 | | - | then { |
---|
41 | | - | let d = c |
---|
42 | | - | d |
---|
43 | | - | } |
---|
44 | | - | else 0 |
---|
45 | | - | } |
---|
46 | | - | |
---|
47 | | - | |
---|
48 | | - | func i (h,b) = { |
---|
49 | | - | let c = getString(addressFromStringValue(h), b) |
---|
50 | | - | if ($isInstanceOf(c, "String")) |
---|
51 | | - | then { |
---|
52 | | - | let d = c |
---|
53 | | - | d |
---|
54 | | - | } |
---|
55 | | - | else "" |
---|
56 | | - | } |
---|
57 | | - | |
---|
58 | | - | |
---|
59 | | - | func j (h,b) = { |
---|
60 | | - | let c = getBoolean(addressFromStringValue(h), b) |
---|
61 | | - | if ($isInstanceOf(c, "Boolean")) |
---|
62 | | - | then { |
---|
63 | | - | let d = c |
---|
64 | | - | d |
---|
65 | | - | } |
---|
66 | | - | else false |
---|
67 | | - | } |
---|
68 | | - | |
---|
69 | | - | |
---|
70 | | - | let k = 30 |
---|
71 | | - | |
---|
72 | | - | let l = "_" |
---|
73 | | - | |
---|
74 | | - | let m = "+" |
---|
75 | | - | |
---|
76 | | - | let n = 100000000 |
---|
77 | | - | |
---|
78 | | - | let o = 1000000 |
---|
79 | | - | |
---|
80 | | - | let p = "neutrino_asset_id" |
---|
81 | | - | |
---|
82 | | - | let q = "bond_asset_id" |
---|
83 | | - | |
---|
84 | | - | let r = "auction_contract" |
---|
85 | | - | |
---|
86 | | - | let s = "liquidation_contract" |
---|
87 | | - | |
---|
88 | | - | let t = "rpd_contract" |
---|
89 | | - | |
---|
90 | | - | let u = "control_contract" |
---|
91 | | - | |
---|
92 | | - | let v = "balance_waves_lock_interval" |
---|
93 | | - | |
---|
94 | | - | let w = "balance_neutrino_lock_interval" |
---|
95 | | - | |
---|
96 | | - | let x = "min_waves_swap_amount" |
---|
97 | | - | |
---|
98 | | - | let y = "min_neutrino_swap_amount" |
---|
99 | | - | |
---|
100 | | - | let z = "node_oracle_provider" |
---|
101 | | - | |
---|
102 | | - | let A = "rpd_balance" |
---|
103 | | - | |
---|
104 | | - | func B (C) = ((A + "_") + toBase58String(C)) |
---|
105 | | - | |
---|
106 | | - | |
---|
107 | | - | let D = "price" |
---|
108 | | - | |
---|
109 | | - | let E = "price_index" |
---|
110 | | - | |
---|
111 | | - | let F = "is_blocked" |
---|
112 | | - | |
---|
113 | | - | func G (H) = ((D + "_") + toString(H)) |
---|
114 | | - | |
---|
115 | | - | |
---|
116 | | - | func I (J) = ((E + "_") + toString(J)) |
---|
117 | | - | |
---|
118 | | - | |
---|
119 | | - | let K = "balance_lock_" |
---|
120 | | - | |
---|
121 | | - | let L = (K + "waves") |
---|
122 | | - | |
---|
123 | | - | let M = (K + "neutrino") |
---|
124 | | - | |
---|
125 | | - | func N (O,C) = ((((A + "_") + toBase58String(C)) + "_") + toString(O)) |
---|
126 | | - | |
---|
127 | | - | |
---|
128 | | - | func P (Q) = (("cancel_lease_tx_reserve_fee" + "_") + Q) |
---|
129 | | - | |
---|
130 | | - | |
---|
131 | | - | func R (S) = ((L + "_") + S) |
---|
132 | | - | |
---|
133 | | - | |
---|
134 | | - | func T (S) = ((M + "_") + S) |
---|
135 | | - | |
---|
136 | | - | |
---|
137 | | - | func U (S) = ("balance_unlock_block_" + S) |
---|
138 | | - | |
---|
139 | | - | |
---|
140 | | - | func V (O) = (("rpd_profit" + "_") + toString(O)) |
---|
141 | | - | |
---|
142 | | - | |
---|
143 | | - | func W (X,Y) = fraction(fraction(X, 100, Y), n, o) |
---|
144 | | - | |
---|
145 | | - | |
---|
146 | | - | func Z (X,Y) = fraction(fraction(X, Y, 100), o, n) |
---|
147 | | - | |
---|
148 | | - | |
---|
149 | | - | func aa (X,Y) = Z(X, Y) |
---|
150 | | - | |
---|
151 | | - | |
---|
152 | | - | func ab (ac) = split(ac, ",") |
---|
153 | | - | |
---|
154 | | - | |
---|
155 | | - | let ad = e(s) |
---|
156 | | - | |
---|
157 | | - | let ae = e(p) |
---|
158 | | - | |
---|
159 | | - | let af = base58'GXEFzEQ6BwnQcftiAFXCygb7tc5Rwq2dMQEfsZxcD1Pu' |
---|
160 | | - | |
---|
161 | | - | let ag = e(r) |
---|
162 | | - | |
---|
163 | | - | let ah = e(t) |
---|
164 | | - | |
---|
165 | | - | let ai = e(u) |
---|
166 | | - | |
---|
167 | | - | let aj = g(ai, E) |
---|
168 | | - | |
---|
169 | | - | let ak = j(ai, F) |
---|
170 | | - | |
---|
171 | | - | let al = fromBase58String(e(z)) |
---|
172 | | - | |
---|
173 | | - | let am = a(v) |
---|
174 | | - | |
---|
175 | | - | let an = a(w) |
---|
176 | | - | |
---|
177 | | - | let ao = a(x) |
---|
178 | | - | |
---|
179 | | - | let ap = a(y) |
---|
180 | | - | |
---|
181 | | - | let aq = fromBase58String("6nSpVyNH7yM69eg446wrQR94ipbbcmZMU1ENPwanC97g") |
---|
182 | | - | |
---|
183 | | - | let ar = fromBase58String("975akZBfnMj513U7MZaHKzQrmsEx5aE3wdWKTrHBhbjF") |
---|
184 | | - | |
---|
185 | | - | let as = this |
---|
186 | | - | |
---|
187 | | - | let at = g(ai, D) |
---|
188 | | - | |
---|
189 | | - | let au = a(M) |
---|
190 | | - | |
---|
191 | | - | let av = a(L) |
---|
192 | | - | |
---|
193 | | - | let aw = (wavesBalance(as) - av) |
---|
194 | | - | |
---|
195 | | - | let ax = (((au + extract(assetInfo(af)).quantity) - assetBalance(as, af)) - assetBalance(addressFromStringValue(ad), af)) |
---|
196 | | - | |
---|
197 | | - | let ay = (Z(aw, at) - ax) |
---|
198 | | - | |
---|
199 | | - | let az = (ax - Z(aw, at)) |
---|
200 | | - | |
---|
201 | | - | func aA (aB) = { |
---|
202 | | - | let aC = 100000 |
---|
203 | | - | let aD = 1000 |
---|
204 | | - | let aE = Z(aC, at) |
---|
205 | | - | let aF = (aE * 2) |
---|
206 | | - | let aG = fraction(aE, aD, 100) |
---|
207 | | - | let aH = extract(aB.minSponsoredAssetFee) |
---|
208 | | - | if (if ((aH >= aF)) |
---|
209 | | - | then (aG >= aH) |
---|
210 | | - | else false) |
---|
211 | | - | then (aB.assetId == af) |
---|
212 | | - | else false |
---|
213 | | - | } |
---|
214 | | - | |
---|
215 | | - | |
---|
216 | | - | func aI (C) = g(ah, B(C)) |
---|
217 | | - | |
---|
218 | | - | |
---|
219 | | - | func aJ (H) = g(ai, G(H)) |
---|
220 | | - | |
---|
221 | | - | |
---|
222 | | - | func aK (J) = g(ai, I(J)) |
---|
223 | | - | |
---|
224 | | - | |
---|
225 | | - | func aL (Q) = a(P(Q)) |
---|
226 | | - | |
---|
227 | | - | |
---|
228 | | - | func aM (S) = a(R(S)) |
---|
229 | | - | |
---|
230 | | - | |
---|
231 | | - | func aN (S) = a(T(S)) |
---|
232 | | - | |
---|
233 | | - | |
---|
234 | | - | func aO (S) = a(U(S)) |
---|
235 | | - | |
---|
236 | | - | |
---|
237 | | - | func aP (O) = a(V(O)) |
---|
238 | | - | |
---|
239 | | - | |
---|
240 | | - | @Callable(aQ) |
---|
241 | | - | func swapWavesToNeutrino () = { |
---|
242 | | - | let aR = extract(aQ.payment) |
---|
243 | | - | let aS = toString(aQ.caller) |
---|
244 | | - | if ((ao > aR.amount)) |
---|
245 | | - | then throw((("The specified Waves amount is less than the required minimum of " + toString(ao)) + " wavelets.")) |
---|
246 | | - | else WriteSet([DataEntry(R(aS), aR.amount), DataEntry(U(aS), (height + am)), DataEntry(L, (av + aR.amount))]) |
---|
251 | | - | @Callable(aQ) |
---|
252 | | - | func swapNeutrinoToWaves () = { |
---|
253 | | - | let aR = extract(aQ.payment) |
---|
254 | | - | let aS = toString(aQ.caller) |
---|
255 | | - | if ((ap > aR.amount)) |
---|
256 | | - | then throw((("The specified Neutrino amount is less than the required minimum of " + toString(ap)) + " Neutrino cents.")) |
---|
257 | | - | else if (ak) |
---|
258 | | - | then throw("The contract is blocked by EMERGENCY SHUTDOWN. Please wait for reactivation by emergency oracles.") |
---|
259 | | - | else if ((aR.assetId != af)) |
---|
260 | | - | then throw("Only appropriate Neutrino tokens are allowed for swapping.") |
---|
261 | | - | else if ((aO(aS) > height)) |
---|
262 | | - | then throw((("await " + toString((aO(aS) - height))) + " blocks")) |
---|
263 | | - | else if (if ((aN(aS) != 0)) |
---|
264 | | - | then true |
---|
265 | | - | else (aM(aS) != 0)) |
---|
266 | | - | then throw("please withdraw locked funds first") |
---|
267 | | - | else WriteSet([DataEntry(T(aS), aR.amount), DataEntry(U(aS), (height + an)), DataEntry(M, (au + aR.amount))]) |
---|
268 | | - | } |
---|
| 51 | + | @Callable(h) |
---|
| 52 | + | func withdrawTips (t) = WriteSet(nil) |
---|
272 | | - | @Callable(aQ) |
---|
273 | | - | func withdraw (aS,J) = { |
---|
274 | | - | let aT = aO(aS) |
---|
275 | | - | let aU = aM(aS) |
---|
276 | | - | let aV = aN(aS) |
---|
277 | | - | let aW = aK(J) |
---|
278 | | - | let aX = aK((J - 1)) |
---|
279 | | - | let aY = aJ(aW) |
---|
280 | | - | let aZ = if ((100 > aY)) |
---|
281 | | - | then 1 |
---|
282 | | - | else (aY / 100) |
---|
283 | | - | let ba = Z(aU, (aY - aZ)) |
---|
284 | | - | let bb = W(aV, (aY + aZ)) |
---|
285 | | - | if (ak) |
---|
286 | | - | then throw("contract is blocked by EMERGENCY SHUTDOWN actions untill reactivation by emergency oracles") |
---|
287 | | - | else if ((aT > height)) |
---|
288 | | - | then throw((("please wait for: " + toString(aT)) + " block height to withdraw WAVES funds")) |
---|
289 | | - | else if (if (if ((J > aj)) |
---|
290 | | - | then true |
---|
291 | | - | else (aT > aW)) |
---|
292 | | - | then true |
---|
293 | | - | else if ((aX != 0)) |
---|
294 | | - | then (aX >= aT) |
---|
295 | | - | else false) |
---|
296 | | - | then throw(((((((((("invalid price history index: index=" + toString(J)) + " priceIndex=") + toString(aj)) + " indexHeight=") + toString(aW)) + " unlockHeight=") + toString(aT)) + " prevIndexHeight=") + toString(aX))) |
---|
297 | | - | else if (if ((0 >= ba)) |
---|
298 | | - | then (0 >= bb) |
---|
299 | | - | else false) |
---|
300 | | - | then throw("balance equals zero") |
---|
301 | | - | else ScriptResult(WriteSet([DataEntry(R(aS), 0), DataEntry(T(aS), 0), DataEntry(L, (av - aU)), DataEntry(M, (au - aV))]), TransferSet([ScriptTransfer(addressFromStringValue(aS), bb, unit), ScriptTransfer(addressFromStringValue(aS), ba, af)])) |
---|
302 | | - | } |
---|
303 | | - | |
---|
304 | | - | |
---|
305 | | - | |
---|
306 | | - | @Callable(aQ) |
---|
307 | | - | func transferToAuction () = { |
---|
308 | | - | let bc = (ax - assetBalance(addressFromStringValue(ag), aq)) |
---|
309 | | - | let bd = (ay - assetBalance(addressFromStringValue(ad), af)) |
---|
310 | | - | if (ak) |
---|
311 | | - | then throw("contract is blocked by EMERGENCY SHUTDOWN actions untill reactivation by emergency oracles") |
---|
312 | | - | else if ((bc > (1 * o))) |
---|
313 | | - | then TransferSet([ScriptTransfer(addressFromStringValue(ag), bc, aq)]) |
---|
314 | | - | else if ((bd >= (1 * o))) |
---|
315 | | - | then TransferSet([ScriptTransfer(addressFromStringValue(ad), bd, af)]) |
---|
316 | | - | else throw(((((((("bond were generated or do not need it. Deficit:" + toString(bc)) + "|") + toString(0)) + ". Surplus:") + toString(bd)) + "|") + toString(ay))) |
---|
317 | | - | } |
---|
318 | | - | |
---|
319 | | - | |
---|
320 | | - | |
---|
321 | | - | @Callable(aQ) |
---|
322 | | - | func transfer (aS) = { |
---|
323 | | - | let aR = extract(aQ.payment) |
---|
324 | | - | TransferSet([ScriptTransfer(addressFromStringValue(aS), aR.amount, aR.assetId)]) |
---|
325 | | - | } |
---|
326 | | - | |
---|
327 | | - | |
---|
328 | | - | |
---|
329 | | - | @Callable(aQ) |
---|
330 | | - | func migrationUSDNB2NSBTSwap () = { |
---|
331 | | - | let aR = extract(aQ.payment) |
---|
332 | | - | let aS = aQ.caller |
---|
333 | | - | if ((ar != aR.assetId)) |
---|
334 | | - | then throw("error: attempt to swap not USDNB tokens") |
---|
335 | | - | else TransferSet([ScriptTransfer(aS, (aR.amount * o), aq)]) |
---|
336 | | - | } |
---|
| 56 | + | @Callable(h) |
---|
| 57 | + | func addTipsReceivers () = WriteSet(nil) |
---|