tx · 5syPSBVkcjGPexCcp7NqjBxCjq8tqWXUWs7HvtzR3Y2a 3MzXdqhXMMdEz7cerqLv4obaJXKjzXoTL2b: -0.02000000 Waves 2022.09.08 11:17 [2219871] smart account 3MzXdqhXMMdEz7cerqLv4obaJXKjzXoTL2b > SELF 0.00000000 Waves
{ "type": 13, "id": "5syPSBVkcjGPexCcp7NqjBxCjq8tqWXUWs7HvtzR3Y2a", "fee": 2000000, "feeAssetId": null, "timestamp": 1662625160696, "version": 1, "sender": "3MzXdqhXMMdEz7cerqLv4obaJXKjzXoTL2b", "senderPublicKey": "8Z3DzPruCMmJAg5Nv62cFmXG8QGWBHagmeMTceT3rXKb", "proofs": [ "2gryvmGZBt1EWYm6RDqJPUSUEcMR1x74oQe82gh2ShJbF82hCacjy7gVXj7o3FfrkfpmR1yTxZtnmvd3RtvZkqhW" ], "script": "base64:AAIFAAAAAAAAA8cIAhIDCgEIEgMKAQgSABIDCgEYEggKBgEBAQEIARIDCgEIIgNTRVAiBUVNUFRZIg5pZHhQb29sQWRkcmVzcyIJaWR4TFBBc0lkIglpZHhBbUFzSWQiCWlkeFByQXNJZCIPaWR4RmFjdFN0YWtDbnRyIgtrZXlGYWN0Q250ciITa2V5TWFuYWdlclB1YmxpY0tleSIaa2V5UGVuZGluZ01hbmFnZXJQdWJsaWNLZXkiC2tleVBvb2xBZGRyIgtrZXlBbXRBc3NldCINa2V5UHJpY2VBc3NldCIPa2V5QWRtaW5QdWJLZXlzIgZrZXlBbXAiDWtleUFtcEhpc3RvcnkiBmhlaWdodCIQa2V5RmFjdG9yeUNvbmZpZyINa2V5UG9vbENvbmZpZyIGaUFtdEFzIgVpUHJBcyIfa2V5TWFwcGluZ3NCYXNlQXNzZXQyaW50ZXJuYWxJZCIFYkFTdHIiIWtleUFsbG93ZWRMcFN0YWJsZUFkZG9uU2NyaXB0SGFzaCIPZ2V0U3RyaW5nT3JGYWlsIgRhZGRyIgNrZXkiDGdldEludE9yRmFpbCIMcG9vbENvbnR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AAAACYXAFAAAAA25pbAUAAAADbmlsBAAAAAJhcgkAA/wAAAAEBQAAAAFDAgAAAARzZXRTCQAETAAAAAIJAQAAAAFwAAAAAQUAAAABcQkABEwAAAACBQAAAAJhcAUAAAADbmlsBQAAAANuaWwJAAUUAAAAAgUAAAADbmlsCQAFFAAAAAIFAAAAAmFxBQAAAAJhcgkAAAIAAAABAgAAACRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4AAAABAAAAAmFzAQAAAAJhdAAAAAAEAAAAAmF1BAAAAAFLCQEAAAABSgAAAAADCQAAAQAAAAIFAAAAAUsCAAAACkJ5dGVWZWN0b3IEAAAAAVEFAAAAAUsFAAAAAVEDCQAAAQAAAAIFAAAAAUsCAAAABFVuaXQIBQAAAAJhcwAAAA9zZW5kZXJQdWJsaWNLZXkJAAACAAAAAQIAAAALTWF0Y2ggZXJyb3IEAAAAAUsFAAAAAmFzAwkAAAEAAAACBQAAAAFLAgAAABRTZXRTY3JpcHRUcmFuc2FjdGlvbgQAAAABTAUAAAABSwQAAAACYXYJAAH2AAAAAQkBAAAABXZhbHVlAAAAAQgFAAAAAUwAAAAGc2NyaXB0BAAAAAJhdwkAAlsAAAABCQEAAAAFdmFsdWUAAAABCQAEHQAAAAIFAAAAAUQJAQAAAAF4AAAAAAQAAAACYXgJAAPxAAAAAQUAAAAEdGhpcwMDCQAAAAAAAAIFAAAAAmF3BQAAAAJhdgkBAAAAAiE9AAAAAgUAAAACYXgFAAAAAmF2BwYJAAH0AAAAAwgFAAAAAmFzAAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACYXMAAAAGcHJvb2ZzAAAAAAAAAAAABQAAAAJhdQkAAfQAAAADCAUAAAACYXMAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJhcwAAAAZwcm9vZnMAAAAAAAAAAAAFAAAAAmF1zAByCw==", "chainId": 84, "height": 2219871, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let SEP = "__" | |
5 | + | ||
6 | + | let EMPTY = "" | |
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 | + | func keyFactCntr () = "%s__factoryContract" | |
19 | + | ||
20 | + | ||
21 | + | func keyManagerPublicKey () = "%s__managerPublicKey" | |
22 | + | ||
23 | + | ||
24 | + | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
25 | + | ||
26 | + | ||
27 | + | func keyPoolAddr () = "%s__poolAddress" | |
28 | + | ||
29 | + | ||
30 | + | func keyAmtAsset () = "%s__amountAsset" | |
31 | + | ||
32 | + | ||
33 | + | func keyPriceAsset () = "%s__priceAsset" | |
34 | + | ||
35 | + | ||
36 | + | func keyAdminPubKeys () = "%s__adminPubKeys" | |
37 | + | ||
38 | + | ||
39 | + | func keyAmp () = "%s__amp" | |
40 | + | ||
41 | + | ||
42 | + | func keyAmpHistory (height) = ("%s%d__amp__" + toString(height)) | |
43 | + | ||
44 | + | ||
45 | + | func keyFactoryConfig () = "%s__factoryConfig" | |
46 | + | ||
47 | + | ||
48 | + | func keyPoolConfig (iAmtAs,iPrAs) = (((("%d%d%s__" + iAmtAs) + "__") + iPrAs) + "__config") | |
49 | + | ||
50 | + | ||
51 | + | func keyMappingsBaseAsset2internalId (bAStr) = ("%s%s%s__mappings__baseAsset2internalId__" + bAStr) | |
52 | + | ||
53 | + | ||
54 | + | func keyAllowedLpStableAddonScriptHash () = "%s__allowedLpStableAddonScriptHash" | |
55 | + | ||
56 | + | ||
57 | + | func getStringOrFail (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
58 | + | ||
59 | + | ||
60 | + | func getIntOrFail (addr,key) = valueOrErrorMessage(getInteger(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
61 | + | ||
62 | + | ||
63 | + | let poolContract = addressFromStringValue(getStringOrFail(this, keyPoolAddr())) | |
64 | + | ||
65 | + | let factoryContract = addressFromStringValue(getStringOrFail(poolContract, keyFactCntr())) | |
66 | + | ||
67 | + | func getPoolConfig () = { | |
68 | + | let amtAs = getStringOrFail(poolContract, keyAmtAsset()) | |
69 | + | let priceAs = getStringOrFail(poolContract, keyPriceAsset()) | |
70 | + | let iPriceAs = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAs)) | |
71 | + | let iAmtAs = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAs)) | |
72 | + | split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAs), toString(iPriceAs))), SEP) | |
73 | + | } | |
74 | + | ||
75 | + | ||
76 | + | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
77 | + | ||
78 | + | ||
79 | + | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
80 | + | case s: String => | |
81 | + | fromBase58String(s) | |
82 | + | case _: Unit => | |
83 | + | unit | |
84 | + | case _ => | |
85 | + | throw("Match error") | |
86 | + | } | |
87 | + | ||
88 | + | ||
89 | + | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
90 | + | case s: String => | |
91 | + | fromBase58String(s) | |
92 | + | case _: Unit => | |
93 | + | unit | |
94 | + | case _ => | |
95 | + | throw("Match error") | |
96 | + | } | |
97 | + | ||
98 | + | ||
99 | + | func mustManager (i) = { | |
100 | + | let pd = throw("Permission denied") | |
101 | + | match managerPublicKeyOrUnit() { | |
102 | + | case pk: ByteVector => | |
103 | + | if ((i.callerPublicKey == pk)) | |
104 | + | then true | |
105 | + | else pd | |
106 | + | case _: Unit => | |
107 | + | if ((i.caller == this)) | |
108 | + | then true | |
109 | + | else pd | |
110 | + | case _ => | |
111 | + | throw("Match error") | |
112 | + | } | |
113 | + | } | |
114 | + | ||
115 | + | ||
116 | + | func getAdmins () = match getString(keyAdminPubKeys()) { | |
117 | + | case s: String => | |
118 | + | if ((size(s) == 0)) | |
119 | + | then nil | |
120 | + | else split(s, SEP) | |
121 | + | case _ => | |
122 | + | nil | |
123 | + | } | |
124 | + | ||
125 | + | ||
126 | + | func mustAdmin (i) = if (containsElement(getAdmins(), toBase58String(i.callerPublicKey))) | |
127 | + | then true | |
128 | + | else mustManager(i) | |
129 | + | ||
130 | + | ||
131 | + | func mustPool (i) = if ((i.caller == poolContract)) | |
132 | + | then true | |
133 | + | else throw("caller must be the pool") | |
134 | + | ||
135 | + | ||
136 | + | @Callable(i) | |
137 | + | func constructor (poolAddress) = { | |
138 | + | let checkCaller = mustManager(i) | |
139 | + | if ((checkCaller == checkCaller)) | |
140 | + | then [StringEntry(keyPoolAddr(), poolAddress)] | |
141 | + | else throw("Strict value is not equal to itself.") | |
142 | + | } | |
143 | + | ||
144 | + | ||
145 | + | ||
146 | + | @Callable(i) | |
147 | + | func setManager (pendingManagerPublicKey) = { | |
148 | + | let checkCaller = mustManager(i) | |
149 | + | if ((checkCaller == checkCaller)) | |
150 | + | then { | |
151 | + | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
152 | + | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
153 | + | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
154 | + | else throw("Strict value is not equal to itself.") | |
155 | + | } | |
156 | + | else throw("Strict value is not equal to itself.") | |
157 | + | } | |
158 | + | ||
159 | + | ||
160 | + | ||
161 | + | @Callable(i) | |
162 | + | func confirmManager () = { | |
163 | + | let pm = pendingManagerPublicKeyOrUnit() | |
164 | + | let hasPM = if (isDefined(pm)) | |
165 | + | then true | |
166 | + | else throw("No pending manager") | |
167 | + | if ((hasPM == hasPM)) | |
168 | + | then { | |
169 | + | let checkPM = if ((i.callerPublicKey == value(pm))) | |
170 | + | then true | |
171 | + | else throw("You are not pending manager") | |
172 | + | if ((checkPM == checkPM)) | |
173 | + | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
174 | + | else throw("Strict value is not equal to itself.") | |
175 | + | } | |
176 | + | else throw("Strict value is not equal to itself.") | |
177 | + | } | |
178 | + | ||
179 | + | ||
180 | + | ||
181 | + | @Callable(i) | |
182 | + | func setAdmins (adminPubKeys) = { | |
183 | + | let checkCaller = mustManager(i) | |
184 | + | if ((checkCaller == checkCaller)) | |
185 | + | then [StringEntry(keyAdminPubKeys(), makeString(adminPubKeys, SEP))] | |
186 | + | else throw("Strict value is not equal to itself.") | |
187 | + | } | |
188 | + | ||
189 | + | ||
190 | + | ||
191 | + | @Callable(i) | |
192 | + | func unstakeAndGetOneTkn (amount,exchResult,notUsed,outAmount,outAssetId,slippage) = { | |
193 | + | let checkPayments = if ((size(i.payments) != 0)) | |
194 | + | then throw("No pmnts expd") | |
195 | + | else true | |
196 | + | if ((checkPayments == checkPayments)) | |
197 | + | then { | |
198 | + | let cfg = getPoolConfig() | |
199 | + | let factoryCfg = getFactoryConfig() | |
200 | + | let lpAssetId = fromBase58String(cfg[idxLPAsId]) | |
201 | + | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr") | |
202 | + | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil) | |
203 | + | if ((unstakeInv == unstakeInv)) | |
204 | + | then { | |
205 | + | let getOneTkn = invoke(poolContract, "getOneTkn", [exchResult, notUsed, outAmount, outAssetId, slippage], [AttachedPayment(lpAssetId, amount)]) | |
206 | + | if ((getOneTkn == getOneTkn)) | |
207 | + | then nil | |
208 | + | else throw("Strict value is not equal to itself.") | |
209 | + | } | |
210 | + | else throw("Strict value is not equal to itself.") | |
211 | + | } | |
212 | + | else throw("Strict value is not equal to itself.") | |
213 | + | } | |
214 | + | ||
215 | + | ||
216 | + | ||
217 | + | @Callable(i) | |
218 | + | func setAmp (amp) = { | |
219 | + | let checkCaller = mustAdmin(i) | |
220 | + | if ((checkCaller == checkCaller)) | |
221 | + | then { | |
222 | + | let res1 = invoke(poolContract, "setS", [keyAmp(), amp], nil) | |
223 | + | let res2 = invoke(poolContract, "setS", [keyAmpHistory(q), amp], nil) | |
224 | + | $Tuple2(nil, $Tuple2(res1, res2)) | |
225 | + | } | |
226 | + | else throw("Strict value is not equal to itself.") | |
227 | + | } | |
228 | + | ||
229 | + | ||
230 | + | @Verifier(tx) | |
231 | + | func verify () = { | |
232 | + | let targetPublicKey = match managerPublicKeyOrUnit() { | |
233 | + | case pk: ByteVector => | |
234 | + | pk | |
235 | + | case _: Unit => | |
236 | + | tx.senderPublicKey | |
237 | + | case _ => | |
238 | + | throw("Match error") | |
239 | + | } | |
240 | + | match tx { | |
241 | + | case s: SetScriptTransaction => | |
242 | + | let newHash = blake2b256(value(s.script)) | |
243 | + | let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpStableAddonScriptHash()))) | |
244 | + | let currentHash = scriptHash(this) | |
245 | + | if (if ((allowedHash == newHash)) | |
246 | + | then (currentHash != newHash) | |
247 | + | else false) | |
248 | + | then true | |
249 | + | else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
250 | + | case _ => | |
251 | + | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
252 | + | } | |
253 | + | } | |
254 | + |
github/deemru/w8io/026f985 22.28 ms ◑