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