tx · 9mHmK9MJveyKADues6jhq9wSvyBgFjnrpdxDzCWVrms3 3N8bnD2caKnxdcTqvrJUEkDe3XebgfwWjSV: -0.01300000 Waves 2022.08.26 09:13 [2201068] smart account 3N8bnD2caKnxdcTqvrJUEkDe3XebgfwWjSV > SELF 0.00000000 Waves
{ "type": 13, "id": "9mHmK9MJveyKADues6jhq9wSvyBgFjnrpdxDzCWVrms3", "fee": 1300000, "feeAssetId": null, "timestamp": 1661494396950, "version": 2, "chainId": 84, "sender": "3N8bnD2caKnxdcTqvrJUEkDe3XebgfwWjSV", "senderPublicKey": "8KXPjDuC8ffL9qjNuDBLnkvJKbMojhZYcnm2o75UCyun", "proofs": [ "56zo4hP8sqVNs1CNcwB15Pxqwx2NEQQUBGigeK2uArJ7arRUGnrXsbiBfxqvZGnJxqLPeMc3PfaV4JiouvUap55G" ], "script": "base64:AAIFAAAAAAAAACIIAhIDCgEIEgMKAQgSABIDCgEYEggKBgEBAQEIARIDCgEIAAAAHwAAAAADU0VQAgAAAAJfXwAAAAAFRU1QVFkCAAAAAAAAAAAOaWR4UG9vbEFkZHJlc3MAAAAAAAAAAAEAAAAACWlkeExQQXNJZAAAAAAAAAAAAwAAAAAJaWR4QW1Bc0lkAAAAAAAAAAAEAAAAAAlpZHhQckFzSWQAAAAAAAAAAAUAAAAAD2lkeEZhY3RTdGFrQ250cgAAAAAAAAAAAQEAAAALa2V5RmFjdENudHIAAAAAAgAAABMlc19fZmFjdG9yeUNvbnRyYWN0AQAAABNrZXlNYW5hZ2VyUHVibGljS2V5AAAAAAIAAAAUJXNfX21hbmFnZXJQdWJsaWNLZXkBAAAAGmtleVBlbmRpbmdNYW5hZ2VyUHVibGljS2V5AAAAAAIAAAAbJXNfX3BlbmRpbmdNYW5hZ2VyUHVibGljS2V5AQAAAAtrZXlQb29sQWRkcgAAAAACAAAADyVzX19wb29sQWRkcmVzcwEAAAALa2V5QW10QXNzZXQAAAAAAgAAAA8lc19fYW1vdW50QXNzZXQBAAAADWt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EAAAAGa2V5QW1wAAAAAAkABEwAAAACBQAAAANhbXAFAAAAA25pbAUAAAADbmlsBAAAAARyZXMyCQAD/AAAAAQFAAAADHBvb2xDb250cmFjdAIAAAAEc2V0UwkABEwAAAACCQEAAAANa2V5QW1wSGlzdG9yeQAAAAEFAAAABmhlaWdodAkABEwAAAACBQAAAANhbXAFAAAAA25pbAUAAAADbmlsCQAFFAAAAAIFAAAAA25pbAkABRQAAAACBQAAAARyZXMxBQAAAARyZXMyCQAAAgAAAAECAAAAJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAEAAAAD3RhcmdldFB1YmxpY0tleQQAAAAHJG1hdGNoMAkBAAAAFm1hbmFnZXJQdWJsaWNLZXlPclVuaXQAAAAAAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAApCeXRlVmVjdG9yBAAAAAJwawUAAAAHJG1hdGNoMAUAAAACcGsDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABFVuaXQIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXkJAAACAAAAAQIAAAALTWF0Y2ggZXJyb3IJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAABQAAAA90YXJnZXRQdWJsaWNLZXmJkpk6", "height": 2201068, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5n65JEjEGcUPhS4AhYNHdCZB32MhCwmDq9dJB139ysac Next: HXgDLo4yBsEhitcdPERtKjbVDU34XHKAG2KerUa7KsED Diff:
Old | New | Differences | |
---|---|---|---|
14 | 14 | let idxPrAsId = 5 | |
15 | 15 | ||
16 | 16 | let idxFactStakCntr = 1 | |
17 | - | ||
18 | - | let delay = "%s__delay" | |
19 | 17 | ||
20 | 18 | func keyFactCntr () = "%s__factoryContract" | |
21 | 19 | ||
42 | 40 | ||
43 | 41 | ||
44 | 42 | func keyAmpHistory (height) = ("%s%d__amp__" + toString(height)) | |
45 | - | ||
46 | - | ||
47 | - | func lastGetOneTknCall (caller) = makeString(["%s%s__lastGetOneTknCall", caller], SEP) | |
48 | - | ||
49 | - | ||
50 | - | func lastPutOneTknCall (caller) = makeString(["%s%s__lastPutOneTknCall", caller], SEP) | |
51 | 43 | ||
52 | 44 | ||
53 | 45 | func keyFactoryConfig () = "%s__factoryConfig" | |
207 | 199 | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil) | |
208 | 200 | if ((unstakeInv == unstakeInv)) | |
209 | 201 | then { | |
210 | - | let getOneTkn = | |
202 | + | let getOneTkn = invoke(poolContract, "getOneTkn", [exchResult, notUsed, outAmount, outAssetId, slippage], [AttachedPayment(lpAssetId, amount)]) | |
211 | 203 | if ((getOneTkn == getOneTkn)) | |
212 | 204 | then nil | |
213 | 205 | else throw("Strict value is not equal to itself.") | |
232 | 224 | } | |
233 | 225 | ||
234 | 226 | ||
235 | - | ||
236 | - | @Callable(i) | |
237 | - | func ensureCanGetOneTkn (caller) = { | |
238 | - | let checkCaller = mustPool(i) | |
239 | - | if ((checkCaller == checkCaller)) | |
240 | - | then { | |
241 | - | let ensureCanPut = match getInteger(poolContract, lastPutOneTknCall(caller)) { | |
242 | - | case int: Int => | |
243 | - | let permittedHeight = (int + value(getInteger(poolContract, delay))) | |
244 | - | let isReadyforPutOneTkn = (height >= permittedHeight) | |
245 | - | let needBlocks = (permittedHeight - height) | |
246 | - | if (isReadyforPutOneTkn) | |
247 | - | then true | |
248 | - | else throw(makeString(["you should wait", toString(needBlocks), "blocks more to perform the action"], " ")) | |
249 | - | case _ => | |
250 | - | true | |
251 | - | } | |
252 | - | if ((ensureCanPut == ensureCanPut)) | |
253 | - | then { | |
254 | - | let ensureCanGet = match getInteger(poolContract, lastGetOneTknCall(caller)) { | |
255 | - | case int: Int => | |
256 | - | let permittedHeight = (int + value(getInteger(poolContract, delay))) | |
257 | - | let isReadyforGetOneTkn = (height >= permittedHeight) | |
258 | - | let needBlocks = (permittedHeight - height) | |
259 | - | if (isReadyforGetOneTkn) | |
260 | - | then true | |
261 | - | else throw(makeString(["you should wait", toString(needBlocks), "blocks more to perform the action"], " ")) | |
262 | - | case _ => | |
263 | - | true | |
264 | - | } | |
265 | - | if ((ensureCanGet == ensureCanGet)) | |
266 | - | then { | |
267 | - | let setI = invoke(poolContract, "setI", [lastPutOneTknCall(caller), height], nil) | |
268 | - | if ((setI == setI)) | |
269 | - | then nil | |
270 | - | else throw("Strict value is not equal to itself.") | |
271 | - | } | |
272 | - | else throw("Strict value is not equal to itself.") | |
273 | - | } | |
274 | - | else throw("Strict value is not equal to itself.") | |
275 | - | } | |
276 | - | else throw("Strict value is not equal to itself.") | |
277 | - | } | |
278 | - | ||
279 | - | ||
280 | - | ||
281 | - | @Callable(i) | |
282 | - | func ensureCanPutOneTkn (caller) = { | |
283 | - | let checkCaller = mustPool(i) | |
284 | - | if ((checkCaller == checkCaller)) | |
285 | - | then { | |
286 | - | let ensureCanPut = match getInteger(poolContract, lastPutOneTknCall(caller)) { | |
287 | - | case int: Int => | |
288 | - | let permittedHeight = (int + value(getInteger(poolContract, delay))) | |
289 | - | let isReadyforPutOneTkn = (height >= permittedHeight) | |
290 | - | let needBlocks = (permittedHeight - height) | |
291 | - | if (isReadyforPutOneTkn) | |
292 | - | then true | |
293 | - | else throw(makeString(["you should wait", toString(needBlocks), "blocks more to perform the action"], " ")) | |
294 | - | case _ => | |
295 | - | true | |
296 | - | } | |
297 | - | if ((ensureCanPut == ensureCanPut)) | |
298 | - | then { | |
299 | - | let ensureCanGet = match getInteger(poolContract, lastGetOneTknCall(caller)) { | |
300 | - | case int: Int => | |
301 | - | let permittedHeight = (int + value(getInteger(poolContract, delay))) | |
302 | - | let isReadyforGetOneTkn = (height >= permittedHeight) | |
303 | - | let needBlocks = (permittedHeight - height) | |
304 | - | if (isReadyforGetOneTkn) | |
305 | - | then true | |
306 | - | else throw(makeString(["you should wait", toString(needBlocks), "blocks more to perform the action"], " ")) | |
307 | - | case _ => | |
308 | - | true | |
309 | - | } | |
310 | - | if ((ensureCanGet == ensureCanGet)) | |
311 | - | then { | |
312 | - | let setI = invoke(poolContract, "setI", [lastPutOneTknCall(caller), height], nil) | |
313 | - | if ((setI == setI)) | |
314 | - | then nil | |
315 | - | else throw("Strict value is not equal to itself.") | |
316 | - | } | |
317 | - | else throw("Strict value is not equal to itself.") | |
318 | - | } | |
319 | - | else throw("Strict value is not equal to itself.") | |
320 | - | } | |
321 | - | else throw("Strict value is not equal to itself.") | |
322 | - | } | |
323 | - | ||
324 | - | ||
325 | 227 | @Verifier(tx) | |
326 | 228 | func verify () = { | |
327 | 229 | let targetPublicKey = match managerPublicKeyOrUnit() { |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | 5 | ||
6 | 6 | let EMPTY = "" | |
7 | 7 | ||
8 | 8 | let idxPoolAddress = 1 | |
9 | 9 | ||
10 | 10 | let idxLPAsId = 3 | |
11 | 11 | ||
12 | 12 | let idxAmAsId = 4 | |
13 | 13 | ||
14 | 14 | let idxPrAsId = 5 | |
15 | 15 | ||
16 | 16 | let idxFactStakCntr = 1 | |
17 | - | ||
18 | - | let delay = "%s__delay" | |
19 | 17 | ||
20 | 18 | func keyFactCntr () = "%s__factoryContract" | |
21 | 19 | ||
22 | 20 | ||
23 | 21 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
24 | 22 | ||
25 | 23 | ||
26 | 24 | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
27 | 25 | ||
28 | 26 | ||
29 | 27 | func keyPoolAddr () = "%s__poolAddress" | |
30 | 28 | ||
31 | 29 | ||
32 | 30 | func keyAmtAsset () = "%s__amountAsset" | |
33 | 31 | ||
34 | 32 | ||
35 | 33 | func keyPriceAsset () = "%s__priceAsset" | |
36 | 34 | ||
37 | 35 | ||
38 | 36 | func keyAdminPubKeys () = "%s__adminPubKeys" | |
39 | 37 | ||
40 | 38 | ||
41 | 39 | func keyAmp () = "%s__amp" | |
42 | 40 | ||
43 | 41 | ||
44 | 42 | func keyAmpHistory (height) = ("%s%d__amp__" + toString(height)) | |
45 | - | ||
46 | - | ||
47 | - | func lastGetOneTknCall (caller) = makeString(["%s%s__lastGetOneTknCall", caller], SEP) | |
48 | - | ||
49 | - | ||
50 | - | func lastPutOneTknCall (caller) = makeString(["%s%s__lastPutOneTknCall", caller], SEP) | |
51 | 43 | ||
52 | 44 | ||
53 | 45 | func keyFactoryConfig () = "%s__factoryConfig" | |
54 | 46 | ||
55 | 47 | ||
56 | 48 | func keyPoolConfig (iAmtAs,iPrAs) = (((("%d%d%s__" + iAmtAs) + "__") + iPrAs) + "__config") | |
57 | 49 | ||
58 | 50 | ||
59 | 51 | func keyMappingsBaseAsset2internalId (bAStr) = ("%s%s%s__mappings__baseAsset2internalId__" + bAStr) | |
60 | 52 | ||
61 | 53 | ||
62 | 54 | func getStringOrFail (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
63 | 55 | ||
64 | 56 | ||
65 | 57 | func getIntOrFail (addr,key) = valueOrErrorMessage(getInteger(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
66 | 58 | ||
67 | 59 | ||
68 | 60 | let poolContract = addressFromStringValue(getStringOrFail(this, keyPoolAddr())) | |
69 | 61 | ||
70 | 62 | let factoryContract = addressFromStringValue(getStringOrFail(poolContract, keyFactCntr())) | |
71 | 63 | ||
72 | 64 | func getPoolConfig () = { | |
73 | 65 | let amtAs = getStringOrFail(poolContract, keyAmtAsset()) | |
74 | 66 | let priceAs = getStringOrFail(poolContract, keyPriceAsset()) | |
75 | 67 | let iPriceAs = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAs)) | |
76 | 68 | let iAmtAs = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAs)) | |
77 | 69 | split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAs), toString(iPriceAs))), SEP) | |
78 | 70 | } | |
79 | 71 | ||
80 | 72 | ||
81 | 73 | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
82 | 74 | ||
83 | 75 | ||
84 | 76 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
85 | 77 | case s: String => | |
86 | 78 | fromBase58String(s) | |
87 | 79 | case _: Unit => | |
88 | 80 | unit | |
89 | 81 | case _ => | |
90 | 82 | throw("Match error") | |
91 | 83 | } | |
92 | 84 | ||
93 | 85 | ||
94 | 86 | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
95 | 87 | case s: String => | |
96 | 88 | fromBase58String(s) | |
97 | 89 | case _: Unit => | |
98 | 90 | unit | |
99 | 91 | case _ => | |
100 | 92 | throw("Match error") | |
101 | 93 | } | |
102 | 94 | ||
103 | 95 | ||
104 | 96 | func mustManager (i) = { | |
105 | 97 | let pd = throw("Permission denied") | |
106 | 98 | match managerPublicKeyOrUnit() { | |
107 | 99 | case pk: ByteVector => | |
108 | 100 | if ((i.callerPublicKey == pk)) | |
109 | 101 | then true | |
110 | 102 | else pd | |
111 | 103 | case _: Unit => | |
112 | 104 | if ((i.caller == this)) | |
113 | 105 | then true | |
114 | 106 | else pd | |
115 | 107 | case _ => | |
116 | 108 | throw("Match error") | |
117 | 109 | } | |
118 | 110 | } | |
119 | 111 | ||
120 | 112 | ||
121 | 113 | func getAdmins () = match getString(keyAdminPubKeys()) { | |
122 | 114 | case s: String => | |
123 | 115 | if ((size(s) == 0)) | |
124 | 116 | then nil | |
125 | 117 | else split(s, SEP) | |
126 | 118 | case _ => | |
127 | 119 | nil | |
128 | 120 | } | |
129 | 121 | ||
130 | 122 | ||
131 | 123 | func mustAdmin (i) = if (containsElement(getAdmins(), toBase58String(i.callerPublicKey))) | |
132 | 124 | then true | |
133 | 125 | else mustManager(i) | |
134 | 126 | ||
135 | 127 | ||
136 | 128 | func mustPool (i) = if ((i.caller == poolContract)) | |
137 | 129 | then true | |
138 | 130 | else throw("caller must be the pool") | |
139 | 131 | ||
140 | 132 | ||
141 | 133 | @Callable(i) | |
142 | 134 | func constructor (poolAddress) = { | |
143 | 135 | let checkCaller = mustManager(i) | |
144 | 136 | if ((checkCaller == checkCaller)) | |
145 | 137 | then [StringEntry(keyPoolAddr(), poolAddress)] | |
146 | 138 | else throw("Strict value is not equal to itself.") | |
147 | 139 | } | |
148 | 140 | ||
149 | 141 | ||
150 | 142 | ||
151 | 143 | @Callable(i) | |
152 | 144 | func setManager (pendingManagerPublicKey) = { | |
153 | 145 | let checkCaller = mustManager(i) | |
154 | 146 | if ((checkCaller == checkCaller)) | |
155 | 147 | then { | |
156 | 148 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
157 | 149 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
158 | 150 | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
159 | 151 | else throw("Strict value is not equal to itself.") | |
160 | 152 | } | |
161 | 153 | else throw("Strict value is not equal to itself.") | |
162 | 154 | } | |
163 | 155 | ||
164 | 156 | ||
165 | 157 | ||
166 | 158 | @Callable(i) | |
167 | 159 | func confirmManager () = { | |
168 | 160 | let pm = pendingManagerPublicKeyOrUnit() | |
169 | 161 | let hasPM = if (isDefined(pm)) | |
170 | 162 | then true | |
171 | 163 | else throw("No pending manager") | |
172 | 164 | if ((hasPM == hasPM)) | |
173 | 165 | then { | |
174 | 166 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
175 | 167 | then true | |
176 | 168 | else throw("You are not pending manager") | |
177 | 169 | if ((checkPM == checkPM)) | |
178 | 170 | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
179 | 171 | else throw("Strict value is not equal to itself.") | |
180 | 172 | } | |
181 | 173 | else throw("Strict value is not equal to itself.") | |
182 | 174 | } | |
183 | 175 | ||
184 | 176 | ||
185 | 177 | ||
186 | 178 | @Callable(i) | |
187 | 179 | func setAdmins (adminPubKeys) = { | |
188 | 180 | let checkCaller = mustManager(i) | |
189 | 181 | if ((checkCaller == checkCaller)) | |
190 | 182 | then [StringEntry(keyAdminPubKeys(), makeString(adminPubKeys, SEP))] | |
191 | 183 | else throw("Strict value is not equal to itself.") | |
192 | 184 | } | |
193 | 185 | ||
194 | 186 | ||
195 | 187 | ||
196 | 188 | @Callable(i) | |
197 | 189 | func unstakeAndGetOneTkn (amount,exchResult,notUsed,outAmount,outAssetId,slippage) = { | |
198 | 190 | let checkPayments = if ((size(i.payments) != 0)) | |
199 | 191 | then throw("No pmnts expd") | |
200 | 192 | else true | |
201 | 193 | if ((checkPayments == checkPayments)) | |
202 | 194 | then { | |
203 | 195 | let cfg = getPoolConfig() | |
204 | 196 | let factoryCfg = getFactoryConfig() | |
205 | 197 | let lpAssetId = fromBase58String(cfg[idxLPAsId]) | |
206 | 198 | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr") | |
207 | 199 | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil) | |
208 | 200 | if ((unstakeInv == unstakeInv)) | |
209 | 201 | then { | |
210 | - | let getOneTkn = | |
202 | + | let getOneTkn = invoke(poolContract, "getOneTkn", [exchResult, notUsed, outAmount, outAssetId, slippage], [AttachedPayment(lpAssetId, amount)]) | |
211 | 203 | if ((getOneTkn == getOneTkn)) | |
212 | 204 | then nil | |
213 | 205 | else throw("Strict value is not equal to itself.") | |
214 | 206 | } | |
215 | 207 | else throw("Strict value is not equal to itself.") | |
216 | 208 | } | |
217 | 209 | else throw("Strict value is not equal to itself.") | |
218 | 210 | } | |
219 | 211 | ||
220 | 212 | ||
221 | 213 | ||
222 | 214 | @Callable(i) | |
223 | 215 | func setAmp (amp) = { | |
224 | 216 | let checkCaller = mustAdmin(i) | |
225 | 217 | if ((checkCaller == checkCaller)) | |
226 | 218 | then { | |
227 | 219 | let res1 = invoke(poolContract, "setS", [keyAmp(), amp], nil) | |
228 | 220 | let res2 = invoke(poolContract, "setS", [keyAmpHistory(height), amp], nil) | |
229 | 221 | $Tuple2(nil, $Tuple2(res1, res2)) | |
230 | 222 | } | |
231 | 223 | else throw("Strict value is not equal to itself.") | |
232 | 224 | } | |
233 | 225 | ||
234 | 226 | ||
235 | - | ||
236 | - | @Callable(i) | |
237 | - | func ensureCanGetOneTkn (caller) = { | |
238 | - | let checkCaller = mustPool(i) | |
239 | - | if ((checkCaller == checkCaller)) | |
240 | - | then { | |
241 | - | let ensureCanPut = match getInteger(poolContract, lastPutOneTknCall(caller)) { | |
242 | - | case int: Int => | |
243 | - | let permittedHeight = (int + value(getInteger(poolContract, delay))) | |
244 | - | let isReadyforPutOneTkn = (height >= permittedHeight) | |
245 | - | let needBlocks = (permittedHeight - height) | |
246 | - | if (isReadyforPutOneTkn) | |
247 | - | then true | |
248 | - | else throw(makeString(["you should wait", toString(needBlocks), "blocks more to perform the action"], " ")) | |
249 | - | case _ => | |
250 | - | true | |
251 | - | } | |
252 | - | if ((ensureCanPut == ensureCanPut)) | |
253 | - | then { | |
254 | - | let ensureCanGet = match getInteger(poolContract, lastGetOneTknCall(caller)) { | |
255 | - | case int: Int => | |
256 | - | let permittedHeight = (int + value(getInteger(poolContract, delay))) | |
257 | - | let isReadyforGetOneTkn = (height >= permittedHeight) | |
258 | - | let needBlocks = (permittedHeight - height) | |
259 | - | if (isReadyforGetOneTkn) | |
260 | - | then true | |
261 | - | else throw(makeString(["you should wait", toString(needBlocks), "blocks more to perform the action"], " ")) | |
262 | - | case _ => | |
263 | - | true | |
264 | - | } | |
265 | - | if ((ensureCanGet == ensureCanGet)) | |
266 | - | then { | |
267 | - | let setI = invoke(poolContract, "setI", [lastPutOneTknCall(caller), height], nil) | |
268 | - | if ((setI == setI)) | |
269 | - | then nil | |
270 | - | else throw("Strict value is not equal to itself.") | |
271 | - | } | |
272 | - | else throw("Strict value is not equal to itself.") | |
273 | - | } | |
274 | - | else throw("Strict value is not equal to itself.") | |
275 | - | } | |
276 | - | else throw("Strict value is not equal to itself.") | |
277 | - | } | |
278 | - | ||
279 | - | ||
280 | - | ||
281 | - | @Callable(i) | |
282 | - | func ensureCanPutOneTkn (caller) = { | |
283 | - | let checkCaller = mustPool(i) | |
284 | - | if ((checkCaller == checkCaller)) | |
285 | - | then { | |
286 | - | let ensureCanPut = match getInteger(poolContract, lastPutOneTknCall(caller)) { | |
287 | - | case int: Int => | |
288 | - | let permittedHeight = (int + value(getInteger(poolContract, delay))) | |
289 | - | let isReadyforPutOneTkn = (height >= permittedHeight) | |
290 | - | let needBlocks = (permittedHeight - height) | |
291 | - | if (isReadyforPutOneTkn) | |
292 | - | then true | |
293 | - | else throw(makeString(["you should wait", toString(needBlocks), "blocks more to perform the action"], " ")) | |
294 | - | case _ => | |
295 | - | true | |
296 | - | } | |
297 | - | if ((ensureCanPut == ensureCanPut)) | |
298 | - | then { | |
299 | - | let ensureCanGet = match getInteger(poolContract, lastGetOneTknCall(caller)) { | |
300 | - | case int: Int => | |
301 | - | let permittedHeight = (int + value(getInteger(poolContract, delay))) | |
302 | - | let isReadyforGetOneTkn = (height >= permittedHeight) | |
303 | - | let needBlocks = (permittedHeight - height) | |
304 | - | if (isReadyforGetOneTkn) | |
305 | - | then true | |
306 | - | else throw(makeString(["you should wait", toString(needBlocks), "blocks more to perform the action"], " ")) | |
307 | - | case _ => | |
308 | - | true | |
309 | - | } | |
310 | - | if ((ensureCanGet == ensureCanGet)) | |
311 | - | then { | |
312 | - | let setI = invoke(poolContract, "setI", [lastPutOneTknCall(caller), height], nil) | |
313 | - | if ((setI == setI)) | |
314 | - | then nil | |
315 | - | else throw("Strict value is not equal to itself.") | |
316 | - | } | |
317 | - | else throw("Strict value is not equal to itself.") | |
318 | - | } | |
319 | - | else throw("Strict value is not equal to itself.") | |
320 | - | } | |
321 | - | else throw("Strict value is not equal to itself.") | |
322 | - | } | |
323 | - | ||
324 | - | ||
325 | 227 | @Verifier(tx) | |
326 | 228 | func verify () = { | |
327 | 229 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
328 | 230 | case pk: ByteVector => | |
329 | 231 | pk | |
330 | 232 | case _: Unit => | |
331 | 233 | tx.senderPublicKey | |
332 | 234 | case _ => | |
333 | 235 | throw("Match error") | |
334 | 236 | } | |
335 | 237 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
336 | 238 | } | |
337 | 239 |
github/deemru/w8io/169f3d6 54.46 ms ◑