tx · C4TkiSCDrj7zGdnd2e9keKLpENHTpVLGGrGtVZVsCzU1 3NCnpxCqhjabawE31qekDPPh2R88gEycSyS: -0.01000000 Waves 2022.09.06 17:55 [2217411] smart account 3NCnpxCqhjabawE31qekDPPh2R88gEycSyS > SELF 0.00000000 Waves
{ "type": 13, "id": "C4TkiSCDrj7zGdnd2e9keKLpENHTpVLGGrGtVZVsCzU1", "fee": 1000000, "feeAssetId": null, "timestamp": 1662476136992, "version": 2, "chainId": 84, "sender": "3NCnpxCqhjabawE31qekDPPh2R88gEycSyS", "senderPublicKey": "CCWEUwWp7pZ2qKWbZcFpfKVjCRFGjNfo7jYq6qxDBBD3", "proofs": [ "2N9Q32YV75jMZAUv6kyhQeoqjUFpQj5e1FU36K5zTEr9M1bcmKJQtr3cSUkZu3tiYh2h1TqHrabi3qsGuix9Z1Bi" ], "script": "base64:BgIjCAISABIAEgASAwoBBBIAEgASBAoCAQQSAwoBBBIDCgEIEgAnAAtrZXlNQWNjUEtleQIJbWFzdGVyX3BrAQxnZXRDRkFkZHJlc3MACQERQGV4dHJOYXRpdmUoMTA2MikBCQETdmFsdWVPckVycm9yTWVzc2FnZQIJAJ0IAgUEdGhpcwIKQ0ZfQUREUkVTUwIUQ0ZfQUREUkVTUyBub3QgZm91bmQBDXRyeUdldEJvb2xlYW4BA2tleQQHJG1hdGNoMAkAmwgCBQR0aGlzBQNrZXkDCQABAgUHJG1hdGNoMAIHQm9vbGVhbgQBYgUHJG1hdGNoMAUBYgcACG1BY2NQS2V5CQDZBAEJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAnQgCCQEMZ2V0Q0ZBZGRyZXNzAAULa2V5TUFjY1BLZXkJAKwCAgULa2V5TUFjY1BLZXkCCiBub3QgZm91bmQACG1BY2NBZGRyCQCnCAEFCG1BY2NQS2V5ARFnZXRDb3Vwb25zQWRkcmVzcwAJARFAZXh0ck5hdGl2ZSgxMDYyKQEJARFAZXh0ck5hdGl2ZSgxMDUzKQIFCG1BY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lEOiBDYW4gYmUgY2FsbGVkIG9ubHkgYnkgdGhlIGRhcHAtYWNjb3VudAkBF3NldENGQWRkcmVzc0FuZEluaXRpYXRlAQUHYWRkcmVzcwFpAQtjbGFpbVJld2FyZAADCQEMaXNMaXF1aWRhdGVkAAkAAgECFkNDUjogQ0YgaXMgbGlxdWlkYXRlZCEDCQBmAgkAkAMBCAUBaQhwYXltZW50cwAACQACAQIeQ0NSOiBQbGVhc2UgZG9uJ3QgYWRkIHBheW1lbnRzCQESY2xhaW1TdGFraW5nUmVzdWx0AQgFAWkGY2FsbGVyACF9hkE=", "height": 2217411, "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 keyMAccPKey = "master_pk" | |
5 | + | ||
6 | + | func getCFAddress () = addressFromStringValue(valueOrErrorMessage(getString(this, "CF_ADDRESS"), "CF_ADDRESS not found")) | |
7 | + | ||
8 | + | ||
9 | + | func tryGetBoolean (key) = match getBoolean(this, key) { | |
10 | + | case b: Boolean => | |
11 | + | b | |
12 | + | case _ => | |
13 | + | false | |
14 | + | } | |
15 | + | ||
16 | + | ||
17 | + | let mAccPKey = fromBase58String(valueOrErrorMessage(getString(getCFAddress(), keyMAccPKey), (keyMAccPKey + " not found"))) | |
18 | + | ||
19 | + | let mAccAddr = addressFromPublicKey(mAccPKey) | |
20 | + | ||
21 | + | func getCouponsAddress () = addressFromStringValue(getStringValue(mAccAddr, "COUPONS_ADDRESS")) | |
22 | + | ||
23 | + | ||
24 | + | let keyTotalCompound = "total_compound" | |
25 | + | ||
26 | + | let keyStakedCompound = "staked_compound" | |
27 | + | ||
28 | + | let keyLastVP = "last_virtual_price" | |
29 | + | ||
30 | + | let VPScale = 100000000 | |
31 | + | ||
32 | + | func keyStakedCompoundUser (user) = ((toString(user) + "_") + keyStakedCompound) | |
33 | + | ||
34 | + | ||
35 | + | func calcVirtualPrice (totalStaked,total) = if ((total == 0)) | |
36 | + | then 1 | |
37 | + | else if ((totalStaked == 0)) | |
38 | + | then 1 | |
39 | + | else fraction(total, VPScale, totalStaked) | |
40 | + | ||
41 | + | ||
42 | + | let Scale = 100000000 | |
43 | + | ||
44 | + | func keyStakedAmount (address) = (toString(address) + "_farm_staked") | |
45 | + | ||
46 | + | ||
47 | + | func keyLastCheckInterest (address) = (toString(address) + "_lastCheck_interest") | |
48 | + | ||
49 | + | ||
50 | + | func keyEggClaimed (address) = (toString(address) + "_claimed") | |
51 | + | ||
52 | + | ||
53 | + | let keyGlobalLastInterest = "global_lastCheck_interest" | |
54 | + | ||
55 | + | let keyGlobalStaked = "global_staked" | |
56 | + | ||
57 | + | let keyGlobalEggEarned = "global_earnings" | |
58 | + | ||
59 | + | let kLockedInvestments = "locked_investments" | |
60 | + | ||
61 | + | func isCollectiveFarmLocked () = match getBoolean(getCFAddress(), kLockedInvestments) { | |
62 | + | case b: Boolean => | |
63 | + | b | |
64 | + | case _ => | |
65 | + | false | |
66 | + | } | |
67 | + | ||
68 | + | ||
69 | + | func getEggId () = fromBase58String(getStringValue(mAccAddr, "EGG_ASSET_ID")) | |
70 | + | ||
71 | + | ||
72 | + | func setCFAddressAndInitiate (address) = [StringEntry("CF_ADDRESS", address), IntegerEntry(keyGlobalLastInterest, 1)] | |
73 | + | ||
74 | + | ||
75 | + | func getShareAssetId () = fromBase58String(getStringValue(getCFAddress(), "SHARE_ASSET_ID")) | |
76 | + | ||
77 | + | ||
78 | + | func tryGetIntegerExternal (address,key) = match getInteger(address, key) { | |
79 | + | case b: Int => | |
80 | + | b | |
81 | + | case _ => | |
82 | + | 0 | |
83 | + | } | |
84 | + | ||
85 | + | ||
86 | + | func tryGetInteger (key) = tryGetIntegerExternal(this, key) | |
87 | + | ||
88 | + | ||
89 | + | func tryGetString (key) = match getString(this, key) { | |
90 | + | case a: String => | |
91 | + | a | |
92 | + | case _ => | |
93 | + | "" | |
94 | + | } | |
95 | + | ||
96 | + | ||
97 | + | func getVoteHeightKey () = "VOTE_HEIGHT_START" | |
98 | + | ||
99 | + | ||
100 | + | func getDuration () = if ((tryGetIntegerExternal(mAccAddr, "VOTE_DURATION") == 0)) | |
101 | + | then 10000 | |
102 | + | else tryGetIntegerExternal(mAccAddr, "VOTE_DURATION") | |
103 | + | ||
104 | + | ||
105 | + | func getVoteByUserKey (user,height) = ((("VOTE_" + user) + "_") + height) | |
106 | + | ||
107 | + | ||
108 | + | func getTotalVoteByTypeKey (type,height) = ((("VOTE_TOTAL_" + type) + "_") + height) | |
109 | + | ||
110 | + | ||
111 | + | func getTotalVoteKey (height) = ("VOTE_TOTAL_" + height) | |
112 | + | ||
113 | + | ||
114 | + | func resultVoteKey (height) = ("LIQUIDATED_" + height) | |
115 | + | ||
116 | + | ||
117 | + | func quorumVoteKey (height) = ("QUORUM_" + height) | |
118 | + | ||
119 | + | ||
120 | + | func claimStakingResult (address) = { | |
121 | + | let currentInterest = tryGetInteger(keyGlobalLastInterest) | |
122 | + | let lastCheckInterest = tryGetInteger(keyLastCheckInterest(address)) | |
123 | + | let stakedAmount = tryGetInteger(keyStakedAmount(address)) | |
124 | + | let reward = if ((lastCheckInterest > 0)) | |
125 | + | then fraction((currentInterest - lastCheckInterest), stakedAmount, Scale) | |
126 | + | else 0 | |
127 | + | let transfer = if ((reward > 0)) | |
128 | + | then [ScriptTransfer(address, reward, getEggId())] | |
129 | + | else nil | |
130 | + | (transfer ++ [IntegerEntry(keyLastCheckInterest(address), currentInterest), IntegerEntry(keyEggClaimed(address), (tryGetInteger(keyEggClaimed(address)) + reward))]) | |
131 | + | } | |
132 | + | ||
133 | + | ||
134 | + | func handleStakingTopUp (amount) = { | |
135 | + | let currentInterest = tryGetInteger(keyGlobalLastInterest) | |
136 | + | let totalStakedAmount = tryGetInteger(keyGlobalStaked) | |
137 | + | let interestDelta = if ((totalStakedAmount > 0)) | |
138 | + | then fraction(amount, Scale, totalStakedAmount) | |
139 | + | else 0 | |
140 | + | [IntegerEntry(keyGlobalEggEarned, (tryGetInteger(keyGlobalEggEarned) + amount)), IntegerEntry(keyGlobalLastInterest, (currentInterest + interestDelta))] | |
141 | + | } | |
142 | + | ||
143 | + | ||
144 | + | func addVotePower (caller,h,vote,votePower) = if (if ((h == 0)) | |
145 | + | then true | |
146 | + | else (vote == "")) | |
147 | + | then nil | |
148 | + | else if ((height > (h + getDuration()))) | |
149 | + | then throw((((((((("CAVP: Voting is finished, please finalize the vote;" + " Arguments: ") + caller) + ", ") + toString(h)) + ", ") + vote) + ", ") + toString(votePower))) | |
150 | + | else { | |
151 | + | let voteTotalByType = tryGetInteger(getTotalVoteByTypeKey(vote, toString(h))) | |
152 | + | let totalVote = tryGetInteger(getTotalVoteKey(toString(h))) | |
153 | + | [StringEntry(getVoteByUserKey(caller, toString(h)), vote), IntegerEntry(getTotalVoteByTypeKey(vote, toString(h)), (voteTotalByType + votePower)), IntegerEntry(getTotalVoteKey(toString(h)), (totalVote + votePower))] | |
154 | + | } | |
155 | + | ||
156 | + | ||
157 | + | func adaptVotePowerStake (caller,votePower) = { | |
158 | + | let voteHeight = tryGetInteger(getVoteHeightKey()) | |
159 | + | let voteByUserString = tryGetString(getVoteByUserKey(caller, toString(voteHeight))) | |
160 | + | addVotePower(caller, voteHeight, voteByUserString, votePower) | |
161 | + | } | |
162 | + | ||
163 | + | ||
164 | + | func isLiquidated () = { | |
165 | + | let voteHeight = tryGetInteger(getVoteHeightKey()) | |
166 | + | if ((voteHeight == 0)) | |
167 | + | then false | |
168 | + | else tryGetBoolean(resultVoteKey(toString(voteHeight))) | |
169 | + | } | |
170 | + | ||
171 | + | ||
172 | + | @Callable(i) | |
173 | + | func claimRefundStaked () = if ((isLiquidated() == false)) | |
174 | + | then throw("CCRS: cf not liquidated") | |
175 | + | else { | |
176 | + | let addressStr = toString(i.caller) | |
177 | + | let stakedAmount = tryGetInteger(keyStakedAmount(i.caller)) | |
178 | + | let voteHeight = tryGetInteger(getVoteHeightKey()) | |
179 | + | let voteByUserString = tryGetString(getVoteByUserKey(addressStr, toString(voteHeight))) | |
180 | + | let multiplier = if ((voteByUserString == "")) | |
181 | + | then 7 | |
182 | + | else 10 | |
183 | + | let refund = ((stakedAmount / 10) * multiplier) | |
184 | + | let couponsCall = invoke(getCouponsAddress(), "CFRefund", [addressStr, refund], nil) | |
185 | + | if ((couponsCall == couponsCall)) | |
186 | + | then [IntegerEntry(keyStakedAmount(i.caller), 0), Burn(getShareAssetId(), stakedAmount)] | |
187 | + | else throw("Strict value is not equal to itself.") | |
188 | + | } | |
189 | + | ||
190 | + | ||
191 | + | ||
192 | + | @Callable(i) | |
193 | + | func claimRefundUnstaked () = if ((isLiquidated() == false)) | |
194 | + | then throw("CCRU: cf not liquidated") | |
195 | + | else { | |
196 | + | let shareTokenId = getShareAssetId() | |
197 | + | if ((size(i.payments) > 1)) | |
198 | + | then throw("CSFT: To many payments added") | |
199 | + | else if ((i.payments[0].assetId != shareTokenId)) | |
200 | + | then throw("CSFT: Wrong assetId") | |
201 | + | else { | |
202 | + | let amount = i.payments[0].amount | |
203 | + | if ((amount == 0)) | |
204 | + | then throw("CSFT: Please attach positive asset amount!") | |
205 | + | else { | |
206 | + | let addressStr = toString(i.caller) | |
207 | + | let multiplier = 7 | |
208 | + | let refund = ((amount / 10) * multiplier) | |
209 | + | let couponsCall = invoke(getCouponsAddress(), "CFRefund", [addressStr, refund], nil) | |
210 | + | if ((couponsCall == couponsCall)) | |
211 | + | then [Burn(getShareAssetId(), amount)] | |
212 | + | else throw("Strict value is not equal to itself.") | |
213 | + | } | |
214 | + | } | |
215 | + | } | |
216 | + | ||
217 | + | ||
218 | + | ||
219 | + | @Callable(i) | |
220 | + | func startVote () = if ((i.caller != mAccAddr)) | |
221 | + | then throw("CSV: Only the admin can start a liquidation vote for now!") | |
222 | + | else if ((tryGetInteger(getVoteHeightKey()) != 0)) | |
223 | + | then throw("CSV: There is already a vote running!") | |
224 | + | else [IntegerEntry("VOTE_HEIGHT_START", height)] | |
225 | + | ||
226 | + | ||
227 | + | ||
228 | + | @Callable(i) | |
229 | + | func voteToLiquidate (vote) = { | |
230 | + | let votePower = tryGetInteger(keyStakedAmount(i.caller)) | |
231 | + | if ((votePower == 0)) | |
232 | + | then throw("CVTL: Please stake some tokens before you can vote!") | |
233 | + | else { | |
234 | + | let voteAsString = toString(vote) | |
235 | + | let voteHeight = tryGetInteger(getVoteHeightKey()) | |
236 | + | if ((height > (voteHeight + getDuration()))) | |
237 | + | then throw("CVTL: Voting is finished, please finalize the vote!") | |
238 | + | else { | |
239 | + | let voteByUserString = tryGetString(getVoteByUserKey(toString(i.caller), toString(voteHeight))) | |
240 | + | if ((voteByUserString != "")) | |
241 | + | then throw("CVTL: You can not change your vote!") | |
242 | + | else addVotePower(toString(i.caller), voteHeight, voteAsString, votePower) | |
243 | + | } | |
244 | + | } | |
245 | + | } | |
246 | + | ||
247 | + | ||
248 | + | ||
249 | + | @Callable(i) | |
250 | + | func finalizeVote () = { | |
251 | + | let voteHeight = tryGetInteger(getVoteHeightKey()) | |
252 | + | if (((voteHeight + getDuration()) > height)) | |
253 | + | then throw("CFV: Voting is not finished!") | |
254 | + | else { | |
255 | + | let shareAssetIdTotal = value(assetInfo(getShareAssetId())).quantity | |
256 | + | let totalStakedAmount = tryGetInteger(keyGlobalStaked) | |
257 | + | let totalVote = tryGetInteger(getTotalVoteKey(toString(voteHeight))) | |
258 | + | let quorum = (totalVote / (shareAssetIdTotal / 100)) | |
259 | + | let voteTotalByYes = tryGetInteger(getTotalVoteByTypeKey("true", toString(voteHeight))) | |
260 | + | let voteTotalByNo = tryGetInteger(getTotalVoteByTypeKey("false", toString(voteHeight))) | |
261 | + | let liquidated = if ((20 > quorum)) | |
262 | + | then true | |
263 | + | else if ((voteTotalByYes > voteTotalByNo)) | |
264 | + | then true | |
265 | + | else false | |
266 | + | let resetKey = if (liquidated) | |
267 | + | then nil | |
268 | + | else [IntegerEntry(getVoteHeightKey(), 0)] | |
269 | + | ([IntegerEntry(quorumVoteKey(toString(voteHeight)), quorum), BooleanEntry(resultVoteKey(toString(voteHeight)), liquidated)] ++ resetKey) | |
270 | + | } | |
271 | + | } | |
272 | + | ||
273 | + | ||
274 | + | ||
275 | + | @Callable(i) | |
276 | + | func topUpReward () = if (isLiquidated()) | |
277 | + | then throw("CTUR: CF is liquidated!") | |
278 | + | else { | |
279 | + | let eggAssetId = getEggId() | |
280 | + | if ((i.payments[0].assetId != eggAssetId)) | |
281 | + | then throw("CTUP: Wrong assetId, payment should be EGG") | |
282 | + | else { | |
283 | + | let resHandleStaking = handleStakingTopUp(i.payments[0].amount) | |
284 | + | $Tuple2(resHandleStaking, true) | |
285 | + | } | |
286 | + | } | |
287 | + | ||
288 | + | ||
289 | + | ||
290 | + | @Callable(i) | |
291 | + | func withdrawFarmTokens (amount,compound) = if (isLiquidated()) | |
292 | + | then throw("CTUR: CF is liquidated!") | |
293 | + | else if ((size(i.payments) > 0)) | |
294 | + | then throw("CWFT: Please don't add payments") | |
295 | + | else { | |
296 | + | let shareTokenId = getShareAssetId() | |
297 | + | if (compound) | |
298 | + | then { | |
299 | + | let staked = tryGetInteger(keyStakedCompound) | |
300 | + | let total = tryGetInteger(keyTotalCompound) | |
301 | + | let vp = calcVirtualPrice(staked, total) | |
302 | + | let keyStakedCompoundU = keyStakedCompoundUser(i.caller) | |
303 | + | let personalStaked = tryGetInteger(keyStakedCompoundU) | |
304 | + | let virtualWd = if ((amount == -1)) | |
305 | + | then personalStaked | |
306 | + | else fraction(amount, VPScale, vp) | |
307 | + | let amountWd = if ((amount == -1)) | |
308 | + | then fraction(virtualWd, vp, VPScale) | |
309 | + | else amount | |
310 | + | if ((virtualWd > personalStaked)) | |
311 | + | then throw("CWFT: You don't have so much funds to withdraw") | |
312 | + | else [IntegerEntry(keyStakedCompoundU, (personalStaked - virtualWd)), IntegerEntry(keyStakedCompound, (staked - virtualWd)), IntegerEntry(keyTotalCompound, (total - amountWd)), ScriptTransfer(i.caller, amountWd, shareTokenId), IntegerEntry(keyLastVP, vp), IntegerEntry("last_virt_compound_wd", virtualWd), IntegerEntry("last_amount_compound_wd", amountWd)] | |
313 | + | } | |
314 | + | else { | |
315 | + | let addressStr = toString(i.caller) | |
316 | + | let stakedAmount = tryGetInteger(keyStakedAmount(i.caller)) | |
317 | + | let wdAmount = if ((amount == -1)) | |
318 | + | then stakedAmount | |
319 | + | else amount | |
320 | + | if ((wdAmount > stakedAmount)) | |
321 | + | then throw("CWFT: you don't have tokens available") | |
322 | + | else { | |
323 | + | let votePower = adaptVotePowerStake(toString(i.caller), -(wdAmount)) | |
324 | + | ((claimStakingResult(i.caller) ++ [IntegerEntry(keyStakedAmount(i.caller), (stakedAmount - wdAmount)), IntegerEntry(keyGlobalStaked, (tryGetInteger(keyGlobalStaked) - wdAmount)), ScriptTransfer(i.caller, wdAmount, shareTokenId), IntegerEntry("last_staking_wd", wdAmount)]) ++ votePower) | |
325 | + | } | |
326 | + | } | |
327 | + | } | |
328 | + | ||
329 | + | ||
330 | + | ||
331 | + | @Callable(i) | |
332 | + | func stakeFarmTokens (compound) = if (isLiquidated()) | |
333 | + | then throw("CSFT: CF is liquidated!") | |
334 | + | else { | |
335 | + | let shareTokenId = getShareAssetId() | |
336 | + | if ((size(i.payments) > 1)) | |
337 | + | then throw("CSFT: Too many payments added") | |
338 | + | else if ((i.payments[0].assetId != shareTokenId)) | |
339 | + | then throw("CSFT: Wrong assetId") | |
340 | + | else { | |
341 | + | let amount = i.payments[0].amount | |
342 | + | if ((amount == 0)) | |
343 | + | then throw("CSFT: Please attach positive asset amount!") | |
344 | + | else if (compound) | |
345 | + | then throw("CSFT: Compound was disabled!") | |
346 | + | else { | |
347 | + | let addressStr = toString(i.caller) | |
348 | + | let totalStakedAmount = tryGetInteger(keyGlobalStaked) | |
349 | + | if ((i.payments[0].assetId != shareTokenId)) | |
350 | + | then throw("CSFT: wrong asset attached") | |
351 | + | else { | |
352 | + | let votePower = adaptVotePowerStake(toString(i.caller), amount) | |
353 | + | ((claimStakingResult(i.caller) ++ [IntegerEntry(keyGlobalStaked, (totalStakedAmount + amount)), IntegerEntry(keyStakedAmount(i.caller), (tryGetInteger(keyStakedAmount(i.caller)) + amount))]) ++ votePower) | |
354 | + | } | |
355 | + | } | |
356 | + | } | |
357 | + | } | |
358 | + | ||
359 | + | ||
360 | + | ||
361 | + | @Callable(i) | |
362 | + | func initiateDapp (address) = if (isLiquidated()) | |
363 | + | then throw("CID: CF is liquidated!") | |
364 | + | else if ((i.caller != this)) | |
365 | + | then throw("CID: Can be called only by the dapp-account") | |
366 | + | else setCFAddressAndInitiate(address) | |
367 | + | ||
368 | + | ||
369 | + | ||
370 | + | @Callable(i) | |
371 | + | func claimReward () = if (isLiquidated()) | |
372 | + | then throw("CCR: CF is liquidated!") | |
373 | + | else if ((size(i.payments) > 0)) | |
374 | + | then throw("CCR: Please don't add payments") | |
375 | + | else claimStakingResult(i.caller) | |
376 | + | ||
377 | + |
github/deemru/w8io/026f985 40.58 ms ◑