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