tx · 6yGwMDsuKTzZDMHpc4DapLN2xUeCR4mgz59sDr2uCVja 3Mown6tyCBRFAXSRwAzUpW1YR9L61mM7FFu: -0.01400000 Waves 2022.11.23 17:20 [2329859] smart account 3Mown6tyCBRFAXSRwAzUpW1YR9L61mM7FFu > SELF 0.00000000 Waves
{ "type": 13, "id": "6yGwMDsuKTzZDMHpc4DapLN2xUeCR4mgz59sDr2uCVja", "fee": 1400000, "feeAssetId": null, "timestamp": 1669213255561, "version": 2, "chainId": 84, "sender": "3Mown6tyCBRFAXSRwAzUpW1YR9L61mM7FFu", "senderPublicKey": "4oWUXkTfb3sTD75A8rRUWDDqjhEKp8wdoJ6AQgGZ6pnD", "proofs": [ "4oeiBMuFkghXpvGuihJGcoCjpoRQVgFou7cYAkKWX2BhSTDz9JcbC27kok5qZsLx3rrbBVVPxZt2hT6QH4CzqF78" ], "script": "base64:BgIsCAISBgoECAgIARIAEgMKAQESABIDCgEIEgMKAQgSAwoBCBIDCgEIEgMKAQEZAAlTRVBBUkFUT1ICAl9fAAhLRVlfSU5JVAIESU5JVAAMS0VZX01VTFRJU0lHAghNVUxUSVNJRwAKS0VZX1NUQVRVUwIGU1RBVFVTAApLRVlfVEFSR0VUAgZUQVJHRVQAC0tFWV9BREFQVEVFAgdBREFQVEVFAAtLRVlfTUFOQUdFUgIHTUFOQUdFUgAMS0VZX0ZFRV9SQVRFAghGRUVfUkFURQAOS0VZX0xBU1RfQ0xBSU0CCkxBU1RfQ0xBSU0ADEtFWV9MRUFTRV9JRAIITEVBU0VfSUQAEEtFWV9MRUFTRV9BTU9VTlQCDExFQVNFX0FNT1VOVAAKRlVOQ19DTEFJTQIFY2xhaW0ACklOVk9LRV9GRUUAoMIeAAxDT01QRU5TQVRJT04FCklOVk9LRV9GRUUADkNMQUlNX0lOVEVSVkFMAKALAA5QRVJDRU5UX0ZBQ1RPUgCQTgEQX3ZhbGlkYXRlQWRkcmVzcwEIYWRkcmVzc18EByRtYXRjaDAJAKYIAQUIYWR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Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let SEPARATOR = "__" | |
5 | + | ||
6 | + | let KEY_INIT = "INIT" | |
7 | + | ||
8 | + | let KEY_MULTISIG = "MULTISIG" | |
9 | + | ||
10 | + | let KEY_STATUS = "STATUS" | |
11 | + | ||
12 | + | let KEY_TARGET = "TARGET" | |
13 | + | ||
14 | + | let KEY_ADAPTEE = "ADAPTEE" | |
15 | + | ||
16 | + | let KEY_MANAGER = "MANAGER" | |
17 | + | ||
18 | + | let KEY_FEE_RATE = "FEE_RATE" | |
19 | + | ||
20 | + | let KEY_LAST_CLAIM = "LAST_CLAIM" | |
21 | + | ||
22 | + | let KEY_LEASE_ID = "LEASE_ID" | |
23 | + | ||
24 | + | let KEY_LEASE_AMOUNT = "LEASE_AMOUNT" | |
25 | + | ||
26 | + | let FUNC_CLAIM = "claim" | |
27 | + | ||
28 | + | let INVOKE_FEE = 500000 | |
29 | + | ||
30 | + | let COMPENSATION = INVOKE_FEE | |
31 | + | ||
32 | + | let CLAIM_INTERVAL = 1440 | |
33 | + | ||
34 | + | let PERCENT_FACTOR = 10000 | |
35 | + | ||
36 | + | func _validateAddress (address_) = match addressFromString(address_) { | |
37 | + | case a: Address => | |
38 | + | true | |
39 | + | case _ => | |
40 | + | false | |
41 | + | } | |
42 | + | ||
43 | + | ||
44 | + | func _loadTarget () = match getString(KEY_TARGET) { | |
45 | + | case a: String => | |
46 | + | addressFromStringValue(a) | |
47 | + | case _ => | |
48 | + | throw("_loadTarget: no target address") | |
49 | + | } | |
50 | + | ||
51 | + | ||
52 | + | func _loadAdaptee () = match getString(KEY_ADAPTEE) { | |
53 | + | case a: String => | |
54 | + | addressFromStringValue(a) | |
55 | + | case _ => | |
56 | + | throw("_loadAdaptee: no adaptee address") | |
57 | + | } | |
58 | + | ||
59 | + | ||
60 | + | func _loadManager () = match getString(KEY_MANAGER) { | |
61 | + | case a: String => | |
62 | + | addressFromStringValue(a) | |
63 | + | case _ => | |
64 | + | throw("_loadManager: no manager address") | |
65 | + | } | |
66 | + | ||
67 | + | ||
68 | + | func _loadFeeRate () = match getInteger(KEY_FEE_RATE) { | |
69 | + | case a: Int => | |
70 | + | a | |
71 | + | case _ => | |
72 | + | throw("_loadFeeRate: no fee rate") | |
73 | + | } | |
74 | + | ||
75 | + | ||
76 | + | func _loadLastClaim () = match getInteger(KEY_LAST_CLAIM) { | |
77 | + | case a: Int => | |
78 | + | a | |
79 | + | case _ => | |
80 | + | throw("_loadLastClaim: no last claim") | |
81 | + | } | |
82 | + | ||
83 | + | ||
84 | + | func _loadInt (key_,default_) = match getInteger(key_) { | |
85 | + | case a: Int => | |
86 | + | a | |
87 | + | case _ => | |
88 | + | default_ | |
89 | + | } | |
90 | + | ||
91 | + | ||
92 | + | func _updateLeasing (amount_,leaseNode_) = { | |
93 | + | let leaseId = getBinary(KEY_LEASE_ID) | |
94 | + | let leaseAmount = _loadInt(KEY_LEASE_AMOUNT, 0) | |
95 | + | let newLeaseAmount = (leaseAmount + amount_) | |
96 | + | let unleaseOrEmpty = if (isDefined(leaseId)) | |
97 | + | then [LeaseCancel(value(leaseId))] | |
98 | + | else nil | |
99 | + | let leaseActions = if ((newLeaseAmount > 0)) | |
100 | + | then { | |
101 | + | let lease = Lease(leaseNode_, newLeaseAmount) | |
102 | + | [lease, BinaryEntry(KEY_LEASE_ID, calculateLeaseId(lease)), IntegerEntry(KEY_LEASE_AMOUNT, newLeaseAmount)] | |
103 | + | } | |
104 | + | else [DeleteEntry(KEY_LEASE_ID), IntegerEntry(KEY_LEASE_AMOUNT, 0)] | |
105 | + | (unleaseOrEmpty ++ leaseActions) | |
106 | + | } | |
107 | + | ||
108 | + | ||
109 | + | func _claimableReward () = { | |
110 | + | let lastClaim = _loadLastClaim() | |
111 | + | let leaseNode = _loadAdaptee() | |
112 | + | let claimAmount = wavesBalance(leaseNode).regular | |
113 | + | let feeRate = _loadFeeRate() | |
114 | + | let fee = fraction(claimAmount, feeRate, PERCENT_FACTOR) | |
115 | + | let rewardAmount = (claimAmount - fee) | |
116 | + | if ((COMPENSATION >= rewardAmount)) | |
117 | + | then $Tuple4(false, 0, 0, 0) | |
118 | + | else if (((lastClaim + CLAIM_INTERVAL) > height)) | |
119 | + | then $Tuple4(false, 0, 0, 0) | |
120 | + | else { | |
121 | + | let invocation = invoke(leaseNode, FUNC_CLAIM, [claimAmount], nil) | |
122 | + | if ((invocation == invocation)) | |
123 | + | then $Tuple4(true, (rewardAmount - COMPENSATION), COMPENSATION, fee) | |
124 | + | else throw("Strict value is not equal to itself.") | |
125 | + | } | |
126 | + | } | |
127 | + | ||
128 | + | ||
129 | + | @Callable(i) | |
130 | + | func init (target_,adaptee_,manager_,feeRate_) = { | |
131 | + | let multisig = valueOrErrorMessage(getString(KEY_MULTISIG), "init: no multisig set") | |
132 | + | let init = valueOrElse(getBoolean(KEY_INIT), false) | |
133 | + | let err = if ((i.caller != this)) | |
134 | + | then throw("init: permission denied") | |
135 | + | else if (init) | |
136 | + | then throw("init: already initialized") | |
137 | + | else if (!(_validateAddress(target_))) | |
138 | + | then throw("init: invalid target address") | |
139 | + | else if (!(_validateAddress(adaptee_))) | |
140 | + | then throw("init: invalid adaptee address") | |
141 | + | else if (!(_validateAddress(manager_))) | |
142 | + | then throw("init: invalid manager address") | |
143 | + | else if (if ((0 > feeRate_)) | |
144 | + | then true | |
145 | + | else (feeRate_ > PERCENT_FACTOR)) | |
146 | + | then throw("init: invalid fee rate") | |
147 | + | else unit | |
148 | + | if ((err == err)) | |
149 | + | then $Tuple2([BooleanEntry(KEY_INIT, true), StringEntry(KEY_TARGET, target_), StringEntry(KEY_ADAPTEE, adaptee_), StringEntry(KEY_MANAGER, manager_), IntegerEntry(KEY_FEE_RATE, feeRate_), IntegerEntry(KEY_LAST_CLAIM, height)], unit) | |
150 | + | else throw("Strict value is not equal to itself.") | |
151 | + | } | |
152 | + | ||
153 | + | ||
154 | + | ||
155 | + | @Callable(i) | |
156 | + | func stake () = { | |
157 | + | let err = if ((i.caller != _loadTarget())) | |
158 | + | then throw("stake: permission denied") | |
159 | + | else if ((size(i.payments) != 1)) | |
160 | + | then throw("stake: no payments") | |
161 | + | else if ((i.payments[0].assetId != unit)) | |
162 | + | then throw("stake: payment is not in waves") | |
163 | + | else if ((0 >= i.payments[0].amount)) | |
164 | + | then throw("stake: invalid payment amount") | |
165 | + | else unit | |
166 | + | if ((err == err)) | |
167 | + | then $Tuple2(_updateLeasing(i.payments[0].amount, _loadAdaptee()), unit) | |
168 | + | else throw("Strict value is not equal to itself.") | |
169 | + | } | |
170 | + | ||
171 | + | ||
172 | + | ||
173 | + | @Callable(i) | |
174 | + | func unstake (amount_) = { | |
175 | + | let err = if ((i.caller != _loadTarget())) | |
176 | + | then throw("unstake: permission denied") | |
177 | + | else if ((0 >= amount_)) | |
178 | + | then throw("unstake: invalid amount") | |
179 | + | else unit | |
180 | + | if ((err == err)) | |
181 | + | then $Tuple2((_updateLeasing((-1 * amount_), _loadAdaptee()) :+ ScriptTransfer(i.caller, amount_, unit)), unit) | |
182 | + | else throw("Strict value is not equal to itself.") | |
183 | + | } | |
184 | + | ||
185 | + | ||
186 | + | ||
187 | + | @Callable(i) | |
188 | + | func claimReward () = { | |
189 | + | let reward = _claimableReward() | |
190 | + | if ((i.caller != _loadTarget())) | |
191 | + | then throw("claimReward: permission denied") | |
192 | + | else if (!(reward._1)) | |
193 | + | then $Tuple2(nil, unit) | |
194 | + | else $Tuple2([ScriptTransfer(i.caller, (reward._2 + reward._3), unit), ScriptTransfer(_loadManager(), reward._4, unit), IntegerEntry(KEY_LAST_CLAIM, height)], $Tuple3(reward._2, reward._3, CLAIM_INTERVAL)) | |
195 | + | } | |
196 | + | ||
197 | + | ||
198 | + | ||
199 | + | @Callable(i) | |
200 | + | func setMultisig (multisig_) = { | |
201 | + | let err = if ((i.caller != this)) | |
202 | + | then throw("setMultisig: permission denied") | |
203 | + | else if (!(_validateAddress(multisig_))) | |
204 | + | then throw("setMultisig: invalid multisig address") | |
205 | + | else unit | |
206 | + | if ((err == err)) | |
207 | + | then $Tuple2([StringEntry(KEY_MULTISIG, multisig_)], unit) | |
208 | + | else throw("Strict value is not equal to itself.") | |
209 | + | } | |
210 | + | ||
211 | + | ||
212 | + | ||
213 | + | @Callable(i) | |
214 | + | func setTarget (target_) = { | |
215 | + | let err = if ((i.caller != this)) | |
216 | + | then throw("setTarget: permission denied") | |
217 | + | else if (!(_validateAddress(target_))) | |
218 | + | then throw("setTarget: invalid target address") | |
219 | + | else unit | |
220 | + | if ((err == err)) | |
221 | + | then $Tuple2([StringEntry(KEY_TARGET, target_)], unit) | |
222 | + | else throw("Strict value is not equal to itself.") | |
223 | + | } | |
224 | + | ||
225 | + | ||
226 | + | ||
227 | + | @Callable(i) | |
228 | + | func setAdaptee (adaptee_) = { | |
229 | + | let err = if ((i.caller != this)) | |
230 | + | then throw("setAdaptee: permission denied") | |
231 | + | else if (!(_validateAddress(adaptee_))) | |
232 | + | then throw("setAdaptee: invalid target address") | |
233 | + | else unit | |
234 | + | if ((err == err)) | |
235 | + | then $Tuple2([StringEntry(KEY_ADAPTEE, adaptee_)], unit) | |
236 | + | else throw("Strict value is not equal to itself.") | |
237 | + | } | |
238 | + | ||
239 | + | ||
240 | + | ||
241 | + | @Callable(i) | |
242 | + | func setManager (manager_) = { | |
243 | + | let err = if ((i.caller != this)) | |
244 | + | then throw("setManager: permission denied") | |
245 | + | else if (!(_validateAddress(manager_))) | |
246 | + | then throw("setManager: invalid target address") | |
247 | + | else unit | |
248 | + | if ((err == err)) | |
249 | + | then $Tuple2([StringEntry(KEY_MANAGER, manager_)], unit) | |
250 | + | else throw("Strict value is not equal to itself.") | |
251 | + | } | |
252 | + | ||
253 | + | ||
254 | + | ||
255 | + | @Callable(i) | |
256 | + | func setFeeRate (feeRate_) = { | |
257 | + | let err = if ((i.caller != this)) | |
258 | + | then throw("setFeeRate: permission denied") | |
259 | + | else if (if ((0 > feeRate_)) | |
260 | + | then true | |
261 | + | else (feeRate_ > PERCENT_FACTOR)) | |
262 | + | then throw("setFeeRate: invalid infrastructure fee") | |
263 | + | else unit | |
264 | + | if ((err == err)) | |
265 | + | then $Tuple2([IntegerEntry(KEY_FEE_RATE, feeRate_)], unit) | |
266 | + | else throw("Strict value is not equal to itself.") | |
267 | + | } | |
268 | + | ||
269 | + | ||
270 | + | @Verifier(tx) | |
271 | + | func verify () = match getString(KEY_MULTISIG) { | |
272 | + | case multisig: String => | |
273 | + | valueOrElse(getBoolean(addressFromStringValue(multisig), makeString([KEY_STATUS, toString(this), toBase58String(tx.id)], SEPARATOR)), false) | |
274 | + | case _ => | |
275 | + | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
276 | + | } | |
277 | + |
github/deemru/w8io/026f985 25.45 ms ◑