tx · 7vWYwan9jcdEdRYtSZsqJWFF7WB9HV4sY8WE5PbwmLuB

3MpMuGN8rW9EpPwzETAQz88Pe9TQhSwiriq:  -0.16000000 Waves

2023.07.31 15:26 [2690058] smart account 3MpMuGN8rW9EpPwzETAQz88Pe9TQhSwiriq > SELF 0.00000000 Waves

{ "type": 13, "id": "7vWYwan9jcdEdRYtSZsqJWFF7WB9HV4sY8WE5PbwmLuB", "fee": 16000000, "feeAssetId": null, "timestamp": 1690806443781, "version": 2, "chainId": 84, "sender": "3MpMuGN8rW9EpPwzETAQz88Pe9TQhSwiriq", "senderPublicKey": "57SkjQUEwC1ayCqLbXLuzBqifK6B6SR6rfxtGsbAo3zW", "proofs": [ "4ugiduqhPxSZEbKSPe4adHj6tCt6n5zZxD227YYVd6FPiyno6RxL5Mo2DgX2BvAqHaic3GvH939owBCJX4rU67BS" ], "script": "base64:BgIkCAISAwoBARIDCgEBEgASAwoBCBIDCgEBEgMKAQgSABIDCgEIMgAMY29udHJhY3RGaWxlAhFsMm1wX3N0YWtpbmcucmlkZQADU0VQAgJfXwAGc2NhbGU4AIDC1y8AB3NjYWxlMTgAgICQu7rWrfANAA1zY2FsZTE4QmlnSW50CQC2AgEFB3NjYWxlMTgAEkFERFJFU1NfQllURVNfU0laRQAaAA1CTE9DS1NfSU5fREFZAKALAQh0aHJvd0VycgEDbXNnCQACAQkArAICCQCsAgIFDGNvbnRyYWN0RmlsZQICOiAFA21zZwAKa2V5QXNzZXRJZAkAuQkCCQDMCAICAiVzCQDMCAICB2Fzc2V0SWQFA25pbAUDU0VQABNrZXlFbWlzc2lvblBlckJsb2NrCQC5CQIJAMwIAgICJXMJAMwIAgIQZW1pc3Npb25QZXJCbG9jawUDbmlsBQNTRVAAGWtleUVtaXNzaW9uUGVyaW9kSW5CbG9ja3MJALkJAgkAzAgCAgIlcwkAzAgCAhZlbWlzc2lvblBlcmlvZEluQmxvY2tzBQNuaWwFA1NFUAANa2V5U3RhcnRCbG9jawkAuQkCCQDM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GVxdWFsIHRvIGl0c2VsZi4BAnR4AQZ2ZXJpZnkABAhieUFkbWlucwkAAAIIBQJ0eAJpZAkA2QQBCQELdmFsdWVPckVsc2UCCQCdCAIFBHRoaXMJAQ5rZXlBbGxvd2VkVHhJZAACAAQHYnlPd25lcgMJAGcCCQCQAwEJAQ1nZXRBZG1pbnNMaXN0AAUGUVVPUlVNBwkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleQMFCGJ5QWRtaW5zBgUHYnlPd25lcpWlhFE=", "height": 2690058, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Ej5mXpi8bmLQ8jkfvvxwTSaZ9LkQi4nqSUtVocHjGMfE Next: CRyNuZAJXhJQjZRHiwFYyEGjx4acxxPFQVErGZuSykJs Diff:
OldNewDifferences
226226 let userAvailableAssetToWithdraw = toInt(fraction(toBigInt(userLpAmount), getCurrentPrice(), scale18BigInt))
227227 let roundedLpAmountFromAvailable = toInt(fraction(toBigInt(userAvailableAssetToWithdraw), scale18BigInt, getCurrentPrice()))
228228 let roundedAssetsAvailableToWithdraw = toInt(fraction(toBigInt(roundedLpAmountFromAvailable), getCurrentPrice(), scale18BigInt))
229- max([0, min([userAvailableAssetToWithdraw, roundedLpAmountFromAvailable])])
229+ max([0, min([userAvailableAssetToWithdraw, roundedAssetsAvailableToWithdraw])])
230230 }
231231
232232
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let contractFile = "l2mp_staking.ride"
55
66 let SEP = "__"
77
88 let scale8 = 100000000
99
1010 let scale18 = 1000000000000000000
1111
1212 let scale18BigInt = toBigInt(scale18)
1313
1414 let ADDRESS_BYTES_SIZE = 26
1515
1616 let BLOCKS_IN_DAY = 1440
1717
1818 func throwErr (msg) = throw(((contractFile + ": ") + msg))
1919
2020
2121 let keyAssetId = makeString(["%s", "assetId"], SEP)
2222
2323 let keyEmissionPerBlock = makeString(["%s", "emissionPerBlock"], SEP)
2424
2525 let keyEmissionPeriodInBlocks = makeString(["%s", "emissionPeriodInBlocks"], SEP)
2626
2727 let keyStartBlock = makeString(["%s", "startBlock"], SEP)
2828
2929 let keyTotalLpAmount = makeString(["%s", "totalLpAmount"], SEP)
3030
3131 let keyTotalAssetAmount = makeString(["%s", "totalAssetAmount"], SEP)
3232
3333 func keyUserLpAmount (userAddress) = makeString(["%s%s", "userLpAmount", userAddress], SEP)
3434
3535
3636 func keyUserTotalAssetWithdrawn (userAddress) = makeString(["%s%s", "totalAssetWithdrawn", userAddress], SEP)
3737
3838
3939 func keyUserTotalAssetStaked (userAddress) = makeString(["%s%s", "totalAssetStaked", userAddress], SEP)
4040
4141
4242 func keyHistory (type,userAddress,txId) = makeString(["%s%s%s", type, userAddress, toBase58String(txId)], SEP)
4343
4444
4545 func formatHistory (totalProfit,price,totalAssetAmount,totalLpAmount) = makeString(["%d%d", toString(totalProfit), toString(price), toString(totalAssetAmount), toString(totalLpAmount)], SEP)
4646
4747
4848 let totalLpAmount = valueOrElse(getInteger(this, keyTotalLpAmount), 0)
4949
5050 let totalAssetAmount = valueOrElse(getInteger(this, keyTotalAssetAmount), 0)
5151
5252 let assetIdString = valueOrElse(getString(this, keyAssetId), "WAVES")
5353
5454 let assetIdBytes = if ((assetIdString == "WAVES"))
5555 then unit
5656 else fromBase58String(assetIdString)
5757
5858 let emissionPeriodInBlocks = valueOrElse(getInteger(this, keyEmissionPeriodInBlocks), BLOCKS_IN_DAY)
5959
6060 let emissionPerPeriod = (valueOrElse(getInteger(this, keyEmissionPerBlock), 0) * emissionPeriodInBlocks)
6161
6262 let ADMIN_LIST_SIZE = 5
6363
6464 let QUORUM = 3
6565
6666 let TXID_BYTES_LENGTH = 32
6767
6868 func keyAllowedTxIdVotePrefix (txId) = makeString(["%s%s%s", "allowTxId", txId], SEP)
6969
7070
7171 func keyFullAdminVote (prefix,adminAddress) = makeString([prefix, adminAddress], SEP)
7272
7373
7474 func keyAdminAddressList () = makeString(["%s", "adminAddressList"], SEP)
7575
7676
7777 func keyAllowedTxId () = makeString(["%s", "txId"], SEP)
7878
7979
8080 func getAdminVote (prefix,admin) = {
8181 let voteKey = keyFullAdminVote(prefix, admin)
8282 valueOrElse(getInteger(voteKey), 0)
8383 }
8484
8585
8686 func getAdminsList () = match getString(this, keyAdminAddressList()) {
8787 case s: String =>
8888 split(s, SEP)
8989 case _ =>
9090 nil
9191 }
9292
9393
9494 func isInAdminList (address) = containsElement(getAdminsList(), address)
9595
9696
9797 func genVotesKeysHelper (a,adminAddress) = {
9898 let $t030453069 = a
9999 let result = $t030453069._1
100100 let prefix = $t030453069._2
101101 $Tuple2((result :+ keyFullAdminVote(prefix, adminAddress)), prefix)
102102 }
103103
104104
105105 func genVotesKeys (keyPrefix) = {
106106 let adminList = keyAdminAddressList()
107107 let $t032163300 = {
108108 let $l = getAdminsList()
109109 let $s = size($l)
110110 let $acc0 = $Tuple2(nil, keyPrefix)
111111 func $f0_1 ($a,$i) = if (($i >= $s))
112112 then $a
113113 else genVotesKeysHelper($a, $l[$i])
114114
115115 func $f0_2 ($a,$i) = if (($i >= $s))
116116 then $a
117117 else throw("List size exceeds 5")
118118
119119 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5)
120120 }
121121 let result = $t032163300._1
122122 let prefix = $t032163300._2
123123 result
124124 }
125125
126126
127127 func countVotesHelper (result,voteKey) = (result + valueOrElse(getInteger(voteKey), 0))
128128
129129
130130 func countVotes (prefix) = {
131131 let votes = genVotesKeys(prefix)
132132 let $l = votes
133133 let $s = size($l)
134134 let $acc0 = 0
135135 func $f0_1 ($a,$i) = if (($i >= $s))
136136 then $a
137137 else countVotesHelper($a, $l[$i])
138138
139139 func $f0_2 ($a,$i) = if (($i >= $s))
140140 then $a
141141 else throw("List size exceeds 5")
142142
143143 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5)
144144 }
145145
146146
147147 func clearVotesHelper (result,key) = (result :+ DeleteEntry(key))
148148
149149
150150 func getClearVoteEntries (prefix) = {
151151 let votes = genVotesKeys(prefix)
152152 let $l = votes
153153 let $s = size($l)
154154 let $acc0 = nil
155155 func $f0_1 ($a,$i) = if (($i >= $s))
156156 then $a
157157 else clearVotesHelper($a, $l[$i])
158158
159159 func $f0_2 ($a,$i) = if (($i >= $s))
160160 then $a
161161 else throw("List size exceeds 5")
162162
163163 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5)
164164 }
165165
166166
167167 func voteINTERNAL (callerAddressString,keyPrefix,minVotes,voteResult) = {
168168 let voteKey = keyFullAdminVote(keyPrefix, callerAddressString)
169169 let adminCurrentVote = getAdminVote(keyPrefix, callerAddressString)
170170 let err = if (!(isInAdminList(callerAddressString)))
171171 then throwErr((("Address: " + callerAddressString) + " not in Admin list"))
172172 else if ((adminCurrentVote == 1))
173173 then throwErr((voteKey + " you already voted"))
174174 else unit
175175 if ((err == err))
176176 then {
177177 let votes = countVotes(keyPrefix)
178178 if (((votes + 1) >= minVotes))
179179 then {
180180 let clearVoteEntries = getClearVoteEntries(keyPrefix)
181181 (clearVoteEntries ++ voteResult)
182182 }
183183 else [IntegerEntry(voteKey, 1)]
184184 }
185185 else throw("Strict value is not equal to itself.")
186186 }
187187
188188
189189 func calcTotalProfitForHeight (h) = {
190190 let startBlock = valueOrElse(getInteger(this, keyStartBlock), 0)
191191 let startPeriod = fraction(startBlock, 1, emissionPeriodInBlocks)
192192 let elapsedPeriods = ((h / emissionPeriodInBlocks) - startPeriod)
193193 max([0, (emissionPerPeriod * elapsedPeriods)])
194194 }
195195
196196
197197 func calcTotalProfit () = calcTotalProfitForHeight(height)
198198
199199
200200 func getTotalAssetAmountWithProfitOrMaxAvailable () = {
201201 let totalAssetAmountWithProfit = (totalAssetAmount + calcTotalProfit())
202202 let totalAmount = match assetIdBytes {
203203 case u: Unit =>
204204 min([totalAssetAmountWithProfit, wavesBalance(this).available])
205205 case b: ByteVector =>
206206 min([totalAssetAmountWithProfit, assetBalance(this, b)])
207207 case _ =>
208208 throw("Match error")
209209 }
210210 if ((totalLpAmount == 0))
211211 then 0
212212 else totalAmount
213213 }
214214
215215
216216 func getCurrentPrice () = if ((totalLpAmount != 0))
217217 then fraction(toBigInt(getTotalAssetAmountWithProfitOrMaxAvailable()), scale18BigInt, toBigInt(totalLpAmount))
218218 else scale18BigInt
219219
220220
221221 func getUserLpAmount (userAddress) = valueOrElse(getInteger(this, keyUserLpAmount(userAddress)), 0)
222222
223223
224224 func getUserAvailableAssetsToWithdraw (userAddress) = {
225225 let userLpAmount = getUserLpAmount(userAddress)
226226 let userAvailableAssetToWithdraw = toInt(fraction(toBigInt(userLpAmount), getCurrentPrice(), scale18BigInt))
227227 let roundedLpAmountFromAvailable = toInt(fraction(toBigInt(userAvailableAssetToWithdraw), scale18BigInt, getCurrentPrice()))
228228 let roundedAssetsAvailableToWithdraw = toInt(fraction(toBigInt(roundedLpAmountFromAvailable), getCurrentPrice(), scale18BigInt))
229- max([0, min([userAvailableAssetToWithdraw, roundedLpAmountFromAvailable])])
229+ max([0, min([userAvailableAssetToWithdraw, roundedAssetsAvailableToWithdraw])])
230230 }
231231
232232
233233 func getStakeActions (i,userAddress) = {
234234 let checks = [if ((size(i.payments) == 1))
235235 then true
236236 else throwErr("should include 1 payment"), if ((i.payments[0].assetId == assetIdBytes))
237237 then true
238238 else throwErr(("payment should be in " + assetIdString)), if ((i.payments[0].amount > 0))
239239 then true
240240 else "payment amount should be greater than 0"]
241241 if ((checks == checks))
242242 then {
243243 let paymentAmount = i.payments[0].amount
244244 let paymentLpAmount = toInt(fraction(toBigInt(paymentAmount), scale18BigInt, getCurrentPrice()))
245245 let userLpAmount = getUserLpAmount(userAddress)
246246 let userTotalStakedAmount = valueOrElse(getInteger(this, keyUserTotalAssetStaked(userAddress)), 0)
247247 let newTotalLpAmount = (totalLpAmount + paymentLpAmount)
248248 let newTotalAssetAmount = (totalAssetAmount + paymentAmount)
249249 let newUserLpAmount = (userLpAmount + paymentLpAmount)
250250 let newUserTotalStakedAmount = (userTotalStakedAmount + paymentAmount)
251251 let updateStartHeightAction = if ((totalLpAmount == 0))
252252 then [IntegerEntry(keyStartBlock, height)]
253253 else nil
254254 ([StringEntry(keyHistory("stake", userAddress, i.transactionId), formatHistory(calcTotalProfit(), getCurrentPrice(), totalLpAmount, totalAssetAmount)), IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetStaked(userAddress), newUserTotalStakedAmount)] ++ updateStartHeightAction)
255255 }
256256 else throw("Strict value is not equal to itself.")
257257 }
258258
259259
260260 func getWithdrawActions (i,lpAssetWithdrawAmount) = {
261261 let userAddress = toString(i.caller)
262262 let userLpAmount = getUserLpAmount(userAddress)
263263 let check = [if ((lpAssetWithdrawAmount > 0))
264264 then true
265265 else throwErr("LP amount should be more than 0"), if ((userLpAmount >= lpAssetWithdrawAmount))
266266 then true
267267 else throwErr((("cannot withdraw more than available LP (" + toString(userLpAmount)) + ")"))]
268268 if ((check == check))
269269 then {
270270 let newUserLpAmount = (userLpAmount - lpAssetWithdrawAmount)
271271 let withdrawAssetAmount = toInt(fraction(toBigInt(lpAssetWithdrawAmount), getCurrentPrice(), scale18BigInt))
272272 let newTotalLpAmount = (totalLpAmount - lpAssetWithdrawAmount)
273273 let newTotalAssetAmount = toInt(fraction(toBigInt(newTotalLpAmount), getCurrentPrice(), scale18BigInt))
274274 let userTotalAssetWithdrawn = valueOrElse(getInteger(this, keyUserTotalAssetWithdrawn(userAddress)), 0)
275275 let newUserTotalAssetWithdrawn = (userTotalAssetWithdrawn + withdrawAssetAmount)
276276 [StringEntry(keyHistory("withdraw", userAddress, i.transactionId), formatHistory(calcTotalProfit(), getCurrentPrice(), totalLpAmount, totalAssetAmount)), IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetWithdrawn(userAddress), newUserTotalAssetWithdrawn), IntegerEntry(keyStartBlock, height), ScriptTransfer(i.caller, withdrawAssetAmount, assetIdBytes)]
277277 }
278278 else throw("Strict value is not equal to itself.")
279279 }
280280
281281
282282 @Callable(i)
283283 func setEmissionPerBlock (emissionPerBlock) = {
284284 let check = [if ((i.caller == this))
285285 then true
286286 else throwErr("permission denied")]
287287 if ((check == check))
288288 then [IntegerEntry(keyTotalAssetAmount, getTotalAssetAmountWithProfitOrMaxAvailable()), IntegerEntry(keyStartBlock, height), IntegerEntry(keyEmissionPerBlock, max([0, emissionPerBlock]))]
289289 else throw("Strict value is not equal to itself.")
290290 }
291291
292292
293293
294294 @Callable(i)
295295 func setEmissionPeriodInBlocks (p) = {
296296 let check = [if ((p > 0))
297297 then true
298298 else throwErr("emission period should be greater than 0"), if ((i.caller == this))
299299 then true
300300 else throwErr("permission denied")]
301301 if ((check == check))
302302 then [IntegerEntry(keyTotalAssetAmount, getTotalAssetAmountWithProfitOrMaxAvailable()), IntegerEntry(keyStartBlock, height), IntegerEntry(keyEmissionPeriodInBlocks, p)]
303303 else throw("Strict value is not equal to itself.")
304304 }
305305
306306
307307
308308 @Callable(i)
309309 func stake () = getStakeActions(i, toString(i.caller))
310310
311311
312312
313313 @Callable(i)
314314 func stakeFor (userAddress) = {
315315 let check = [if ((size(fromBase58String(userAddress)) == ADDRESS_BYTES_SIZE))
316316 then true
317317 else throwErr("address is not valid")]
318318 if ((check == check))
319319 then getStakeActions(i, userAddress)
320320 else throw("Strict value is not equal to itself.")
321321 }
322322
323323
324324
325325 @Callable(i)
326326 func withdraw (withdrawAssetAmount) = {
327327 let userAddress = toString(i.caller)
328328 let userLpAmount = getUserLpAmount(userAddress)
329329 let lpAmountToWithdraw = toInt(fraction(toBigInt(withdrawAssetAmount), scale18BigInt, getCurrentPrice()))
330330 let userAvailableAssetToWithdraw = getUserAvailableAssetsToWithdraw(userAddress)
331331 let minWithdrawAssetAmount = toInt(fraction(getCurrentPrice(), toBigInt(1), scale18BigInt, CEILING))
332332 let check = [if ((withdrawAssetAmount > 0))
333333 then true
334334 else throwErr("withdraw amount should be more than 0"), if ((userAvailableAssetToWithdraw >= withdrawAssetAmount))
335335 then true
336336 else throwErr((("cannot withdraw more than available (" + toString(userAvailableAssetToWithdraw)) + ")")), if ((withdrawAssetAmount >= minWithdrawAssetAmount))
337337 then true
338338 else throwErr((("withdraw amount is too small. Min: (" + toString(minWithdrawAssetAmount)) + ")"))]
339339 if ((check == check))
340340 then getWithdrawActions(i, lpAmountToWithdraw)
341341 else throw("Strict value is not equal to itself.")
342342 }
343343
344344
345345
346346 @Callable(i)
347347 func getUserAssetsREADONLY (userAddress) = {
348348 let userLpAmount = getUserLpAmount(userAddress)
349349 let userAvailableAssetToWithdraw = getUserAvailableAssetsToWithdraw(userAddress)
350350 let userTotalStakedAmount = valueOrElse(getInteger(this, keyUserTotalAssetStaked(userAddress)), 0)
351351 let userTotalAssetWithdrawn = valueOrElse(getInteger(this, keyUserTotalAssetWithdrawn(userAddress)), 0)
352352 $Tuple2(nil, $Tuple5(userLpAmount, userAvailableAssetToWithdraw, getCurrentPrice(), userTotalStakedAmount, userTotalAssetWithdrawn))
353353 }
354354
355355
356356
357357 @Callable(i)
358358 func getTotalAssetsREADONLY () = $Tuple2(nil, $Tuple3(totalLpAmount, getTotalAssetAmountWithProfitOrMaxAvailable(), getCurrentPrice()))
359359
360360
361361
362362 @Callable(i)
363363 func voteForTxId (txId) = {
364364 let callerAddressString = toBase58String(i.caller.bytes)
365365 let keyPrefix = keyAllowedTxIdVotePrefix(txId)
366366 let result = [StringEntry(keyAllowedTxId(), txId)]
367367 let allowedTxIdOption = getString(this, keyAllowedTxId())
368368 let err = [if ((size(fromBase58String(txId)) == TXID_BYTES_LENGTH))
369369 then true
370370 else throwErr((txId + " is not valid txId")), if (if ((allowedTxIdOption == unit))
371371 then true
372372 else (value(allowedTxIdOption) != txId))
373373 then true
374374 else throwErr((txId + " is already allowed"))]
375375 if ((err == err))
376376 then voteINTERNAL(callerAddressString, keyPrefix, QUORUM, result)
377377 else throw("Strict value is not equal to itself.")
378378 }
379379
380380
381381 @Verifier(tx)
382382 func verify () = {
383383 let byAdmins = (tx.id == fromBase58String(valueOrElse(getString(this, keyAllowedTxId()), "")))
384384 let byOwner = if ((size(getAdminsList()) >= QUORUM))
385385 then false
386386 else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
387387 if (byAdmins)
388388 then true
389389 else byOwner
390390 }
391391

github/deemru/w8io/026f985 
40.96 ms