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