tx · J83PeMgQWozZ9YvULLGmMJSssvSo4aSSFy78pDBGMQy7 3MpEpLJMg8Vahe61vXsBvj2cQo9oJDmcs7n: -0.01000000 Waves 2022.09.06 15:52 [2217284] smart account 3MpEpLJMg8Vahe61vXsBvj2cQo9oJDmcs7n > SELF 0.00000000 Waves
{ "type": 13, "id": "J83PeMgQWozZ9YvULLGmMJSssvSo4aSSFy78pDBGMQy7", "fee": 1000000, "feeAssetId": null, "timestamp": 1662468770277, "version": 2, "chainId": 84, "sender": "3MpEpLJMg8Vahe61vXsBvj2cQo9oJDmcs7n", "senderPublicKey": "2cdzciichBZFXYvcrwDcTszr7UemgafUcSMaHQW8h6Wo", "proofs": [ "2wyZifHT16NgEdRNf9aGshKP7iJD1CVaMLsktDXcd5XQkSKN8GA5tRUnfMKcdK6AL7UoHhxuQeoU388qff9RsP86" ], "script": "base64:BgIjCAISABIAEgASAwoBBBIAEgASBAoCAQQSAwoBBBIDCgEIEgAnAAtrZXlNQWNjUEtleQIJbWFzdGVyX3BrAQxnZXRDRkFkZHJlc3MACQERQGV4dHJOYXRpdmUoMTA2MikBCQETdmFsdWVPckVycm9yTWVzc2FnZQIJAJ0IAgUEdGhpcwIKQ0ZfQUREUkVTUwIUQ0ZfQUREUkVTUyBub3QgZm91bmQBDXRyeUdldEJvb2xlYW4BA2tleQQHJG1hdGNoMAkAmwgCBQR0aGlzBQNrZXkDCQABAgUHJG1hdGNoMAIHQm9vbGVhbgQBYgUHJG1hdGNoMAUBYgcACG1BY2NQS2V5CQDZBAEJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAnQgCCQEMZ2V0Q0ZBZGRyZXNzAAULa2V5TUFjY1BLZXkJAKwCAgULa2V5TUFjY1BLZXkCCiBub3QgZm91bmQACG1BY2NBZGRyCQCnCAEFCG1BY2NQS2V5ARFnZXRDb3Vwb25zQWRkcmVzcwAJARFAZXh0ck5hdGl2ZSgxMDYyKQEJARFAZXh0ck5hdGl2ZSgxMDUzKQIFCG1BY2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dGVkAAkAAgECFkNDUjogQ0YgaXMgbGlxdWlkYXRlZCEDCQBmAgkAkAMBCAUBaQhwYXltZW50cwAACQACAQIeQ0NSOiBQbGVhc2UgZG9uJ3QgYWRkIHBheW1lbnRzCQESY2xhaW1TdGFraW5nUmVzdWx0AQgFAWkGY2FsbGVyAJdGZMk=", "height": 2217284, "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 () = { | |
174 | + | let addressStr = toString(i.caller) | |
175 | + | let stakedAmount = tryGetInteger(keyStakedAmount(i.caller)) | |
176 | + | let voteHeight = tryGetInteger(getVoteHeightKey()) | |
177 | + | let voteByUserString = tryGetString(getVoteByUserKey(addressStr, toString(voteHeight))) | |
178 | + | let multiplier = if ((voteByUserString == "")) | |
179 | + | then 7 | |
180 | + | else 10 | |
181 | + | let refund = ((stakedAmount / 10) * multiplier) | |
182 | + | let couponsCall = invoke(getCouponsAddress(), "CFRefund", [addressStr, refund], nil) | |
183 | + | if ((couponsCall == couponsCall)) | |
184 | + | then [IntegerEntry(keyStakedAmount(i.caller), 0), Burn(getShareAssetId(), stakedAmount)] | |
185 | + | else throw("Strict value is not equal to itself.") | |
186 | + | } | |
187 | + | ||
188 | + | ||
189 | + | ||
190 | + | @Callable(i) | |
191 | + | func claimRefundUnstaked () = { | |
192 | + | let shareTokenId = getShareAssetId() | |
193 | + | if ((size(i.payments) > 1)) | |
194 | + | then throw("CSFT: To many payments added") | |
195 | + | else if ((i.payments[0].assetId != shareTokenId)) | |
196 | + | then throw("CSFT: Wrong assetId") | |
197 | + | else { | |
198 | + | let amount = i.payments[0].amount | |
199 | + | if ((amount == 0)) | |
200 | + | then throw("CSFT: Please attach positive asset amount!") | |
201 | + | else { | |
202 | + | let addressStr = toString(i.caller) | |
203 | + | let multiplier = 7 | |
204 | + | let refund = ((amount / 10) * multiplier) | |
205 | + | let couponsCall = invoke(getCouponsAddress(), "CFRefund", [addressStr, refund], nil) | |
206 | + | if ((couponsCall == couponsCall)) | |
207 | + | then [Burn(getShareAssetId(), amount)] | |
208 | + | else throw("Strict value is not equal to itself.") | |
209 | + | } | |
210 | + | } | |
211 | + | } | |
212 | + | ||
213 | + | ||
214 | + | ||
215 | + | @Callable(i) | |
216 | + | func startVote () = if ((i.caller != mAccAddr)) | |
217 | + | then throw("CSV: Only the admin can start a liquidation vote for now!") | |
218 | + | else if ((tryGetInteger(getVoteHeightKey()) != 0)) | |
219 | + | then throw("CSV: There is already a vote running!") | |
220 | + | else [IntegerEntry("VOTE_HEIGHT_START", height)] | |
221 | + | ||
222 | + | ||
223 | + | ||
224 | + | @Callable(i) | |
225 | + | func voteToLiquidate (vote) = { | |
226 | + | let votePower = tryGetInteger(keyStakedAmount(i.caller)) | |
227 | + | if ((votePower == 0)) | |
228 | + | then throw("CVTL: Please stake some tokens before you can vote!") | |
229 | + | else { | |
230 | + | let voteAsString = toString(vote) | |
231 | + | let voteHeight = tryGetInteger(getVoteHeightKey()) | |
232 | + | if ((height > (voteHeight + getDuration()))) | |
233 | + | then throw("CVTL: Voting is finished, please finalize the vote!") | |
234 | + | else { | |
235 | + | let voteByUserString = tryGetString(getVoteByUserKey(toString(i.caller), toString(voteHeight))) | |
236 | + | if ((voteByUserString != "")) | |
237 | + | then throw("CVTL: You can not change your vote!") | |
238 | + | else addVotePower(toString(i.caller), voteHeight, voteAsString, votePower) | |
239 | + | } | |
240 | + | } | |
241 | + | } | |
242 | + | ||
243 | + | ||
244 | + | ||
245 | + | @Callable(i) | |
246 | + | func finalizeVote () = { | |
247 | + | let voteHeight = tryGetInteger(getVoteHeightKey()) | |
248 | + | if (((voteHeight + getDuration()) > height)) | |
249 | + | then throw("CFV: Voting is not finished!") | |
250 | + | else { | |
251 | + | let shareAssetIdTotal = value(assetInfo(getShareAssetId())).quantity | |
252 | + | let totalStakedAmount = tryGetInteger(keyGlobalStaked) | |
253 | + | let totalVote = tryGetInteger(getTotalVoteKey(toString(voteHeight))) | |
254 | + | let quorum = (totalVote / (shareAssetIdTotal / 100)) | |
255 | + | let voteTotalByYes = tryGetInteger(getTotalVoteByTypeKey("true", toString(voteHeight))) | |
256 | + | let voteTotalByNo = tryGetInteger(getTotalVoteByTypeKey("false", toString(voteHeight))) | |
257 | + | let liquidated = if ((20 > quorum)) | |
258 | + | then true | |
259 | + | else if ((voteTotalByYes > voteTotalByNo)) | |
260 | + | then true | |
261 | + | else false | |
262 | + | let resetKey = if (liquidated) | |
263 | + | then nil | |
264 | + | else [IntegerEntry(getVoteHeightKey(), 0)] | |
265 | + | ([IntegerEntry(quorumVoteKey(toString(voteHeight)), quorum), BooleanEntry(resultVoteKey(toString(voteHeight)), liquidated)] ++ resetKey) | |
266 | + | } | |
267 | + | } | |
268 | + | ||
269 | + | ||
270 | + | ||
271 | + | @Callable(i) | |
272 | + | func topUpReward () = if (isLiquidated()) | |
273 | + | then throw("CTUR: CF is liquidated!") | |
274 | + | else { | |
275 | + | let eggAssetId = getEggId() | |
276 | + | if ((i.payments[0].assetId != eggAssetId)) | |
277 | + | then throw("CTUP: Wrong assetId, payment should be EGG") | |
278 | + | else { | |
279 | + | let resHandleStaking = handleStakingTopUp(i.payments[0].amount) | |
280 | + | $Tuple2(resHandleStaking, true) | |
281 | + | } | |
282 | + | } | |
283 | + | ||
284 | + | ||
285 | + | ||
286 | + | @Callable(i) | |
287 | + | func withdrawFarmTokens (amount,compound) = if (isLiquidated()) | |
288 | + | then throw("CTUR: CF is liquidated!") | |
289 | + | else if ((size(i.payments) > 0)) | |
290 | + | then throw("CWFT: Please don't add payments") | |
291 | + | else { | |
292 | + | let shareTokenId = getShareAssetId() | |
293 | + | if (compound) | |
294 | + | then { | |
295 | + | let staked = tryGetInteger(keyStakedCompound) | |
296 | + | let total = tryGetInteger(keyTotalCompound) | |
297 | + | let vp = calcVirtualPrice(staked, total) | |
298 | + | let keyStakedCompoundU = keyStakedCompoundUser(i.caller) | |
299 | + | let personalStaked = tryGetInteger(keyStakedCompoundU) | |
300 | + | let virtualWd = if ((amount == -1)) | |
301 | + | then personalStaked | |
302 | + | else fraction(amount, VPScale, vp) | |
303 | + | let amountWd = if ((amount == -1)) | |
304 | + | then fraction(virtualWd, vp, VPScale) | |
305 | + | else amount | |
306 | + | if ((virtualWd > personalStaked)) | |
307 | + | then throw("CWFT: You don't have so much funds to withdraw") | |
308 | + | 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)] | |
309 | + | } | |
310 | + | else { | |
311 | + | let addressStr = toString(i.caller) | |
312 | + | let stakedAmount = tryGetInteger(keyStakedAmount(i.caller)) | |
313 | + | let wdAmount = if ((amount == -1)) | |
314 | + | then stakedAmount | |
315 | + | else amount | |
316 | + | if ((wdAmount > stakedAmount)) | |
317 | + | then throw("CWFT: you don't have tokens available") | |
318 | + | else { | |
319 | + | let votePower = adaptVotePowerStake(toString(i.caller), -(wdAmount)) | |
320 | + | ((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) | |
321 | + | } | |
322 | + | } | |
323 | + | } | |
324 | + | ||
325 | + | ||
326 | + | ||
327 | + | @Callable(i) | |
328 | + | func stakeFarmTokens (compound) = if (isLiquidated()) | |
329 | + | then throw("CSFT: CF is liquidated!") | |
330 | + | else { | |
331 | + | let shareTokenId = getShareAssetId() | |
332 | + | if ((size(i.payments) > 1)) | |
333 | + | then throw("CSFT: Too many payments added") | |
334 | + | else if ((i.payments[0].assetId != shareTokenId)) | |
335 | + | then throw("CSFT: Wrong assetId") | |
336 | + | else { | |
337 | + | let amount = i.payments[0].amount | |
338 | + | if ((amount == 0)) | |
339 | + | then throw("CSFT: Please attach positive asset amount!") | |
340 | + | else if (compound) | |
341 | + | then throw("CSFT: Compound was disabled!") | |
342 | + | else { | |
343 | + | let addressStr = toString(i.caller) | |
344 | + | let totalStakedAmount = tryGetInteger(keyGlobalStaked) | |
345 | + | if ((i.payments[0].assetId != shareTokenId)) | |
346 | + | then throw("CSFT: wrong asset attached") | |
347 | + | else { | |
348 | + | let votePower = adaptVotePowerStake(toString(i.caller), amount) | |
349 | + | ((claimStakingResult(i.caller) ++ [IntegerEntry(keyGlobalStaked, (totalStakedAmount + amount)), IntegerEntry(keyStakedAmount(i.caller), (tryGetInteger(keyStakedAmount(i.caller)) + amount))]) ++ votePower) | |
350 | + | } | |
351 | + | } | |
352 | + | } | |
353 | + | } | |
354 | + | ||
355 | + | ||
356 | + | ||
357 | + | @Callable(i) | |
358 | + | func initiateDapp (address) = if (isLiquidated()) | |
359 | + | then throw("CID: CF is liquidated!") | |
360 | + | else if ((i.caller != this)) | |
361 | + | then throw("CID: Can be called only by the dapp-account") | |
362 | + | else setCFAddressAndInitiate(address) | |
363 | + | ||
364 | + | ||
365 | + | ||
366 | + | @Callable(i) | |
367 | + | func claimReward () = if (isLiquidated()) | |
368 | + | then throw("CCR: CF is liquidated!") | |
369 | + | else if ((size(i.payments) > 0)) | |
370 | + | then throw("CCR: Please don't add payments") | |
371 | + | else claimStakingResult(i.caller) | |
372 | + | ||
373 | + |
github/deemru/w8io/169f3d6 29.96 ms ◑