tx · 8JtBbGpfiAo9bQDbY7MQKHJx7cwCgyVbqfHu11LSD8Zc 3NBbSp7yXAeyAmM8uuoenTt3XFfCGQZsHon: -0.01300000 Waves 2023.03.16 17:06 [2492672] smart account 3NBbSp7yXAeyAmM8uuoenTt3XFfCGQZsHon > SELF 0.00000000 Waves
{ "type": 13, "id": "8JtBbGpfiAo9bQDbY7MQKHJx7cwCgyVbqfHu11LSD8Zc", "fee": 1300000, "feeAssetId": null, "timestamp": 1678975622069, "version": 2, "chainId": 84, "sender": "3NBbSp7yXAeyAmM8uuoenTt3XFfCGQZsHon", "senderPublicKey": "EdMvX1KG6dSSSsAqgamTtbKQho4ZLojCVgcBU4CDSeix", "proofs": [ "3cUKhqjUDq1z9d7KNfSfqwbAp3wr9KvAxFbqtFMyF8rmRAKnKtXkajbFwfZHx5P71kLM1P6DUgeVcToV4ATuaDBo" ], "script": "base64:BgIXCAISBQoDAQgIEgUKAwEICBIDCgEIEgAXAANTRVACAl9fAAhmZWVTY2FsZQkAtgIBAIDC1y8BD2dldFN0cmluZ09yRmFpbAEDa2V5CQETdmFsdWVPckVycm9yTWVzc2FnZQIJAJ0IAgUEdGhpcwUDa2V5CQCsAgICFU5vIGRhdGEgZm9yIHRoaXMua2V5PQUDa2V5AAxwb29sRGlzYWJsZWQJAAIBAg1Qb29sIGRpc2FibGVkAAxwb29sTm90RXhpc3QJAAIBAhFQb29sIGlzIG5vdCBleGlzdAAOc2xpcHBhZ2VUb29CaWcJAAIBAhNTbGlwcGFnZSBpcyB0b28gYmlnARNrZXlNYW5hZ2VyUHVibGljS2V5AAIUJXNfX21hbmFnZXJQdWJsaWNLZXkBGmtleVBlbmRpbmdNYW5hZ2VyUHVibGljS2V5AAIbJXNfX3BlbmRpbmdNYW5hZ2VyUHVibGljS2V5AQJmYwACEyVzX19mYWN0b3J5Q29udHJhY3QAD2ZhY3RvcnlDb250cmFjdAkBEUBleHRyTmF0aXZlKDEwNjIpAQkBD2dldFN0cmluZ09yRmFpbAE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lPclVuaXQAAwkAAQIFByRtYXRjaDACCkJ5dGVWZWN0b3IEAnBrBQckbWF0Y2gwBQJwawMJAAECBQckbWF0Y2gwAgRVbml0CAUCdHgPc2VuZGVyUHVibGljS2V5CQACAQILTWF0Y2ggZXJyb3IJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAFD3RhcmdldFB1YmxpY0tleVf/3mw=", "height": 2492672, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: GM9X9b6XVd4QXWzch2bDB1GBgue7ScY9iAwbKoGW6eFN Next: J3xLZsKykoorj8hY2fMpGxY96db7LU9Zdkj2yBDbCcFn Diff:
Old | New | Differences | |
---|---|---|---|
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let a = "__" | |
5 | 5 | ||
6 | - | let b = | |
6 | + | let b = toBigInt(100000000) | |
7 | 7 | ||
8 | - | let c = "WAVES" | |
9 | - | ||
10 | - | let d = 1000000000000000000 | |
11 | - | ||
12 | - | let e = toBigInt(d) | |
13 | - | ||
14 | - | func f (g) = makeString(["lp_staking_pools.ride:", g], " ") | |
8 | + | func c (d) = valueOrErrorMessage(getString(this, d), ("No data for this.key=" + d)) | |
15 | 9 | ||
16 | 10 | ||
17 | - | func h (g) = throw(f(g)) | |
11 | + | let e = throw("Pool disabled") | |
12 | + | ||
13 | + | let f = throw("Pool is not exist") | |
14 | + | ||
15 | + | let g = throw("Slippage is too big") | |
16 | + | ||
17 | + | func h () = "%s__managerPublicKey" | |
18 | 18 | ||
19 | 19 | ||
20 | - | func i ( | |
20 | + | func i () = "%s__pendingManagerPublicKey" | |
21 | 21 | ||
22 | 22 | ||
23 | - | func | |
23 | + | func j () = "%s__factoryContract" | |
24 | 24 | ||
25 | 25 | ||
26 | - | func m (j,k) = valueOrErrorMessage(getInteger(j, k), i(j, k)) | |
26 | + | let k = addressFromStringValue(c(j())) | |
27 | + | ||
28 | + | func l () = makeString(["%s", "protocolFee"], a) | |
27 | 29 | ||
28 | 30 | ||
29 | - | func n (o) = if ((o == c)) | |
30 | - | then unit | |
31 | - | else fromBase58String(o) | |
31 | + | func m () = makeString(["%s", "poolFee"], a) | |
32 | 32 | ||
33 | 33 | ||
34 | - | func p (o) = if ((o == unit)) | |
35 | - | then c | |
36 | - | else toBase58String(value(o)) | |
34 | + | func n (o,d) = valueOrErrorMessage(getString(o, d), makeString(["mandatory ", toString(o), ".", d, " is not defined"], "")) | |
37 | 35 | ||
38 | 36 | ||
39 | - | func q (r) = if ((r >= 0)) | |
40 | - | then r | |
41 | - | else h("value should be positive") | |
37 | + | let p = "%s__feeCollectorAddress" | |
38 | + | ||
39 | + | let q = addressFromStringValue(n(k, p)) | |
40 | + | ||
41 | + | func r (s) = { | |
42 | + | let t = s | |
43 | + | if ($isInstanceOf(t, "Int")) | |
44 | + | then { | |
45 | + | let u = t | |
46 | + | u | |
47 | + | } | |
48 | + | else throw("fail to cast into Int") | |
49 | + | } | |
42 | 50 | ||
43 | 51 | ||
44 | - | func | |
52 | + | func v (w,x) = makeString(["%d%d", toString(w), toString(x)], a) | |
45 | 53 | ||
46 | 54 | ||
47 | - | func t () = makeString(["%s", "lpStakingContract"], a) | |
48 | - | ||
49 | - | ||
50 | - | func u () = makeString(["%s", "stakingContract"], a) | |
51 | - | ||
52 | - | ||
53 | - | func v () = makeString(["%s", "boostingContract"], a) | |
54 | - | ||
55 | - | ||
56 | - | func w () = makeString(["%s", "swapContract"], a) | |
57 | - | ||
58 | - | ||
59 | - | func x () = makeString(["%s", "assetsStoreContract"], a) | |
60 | - | ||
61 | - | ||
62 | - | func y () = makeString(["%s", "usdtAssetId"], a) | |
63 | - | ||
64 | - | ||
65 | - | func z () = makeString(["%s", "wxAssetId"], a) | |
66 | - | ||
67 | - | ||
68 | - | func A () = makeString(["%s", "shutdown"], a) | |
69 | - | ||
70 | - | ||
71 | - | func B () = makeString(["%s", "minDelay"], a) | |
72 | - | ||
73 | - | ||
74 | - | func C () = makeString(["%s", "lockFraction"], a) | |
75 | - | ||
76 | - | ||
77 | - | func D (E) = makeString(["%s%s", p(E), "shareAssetId"], a) | |
78 | - | ||
79 | - | ||
80 | - | func F (G) = makeString(["%s%s", p(G), "baseAssetId"], a) | |
81 | - | ||
82 | - | ||
83 | - | func H (E) = makeString(["%s%s", p(E), "period"], a) | |
84 | - | ||
85 | - | ||
86 | - | func I (E,J) = makeString(["%s%s%d", p(E), "periodStartHeight", toString(J)], a) | |
87 | - | ||
88 | - | ||
89 | - | func K (E) = makeString(["%s%s", p(E), "baseAssetAmountToConvert"], a) | |
90 | - | ||
91 | - | ||
92 | - | func L (E) = makeString(["%s%s", p(E), "shareAssetAmountToConvert"], a) | |
93 | - | ||
94 | - | ||
95 | - | func M (E,N) = makeString(["%s%s%s", p(E), toString(N), "baseAssetAmountToConvert"], a) | |
96 | - | ||
97 | - | ||
98 | - | func O (E,N) = makeString(["%s%s%s%s", p(E), toString(N), "baseAssetAmountToConvert", "period"], a) | |
99 | - | ||
100 | - | ||
101 | - | func P (E,N) = makeString(["%s%s%s", p(E), toString(N), "shareAssetAmountToConvert"], a) | |
102 | - | ||
103 | - | ||
104 | - | func Q (E,N) = makeString(["%s%s%s%s", p(E), toString(N), "shareAssetAmountToConvert", "period"], a) | |
105 | - | ||
106 | - | ||
107 | - | func R (E,J) = makeString(["%s%s%d", p(E), "price", toString(J)], a) | |
108 | - | ||
109 | - | ||
110 | - | func S (E) = makeString(["%s%s%s%d%d", p(E), "price", "history", toString(lastBlock.height), toString(lastBlock.timestamp)], a) | |
111 | - | ||
112 | - | ||
113 | - | func T (E,J) = makeString(["%s%s%d%s", p(E), "price", toString(J), "put"], a) | |
114 | - | ||
115 | - | ||
116 | - | func U (E) = makeString(["%s%s%s%s%d%d", p(E), "price", "history", "put", toString(lastBlock.height), toString(lastBlock.timestamp)], a) | |
117 | - | ||
118 | - | ||
119 | - | func V (E,J) = makeString(["%s%s%d%s", p(E), "price", toString(J), "get"], a) | |
120 | - | ||
121 | - | ||
122 | - | func W (E) = makeString(["%s%s%s%s%d%d", p(E), "price", "history", "get", toString(lastBlock.height), toString(lastBlock.timestamp)], a) | |
123 | - | ||
124 | - | ||
125 | - | func X (E,Y,J,N,Z) = makeString(["%s%s%s%s", "history", Y, toString(N), toBase58String(Z), toString(height)], a) | |
126 | - | ||
127 | - | ||
128 | - | func aa () = "%s__managerPublicKey" | |
129 | - | ||
130 | - | ||
131 | - | func ab () = "%s__pendingManagerPublicKey" | |
132 | - | ||
133 | - | ||
134 | - | func ac () = { | |
135 | - | let ad = getString(aa()) | |
136 | - | if ($isInstanceOf(ad, "String")) | |
55 | + | func y () = { | |
56 | + | let t = getString(h()) | |
57 | + | if ($isInstanceOf(t, "String")) | |
137 | 58 | then { | |
138 | - | let | |
139 | - | fromBase58String( | |
59 | + | let z = t | |
60 | + | fromBase58String(z) | |
140 | 61 | } | |
141 | - | else if ($isInstanceOf( | |
62 | + | else if ($isInstanceOf(t, "Unit")) | |
142 | 63 | then unit | |
143 | 64 | else throw("Match error") | |
144 | 65 | } | |
145 | 66 | ||
146 | 67 | ||
147 | - | func | |
148 | - | let | |
149 | - | if ($isInstanceOf( | |
68 | + | func A () = { | |
69 | + | let t = getString(i()) | |
70 | + | if ($isInstanceOf(t, "String")) | |
150 | 71 | then { | |
151 | - | let | |
152 | - | fromBase58String( | |
72 | + | let z = t | |
73 | + | fromBase58String(z) | |
153 | 74 | } | |
154 | - | else if ($isInstanceOf( | |
75 | + | else if ($isInstanceOf(t, "Unit")) | |
155 | 76 | then unit | |
156 | 77 | else throw("Match error") | |
157 | 78 | } | |
158 | 79 | ||
159 | 80 | ||
160 | - | let ag = throw("Permission denied") | |
161 | - | ||
162 | - | func ah (ai) = if ((ai.caller == this)) | |
163 | - | then true | |
164 | - | else ag | |
165 | - | ||
166 | - | ||
167 | - | func aj (ai) = { | |
168 | - | let ad = ac() | |
169 | - | if ($isInstanceOf(ad, "ByteVector")) | |
81 | + | func B (C) = { | |
82 | + | let t = y() | |
83 | + | if ($isInstanceOf(t, "ByteVector")) | |
170 | 84 | then { | |
171 | - | let ak = ad | |
172 | - | if ((ai.callerPublicKey == ak)) | |
173 | - | then true | |
174 | - | else ag | |
85 | + | let D = t | |
86 | + | (C.callerPublicKey == D) | |
175 | 87 | } | |
176 | - | else if ($isInstanceOf( | |
177 | - | then | |
88 | + | else if ($isInstanceOf(t, "Unit")) | |
89 | + | then (C.caller == this) | |
178 | 90 | else throw("Match error") | |
179 | 91 | } | |
180 | 92 | ||
181 | 93 | ||
182 | - | let al = valueOrElse(getBoolean(A()), false) | |
183 | - | ||
184 | - | func am (ai) = if (if (!(al)) | |
94 | + | func E (C) = if (B(C)) | |
185 | 95 | then true | |
186 | - | else aj(ai)) | |
187 | - | then true | |
188 | - | else throw("operation is disabled") | |
96 | + | else throw("permission denied") | |
189 | 97 | ||
190 | 98 | ||
191 | - | let an = addressFromStringValue(l(this, s())) | |
99 | + | func F (G) = if ((G == "WAVES")) | |
100 | + | then wavesBalance(this).available | |
101 | + | else assetBalance(this, fromBase58String(G)) | |
192 | 102 | ||
193 | - | let ao = addressFromStringValue(l(this, t())) | |
194 | 103 | ||
195 | - | let ap = addressFromStringValue(l(this, u())) | |
196 | - | ||
197 | - | let aq = addressFromStringValue(l(this, v())) | |
198 | - | ||
199 | - | let ar = addressFromStringValue(l(this, w())) | |
200 | - | ||
201 | - | let as = addressFromStringValue(l(this, x())) | |
202 | - | ||
203 | - | let at = n(l(this, y())) | |
204 | - | ||
205 | - | let au = n(l(this, z())) | |
206 | - | ||
207 | - | let av = 1440 | |
208 | - | ||
209 | - | let aw = valueOrElse(getInteger(this, B()), av) | |
210 | - | ||
211 | - | let ax = 100000000 | |
212 | - | ||
213 | - | let ay = fraction(1, ax, 2) | |
214 | - | ||
215 | - | let az = valueOrElse(getInteger(this, C()), ay) | |
216 | - | ||
217 | - | func aA (aB) = { | |
218 | - | let aC = p(aB) | |
219 | - | let aD = p(at) | |
220 | - | let aE = { | |
221 | - | let aF = invoke(an, "poolInfoREADONLY", [aC, aD], nil) | |
222 | - | if ($isInstanceOf(aF, "(Address, ByteVector)")) | |
223 | - | then aF | |
104 | + | func H (I,J) = { | |
105 | + | let K = { | |
106 | + | let L = invoke(k, "getLpAssetFromPoolAssetsREADONLY", [I, J], nil) | |
107 | + | if ($isInstanceOf(L, "String")) | |
108 | + | then L | |
224 | 109 | else unit | |
225 | 110 | } | |
226 | - | aE | |
111 | + | let M = { | |
112 | + | let L = invoke(k, "getLpAssetFromPoolAssetsREADONLY", [J, I], nil) | |
113 | + | if ($isInstanceOf(L, "String")) | |
114 | + | then L | |
115 | + | else unit | |
116 | + | } | |
117 | + | let N = if ((K != unit)) | |
118 | + | then { | |
119 | + | let O = { | |
120 | + | let L = invoke(k, "getPoolAddressFromLpAssetREADONLY", [value(K)], nil) | |
121 | + | if ($isInstanceOf(L, "String")) | |
122 | + | then L | |
123 | + | else throw(($getType(L) + " couldn't be cast to String")) | |
124 | + | } | |
125 | + | $Tuple2(false, O) | |
126 | + | } | |
127 | + | else if ((M != unit)) | |
128 | + | then { | |
129 | + | let O = { | |
130 | + | let L = invoke(k, "getPoolAddressFromLpAssetREADONLY", [value(M)], nil) | |
131 | + | if ($isInstanceOf(L, "String")) | |
132 | + | then L | |
133 | + | else throw(($getType(L) + " couldn't be cast to String")) | |
134 | + | } | |
135 | + | $Tuple2(true, O) | |
136 | + | } | |
137 | + | else f | |
138 | + | let P = N._1 | |
139 | + | let O = N._2 | |
140 | + | let Q = { | |
141 | + | let L = invoke(k, "getPoolStatusREADONLY", [O], nil) | |
142 | + | if ($isInstanceOf(L, "Int")) | |
143 | + | then L | |
144 | + | else throw(($getType(L) + " couldn't be cast to Int")) | |
145 | + | } | |
146 | + | let R = if ((Q == 1)) | |
147 | + | then true | |
148 | + | else e | |
149 | + | if ((R == R)) | |
150 | + | then { | |
151 | + | let S = addressFromStringValue(valueOrElse(O, "")) | |
152 | + | $Tuple2(S, P) | |
153 | + | } | |
154 | + | else throw("Strict value is not equal to itself.") | |
227 | 155 | } | |
228 | 156 | ||
229 | 157 | ||
230 | - | func aG (aH,G) = { | |
231 | - | let aI = valueOrErrorMessage(assetInfo(G), "failed to get share asset info") | |
232 | - | let aJ = aI.quantity | |
233 | - | let aK = q(valueOrErrorMessage({ | |
234 | - | let aF = invoke(ap, "stakedByUserREADONLY", [p(aH), toString(this)], nil) | |
235 | - | if ($isInstanceOf(aF, "Int")) | |
236 | - | then aF | |
237 | - | else unit | |
238 | - | }, f("invalid stakedByUserREADONLY result"))) | |
239 | - | let aL = if ((aJ == 0)) | |
240 | - | then e | |
241 | - | else fraction(toBigInt(aK), e, toBigInt(aJ), FLOOR) | |
242 | - | aL | |
158 | + | @Callable(C) | |
159 | + | func swapCalculateREADONLY (T,I,J) = { | |
160 | + | let U = value(getInteger(l())) | |
161 | + | let V = fraction(toBigInt(T), toBigInt(U), b) | |
162 | + | let W = value(getInteger(m())) | |
163 | + | let X = fraction(toBigInt(T), toBigInt(W), b) | |
164 | + | let Y = if ((toInt(V) == 0)) | |
165 | + | then toBigInt(1) | |
166 | + | else V | |
167 | + | let Z = if ((toInt(X) == 0)) | |
168 | + | then toBigInt(1) | |
169 | + | else X | |
170 | + | let aa = ((toBigInt(T) - Y) - Z) | |
171 | + | let ab = H(I, J) | |
172 | + | let S = ab._1 | |
173 | + | let P = ab._2 | |
174 | + | let ac = { | |
175 | + | let L = invoke(S, "calculateAmountOutForSwapREADONLY", [toInt(aa), P, toInt(Z)], nil) | |
176 | + | if ($isInstanceOf(L, "Int")) | |
177 | + | then L | |
178 | + | else throw(($getType(L) + " couldn't be cast to Int")) | |
179 | + | } | |
180 | + | $Tuple2(nil, ac) | |
243 | 181 | } | |
244 | 182 | ||
245 | 183 | ||
246 | - | @Callable(ai) | |
247 | - | func setManager (aM) = { | |
248 | - | let aN = aj(ai) | |
249 | - | if ((aN == aN)) | |
184 | + | ||
185 | + | @Callable(C) | |
186 | + | func swap (ad,ae,af) = { | |
187 | + | let J = if ((ae == "")) | |
188 | + | then "WAVES" | |
189 | + | else ae | |
190 | + | let ag = value(C.payments[0]) | |
191 | + | let I = if ((ag.assetId == unit)) | |
192 | + | then "WAVES" | |
193 | + | else toBase58String(value(ag.assetId)) | |
194 | + | let T = value(ag.amount) | |
195 | + | let U = value(getInteger(l())) | |
196 | + | let V = fraction(toBigInt(T), toBigInt(U), b) | |
197 | + | let W = value(getInteger(m())) | |
198 | + | let X = fraction(toBigInt(T), toBigInt(W), b) | |
199 | + | let Y = if ((toInt(V) == 0)) | |
200 | + | then toBigInt(1) | |
201 | + | else V | |
202 | + | let Z = if ((toInt(X) == 0)) | |
203 | + | then toBigInt(1) | |
204 | + | else X | |
205 | + | let aa = ((toBigInt(T) - Y) - Z) | |
206 | + | let ah = [if ((size(C.payments) == 1)) | |
207 | + | then true | |
208 | + | else throw("exactly 1 payment are expected")] | |
209 | + | if ((ah == ah)) | |
250 | 210 | then { | |
251 | - | let aO = fromBase58String(aM) | |
252 | - | if ((aO == aO)) | |
253 | - | then [StringEntry(ab(), aM)] | |
211 | + | let ai = H(I, J) | |
212 | + | let S = ai._1 | |
213 | + | let P = ai._2 | |
214 | + | let aj = if ((I == "WAVES")) | |
215 | + | then unit | |
216 | + | else fromBase58String(I) | |
217 | + | let ak = { | |
218 | + | let L = invoke(S, "calculateAmountOutForSwapAndSendTokens", [toInt(aa), P, ad, af, toInt(Z)], [AttachedPayment(aj, toInt(aa))]) | |
219 | + | if ($isInstanceOf(L, "Int")) | |
220 | + | then L | |
221 | + | else throw(($getType(L) + " couldn't be cast to Int")) | |
222 | + | } | |
223 | + | $Tuple2([ScriptTransfer(q, toInt(Y), aj), ScriptTransfer(S, toInt(Z), aj)], ak) | |
224 | + | } | |
225 | + | else throw("Strict value is not equal to itself.") | |
226 | + | } | |
227 | + | ||
228 | + | ||
229 | + | ||
230 | + | @Callable(C) | |
231 | + | func setManager (al) = { | |
232 | + | let am = E(C) | |
233 | + | if ((am == am)) | |
234 | + | then { | |
235 | + | let an = fromBase58String(al) | |
236 | + | if ((an == an)) | |
237 | + | then [StringEntry(i(), al)] | |
254 | 238 | else throw("Strict value is not equal to itself.") | |
255 | 239 | } | |
256 | 240 | else throw("Strict value is not equal to itself.") | |
258 | 242 | ||
259 | 243 | ||
260 | 244 | ||
261 | - | @Callable( | |
245 | + | @Callable(C) | |
262 | 246 | func confirmManager () = { | |
263 | - | let | |
264 | - | let | |
247 | + | let ao = A() | |
248 | + | let ap = if (isDefined(ao)) | |
265 | 249 | then true | |
266 | - | else | |
267 | - | if (( | |
250 | + | else throw("no pending manager") | |
251 | + | if ((ap == ap)) | |
268 | 252 | then { | |
269 | - | let | |
253 | + | let aq = if ((C.callerPublicKey == value(ao))) | |
270 | 254 | then true | |
271 | - | else | |
272 | - | if (( | |
273 | - | then [StringEntry( | |
255 | + | else throw("you are not pending manager") | |
256 | + | if ((aq == aq)) | |
257 | + | then [StringEntry(h(), toBase58String(value(ao))), DeleteEntry(i())] | |
274 | 258 | else throw("Strict value is not equal to itself.") | |
275 | 259 | } | |
276 | 260 | else throw("Strict value is not equal to itself.") | |
277 | 261 | } | |
278 | 262 | ||
279 | 263 | ||
280 | - | ||
281 | - | @Callable(ai) | |
282 | - | func emit (aS,aT) = { | |
283 | - | let aN = ah(ai) | |
284 | - | if ((aN == aN)) | |
285 | - | then { | |
286 | - | let aU = true | |
287 | - | $Tuple2([Reissue(aS, aT, aU)], aT) | |
288 | - | } | |
289 | - | else throw("Strict value is not equal to itself.") | |
290 | - | } | |
291 | - | ||
292 | - | ||
293 | - | ||
294 | - | @Callable(ai) | |
295 | - | func burn (aS,aT) = { | |
296 | - | let aN = ah(ai) | |
297 | - | if ((aN == aN)) | |
298 | - | then $Tuple2([Burn(aS, aT)], aT) | |
299 | - | else throw("Strict value is not equal to itself.") | |
300 | - | } | |
301 | - | ||
302 | - | ||
303 | - | ||
304 | - | @Callable(ai) | |
305 | - | func create (aV,aW,aX,aY,aZ) = { | |
306 | - | let ba = "STAKING_LP" | |
307 | - | let E = n(aV) | |
308 | - | let bb = [aj(ai), if (isDefined(aA(E))) | |
309 | - | then true | |
310 | - | else h("invalid base asset")] | |
311 | - | if ((bb == bb)) | |
312 | - | then { | |
313 | - | let bc = [IntegerEntry(H(E), 0)] | |
314 | - | if ((aW == "")) | |
315 | - | then { | |
316 | - | let bd = 1 | |
317 | - | let be = Issue(aX, aY, bd, b, true) | |
318 | - | let bf = calculateAssetId(be) | |
319 | - | let bg = Burn(bf, bd) | |
320 | - | let bh = toBase58String(bf) | |
321 | - | let bi = invoke(as, "createOrUpdate", [bh, aZ, false], nil) | |
322 | - | if ((bi == bi)) | |
323 | - | then { | |
324 | - | let bj = invoke(as, "addLabel", [bh, ba], nil) | |
325 | - | if ((bj == bj)) | |
326 | - | then $Tuple2((bc ++ [be, bg, StringEntry(D(E), bh), StringEntry(F(bf), aV)]), bh) | |
327 | - | else throw("Strict value is not equal to itself.") | |
328 | - | } | |
329 | - | else throw("Strict value is not equal to itself.") | |
330 | - | } | |
331 | - | else { | |
332 | - | let G = fromBase58String(aW) | |
333 | - | let aI = valueOrErrorMessage(assetInfo(G), f("invalid share asset id")) | |
334 | - | let bk = if ((aI.issuer == ao)) | |
335 | - | then true | |
336 | - | else h("invalid share asset id issuer") | |
337 | - | if ((bk == bk)) | |
338 | - | then $Tuple2((bc ++ [StringEntry(D(E), aW), StringEntry(F(G), aV)]), aW) | |
339 | - | else throw("Strict value is not equal to itself.") | |
340 | - | } | |
341 | - | } | |
342 | - | else throw("Strict value is not equal to itself.") | |
343 | - | } | |
344 | - | ||
345 | - | ||
346 | - | ||
347 | - | @Callable(ai) | |
348 | - | func put () = { | |
349 | - | let bl = if ((size(ai.payments) == 1)) | |
350 | - | then ai.payments[0] | |
351 | - | else h("exactly 1 payment is expected") | |
352 | - | let E = bl.assetId | |
353 | - | let N = ai.caller | |
354 | - | let bb = [am(ai), if (isDefined(getString(D(E)))) | |
355 | - | then true | |
356 | - | else h("invalid asset")] | |
357 | - | if ((bb == bb)) | |
358 | - | then { | |
359 | - | let bm = valueOrErrorMessage(aA(E), f("invalid asset")) | |
360 | - | let bn = bm._1 | |
361 | - | let aH = bm._2 | |
362 | - | let J = value(getInteger(H(E))) | |
363 | - | let bo = getInteger(O(E, N)) | |
364 | - | let bp = if ((bo == unit)) | |
365 | - | then unit | |
366 | - | else { | |
367 | - | let bq = value(bo) | |
368 | - | if ((bq == J)) | |
369 | - | then unit | |
370 | - | else invoke(this, "claimShareAsset", [p(E), toString(N)], nil) | |
371 | - | } | |
372 | - | if ((bp == bp)) | |
373 | - | then { | |
374 | - | let br = valueOrElse(getInteger(K(E)), 0) | |
375 | - | let bs = valueOrElse(getInteger(M(E, N)), 0) | |
376 | - | $Tuple2([IntegerEntry(K(E), (br + bl.amount)), IntegerEntry(M(E, N), (bs + bl.amount)), IntegerEntry(O(E, N), J), IntegerEntry(X(E, "put", J, N, ai.transactionId), bl.amount)], unit) | |
377 | - | } | |
378 | - | else throw("Strict value is not equal to itself.") | |
379 | - | } | |
380 | - | else throw("Strict value is not equal to itself.") | |
381 | - | } | |
382 | - | ||
383 | - | ||
384 | - | ||
385 | - | @Callable(ai) | |
386 | - | func claimShareAsset (aV,bt) = { | |
387 | - | let bb = [am(ai)] | |
388 | - | if ((bb == bb)) | |
389 | - | then { | |
390 | - | let N = if ((bt == "")) | |
391 | - | then ai.caller | |
392 | - | else { | |
393 | - | let aN = ah(ai) | |
394 | - | if ((aN == aN)) | |
395 | - | then valueOrErrorMessage(addressFromString(bt), f("invalid user address")) | |
396 | - | else throw("Strict value is not equal to itself.") | |
397 | - | } | |
398 | - | if ((N == N)) | |
399 | - | then { | |
400 | - | let E = n(aV) | |
401 | - | let G = value(n(valueOrErrorMessage(getString(D(E)), f("invalid base asset id")))) | |
402 | - | if ((G == G)) | |
403 | - | then { | |
404 | - | let J = valueOrErrorMessage(getInteger(H(E)), f("invalid period")) | |
405 | - | if ((J == J)) | |
406 | - | then { | |
407 | - | let bs = valueOrElse(getInteger(M(E, N)), 0) | |
408 | - | let bu = if ((bs > 0)) | |
409 | - | then true | |
410 | - | else h("nothing to claim") | |
411 | - | if ((bu == bu)) | |
412 | - | then { | |
413 | - | let bq = valueOrErrorMessage(getInteger(O(E, N)), f("failed to get period")) | |
414 | - | let bv = if ((J > bq)) | |
415 | - | then true | |
416 | - | else h("invalid period") | |
417 | - | if ((bv == bv)) | |
418 | - | then { | |
419 | - | let aL = toBigInt(valueOrErrorMessage(getBinary(T(E, bq)), f("failed to get price"))) | |
420 | - | let bw = toInt(fraction(toBigInt(bs), e, aL)) | |
421 | - | $Tuple2([IntegerEntry(M(E, N), 0), DeleteEntry(O(E, N)), ScriptTransfer(N, bw, G), IntegerEntry(X(E, "claimShareAsset", J, N, ai.transactionId), bw)], unit) | |
422 | - | } | |
423 | - | else throw("Strict value is not equal to itself.") | |
424 | - | } | |
425 | - | else throw("Strict value is not equal to itself.") | |
426 | - | } | |
427 | - | else throw("Strict value is not equal to itself.") | |
428 | - | } | |
429 | - | else throw("Strict value is not equal to itself.") | |
430 | - | } | |
431 | - | else throw("Strict value is not equal to itself.") | |
432 | - | } | |
433 | - | else throw("Strict value is not equal to itself.") | |
434 | - | } | |
435 | - | ||
436 | - | ||
437 | - | ||
438 | - | @Callable(ai) | |
439 | - | func get () = { | |
440 | - | let bb = [am(ai)] | |
441 | - | if ((bb == bb)) | |
442 | - | then { | |
443 | - | let bl = if ((size(ai.payments) == 1)) | |
444 | - | then ai.payments[0] | |
445 | - | else h("exactly 1 payment is expected") | |
446 | - | let G = bl.assetId | |
447 | - | let E = value(n(valueOrErrorMessage(getString(F(G)), f("invalid share asset id")))) | |
448 | - | if ((E == E)) | |
449 | - | then { | |
450 | - | let N = ai.caller | |
451 | - | let bx = valueOrErrorMessage(aA(E), f("invalid asset")) | |
452 | - | let bn = bx._1 | |
453 | - | let aH = bx._2 | |
454 | - | let J = value(getInteger(H(E))) | |
455 | - | let by = getInteger(Q(E, N)) | |
456 | - | let bz = if ((by == unit)) | |
457 | - | then unit | |
458 | - | else { | |
459 | - | let bA = value(by) | |
460 | - | if ((bA == J)) | |
461 | - | then unit | |
462 | - | else invoke(this, "claimBaseAsset", [p(E), toString(N)], nil) | |
463 | - | } | |
464 | - | if ((bz == bz)) | |
465 | - | then { | |
466 | - | let bB = valueOrElse(getInteger(L(E)), 0) | |
467 | - | let bC = valueOrElse(getInteger(P(E, N)), 0) | |
468 | - | $Tuple2([IntegerEntry(L(E), (bB + bl.amount)), IntegerEntry(P(E, N), (bC + bl.amount)), IntegerEntry(Q(E, N), J), IntegerEntry(X(E, "get", J, N, ai.transactionId), bl.amount)], unit) | |
469 | - | } | |
470 | - | else throw("Strict value is not equal to itself.") | |
471 | - | } | |
472 | - | else throw("Strict value is not equal to itself.") | |
473 | - | } | |
474 | - | else throw("Strict value is not equal to itself.") | |
475 | - | } | |
476 | - | ||
477 | - | ||
478 | - | ||
479 | - | @Callable(ai) | |
480 | - | func claimBaseAsset (aV,bt) = { | |
481 | - | let bb = [am(ai)] | |
482 | - | if ((bb == bb)) | |
483 | - | then { | |
484 | - | let N = if ((bt == "")) | |
485 | - | then ai.caller | |
486 | - | else { | |
487 | - | let aN = ah(ai) | |
488 | - | if ((aN == aN)) | |
489 | - | then valueOrErrorMessage(addressFromString(bt), f("invalid user address")) | |
490 | - | else throw("Strict value is not equal to itself.") | |
491 | - | } | |
492 | - | if ((N == N)) | |
493 | - | then { | |
494 | - | let E = n(aV) | |
495 | - | let G = value(n(valueOrErrorMessage(getString(D(E)), f("invalid base asset id")))) | |
496 | - | if ((G == G)) | |
497 | - | then { | |
498 | - | let J = valueOrErrorMessage(getInteger(H(E)), f("invalid period")) | |
499 | - | if ((J == J)) | |
500 | - | then { | |
501 | - | let bC = valueOrElse(getInteger(P(E, N)), 0) | |
502 | - | let bu = if ((bC > 0)) | |
503 | - | then true | |
504 | - | else h("nothing to claim") | |
505 | - | if ((bu == bu)) | |
506 | - | then { | |
507 | - | let bA = valueOrErrorMessage(getInteger(Q(E, N)), f("failed to get period")) | |
508 | - | let bv = if ((J > bA)) | |
509 | - | then true | |
510 | - | else h("invalid period") | |
511 | - | if ((bv == bv)) | |
512 | - | then { | |
513 | - | let aL = toBigInt(valueOrErrorMessage(getBinary(V(E, bA)), f("failed to get price"))) | |
514 | - | let bD = toInt(fraction(toBigInt(bC), aL, e)) | |
515 | - | $Tuple2([IntegerEntry(P(E, N), 0), DeleteEntry(Q(E, N)), ScriptTransfer(N, bD, E), IntegerEntry(X(E, "claimBaseAsset", J, N, ai.transactionId), bD)], unit) | |
516 | - | } | |
517 | - | else throw("Strict value is not equal to itself.") | |
518 | - | } | |
519 | - | else throw("Strict value is not equal to itself.") | |
520 | - | } | |
521 | - | else throw("Strict value is not equal to itself.") | |
522 | - | } | |
523 | - | else throw("Strict value is not equal to itself.") | |
524 | - | } | |
525 | - | else throw("Strict value is not equal to itself.") | |
526 | - | } | |
527 | - | else throw("Strict value is not equal to itself.") | |
528 | - | } | |
529 | - | ||
530 | - | ||
531 | - | ||
532 | - | @Callable(ai) | |
533 | - | func finalize (aV) = { | |
534 | - | let bb = [am(ai)] | |
535 | - | if ((bb == bb)) | |
536 | - | then { | |
537 | - | let E = n(aV) | |
538 | - | let G = value(n(valueOrErrorMessage(getString(D(E)), f("invalid base asset id")))) | |
539 | - | if ((G == G)) | |
540 | - | then { | |
541 | - | let aI = valueOrErrorMessage(assetInfo(G), f("invalid share asset id")) | |
542 | - | let J = valueOrErrorMessage(getInteger(H(E)), f("invalid period")) | |
543 | - | if ((J == J)) | |
544 | - | then { | |
545 | - | let bE = getInteger(I(E, J)) | |
546 | - | let bF = if ((bE == unit)) | |
547 | - | then unit | |
548 | - | else { | |
549 | - | let bG = (height - value(bE)) | |
550 | - | let bH = max([0, (aw - bG)]) | |
551 | - | if ((bH == 0)) | |
552 | - | then unit | |
553 | - | else h(makeString(["finalization will be possible in ", toString(bH), " blocks"], "")) | |
554 | - | } | |
555 | - | if ((bF == bF)) | |
556 | - | then { | |
557 | - | let bI = valueOrErrorMessage(aA(E), f("invalid asset")) | |
558 | - | let bn = bI._1 | |
559 | - | let aH = bI._2 | |
560 | - | let bJ = valueOrErrorMessage({ | |
561 | - | let aF = invoke(ap, "claimWxDoNotThrow", [p(aH)], nil) | |
562 | - | if ($isInstanceOf(aF, "Int")) | |
563 | - | then aF | |
564 | - | else unit | |
565 | - | }, f("invalid claimWx result")) | |
566 | - | if ((bJ == bJ)) | |
567 | - | then { | |
568 | - | let br = valueOrElse(getInteger(K(E)), 0) | |
569 | - | let bB = valueOrElse(getInteger(L(E)), 0) | |
570 | - | let bK = { | |
571 | - | let bL = if (if ((bJ > 0)) | |
572 | - | then true | |
573 | - | else (br > 0)) | |
574 | - | then true | |
575 | - | else (bB > 0) | |
576 | - | if (bL) | |
577 | - | then true | |
578 | - | else h("nothing to finalize") | |
579 | - | } | |
580 | - | if ((bK == bK)) | |
581 | - | then { | |
582 | - | let bM = if ((bJ > 0)) | |
583 | - | then { | |
584 | - | let bN = fraction(bJ, az, ax) | |
585 | - | let bO = (bJ - bN) | |
586 | - | let bP = invoke(aq, "userMaxDurationREADONLY", [toString(this)], nil) | |
587 | - | let bQ = if ((bN > 0)) | |
588 | - | then { | |
589 | - | let ad = bP | |
590 | - | if (if (if ($isInstanceOf(ad._1, "String")) | |
591 | - | then $isInstanceOf(ad._2, "Int") | |
592 | - | else false) | |
593 | - | then $isInstanceOf(ad, "(String, Int)") | |
594 | - | else false) | |
595 | - | then { | |
596 | - | let bR = ad._1 | |
597 | - | let bS = ad._2 | |
598 | - | if ((bN > 0)) | |
599 | - | then invoke(aq, bR, [bS], [AttachedPayment(au, bN)]) | |
600 | - | else unit | |
601 | - | } | |
602 | - | else h("invalid lock params") | |
603 | - | } | |
604 | - | else unit | |
605 | - | if ((bQ == bQ)) | |
606 | - | then { | |
607 | - | let bT = if ((bO > 0)) | |
608 | - | then { | |
609 | - | let bU = au | |
610 | - | let bV = 0 | |
611 | - | let bW = p(at) | |
612 | - | let bX = toString(this) | |
613 | - | valueOrErrorMessage({ | |
614 | - | let aF = invoke(ar, "swap", [bV, bW, bX], [AttachedPayment(bU, bO)]) | |
615 | - | if ($isInstanceOf(aF, "Int")) | |
616 | - | then aF | |
617 | - | else unit | |
618 | - | }, f("invalid swap result")) | |
619 | - | } | |
620 | - | else 0 | |
621 | - | if ((bT == bT)) | |
622 | - | then { | |
623 | - | let bY = if ((bT > 0)) | |
624 | - | then { | |
625 | - | let bZ = 0 | |
626 | - | let ca = true | |
627 | - | valueOrErrorMessage({ | |
628 | - | let aF = invoke(bn, "putOneTknV2", [bZ, ca], [AttachedPayment(at, bT)]) | |
629 | - | if ($isInstanceOf(aF, "Int")) | |
630 | - | then aF | |
631 | - | else unit | |
632 | - | }, f("invalid putOneTknV2 result")) | |
633 | - | } | |
634 | - | else 0 | |
635 | - | if ((bY == bY)) | |
636 | - | then bY | |
637 | - | else throw("Strict value is not equal to itself.") | |
638 | - | } | |
639 | - | else throw("Strict value is not equal to itself.") | |
640 | - | } | |
641 | - | else throw("Strict value is not equal to itself.") | |
642 | - | } | |
643 | - | else unit | |
644 | - | if ((bM == bM)) | |
645 | - | then { | |
646 | - | let cb = if ((bB > 0)) | |
647 | - | then { | |
648 | - | let aL = aG(aH, G) | |
649 | - | if ((aL == aL)) | |
650 | - | then { | |
651 | - | let cc = toInt(fraction(toBigInt(bB), aL, e, FLOOR)) | |
652 | - | let bD = { | |
653 | - | let cd = E | |
654 | - | let bZ = 0 | |
655 | - | valueOrErrorMessage({ | |
656 | - | let aF = invoke(bn, "unstakeAndGetOneTknV2", [cc, p(cd), bZ], nil) | |
657 | - | if ($isInstanceOf(aF, "Int")) | |
658 | - | then aF | |
659 | - | else unit | |
660 | - | }, f("invalid unstakeAndGetOneTknV2 result")) | |
661 | - | } | |
662 | - | if ((bD == bD)) | |
663 | - | then { | |
664 | - | let ce = if ((aI.issuer == this)) | |
665 | - | then invoke(this, "burn", [G, bB], nil) | |
666 | - | else h("invalid share asset issuer") | |
667 | - | if ((ce == ce)) | |
668 | - | then { | |
669 | - | let cf = fraction(toBigInt(bD), e, toBigInt(bB), FLOOR) | |
670 | - | let cg = [BinaryEntry(V(E, J), toBytes(cf)), StringEntry(W(E), toString(cf))] | |
671 | - | cg | |
672 | - | } | |
673 | - | else throw("Strict value is not equal to itself.") | |
674 | - | } | |
675 | - | else throw("Strict value is not equal to itself.") | |
676 | - | } | |
677 | - | else throw("Strict value is not equal to itself.") | |
678 | - | } | |
679 | - | else nil | |
680 | - | if ((cb == cb)) | |
681 | - | then { | |
682 | - | let ch = if ((br > 0)) | |
683 | - | then { | |
684 | - | let bY = { | |
685 | - | let bZ = 0 | |
686 | - | let ca = true | |
687 | - | valueOrErrorMessage({ | |
688 | - | let aF = invoke(bn, "putOneTknV2", [bZ, ca], [AttachedPayment(E, br)]) | |
689 | - | if ($isInstanceOf(aF, "Int")) | |
690 | - | then aF | |
691 | - | else unit | |
692 | - | }, f("invalid putOneTknV2 result")) | |
693 | - | } | |
694 | - | if ((bY == bY)) | |
695 | - | then { | |
696 | - | let aL = aG(aH, G) | |
697 | - | if ((aL == aL)) | |
698 | - | then { | |
699 | - | let bw = toInt(fraction(toBigInt(bY), e, aL, FLOOR)) | |
700 | - | let ci = if ((aI.issuer == this)) | |
701 | - | then invoke(this, "emit", [G, bw], nil) | |
702 | - | else h("invalid share asset issuer") | |
703 | - | if ((ci == ci)) | |
704 | - | then { | |
705 | - | let cj = fraction(toBigInt(br), e, toBigInt(bw)) | |
706 | - | let ck = [BinaryEntry(T(E, J), toBytes(cj)), StringEntry(U(E), toString(cj))] | |
707 | - | ck | |
708 | - | } | |
709 | - | else throw("Strict value is not equal to itself.") | |
710 | - | } | |
711 | - | else throw("Strict value is not equal to itself.") | |
712 | - | } | |
713 | - | else throw("Strict value is not equal to itself.") | |
714 | - | } | |
715 | - | else nil | |
716 | - | if ((ch == ch)) | |
717 | - | then { | |
718 | - | let cl = (J + 1) | |
719 | - | let cm = aG(aH, G) | |
720 | - | let cn = (([IntegerEntry(H(E), cl), IntegerEntry(I(E, cl), height), IntegerEntry(L(E), 0), IntegerEntry(K(E), 0), BinaryEntry(R(E, J), toBytes(cm)), StringEntry(S(E), toString(cm))] ++ ch) ++ cb) | |
721 | - | $Tuple2(cn, toBytes(cm)) | |
722 | - | } | |
723 | - | else throw("Strict value is not equal to itself.") | |
724 | - | } | |
725 | - | else throw("Strict value is not equal to itself.") | |
726 | - | } | |
727 | - | else throw("Strict value is not equal to itself.") | |
728 | - | } | |
729 | - | else throw("Strict value is not equal to itself.") | |
730 | - | } | |
731 | - | else throw("Strict value is not equal to itself.") | |
732 | - | } | |
733 | - | else throw("Strict value is not equal to itself.") | |
734 | - | } | |
735 | - | else throw("Strict value is not equal to itself.") | |
736 | - | } | |
737 | - | else throw("Strict value is not equal to itself.") | |
738 | - | } | |
739 | - | else throw("Strict value is not equal to itself.") | |
740 | - | } | |
741 | - | ||
742 | - | ||
743 | - | @Verifier(co) | |
744 | - | func cp () = { | |
745 | - | let cq = { | |
746 | - | let ad = ac() | |
747 | - | if ($isInstanceOf(ad, "ByteVector")) | |
264 | + | @Verifier(ar) | |
265 | + | func as () = { | |
266 | + | let at = { | |
267 | + | let t = y() | |
268 | + | if ($isInstanceOf(t, "ByteVector")) | |
748 | 269 | then { | |
749 | - | let | |
750 | - | | |
270 | + | let D = t | |
271 | + | D | |
751 | 272 | } | |
752 | - | else if ($isInstanceOf( | |
753 | - | then | |
273 | + | else if ($isInstanceOf(t, "Unit")) | |
274 | + | then ar.senderPublicKey | |
754 | 275 | else throw("Match error") | |
755 | 276 | } | |
756 | - | sigVerify( | |
277 | + | sigVerify(ar.bodyBytes, ar.proofs[0], at) | |
757 | 278 | } | |
758 | 279 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let a = "__" | |
5 | 5 | ||
6 | - | let b = | |
6 | + | let b = toBigInt(100000000) | |
7 | 7 | ||
8 | - | let c = "WAVES" | |
9 | - | ||
10 | - | let d = 1000000000000000000 | |
11 | - | ||
12 | - | let e = toBigInt(d) | |
13 | - | ||
14 | - | func f (g) = makeString(["lp_staking_pools.ride:", g], " ") | |
8 | + | func c (d) = valueOrErrorMessage(getString(this, d), ("No data for this.key=" + d)) | |
15 | 9 | ||
16 | 10 | ||
17 | - | func h (g) = throw(f(g)) | |
11 | + | let e = throw("Pool disabled") | |
12 | + | ||
13 | + | let f = throw("Pool is not exist") | |
14 | + | ||
15 | + | let g = throw("Slippage is too big") | |
16 | + | ||
17 | + | func h () = "%s__managerPublicKey" | |
18 | 18 | ||
19 | 19 | ||
20 | - | func i ( | |
20 | + | func i () = "%s__pendingManagerPublicKey" | |
21 | 21 | ||
22 | 22 | ||
23 | - | func | |
23 | + | func j () = "%s__factoryContract" | |
24 | 24 | ||
25 | 25 | ||
26 | - | func m (j,k) = valueOrErrorMessage(getInteger(j, k), i(j, k)) | |
26 | + | let k = addressFromStringValue(c(j())) | |
27 | + | ||
28 | + | func l () = makeString(["%s", "protocolFee"], a) | |
27 | 29 | ||
28 | 30 | ||
29 | - | func n (o) = if ((o == c)) | |
30 | - | then unit | |
31 | - | else fromBase58String(o) | |
31 | + | func m () = makeString(["%s", "poolFee"], a) | |
32 | 32 | ||
33 | 33 | ||
34 | - | func p (o) = if ((o == unit)) | |
35 | - | then c | |
36 | - | else toBase58String(value(o)) | |
34 | + | func n (o,d) = valueOrErrorMessage(getString(o, d), makeString(["mandatory ", toString(o), ".", d, " is not defined"], "")) | |
37 | 35 | ||
38 | 36 | ||
39 | - | func q (r) = if ((r >= 0)) | |
40 | - | then r | |
41 | - | else h("value should be positive") | |
37 | + | let p = "%s__feeCollectorAddress" | |
38 | + | ||
39 | + | let q = addressFromStringValue(n(k, p)) | |
40 | + | ||
41 | + | func r (s) = { | |
42 | + | let t = s | |
43 | + | if ($isInstanceOf(t, "Int")) | |
44 | + | then { | |
45 | + | let u = t | |
46 | + | u | |
47 | + | } | |
48 | + | else throw("fail to cast into Int") | |
49 | + | } | |
42 | 50 | ||
43 | 51 | ||
44 | - | func | |
52 | + | func v (w,x) = makeString(["%d%d", toString(w), toString(x)], a) | |
45 | 53 | ||
46 | 54 | ||
47 | - | func t () = makeString(["%s", "lpStakingContract"], a) | |
48 | - | ||
49 | - | ||
50 | - | func u () = makeString(["%s", "stakingContract"], a) | |
51 | - | ||
52 | - | ||
53 | - | func v () = makeString(["%s", "boostingContract"], a) | |
54 | - | ||
55 | - | ||
56 | - | func w () = makeString(["%s", "swapContract"], a) | |
57 | - | ||
58 | - | ||
59 | - | func x () = makeString(["%s", "assetsStoreContract"], a) | |
60 | - | ||
61 | - | ||
62 | - | func y () = makeString(["%s", "usdtAssetId"], a) | |
63 | - | ||
64 | - | ||
65 | - | func z () = makeString(["%s", "wxAssetId"], a) | |
66 | - | ||
67 | - | ||
68 | - | func A () = makeString(["%s", "shutdown"], a) | |
69 | - | ||
70 | - | ||
71 | - | func B () = makeString(["%s", "minDelay"], a) | |
72 | - | ||
73 | - | ||
74 | - | func C () = makeString(["%s", "lockFraction"], a) | |
75 | - | ||
76 | - | ||
77 | - | func D (E) = makeString(["%s%s", p(E), "shareAssetId"], a) | |
78 | - | ||
79 | - | ||
80 | - | func F (G) = makeString(["%s%s", p(G), "baseAssetId"], a) | |
81 | - | ||
82 | - | ||
83 | - | func H (E) = makeString(["%s%s", p(E), "period"], a) | |
84 | - | ||
85 | - | ||
86 | - | func I (E,J) = makeString(["%s%s%d", p(E), "periodStartHeight", toString(J)], a) | |
87 | - | ||
88 | - | ||
89 | - | func K (E) = makeString(["%s%s", p(E), "baseAssetAmountToConvert"], a) | |
90 | - | ||
91 | - | ||
92 | - | func L (E) = makeString(["%s%s", p(E), "shareAssetAmountToConvert"], a) | |
93 | - | ||
94 | - | ||
95 | - | func M (E,N) = makeString(["%s%s%s", p(E), toString(N), "baseAssetAmountToConvert"], a) | |
96 | - | ||
97 | - | ||
98 | - | func O (E,N) = makeString(["%s%s%s%s", p(E), toString(N), "baseAssetAmountToConvert", "period"], a) | |
99 | - | ||
100 | - | ||
101 | - | func P (E,N) = makeString(["%s%s%s", p(E), toString(N), "shareAssetAmountToConvert"], a) | |
102 | - | ||
103 | - | ||
104 | - | func Q (E,N) = makeString(["%s%s%s%s", p(E), toString(N), "shareAssetAmountToConvert", "period"], a) | |
105 | - | ||
106 | - | ||
107 | - | func R (E,J) = makeString(["%s%s%d", p(E), "price", toString(J)], a) | |
108 | - | ||
109 | - | ||
110 | - | func S (E) = makeString(["%s%s%s%d%d", p(E), "price", "history", toString(lastBlock.height), toString(lastBlock.timestamp)], a) | |
111 | - | ||
112 | - | ||
113 | - | func T (E,J) = makeString(["%s%s%d%s", p(E), "price", toString(J), "put"], a) | |
114 | - | ||
115 | - | ||
116 | - | func U (E) = makeString(["%s%s%s%s%d%d", p(E), "price", "history", "put", toString(lastBlock.height), toString(lastBlock.timestamp)], a) | |
117 | - | ||
118 | - | ||
119 | - | func V (E,J) = makeString(["%s%s%d%s", p(E), "price", toString(J), "get"], a) | |
120 | - | ||
121 | - | ||
122 | - | func W (E) = makeString(["%s%s%s%s%d%d", p(E), "price", "history", "get", toString(lastBlock.height), toString(lastBlock.timestamp)], a) | |
123 | - | ||
124 | - | ||
125 | - | func X (E,Y,J,N,Z) = makeString(["%s%s%s%s", "history", Y, toString(N), toBase58String(Z), toString(height)], a) | |
126 | - | ||
127 | - | ||
128 | - | func aa () = "%s__managerPublicKey" | |
129 | - | ||
130 | - | ||
131 | - | func ab () = "%s__pendingManagerPublicKey" | |
132 | - | ||
133 | - | ||
134 | - | func ac () = { | |
135 | - | let ad = getString(aa()) | |
136 | - | if ($isInstanceOf(ad, "String")) | |
55 | + | func y () = { | |
56 | + | let t = getString(h()) | |
57 | + | if ($isInstanceOf(t, "String")) | |
137 | 58 | then { | |
138 | - | let | |
139 | - | fromBase58String( | |
59 | + | let z = t | |
60 | + | fromBase58String(z) | |
140 | 61 | } | |
141 | - | else if ($isInstanceOf( | |
62 | + | else if ($isInstanceOf(t, "Unit")) | |
142 | 63 | then unit | |
143 | 64 | else throw("Match error") | |
144 | 65 | } | |
145 | 66 | ||
146 | 67 | ||
147 | - | func | |
148 | - | let | |
149 | - | if ($isInstanceOf( | |
68 | + | func A () = { | |
69 | + | let t = getString(i()) | |
70 | + | if ($isInstanceOf(t, "String")) | |
150 | 71 | then { | |
151 | - | let | |
152 | - | fromBase58String( | |
72 | + | let z = t | |
73 | + | fromBase58String(z) | |
153 | 74 | } | |
154 | - | else if ($isInstanceOf( | |
75 | + | else if ($isInstanceOf(t, "Unit")) | |
155 | 76 | then unit | |
156 | 77 | else throw("Match error") | |
157 | 78 | } | |
158 | 79 | ||
159 | 80 | ||
160 | - | let ag = throw("Permission denied") | |
161 | - | ||
162 | - | func ah (ai) = if ((ai.caller == this)) | |
163 | - | then true | |
164 | - | else ag | |
165 | - | ||
166 | - | ||
167 | - | func aj (ai) = { | |
168 | - | let ad = ac() | |
169 | - | if ($isInstanceOf(ad, "ByteVector")) | |
81 | + | func B (C) = { | |
82 | + | let t = y() | |
83 | + | if ($isInstanceOf(t, "ByteVector")) | |
170 | 84 | then { | |
171 | - | let ak = ad | |
172 | - | if ((ai.callerPublicKey == ak)) | |
173 | - | then true | |
174 | - | else ag | |
85 | + | let D = t | |
86 | + | (C.callerPublicKey == D) | |
175 | 87 | } | |
176 | - | else if ($isInstanceOf( | |
177 | - | then | |
88 | + | else if ($isInstanceOf(t, "Unit")) | |
89 | + | then (C.caller == this) | |
178 | 90 | else throw("Match error") | |
179 | 91 | } | |
180 | 92 | ||
181 | 93 | ||
182 | - | let al = valueOrElse(getBoolean(A()), false) | |
183 | - | ||
184 | - | func am (ai) = if (if (!(al)) | |
94 | + | func E (C) = if (B(C)) | |
185 | 95 | then true | |
186 | - | else aj(ai)) | |
187 | - | then true | |
188 | - | else throw("operation is disabled") | |
96 | + | else throw("permission denied") | |
189 | 97 | ||
190 | 98 | ||
191 | - | let an = addressFromStringValue(l(this, s())) | |
99 | + | func F (G) = if ((G == "WAVES")) | |
100 | + | then wavesBalance(this).available | |
101 | + | else assetBalance(this, fromBase58String(G)) | |
192 | 102 | ||
193 | - | let ao = addressFromStringValue(l(this, t())) | |
194 | 103 | ||
195 | - | let ap = addressFromStringValue(l(this, u())) | |
196 | - | ||
197 | - | let aq = addressFromStringValue(l(this, v())) | |
198 | - | ||
199 | - | let ar = addressFromStringValue(l(this, w())) | |
200 | - | ||
201 | - | let as = addressFromStringValue(l(this, x())) | |
202 | - | ||
203 | - | let at = n(l(this, y())) | |
204 | - | ||
205 | - | let au = n(l(this, z())) | |
206 | - | ||
207 | - | let av = 1440 | |
208 | - | ||
209 | - | let aw = valueOrElse(getInteger(this, B()), av) | |
210 | - | ||
211 | - | let ax = 100000000 | |
212 | - | ||
213 | - | let ay = fraction(1, ax, 2) | |
214 | - | ||
215 | - | let az = valueOrElse(getInteger(this, C()), ay) | |
216 | - | ||
217 | - | func aA (aB) = { | |
218 | - | let aC = p(aB) | |
219 | - | let aD = p(at) | |
220 | - | let aE = { | |
221 | - | let aF = invoke(an, "poolInfoREADONLY", [aC, aD], nil) | |
222 | - | if ($isInstanceOf(aF, "(Address, ByteVector)")) | |
223 | - | then aF | |
104 | + | func H (I,J) = { | |
105 | + | let K = { | |
106 | + | let L = invoke(k, "getLpAssetFromPoolAssetsREADONLY", [I, J], nil) | |
107 | + | if ($isInstanceOf(L, "String")) | |
108 | + | then L | |
224 | 109 | else unit | |
225 | 110 | } | |
226 | - | aE | |
111 | + | let M = { | |
112 | + | let L = invoke(k, "getLpAssetFromPoolAssetsREADONLY", [J, I], nil) | |
113 | + | if ($isInstanceOf(L, "String")) | |
114 | + | then L | |
115 | + | else unit | |
116 | + | } | |
117 | + | let N = if ((K != unit)) | |
118 | + | then { | |
119 | + | let O = { | |
120 | + | let L = invoke(k, "getPoolAddressFromLpAssetREADONLY", [value(K)], nil) | |
121 | + | if ($isInstanceOf(L, "String")) | |
122 | + | then L | |
123 | + | else throw(($getType(L) + " couldn't be cast to String")) | |
124 | + | } | |
125 | + | $Tuple2(false, O) | |
126 | + | } | |
127 | + | else if ((M != unit)) | |
128 | + | then { | |
129 | + | let O = { | |
130 | + | let L = invoke(k, "getPoolAddressFromLpAssetREADONLY", [value(M)], nil) | |
131 | + | if ($isInstanceOf(L, "String")) | |
132 | + | then L | |
133 | + | else throw(($getType(L) + " couldn't be cast to String")) | |
134 | + | } | |
135 | + | $Tuple2(true, O) | |
136 | + | } | |
137 | + | else f | |
138 | + | let P = N._1 | |
139 | + | let O = N._2 | |
140 | + | let Q = { | |
141 | + | let L = invoke(k, "getPoolStatusREADONLY", [O], nil) | |
142 | + | if ($isInstanceOf(L, "Int")) | |
143 | + | then L | |
144 | + | else throw(($getType(L) + " couldn't be cast to Int")) | |
145 | + | } | |
146 | + | let R = if ((Q == 1)) | |
147 | + | then true | |
148 | + | else e | |
149 | + | if ((R == R)) | |
150 | + | then { | |
151 | + | let S = addressFromStringValue(valueOrElse(O, "")) | |
152 | + | $Tuple2(S, P) | |
153 | + | } | |
154 | + | else throw("Strict value is not equal to itself.") | |
227 | 155 | } | |
228 | 156 | ||
229 | 157 | ||
230 | - | func aG (aH,G) = { | |
231 | - | let aI = valueOrErrorMessage(assetInfo(G), "failed to get share asset info") | |
232 | - | let aJ = aI.quantity | |
233 | - | let aK = q(valueOrErrorMessage({ | |
234 | - | let aF = invoke(ap, "stakedByUserREADONLY", [p(aH), toString(this)], nil) | |
235 | - | if ($isInstanceOf(aF, "Int")) | |
236 | - | then aF | |
237 | - | else unit | |
238 | - | }, f("invalid stakedByUserREADONLY result"))) | |
239 | - | let aL = if ((aJ == 0)) | |
240 | - | then e | |
241 | - | else fraction(toBigInt(aK), e, toBigInt(aJ), FLOOR) | |
242 | - | aL | |
158 | + | @Callable(C) | |
159 | + | func swapCalculateREADONLY (T,I,J) = { | |
160 | + | let U = value(getInteger(l())) | |
161 | + | let V = fraction(toBigInt(T), toBigInt(U), b) | |
162 | + | let W = value(getInteger(m())) | |
163 | + | let X = fraction(toBigInt(T), toBigInt(W), b) | |
164 | + | let Y = if ((toInt(V) == 0)) | |
165 | + | then toBigInt(1) | |
166 | + | else V | |
167 | + | let Z = if ((toInt(X) == 0)) | |
168 | + | then toBigInt(1) | |
169 | + | else X | |
170 | + | let aa = ((toBigInt(T) - Y) - Z) | |
171 | + | let ab = H(I, J) | |
172 | + | let S = ab._1 | |
173 | + | let P = ab._2 | |
174 | + | let ac = { | |
175 | + | let L = invoke(S, "calculateAmountOutForSwapREADONLY", [toInt(aa), P, toInt(Z)], nil) | |
176 | + | if ($isInstanceOf(L, "Int")) | |
177 | + | then L | |
178 | + | else throw(($getType(L) + " couldn't be cast to Int")) | |
179 | + | } | |
180 | + | $Tuple2(nil, ac) | |
243 | 181 | } | |
244 | 182 | ||
245 | 183 | ||
246 | - | @Callable(ai) | |
247 | - | func setManager (aM) = { | |
248 | - | let aN = aj(ai) | |
249 | - | if ((aN == aN)) | |
184 | + | ||
185 | + | @Callable(C) | |
186 | + | func swap (ad,ae,af) = { | |
187 | + | let J = if ((ae == "")) | |
188 | + | then "WAVES" | |
189 | + | else ae | |
190 | + | let ag = value(C.payments[0]) | |
191 | + | let I = if ((ag.assetId == unit)) | |
192 | + | then "WAVES" | |
193 | + | else toBase58String(value(ag.assetId)) | |
194 | + | let T = value(ag.amount) | |
195 | + | let U = value(getInteger(l())) | |
196 | + | let V = fraction(toBigInt(T), toBigInt(U), b) | |
197 | + | let W = value(getInteger(m())) | |
198 | + | let X = fraction(toBigInt(T), toBigInt(W), b) | |
199 | + | let Y = if ((toInt(V) == 0)) | |
200 | + | then toBigInt(1) | |
201 | + | else V | |
202 | + | let Z = if ((toInt(X) == 0)) | |
203 | + | then toBigInt(1) | |
204 | + | else X | |
205 | + | let aa = ((toBigInt(T) - Y) - Z) | |
206 | + | let ah = [if ((size(C.payments) == 1)) | |
207 | + | then true | |
208 | + | else throw("exactly 1 payment are expected")] | |
209 | + | if ((ah == ah)) | |
250 | 210 | then { | |
251 | - | let aO = fromBase58String(aM) | |
252 | - | if ((aO == aO)) | |
253 | - | then [StringEntry(ab(), aM)] | |
211 | + | let ai = H(I, J) | |
212 | + | let S = ai._1 | |
213 | + | let P = ai._2 | |
214 | + | let aj = if ((I == "WAVES")) | |
215 | + | then unit | |
216 | + | else fromBase58String(I) | |
217 | + | let ak = { | |
218 | + | let L = invoke(S, "calculateAmountOutForSwapAndSendTokens", [toInt(aa), P, ad, af, toInt(Z)], [AttachedPayment(aj, toInt(aa))]) | |
219 | + | if ($isInstanceOf(L, "Int")) | |
220 | + | then L | |
221 | + | else throw(($getType(L) + " couldn't be cast to Int")) | |
222 | + | } | |
223 | + | $Tuple2([ScriptTransfer(q, toInt(Y), aj), ScriptTransfer(S, toInt(Z), aj)], ak) | |
224 | + | } | |
225 | + | else throw("Strict value is not equal to itself.") | |
226 | + | } | |
227 | + | ||
228 | + | ||
229 | + | ||
230 | + | @Callable(C) | |
231 | + | func setManager (al) = { | |
232 | + | let am = E(C) | |
233 | + | if ((am == am)) | |
234 | + | then { | |
235 | + | let an = fromBase58String(al) | |
236 | + | if ((an == an)) | |
237 | + | then [StringEntry(i(), al)] | |
254 | 238 | else throw("Strict value is not equal to itself.") | |
255 | 239 | } | |
256 | 240 | else throw("Strict value is not equal to itself.") | |
257 | 241 | } | |
258 | 242 | ||
259 | 243 | ||
260 | 244 | ||
261 | - | @Callable( | |
245 | + | @Callable(C) | |
262 | 246 | func confirmManager () = { | |
263 | - | let | |
264 | - | let | |
247 | + | let ao = A() | |
248 | + | let ap = if (isDefined(ao)) | |
265 | 249 | then true | |
266 | - | else | |
267 | - | if (( | |
250 | + | else throw("no pending manager") | |
251 | + | if ((ap == ap)) | |
268 | 252 | then { | |
269 | - | let | |
253 | + | let aq = if ((C.callerPublicKey == value(ao))) | |
270 | 254 | then true | |
271 | - | else | |
272 | - | if (( | |
273 | - | then [StringEntry( | |
255 | + | else throw("you are not pending manager") | |
256 | + | if ((aq == aq)) | |
257 | + | then [StringEntry(h(), toBase58String(value(ao))), DeleteEntry(i())] | |
274 | 258 | else throw("Strict value is not equal to itself.") | |
275 | 259 | } | |
276 | 260 | else throw("Strict value is not equal to itself.") | |
277 | 261 | } | |
278 | 262 | ||
279 | 263 | ||
280 | - | ||
281 | - | @Callable(ai) | |
282 | - | func emit (aS,aT) = { | |
283 | - | let aN = ah(ai) | |
284 | - | if ((aN == aN)) | |
285 | - | then { | |
286 | - | let aU = true | |
287 | - | $Tuple2([Reissue(aS, aT, aU)], aT) | |
288 | - | } | |
289 | - | else throw("Strict value is not equal to itself.") | |
290 | - | } | |
291 | - | ||
292 | - | ||
293 | - | ||
294 | - | @Callable(ai) | |
295 | - | func burn (aS,aT) = { | |
296 | - | let aN = ah(ai) | |
297 | - | if ((aN == aN)) | |
298 | - | then $Tuple2([Burn(aS, aT)], aT) | |
299 | - | else throw("Strict value is not equal to itself.") | |
300 | - | } | |
301 | - | ||
302 | - | ||
303 | - | ||
304 | - | @Callable(ai) | |
305 | - | func create (aV,aW,aX,aY,aZ) = { | |
306 | - | let ba = "STAKING_LP" | |
307 | - | let E = n(aV) | |
308 | - | let bb = [aj(ai), if (isDefined(aA(E))) | |
309 | - | then true | |
310 | - | else h("invalid base asset")] | |
311 | - | if ((bb == bb)) | |
312 | - | then { | |
313 | - | let bc = [IntegerEntry(H(E), 0)] | |
314 | - | if ((aW == "")) | |
315 | - | then { | |
316 | - | let bd = 1 | |
317 | - | let be = Issue(aX, aY, bd, b, true) | |
318 | - | let bf = calculateAssetId(be) | |
319 | - | let bg = Burn(bf, bd) | |
320 | - | let bh = toBase58String(bf) | |
321 | - | let bi = invoke(as, "createOrUpdate", [bh, aZ, false], nil) | |
322 | - | if ((bi == bi)) | |
323 | - | then { | |
324 | - | let bj = invoke(as, "addLabel", [bh, ba], nil) | |
325 | - | if ((bj == bj)) | |
326 | - | then $Tuple2((bc ++ [be, bg, StringEntry(D(E), bh), StringEntry(F(bf), aV)]), bh) | |
327 | - | else throw("Strict value is not equal to itself.") | |
328 | - | } | |
329 | - | else throw("Strict value is not equal to itself.") | |
330 | - | } | |
331 | - | else { | |
332 | - | let G = fromBase58String(aW) | |
333 | - | let aI = valueOrErrorMessage(assetInfo(G), f("invalid share asset id")) | |
334 | - | let bk = if ((aI.issuer == ao)) | |
335 | - | then true | |
336 | - | else h("invalid share asset id issuer") | |
337 | - | if ((bk == bk)) | |
338 | - | then $Tuple2((bc ++ [StringEntry(D(E), aW), StringEntry(F(G), aV)]), aW) | |
339 | - | else throw("Strict value is not equal to itself.") | |
340 | - | } | |
341 | - | } | |
342 | - | else throw("Strict value is not equal to itself.") | |
343 | - | } | |
344 | - | ||
345 | - | ||
346 | - | ||
347 | - | @Callable(ai) | |
348 | - | func put () = { | |
349 | - | let bl = if ((size(ai.payments) == 1)) | |
350 | - | then ai.payments[0] | |
351 | - | else h("exactly 1 payment is expected") | |
352 | - | let E = bl.assetId | |
353 | - | let N = ai.caller | |
354 | - | let bb = [am(ai), if (isDefined(getString(D(E)))) | |
355 | - | then true | |
356 | - | else h("invalid asset")] | |
357 | - | if ((bb == bb)) | |
358 | - | then { | |
359 | - | let bm = valueOrErrorMessage(aA(E), f("invalid asset")) | |
360 | - | let bn = bm._1 | |
361 | - | let aH = bm._2 | |
362 | - | let J = value(getInteger(H(E))) | |
363 | - | let bo = getInteger(O(E, N)) | |
364 | - | let bp = if ((bo == unit)) | |
365 | - | then unit | |
366 | - | else { | |
367 | - | let bq = value(bo) | |
368 | - | if ((bq == J)) | |
369 | - | then unit | |
370 | - | else invoke(this, "claimShareAsset", [p(E), toString(N)], nil) | |
371 | - | } | |
372 | - | if ((bp == bp)) | |
373 | - | then { | |
374 | - | let br = valueOrElse(getInteger(K(E)), 0) | |
375 | - | let bs = valueOrElse(getInteger(M(E, N)), 0) | |
376 | - | $Tuple2([IntegerEntry(K(E), (br + bl.amount)), IntegerEntry(M(E, N), (bs + bl.amount)), IntegerEntry(O(E, N), J), IntegerEntry(X(E, "put", J, N, ai.transactionId), bl.amount)], unit) | |
377 | - | } | |
378 | - | else throw("Strict value is not equal to itself.") | |
379 | - | } | |
380 | - | else throw("Strict value is not equal to itself.") | |
381 | - | } | |
382 | - | ||
383 | - | ||
384 | - | ||
385 | - | @Callable(ai) | |
386 | - | func claimShareAsset (aV,bt) = { | |
387 | - | let bb = [am(ai)] | |
388 | - | if ((bb == bb)) | |
389 | - | then { | |
390 | - | let N = if ((bt == "")) | |
391 | - | then ai.caller | |
392 | - | else { | |
393 | - | let aN = ah(ai) | |
394 | - | if ((aN == aN)) | |
395 | - | then valueOrErrorMessage(addressFromString(bt), f("invalid user address")) | |
396 | - | else throw("Strict value is not equal to itself.") | |
397 | - | } | |
398 | - | if ((N == N)) | |
399 | - | then { | |
400 | - | let E = n(aV) | |
401 | - | let G = value(n(valueOrErrorMessage(getString(D(E)), f("invalid base asset id")))) | |
402 | - | if ((G == G)) | |
403 | - | then { | |
404 | - | let J = valueOrErrorMessage(getInteger(H(E)), f("invalid period")) | |
405 | - | if ((J == J)) | |
406 | - | then { | |
407 | - | let bs = valueOrElse(getInteger(M(E, N)), 0) | |
408 | - | let bu = if ((bs > 0)) | |
409 | - | then true | |
410 | - | else h("nothing to claim") | |
411 | - | if ((bu == bu)) | |
412 | - | then { | |
413 | - | let bq = valueOrErrorMessage(getInteger(O(E, N)), f("failed to get period")) | |
414 | - | let bv = if ((J > bq)) | |
415 | - | then true | |
416 | - | else h("invalid period") | |
417 | - | if ((bv == bv)) | |
418 | - | then { | |
419 | - | let aL = toBigInt(valueOrErrorMessage(getBinary(T(E, bq)), f("failed to get price"))) | |
420 | - | let bw = toInt(fraction(toBigInt(bs), e, aL)) | |
421 | - | $Tuple2([IntegerEntry(M(E, N), 0), DeleteEntry(O(E, N)), ScriptTransfer(N, bw, G), IntegerEntry(X(E, "claimShareAsset", J, N, ai.transactionId), bw)], unit) | |
422 | - | } | |
423 | - | else throw("Strict value is not equal to itself.") | |
424 | - | } | |
425 | - | else throw("Strict value is not equal to itself.") | |
426 | - | } | |
427 | - | else throw("Strict value is not equal to itself.") | |
428 | - | } | |
429 | - | else throw("Strict value is not equal to itself.") | |
430 | - | } | |
431 | - | else throw("Strict value is not equal to itself.") | |
432 | - | } | |
433 | - | else throw("Strict value is not equal to itself.") | |
434 | - | } | |
435 | - | ||
436 | - | ||
437 | - | ||
438 | - | @Callable(ai) | |
439 | - | func get () = { | |
440 | - | let bb = [am(ai)] | |
441 | - | if ((bb == bb)) | |
442 | - | then { | |
443 | - | let bl = if ((size(ai.payments) == 1)) | |
444 | - | then ai.payments[0] | |
445 | - | else h("exactly 1 payment is expected") | |
446 | - | let G = bl.assetId | |
447 | - | let E = value(n(valueOrErrorMessage(getString(F(G)), f("invalid share asset id")))) | |
448 | - | if ((E == E)) | |
449 | - | then { | |
450 | - | let N = ai.caller | |
451 | - | let bx = valueOrErrorMessage(aA(E), f("invalid asset")) | |
452 | - | let bn = bx._1 | |
453 | - | let aH = bx._2 | |
454 | - | let J = value(getInteger(H(E))) | |
455 | - | let by = getInteger(Q(E, N)) | |
456 | - | let bz = if ((by == unit)) | |
457 | - | then unit | |
458 | - | else { | |
459 | - | let bA = value(by) | |
460 | - | if ((bA == J)) | |
461 | - | then unit | |
462 | - | else invoke(this, "claimBaseAsset", [p(E), toString(N)], nil) | |
463 | - | } | |
464 | - | if ((bz == bz)) | |
465 | - | then { | |
466 | - | let bB = valueOrElse(getInteger(L(E)), 0) | |
467 | - | let bC = valueOrElse(getInteger(P(E, N)), 0) | |
468 | - | $Tuple2([IntegerEntry(L(E), (bB + bl.amount)), IntegerEntry(P(E, N), (bC + bl.amount)), IntegerEntry(Q(E, N), J), IntegerEntry(X(E, "get", J, N, ai.transactionId), bl.amount)], unit) | |
469 | - | } | |
470 | - | else throw("Strict value is not equal to itself.") | |
471 | - | } | |
472 | - | else throw("Strict value is not equal to itself.") | |
473 | - | } | |
474 | - | else throw("Strict value is not equal to itself.") | |
475 | - | } | |
476 | - | ||
477 | - | ||
478 | - | ||
479 | - | @Callable(ai) | |
480 | - | func claimBaseAsset (aV,bt) = { | |
481 | - | let bb = [am(ai)] | |
482 | - | if ((bb == bb)) | |
483 | - | then { | |
484 | - | let N = if ((bt == "")) | |
485 | - | then ai.caller | |
486 | - | else { | |
487 | - | let aN = ah(ai) | |
488 | - | if ((aN == aN)) | |
489 | - | then valueOrErrorMessage(addressFromString(bt), f("invalid user address")) | |
490 | - | else throw("Strict value is not equal to itself.") | |
491 | - | } | |
492 | - | if ((N == N)) | |
493 | - | then { | |
494 | - | let E = n(aV) | |
495 | - | let G = value(n(valueOrErrorMessage(getString(D(E)), f("invalid base asset id")))) | |
496 | - | if ((G == G)) | |
497 | - | then { | |
498 | - | let J = valueOrErrorMessage(getInteger(H(E)), f("invalid period")) | |
499 | - | if ((J == J)) | |
500 | - | then { | |
501 | - | let bC = valueOrElse(getInteger(P(E, N)), 0) | |
502 | - | let bu = if ((bC > 0)) | |
503 | - | then true | |
504 | - | else h("nothing to claim") | |
505 | - | if ((bu == bu)) | |
506 | - | then { | |
507 | - | let bA = valueOrErrorMessage(getInteger(Q(E, N)), f("failed to get period")) | |
508 | - | let bv = if ((J > bA)) | |
509 | - | then true | |
510 | - | else h("invalid period") | |
511 | - | if ((bv == bv)) | |
512 | - | then { | |
513 | - | let aL = toBigInt(valueOrErrorMessage(getBinary(V(E, bA)), f("failed to get price"))) | |
514 | - | let bD = toInt(fraction(toBigInt(bC), aL, e)) | |
515 | - | $Tuple2([IntegerEntry(P(E, N), 0), DeleteEntry(Q(E, N)), ScriptTransfer(N, bD, E), IntegerEntry(X(E, "claimBaseAsset", J, N, ai.transactionId), bD)], unit) | |
516 | - | } | |
517 | - | else throw("Strict value is not equal to itself.") | |
518 | - | } | |
519 | - | else throw("Strict value is not equal to itself.") | |
520 | - | } | |
521 | - | else throw("Strict value is not equal to itself.") | |
522 | - | } | |
523 | - | else throw("Strict value is not equal to itself.") | |
524 | - | } | |
525 | - | else throw("Strict value is not equal to itself.") | |
526 | - | } | |
527 | - | else throw("Strict value is not equal to itself.") | |
528 | - | } | |
529 | - | ||
530 | - | ||
531 | - | ||
532 | - | @Callable(ai) | |
533 | - | func finalize (aV) = { | |
534 | - | let bb = [am(ai)] | |
535 | - | if ((bb == bb)) | |
536 | - | then { | |
537 | - | let E = n(aV) | |
538 | - | let G = value(n(valueOrErrorMessage(getString(D(E)), f("invalid base asset id")))) | |
539 | - | if ((G == G)) | |
540 | - | then { | |
541 | - | let aI = valueOrErrorMessage(assetInfo(G), f("invalid share asset id")) | |
542 | - | let J = valueOrErrorMessage(getInteger(H(E)), f("invalid period")) | |
543 | - | if ((J == J)) | |
544 | - | then { | |
545 | - | let bE = getInteger(I(E, J)) | |
546 | - | let bF = if ((bE == unit)) | |
547 | - | then unit | |
548 | - | else { | |
549 | - | let bG = (height - value(bE)) | |
550 | - | let bH = max([0, (aw - bG)]) | |
551 | - | if ((bH == 0)) | |
552 | - | then unit | |
553 | - | else h(makeString(["finalization will be possible in ", toString(bH), " blocks"], "")) | |
554 | - | } | |
555 | - | if ((bF == bF)) | |
556 | - | then { | |
557 | - | let bI = valueOrErrorMessage(aA(E), f("invalid asset")) | |
558 | - | let bn = bI._1 | |
559 | - | let aH = bI._2 | |
560 | - | let bJ = valueOrErrorMessage({ | |
561 | - | let aF = invoke(ap, "claimWxDoNotThrow", [p(aH)], nil) | |
562 | - | if ($isInstanceOf(aF, "Int")) | |
563 | - | then aF | |
564 | - | else unit | |
565 | - | }, f("invalid claimWx result")) | |
566 | - | if ((bJ == bJ)) | |
567 | - | then { | |
568 | - | let br = valueOrElse(getInteger(K(E)), 0) | |
569 | - | let bB = valueOrElse(getInteger(L(E)), 0) | |
570 | - | let bK = { | |
571 | - | let bL = if (if ((bJ > 0)) | |
572 | - | then true | |
573 | - | else (br > 0)) | |
574 | - | then true | |
575 | - | else (bB > 0) | |
576 | - | if (bL) | |
577 | - | then true | |
578 | - | else h("nothing to finalize") | |
579 | - | } | |
580 | - | if ((bK == bK)) | |
581 | - | then { | |
582 | - | let bM = if ((bJ > 0)) | |
583 | - | then { | |
584 | - | let bN = fraction(bJ, az, ax) | |
585 | - | let bO = (bJ - bN) | |
586 | - | let bP = invoke(aq, "userMaxDurationREADONLY", [toString(this)], nil) | |
587 | - | let bQ = if ((bN > 0)) | |
588 | - | then { | |
589 | - | let ad = bP | |
590 | - | if (if (if ($isInstanceOf(ad._1, "String")) | |
591 | - | then $isInstanceOf(ad._2, "Int") | |
592 | - | else false) | |
593 | - | then $isInstanceOf(ad, "(String, Int)") | |
594 | - | else false) | |
595 | - | then { | |
596 | - | let bR = ad._1 | |
597 | - | let bS = ad._2 | |
598 | - | if ((bN > 0)) | |
599 | - | then invoke(aq, bR, [bS], [AttachedPayment(au, bN)]) | |
600 | - | else unit | |
601 | - | } | |
602 | - | else h("invalid lock params") | |
603 | - | } | |
604 | - | else unit | |
605 | - | if ((bQ == bQ)) | |
606 | - | then { | |
607 | - | let bT = if ((bO > 0)) | |
608 | - | then { | |
609 | - | let bU = au | |
610 | - | let bV = 0 | |
611 | - | let bW = p(at) | |
612 | - | let bX = toString(this) | |
613 | - | valueOrErrorMessage({ | |
614 | - | let aF = invoke(ar, "swap", [bV, bW, bX], [AttachedPayment(bU, bO)]) | |
615 | - | if ($isInstanceOf(aF, "Int")) | |
616 | - | then aF | |
617 | - | else unit | |
618 | - | }, f("invalid swap result")) | |
619 | - | } | |
620 | - | else 0 | |
621 | - | if ((bT == bT)) | |
622 | - | then { | |
623 | - | let bY = if ((bT > 0)) | |
624 | - | then { | |
625 | - | let bZ = 0 | |
626 | - | let ca = true | |
627 | - | valueOrErrorMessage({ | |
628 | - | let aF = invoke(bn, "putOneTknV2", [bZ, ca], [AttachedPayment(at, bT)]) | |
629 | - | if ($isInstanceOf(aF, "Int")) | |
630 | - | then aF | |
631 | - | else unit | |
632 | - | }, f("invalid putOneTknV2 result")) | |
633 | - | } | |
634 | - | else 0 | |
635 | - | if ((bY == bY)) | |
636 | - | then bY | |
637 | - | else throw("Strict value is not equal to itself.") | |
638 | - | } | |
639 | - | else throw("Strict value is not equal to itself.") | |
640 | - | } | |
641 | - | else throw("Strict value is not equal to itself.") | |
642 | - | } | |
643 | - | else unit | |
644 | - | if ((bM == bM)) | |
645 | - | then { | |
646 | - | let cb = if ((bB > 0)) | |
647 | - | then { | |
648 | - | let aL = aG(aH, G) | |
649 | - | if ((aL == aL)) | |
650 | - | then { | |
651 | - | let cc = toInt(fraction(toBigInt(bB), aL, e, FLOOR)) | |
652 | - | let bD = { | |
653 | - | let cd = E | |
654 | - | let bZ = 0 | |
655 | - | valueOrErrorMessage({ | |
656 | - | let aF = invoke(bn, "unstakeAndGetOneTknV2", [cc, p(cd), bZ], nil) | |
657 | - | if ($isInstanceOf(aF, "Int")) | |
658 | - | then aF | |
659 | - | else unit | |
660 | - | }, f("invalid unstakeAndGetOneTknV2 result")) | |
661 | - | } | |
662 | - | if ((bD == bD)) | |
663 | - | then { | |
664 | - | let ce = if ((aI.issuer == this)) | |
665 | - | then invoke(this, "burn", [G, bB], nil) | |
666 | - | else h("invalid share asset issuer") | |
667 | - | if ((ce == ce)) | |
668 | - | then { | |
669 | - | let cf = fraction(toBigInt(bD), e, toBigInt(bB), FLOOR) | |
670 | - | let cg = [BinaryEntry(V(E, J), toBytes(cf)), StringEntry(W(E), toString(cf))] | |
671 | - | cg | |
672 | - | } | |
673 | - | else throw("Strict value is not equal to itself.") | |
674 | - | } | |
675 | - | else throw("Strict value is not equal to itself.") | |
676 | - | } | |
677 | - | else throw("Strict value is not equal to itself.") | |
678 | - | } | |
679 | - | else nil | |
680 | - | if ((cb == cb)) | |
681 | - | then { | |
682 | - | let ch = if ((br > 0)) | |
683 | - | then { | |
684 | - | let bY = { | |
685 | - | let bZ = 0 | |
686 | - | let ca = true | |
687 | - | valueOrErrorMessage({ | |
688 | - | let aF = invoke(bn, "putOneTknV2", [bZ, ca], [AttachedPayment(E, br)]) | |
689 | - | if ($isInstanceOf(aF, "Int")) | |
690 | - | then aF | |
691 | - | else unit | |
692 | - | }, f("invalid putOneTknV2 result")) | |
693 | - | } | |
694 | - | if ((bY == bY)) | |
695 | - | then { | |
696 | - | let aL = aG(aH, G) | |
697 | - | if ((aL == aL)) | |
698 | - | then { | |
699 | - | let bw = toInt(fraction(toBigInt(bY), e, aL, FLOOR)) | |
700 | - | let ci = if ((aI.issuer == this)) | |
701 | - | then invoke(this, "emit", [G, bw], nil) | |
702 | - | else h("invalid share asset issuer") | |
703 | - | if ((ci == ci)) | |
704 | - | then { | |
705 | - | let cj = fraction(toBigInt(br), e, toBigInt(bw)) | |
706 | - | let ck = [BinaryEntry(T(E, J), toBytes(cj)), StringEntry(U(E), toString(cj))] | |
707 | - | ck | |
708 | - | } | |
709 | - | else throw("Strict value is not equal to itself.") | |
710 | - | } | |
711 | - | else throw("Strict value is not equal to itself.") | |
712 | - | } | |
713 | - | else throw("Strict value is not equal to itself.") | |
714 | - | } | |
715 | - | else nil | |
716 | - | if ((ch == ch)) | |
717 | - | then { | |
718 | - | let cl = (J + 1) | |
719 | - | let cm = aG(aH, G) | |
720 | - | let cn = (([IntegerEntry(H(E), cl), IntegerEntry(I(E, cl), height), IntegerEntry(L(E), 0), IntegerEntry(K(E), 0), BinaryEntry(R(E, J), toBytes(cm)), StringEntry(S(E), toString(cm))] ++ ch) ++ cb) | |
721 | - | $Tuple2(cn, toBytes(cm)) | |
722 | - | } | |
723 | - | else throw("Strict value is not equal to itself.") | |
724 | - | } | |
725 | - | else throw("Strict value is not equal to itself.") | |
726 | - | } | |
727 | - | else throw("Strict value is not equal to itself.") | |
728 | - | } | |
729 | - | else throw("Strict value is not equal to itself.") | |
730 | - | } | |
731 | - | else throw("Strict value is not equal to itself.") | |
732 | - | } | |
733 | - | else throw("Strict value is not equal to itself.") | |
734 | - | } | |
735 | - | else throw("Strict value is not equal to itself.") | |
736 | - | } | |
737 | - | else throw("Strict value is not equal to itself.") | |
738 | - | } | |
739 | - | else throw("Strict value is not equal to itself.") | |
740 | - | } | |
741 | - | ||
742 | - | ||
743 | - | @Verifier(co) | |
744 | - | func cp () = { | |
745 | - | let cq = { | |
746 | - | let ad = ac() | |
747 | - | if ($isInstanceOf(ad, "ByteVector")) | |
264 | + | @Verifier(ar) | |
265 | + | func as () = { | |
266 | + | let at = { | |
267 | + | let t = y() | |
268 | + | if ($isInstanceOf(t, "ByteVector")) | |
748 | 269 | then { | |
749 | - | let | |
750 | - | | |
270 | + | let D = t | |
271 | + | D | |
751 | 272 | } | |
752 | - | else if ($isInstanceOf( | |
753 | - | then | |
273 | + | else if ($isInstanceOf(t, "Unit")) | |
274 | + | then ar.senderPublicKey | |
754 | 275 | else throw("Match error") | |
755 | 276 | } | |
756 | - | sigVerify( | |
277 | + | sigVerify(ar.bodyBytes, ar.proofs[0], at) | |
757 | 278 | } | |
758 | 279 |
github/deemru/w8io/026f985 73.60 ms ◑