tx · HtV37J7tBNTzpMD31MYs2tDv8qk7j3DwebfkVyKUVUiY 3MyFHYRXw55tL2gQ928mKUuQoEabktL3hCR: -0.05000000 Waves 2023.07.18 16:28 [2671378] smart account 3MyFHYRXw55tL2gQ928mKUuQoEabktL3hCR > SELF 0.00000000 Waves
{ "type": 13, "id": "HtV37J7tBNTzpMD31MYs2tDv8qk7j3DwebfkVyKUVUiY", "fee": 5000000, "feeAssetId": null, "timestamp": 1689686928096, "version": 2, "chainId": 84, "sender": "3MyFHYRXw55tL2gQ928mKUuQoEabktL3hCR", "senderPublicKey": "bMD2x5tkB4skw1DeXM1jqE4hBh4o6tehbczXwwV7aRa", "proofs": [ "cUF7zACiTz4oJHBN6QHUzV1JgEPbj8V6wFCMnyEJacxpWq1E4M9BcKFZ6X12G9vx5sVw3XDNu6bvdtNL47tz649" ], "script": "base64:BgLnBwgCEgMKAQgSBQoDCAgIEgMKAQgSACIDU0VQIglQUkVDSVNJT04iFERFRkFVTFRfTUFYX1NMSVBQQUdFIgRtdWxwIgJfeCICX3kiBGpvaW4iAmFyIg5rZXlJbml0aWFsaXplZCIVa2V5Q29vcmRpbmF0b3JBZGRyZXNzIhJrZXlWZXJpZmllckFkZHJlc3MiFWtleUVhc3RTdGFraW5nQWRkcmVzcyISa2V5U3VidmF1bHRBZGRyZXNzIgxrZXlFYXN0QXNzZXQiDmtleU1heFNsaXBwYWdlIglrZXlTaWduZWQiCF9hZGRyZXNzIgVfdHhJZCINaXNJbml0aWFsaXplZCIPbXVzdEluaXRpYWxpemVkIhJtdXN0Tm90SW5pdGlhbGl6ZWQiCG11c3RTZWxmIgFpIgtjb29yZGluYXRvciIIdmVyaWZpZXIiByRtYXRjaDAiAXMiCmdldEFkZHJlc3MiA2tleSIDZXJyIhVnZXRFYXN0U3Rha2luZ0FkZHJlc3MiDmdldE1heFNsaXBwYWdlIg9nZXRFYXN0QXNzZXRTdHIiDGdldEVhc3RBc3NldCIMY2hlY2tBZGRyZXNzIgdhZGRyZX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Qgc2l6ZSBleGNlZWRzIDEwCQECYUECCQECYXgCCQECYXgCCQECYXgCCQECYXgCCQECYXgCCQECYXgCCQECYXgCCQECYXgCCQECYXgCCQECYXgCBQJhdwAAAAEAAgADAAQABQAGAAcACAAJAAoDCQAAAgUCYXQFAmF0BAJhQgkAZAIJAQFUAAUCYXQEAmFDCQEPQXR0YWNoZWRQYXltZW50AgkBAUgABQJhdAQCYUQJAPwHBAkBAUUAAhFhZGRTdGFraW5nUmV3YXJkcwUDbmlsCQDMCAIFAmFDBQNuaWwDCQAAAgUCYUQFAmFECQDMCAIJAQxJbnRlZ2VyRW50cnkCCQEBUAAFAmFCBQNuaWwJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4JAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4BAmFFAQJhRgAEAXoJAQF5AAMJAAECBQF6AgZTdHJpbmcEAUoFAXoJAQt2YWx1ZU9yRWxzZQIJAJsIAgkBEUBleHRyTmF0aXZlKDEwNjIpAQUBSgkBAXACCQClCAEFBHRoaXMJANgEAQgFAmFFAmlkBwkA9AMDCAUCYUUJYm9keUJ5dGVzCQCRAwIIBQJhRQZwcm9vZnMAAAgFAmFFD3NlbmRlclB1YmxpY0tleR+hRiM=", "height": 2671378, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let SEP = "__" | |
5 | + | ||
6 | + | let PRECISION = 1000000000000 | |
7 | + | ||
8 | + | let DEFAULT_MAX_SLIPPAGE = ((PRECISION / 20) * 19) | |
9 | + | ||
10 | + | func mulp (_x,_y) = fraction(_x, _y, PRECISION, HALFEVEN) | |
11 | + | ||
12 | + | ||
13 | + | func join (ar) = makeString(ar, SEP) | |
14 | + | ||
15 | + | ||
16 | + | func keyInitialized () = join(["%s", "initialized"]) | |
17 | + | ||
18 | + | ||
19 | + | func keyCoordinatorAddress () = join(["%s", "coordinatorAddress"]) | |
20 | + | ||
21 | + | ||
22 | + | func keyVerifierAddress () = join(["%s", "verifierAddress"]) | |
23 | + | ||
24 | + | ||
25 | + | func keyEastStakingAddress () = join(["%s", "eastStakingAddress"]) | |
26 | + | ||
27 | + | ||
28 | + | func keySubvaultAddress () = join(["%s", "subvaultAddress"]) | |
29 | + | ||
30 | + | ||
31 | + | func keyEastAsset () = join(["%s", "eastAsset"]) | |
32 | + | ||
33 | + | ||
34 | + | func keyMaxSlippage () = join(["%s", "maxSlippage"]) | |
35 | + | ||
36 | + | ||
37 | + | func keySigned (_address,_txId) = join(["%s%s%s", "signed", _address, _txId]) | |
38 | + | ||
39 | + | ||
40 | + | func isInitialized () = valueOrElse(getBoolean(this, keyInitialized()), false) | |
41 | + | ||
42 | + | ||
43 | + | func mustInitialized () = if (!(isInitialized())) | |
44 | + | then throw("Not initialized") | |
45 | + | else unit | |
46 | + | ||
47 | + | ||
48 | + | func mustNotInitialized () = if (isInitialized()) | |
49 | + | then throw("Already initialized") | |
50 | + | else unit | |
51 | + | ||
52 | + | ||
53 | + | func mustSelf (i) = if ((i.caller != this)) | |
54 | + | then throw("Only self invocation allowed.") | |
55 | + | else unit | |
56 | + | ||
57 | + | ||
58 | + | func coordinator () = addressFromStringValue(valueOrErrorMessage(getString(keyCoordinatorAddress()), "Coordinator is not set")) | |
59 | + | ||
60 | + | ||
61 | + | func verifier () = match getString(keyCoordinatorAddress()) { | |
62 | + | case s: String => | |
63 | + | getString(addressFromStringValue(s), keyVerifierAddress()) | |
64 | + | case _: Unit => | |
65 | + | unit | |
66 | + | case _ => | |
67 | + | throw("Match error") | |
68 | + | } | |
69 | + | ||
70 | + | ||
71 | + | func getAddress (key,err) = addressFromStringValue(valueOrErrorMessage(getString(coordinator(), key), err)) | |
72 | + | ||
73 | + | ||
74 | + | func getEastStakingAddress () = getAddress(keyEastStakingAddress(), "East staking is not set") | |
75 | + | ||
76 | + | ||
77 | + | func getMaxSlippage () = valueOrElse(getInteger(coordinator(), keyMaxSlippage()), DEFAULT_MAX_SLIPPAGE) | |
78 | + | ||
79 | + | ||
80 | + | func getEastAssetStr () = valueOrErrorMessage(getString(coordinator(), keyEastAsset()), "East asset is not set") | |
81 | + | ||
82 | + | ||
83 | + | func getEastAsset () = fromBase58String(getEastAssetStr()) | |
84 | + | ||
85 | + | ||
86 | + | func checkAddress (_address) = match addressFromString(_address) { | |
87 | + | case address: Address => | |
88 | + | true | |
89 | + | case _: Unit => | |
90 | + | throw("Invalid address") | |
91 | + | case _ => | |
92 | + | throw("Match error") | |
93 | + | } | |
94 | + | ||
95 | + | ||
96 | + | let IdxStakerAddress = 1 | |
97 | + | ||
98 | + | let IdxExchangeAddress = 2 | |
99 | + | ||
100 | + | func keyAssets () = join(["%s", "assets"]) | |
101 | + | ||
102 | + | ||
103 | + | func keyAsset (_assetStr) = join(["%s%s", "asset", _assetStr]) | |
104 | + | ||
105 | + | ||
106 | + | func keyTotalRewardCollected () = join(["%s", "totalRewardPayed"]) | |
107 | + | ||
108 | + | ||
109 | + | func dataAsset (_stakerAddress,_exchangeAddress) = makeString(["%s%s", _stakerAddress, _exchangeAddress], SEP) | |
110 | + | ||
111 | + | ||
112 | + | func getTotalRewardCollected () = valueOrElse(getInteger(keyTotalRewardCollected()), 0) | |
113 | + | ||
114 | + | ||
115 | + | func getAssets () = split(valueOrErrorMessage(getString(keyAssets()), "No assets configured."), SEP) | |
116 | + | ||
117 | + | ||
118 | + | func getAssetsValue () = match getString(keyAssets()) { | |
119 | + | case s: String => | |
120 | + | split(value(s), SEP) | |
121 | + | case _: Unit => | |
122 | + | nil | |
123 | + | case _ => | |
124 | + | throw("Match error") | |
125 | + | } | |
126 | + | ||
127 | + | ||
128 | + | func getAsset (_assetStr) = { | |
129 | + | let config = split(valueOrErrorMessage(getString(keyAsset(_assetStr)), "Asset config not found."), SEP) | |
130 | + | let staker = addressFromStringValue(config[IdxStakerAddress]) | |
131 | + | let exchange = addressFromStringValue(config[IdxExchangeAddress]) | |
132 | + | $Tuple2(staker, exchange) | |
133 | + | } | |
134 | + | ||
135 | + | ||
136 | + | @Callable(i) | |
137 | + | func initialize (_coordinatorAddress) = { | |
138 | + | let checks = [mustSelf(i), mustNotInitialized(), checkAddress(_coordinatorAddress)] | |
139 | + | if ((checks == checks)) | |
140 | + | then [StringEntry(keyCoordinatorAddress(), _coordinatorAddress), BooleanEntry(keyInitialized(), true)] | |
141 | + | else throw("Strict value is not equal to itself.") | |
142 | + | } | |
143 | + | ||
144 | + | ||
145 | + | ||
146 | + | @Callable(i) | |
147 | + | func addAsset (_assetStr,_stakerAddress,_exchangeAddress) = { | |
148 | + | let checks = [mustInitialized(), mustSelf(i), checkAddress(_stakerAddress), checkAddress(_exchangeAddress)] | |
149 | + | if ((checks == checks)) | |
150 | + | then { | |
151 | + | let assets = getAssetsValue() | |
152 | + | if (containsElement(assets, _assetStr)) | |
153 | + | then throw("Asset already exists.") | |
154 | + | else { | |
155 | + | let newAssets = makeString((assets :+ _assetStr), SEP) | |
156 | + | [StringEntry(keyAssets(), newAssets), StringEntry(keyAsset(_assetStr), dataAsset(_stakerAddress, _exchangeAddress))] | |
157 | + | } | |
158 | + | } | |
159 | + | else throw("Strict value is not equal to itself.") | |
160 | + | } | |
161 | + | ||
162 | + | ||
163 | + | ||
164 | + | @Callable(i) | |
165 | + | func removeAsset (_assetStr) = { | |
166 | + | let checks = [mustInitialized(), mustSelf(i)] | |
167 | + | if ((checks == checks)) | |
168 | + | then { | |
169 | + | let assets = getAssets() | |
170 | + | let newAssets = match indexOf(assets, _assetStr) { | |
171 | + | case idx: Int => | |
172 | + | makeString(removeByIndex(assets, idx), SEP) | |
173 | + | case _: Unit => | |
174 | + | throw("Unable to proceed. Asset not found.") | |
175 | + | case _ => | |
176 | + | throw("Match error") | |
177 | + | } | |
178 | + | [StringEntry(keyAssets(), newAssets), DeleteEntry(keyAsset(_assetStr))] | |
179 | + | } | |
180 | + | else throw("Strict value is not equal to itself.") | |
181 | + | } | |
182 | + | ||
183 | + | ||
184 | + | ||
185 | + | @Callable(i) | |
186 | + | func ackRewards () = { | |
187 | + | func claimAndExchange (acc,next) = match next { | |
188 | + | case assetStr: String => | |
189 | + | let $t01366413730 = getAsset(assetStr) | |
190 | + | let staker = $t01366413730._1 | |
191 | + | let exchange = $t01366413730._2 | |
192 | + | let profit = { | |
193 | + | let @ = invoke(staker, "claimProfit", nil, nil) | |
194 | + | if ($isInstanceOf(@, "Int")) | |
195 | + | then @ | |
196 | + | else throw(($getType(@) + " couldn't be cast to Int")) | |
197 | + | } | |
198 | + | if ((profit == profit)) | |
199 | + | then { | |
200 | + | let subvault = addressFromStringValue(valueOrErrorMessage(getString(staker, keySubvaultAddress()), "Subvault not found.")) | |
201 | + | let assetRate = { | |
202 | + | let @ = invoke(subvault, "getCurrentUsdPrice", nil, nil) | |
203 | + | if ($isInstanceOf(@, "Int")) | |
204 | + | then @ | |
205 | + | else throw(($getType(@) + " couldn't be cast to Int")) | |
206 | + | } | |
207 | + | if ((assetRate == assetRate)) | |
208 | + | then { | |
209 | + | let usdEq = mulp(profit, assetRate) | |
210 | + | let slippage = getMaxSlippage() | |
211 | + | let minEastAmount = mulp(usdEq, slippage) | |
212 | + | let asset = if ((assetStr == "WAVES")) | |
213 | + | then unit | |
214 | + | else fromBase58String(assetStr) | |
215 | + | let exchangedAmount = { | |
216 | + | let @ = invoke(exchange, "swap", [minEastAmount, getEastAssetStr(), toString(this)], [AttachedPayment(asset, profit)]) | |
217 | + | if ($isInstanceOf(@, "Int")) | |
218 | + | then @ | |
219 | + | else throw(($getType(@) + " couldn't be cast to Int")) | |
220 | + | } | |
221 | + | if ((exchangedAmount == exchangedAmount)) | |
222 | + | then (acc + exchangedAmount) | |
223 | + | else throw("Strict value is not equal to itself.") | |
224 | + | } | |
225 | + | else throw("Strict value is not equal to itself.") | |
226 | + | } | |
227 | + | else throw("Strict value is not equal to itself.") | |
228 | + | case _: Unit => | |
229 | + | acc | |
230 | + | case _ => | |
231 | + | throw("Match error") | |
232 | + | } | |
233 | + | ||
234 | + | let assets = getAssets() | |
235 | + | let rewardAmount = { | |
236 | + | let $l = assets | |
237 | + | let $s = size($l) | |
238 | + | let $acc0 = 0 | |
239 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
240 | + | then $a | |
241 | + | else claimAndExchange($a, $l[$i]) | |
242 | + | ||
243 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
244 | + | then $a | |
245 | + | else throw("List size exceeds 10") | |
246 | + | ||
247 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
248 | + | } | |
249 | + | if ((rewardAmount == rewardAmount)) | |
250 | + | then { | |
251 | + | let newTotalRewardCollected = (getTotalRewardCollected() + rewardAmount) | |
252 | + | let eastPayment = AttachedPayment(getEastAsset(), rewardAmount) | |
253 | + | let doAddEastReward = invoke(getEastStakingAddress(), "addStakingRewards", nil, [eastPayment]) | |
254 | + | if ((doAddEastReward == doAddEastReward)) | |
255 | + | then [IntegerEntry(keyTotalRewardCollected(), newTotalRewardCollected)] | |
256 | + | else throw("Strict value is not equal to itself.") | |
257 | + | } | |
258 | + | else throw("Strict value is not equal to itself.") | |
259 | + | } | |
260 | + | ||
261 | + | ||
262 | + | @Verifier(tx) | |
263 | + | func verify () = match verifier() { | |
264 | + | case address: String => | |
265 | + | valueOrElse(getBoolean(addressFromStringValue(address), keySigned(toString(this), toBase58String(tx.id))), false) | |
266 | + | case _ => | |
267 | + | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
268 | + | } | |
269 | + |
github/deemru/w8io/026f985 44.48 ms ◑