tx · 8XGNQH7eWoc3gVeP6sQJFmu11bkNvVSHcACBYLbY97oY 3Mv27MSC1Wm2P8euWECkqZp8EyfAL2zWXr4: -0.05000000 Waves 2023.07.12 15:24 [2662676] smart account 3Mv27MSC1Wm2P8euWECkqZp8EyfAL2zWXr4 > SELF 0.00000000 Waves
{ "type": 13, "id": "8XGNQH7eWoc3gVeP6sQJFmu11bkNvVSHcACBYLbY97oY", "fee": 5000000, "feeAssetId": null, "timestamp": 1689164703483, "version": 2, "chainId": 84, "sender": "3Mv27MSC1Wm2P8euWECkqZp8EyfAL2zWXr4", "senderPublicKey": "GRxkJuBBYQZZbJnRT56xcdHdLiLLYK7Qtp8cLrX7s2V7", "proofs": [ "ptVgYUnBJYMYMjoNCwGJKoSuoAk5fLvqLRn6xki3DGNuWoLu1uX7zusvgjizSZL1hvyuBFCigmnMspdVSLkvjY2" ], "script": "base64:BgLcBwgCEgMKAQgSBQoDCAgIEgMKAQgSACIDU0VQIglQUkVDSVNJT04iFERFRkFVTFRfTUFYX1NMSVBQQUdFIgRtdWxwIgJfeCICX3kiBGpvaW4iAmFyIg5rZXlJbml0aWFsaXplZCIVa2V5Q29vcmRpbmF0b3JBZGRyZXNzIhJrZXlWZXJpZmllckFkZHJlc3MiFWtleUVhc3RTdGFraW5nQWRkcmVzcyISa2V5U3VidmF1bHRBZGRyZXNzIgxrZXlFYXN0QXNzZXQiDmtleU1heFNsaXBwYWdlIglrZXlTaWduZWQiCF9hZGRyZXNzIgVfdHhJZCINaXNJbml0aWFsaXplZCIPbXVzdEluaXRpYWxpemVkIhJtdXN0Tm90SW5pdGlhbGl6ZWQiCG11c3RTZWxmIgFpIgtjb29yZGluYXRvciIIdmVyaWZpZXIiByRtYXRjaDAiAXMiCmdldEFkZHJlc3MiA2tleSIDZXJyIhVnZXRFYXN0U3Rha2luZ0FkZHJlc3MiDmdldE1heFNsaXBwYWdlIg9nZXRFYXN0QXNzZXRTdHIiDGdldEVhc3RBc3NldCIMY2hlY2tBZGR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AIFAmFzBQJhcwQCYUEJAGQCCQEBUQAFAmFzBAJhQgkBD0F0dGFjaGVkUGF5bWVudAIJAQFIAAUCYXMEAmFDCQD8BwQJAQFFAAIRYWRkU3Rha2luZ1Jld2FyZHMFA25pbAkAzAgCBQJhQgUDbmlsAwkAAAIFAmFDBQJhQwkAzAgCCQEMSW50ZWdlckVudHJ5AgkBAVAABQJhQQUDbmlsCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAQJhRAECYUUABAF6CQEBeQADCQABAgUBegIGU3RyaW5nBAFKBQF6CQELdmFsdWVPckVsc2UCCQCbCAIJARFAZXh0ck5hdGl2ZSgxMDYyKQEFAUoJAQFwAgkApQgBBQR0aGlzCQDYBAEIBQJhRAJpZAcJAPQDAwgFAmFECWJvZHlCeXRlcwkAkQMCCAUCYUQGcHJvb2ZzAAAIBQJhRA9zZW5kZXJQdWJsaWNLZXkmJ+z7", "height": 2662676, "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 getTotalRewardCollected () = valueOrElse(getInteger(keyTotalRewardCollected()), 0) | |
110 | + | ||
111 | + | ||
112 | + | func getAssets () = split(valueOrErrorMessage(getString(keyAssets()), "No assets configured."), SEP) | |
113 | + | ||
114 | + | ||
115 | + | func getAssetsValue () = split(valueOrElse(getString(keyAssets()), ""), SEP) | |
116 | + | ||
117 | + | ||
118 | + | func getAsset (_assetStr) = { | |
119 | + | let config = split(valueOrErrorMessage(getString(keyAsset(_assetStr)), "Asset config not found."), SEP) | |
120 | + | let staker = addressFromStringValue(config[IdxStakerAddress]) | |
121 | + | let exchange = addressFromStringValue(config[IdxExchangeAddress]) | |
122 | + | $Tuple2(staker, exchange) | |
123 | + | } | |
124 | + | ||
125 | + | ||
126 | + | @Callable(i) | |
127 | + | func initialize (_coordinatorAddress) = { | |
128 | + | let checks = [mustSelf(i), mustNotInitialized(), checkAddress(_coordinatorAddress)] | |
129 | + | if ((checks == checks)) | |
130 | + | then [StringEntry(keyCoordinatorAddress(), _coordinatorAddress), BooleanEntry(keyInitialized(), true)] | |
131 | + | else throw("Strict value is not equal to itself.") | |
132 | + | } | |
133 | + | ||
134 | + | ||
135 | + | ||
136 | + | @Callable(i) | |
137 | + | func addAsset (_assetStr,_stakerAddress,_exchangeAddress) = { | |
138 | + | let checks = [mustInitialized(), mustSelf(i)] | |
139 | + | if ((checks == checks)) | |
140 | + | then { | |
141 | + | let assets = getAssetsValue() | |
142 | + | if (containsElement(assets, _assetStr)) | |
143 | + | then throw("Asset already exists.") | |
144 | + | else { | |
145 | + | let newAssets = makeString((assets :+ _assetStr), SEP) | |
146 | + | [StringEntry(keyAssets(), newAssets), StringEntry(keyAsset(_assetStr), makeString((assets :+ _assetStr), SEP))] | |
147 | + | } | |
148 | + | } | |
149 | + | else throw("Strict value is not equal to itself.") | |
150 | + | } | |
151 | + | ||
152 | + | ||
153 | + | ||
154 | + | @Callable(i) | |
155 | + | func removeAsset (_assetStr) = { | |
156 | + | let checks = [mustInitialized(), mustSelf(i)] | |
157 | + | if ((checks == checks)) | |
158 | + | then { | |
159 | + | let assets = getAssets() | |
160 | + | let newAssets = match indexOf(assets, _assetStr) { | |
161 | + | case idx: Int => | |
162 | + | makeString(removeByIndex(assets, idx), SEP) | |
163 | + | case _: Unit => | |
164 | + | throw("Unable to proceed. Asset not found.") | |
165 | + | case _ => | |
166 | + | throw("Match error") | |
167 | + | } | |
168 | + | [StringEntry(keyAssets(), newAssets), DeleteEntry(keyAsset(_assetStr))] | |
169 | + | } | |
170 | + | else throw("Strict value is not equal to itself.") | |
171 | + | } | |
172 | + | ||
173 | + | ||
174 | + | ||
175 | + | @Callable(i) | |
176 | + | func ackRewards () = { | |
177 | + | func claimAndExchange (acc,next) = match next { | |
178 | + | case assetStr: String => | |
179 | + | let $t01353013596 = getAsset(assetStr) | |
180 | + | let staker = $t01353013596._1 | |
181 | + | let exchange = $t01353013596._2 | |
182 | + | let profit = { | |
183 | + | let @ = invoke(staker, "claimProfit", nil, nil) | |
184 | + | if ($isInstanceOf(@, "Int")) | |
185 | + | then @ | |
186 | + | else throw(($getType(@) + " couldn't be cast to Int")) | |
187 | + | } | |
188 | + | if ((profit == profit)) | |
189 | + | then { | |
190 | + | let subvault = addressFromStringValue(valueOrErrorMessage(getString(staker, keySubvaultAddress()), "Subvault not found.")) | |
191 | + | let assetRate = { | |
192 | + | let @ = invoke(subvault, "getCurrentUsdPrice", nil, nil) | |
193 | + | if ($isInstanceOf(@, "Int")) | |
194 | + | then @ | |
195 | + | else throw(($getType(@) + " couldn't be cast to Int")) | |
196 | + | } | |
197 | + | if ((assetRate == assetRate)) | |
198 | + | then { | |
199 | + | let usdEq = mulp(profit, assetRate) | |
200 | + | let slippage = getMaxSlippage() | |
201 | + | let minEastAmount = mulp(usdEq, slippage) | |
202 | + | let asset = if ((assetStr == "WAVES")) | |
203 | + | then unit | |
204 | + | else fromBase58String(assetStr) | |
205 | + | let exchangedAmount = { | |
206 | + | let @ = invoke(exchange, "swap", [minEastAmount, getEastAssetStr(), toString(this)], [AttachedPayment(asset, profit)]) | |
207 | + | if ($isInstanceOf(@, "Int")) | |
208 | + | then @ | |
209 | + | else throw(($getType(@) + " couldn't be cast to Int")) | |
210 | + | } | |
211 | + | if ((exchangedAmount == exchangedAmount)) | |
212 | + | then (acc + exchangedAmount) | |
213 | + | else throw("Strict value is not equal to itself.") | |
214 | + | } | |
215 | + | else throw("Strict value is not equal to itself.") | |
216 | + | } | |
217 | + | else throw("Strict value is not equal to itself.") | |
218 | + | case _: Unit => | |
219 | + | acc | |
220 | + | case _ => | |
221 | + | throw("Match error") | |
222 | + | } | |
223 | + | ||
224 | + | let assets = getAssets() | |
225 | + | let rewardAmount = { | |
226 | + | let $l = assets | |
227 | + | let $s = size($l) | |
228 | + | let $acc0 = 0 | |
229 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
230 | + | then $a | |
231 | + | else claimAndExchange($a, $l[$i]) | |
232 | + | ||
233 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
234 | + | then $a | |
235 | + | else throw("List size exceeds 10") | |
236 | + | ||
237 | + | $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) | |
238 | + | } | |
239 | + | if ((rewardAmount == rewardAmount)) | |
240 | + | then { | |
241 | + | let newTotalRewardCollected = (getTotalRewardCollected() + rewardAmount) | |
242 | + | let eastPayment = AttachedPayment(getEastAsset(), rewardAmount) | |
243 | + | let doAddEastReward = invoke(getEastStakingAddress(), "addStakingRewards", nil, [eastPayment]) | |
244 | + | if ((doAddEastReward == doAddEastReward)) | |
245 | + | then [IntegerEntry(keyTotalRewardCollected(), newTotalRewardCollected)] | |
246 | + | else throw("Strict value is not equal to itself.") | |
247 | + | } | |
248 | + | else throw("Strict value is not equal to itself.") | |
249 | + | } | |
250 | + | ||
251 | + | ||
252 | + | @Verifier(tx) | |
253 | + | func verify () = match verifier() { | |
254 | + | case address: String => | |
255 | + | valueOrElse(getBoolean(addressFromStringValue(address), keySigned(toString(this), toBase58String(tx.id))), false) | |
256 | + | case _ => | |
257 | + | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
258 | + | } | |
259 | + |
github/deemru/w8io/026f985 109.32 ms ◑