tx · Gr3wQvFqWEQmDpPUeQnfFazxu5tqRDW1agfzAVU15tTc

3N1HdGqmcf4nVsUgmWiwB8p6p8ErWBmvQua:  -0.01000000 Waves

2023.11.16 02:56 [2845161] smart account 3N1HdGqmcf4nVsUgmWiwB8p6p8ErWBmvQua > SELF 0.00000000 Waves

{ "type": 13, "id": "Gr3wQvFqWEQmDpPUeQnfFazxu5tqRDW1agfzAVU15tTc", "fee": 1000000, "feeAssetId": null, "timestamp": 1700092566573, "version": 2, "chainId": 84, "sender": "3N1HdGqmcf4nVsUgmWiwB8p6p8ErWBmvQua", "senderPublicKey": "JAEVvs5E9kGyXWx3YQaivUpUP3vb3pgr2eS6UrYr1A8P", "proofs": [ "gWG9gyb81zfJqHnYzUkNZrwbf6w4CTqvFGBok5S31gQ8R5zkEz3soa3qgresdQhNiP7PeGPvP6BHKgZCuRy57vF" ], "script": "base64:AAIFAAAAAAAAAAYIAhIAEgAAAAAOAAAAAAtTVEFLRV9BU1NFVAEAAAAg+yz52JX9bMBBBD7WcJozZ6kHlw3R1qS6Jzk7Sn1TrCIAAAAACkVBUk5fQVNTRVQBAAAAIPss+diV/WzAQQQ+1nCaM2epB5cN0dakuic5O0p9U6wiAAAAAA1UT0tFTlNfUEVSX01TAAAAAAAAAAABAAAAAANTRVACAAAAAl9fAAAAAAtERU5PTUlOQVRPUgAN4Lazp2QAAAEAAAAQdXNlckRlcG9zaXRlZEtleQAAAAEAAAAEdXNlcgkABLkAAAACCQAETAAAAAICAAAAAnVkCQAETAAAAAIJAAJYAAAAAQgFAAAABHVzZXIAAAAFYnl0ZXMFAAAAA25pbAUAAAADU0VQAQAAAA11c2VyVXBkYXRlS2V5AAAAAQAAAAR1c2VyCQAEuQAAAAIJAARMAAAAAgIAAAACdXUJAARMAAAAAgkAAlgAAAABCAUAAAAEdXNlcgAAAAVieXRlcwUAAAADbmlsBQAAAANTRVABAAAAEXRvdGFsRGVwb3NpdGVkS2V5AAAAAAIAAAACdGQBAAAADWxhc3RVc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AJAABlAAAAAgUAAAAOdG90YWxEZXBvc2l0ZWQFAAAADXVzZXJEZXBvc2l0ZWQJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAQAAAA1sYXN0VXBkYXRlS2V5AAAAAAgFAAAACWxhc3RCbG9jawAAAAl0aW1lc3RhbXAJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAA11c2VyRGVwb3NpdGVkBQAAAAtTVEFLRV9BU1NFVAkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIFAAAADGVhcm5lZFRva2VucwUAAAAKRUFSTl9BU1NFVAkABEwAAAACCQEAAAALU3RyaW5nRW50cnkAAAACCQEAAAAXcmV3YXJkUGVyVG9rZW5TdG9yZWRLZXkAAAAACQABpgAAAAEJAQAAABhjYWxjUmV3YXJkUGVyVG9rZW5TdG9yZWQAAAAACQAETAAAAAIJAQAAAAtTdHJpbmdFbnRyeQAAAAIJAQAAABl1c2VyUmV3YXJkUGVyVG9rZW5QYWlkS2V5AAAAAQgFAAAAAWkAAAAGY2FsbGVyCQABpgAAAAEJAQAAABhjYWxjUmV3YXJkUGVyVG9rZW5TdG9yZWQAAAAACQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACCQEAAAALdXNlclJld2FyZHMAAAABCAUAAAABaQAAAAZjYWxsZXIAAAAAAAAAAAAFAAAAA25pbAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5C14sAQ==", "height": 2845161, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: f3cUv2VcktjQXLUho5ooGMVXwZKHsTzPQj9nYbXg8Qk Next: Ga8ix3Wcaf4Hr4JJR7B1r4T3TtmjmwKU4yRqNorkHQGZ Diff:
OldNewDifferences
9393 case _ =>
9494 0
9595 }
96-[IntegerEntry(userDepositedKey(i.caller), (userDeposited + i.payments[0].amount)), IntegerEntry(totalDepositedKey(), (totalDeposited + i.payments[0].amount)), StringEntry(rewardPerTokenStoredKey(), toString(calcRewardPerTokenStored())), StringEntry(userRewardPerTokenPaidKey(i.caller), toString(calcRewardPerTokenStored())), IntegerEntry(userRewards(i.caller), if ((userDeposited == 0))
96+[IntegerEntry(userDepositedKey(i.caller), (userDeposited + i.payments[0].amount)), IntegerEntry(totalDepositedKey(), (totalDeposited + i.payments[0].amount)), IntegerEntry(lastUpdateKey(), lastBlock.timestamp), StringEntry(rewardPerTokenStoredKey(), toString(calcRewardPerTokenStored())), StringEntry(userRewardPerTokenPaidKey(i.caller), toString(calcRewardPerTokenStored())), IntegerEntry(userRewards(i.caller), if ((userDeposited == 0))
9797 then 0
9898 else toInt(earned(i.caller)))]
9999 }
115115 0
116116 }
117117 let earnedTokens = toInt(earned(i.caller))
118-[IntegerEntry(userDepositedKey(i.caller), 0), IntegerEntry(totalDepositedKey(), (totalDeposited - userDeposited)), ScriptTransfer(i.caller, userDeposited, STAKE_ASSET), ScriptTransfer(i.caller, earnedTokens, EARN_ASSET), StringEntry(rewardPerTokenStoredKey(), toString(calcRewardPerTokenStored())), StringEntry(userRewardPerTokenPaidKey(i.caller), toString(calcRewardPerTokenStored())), IntegerEntry(userRewards(i.caller), 0)]
118+[IntegerEntry(userDepositedKey(i.caller), 0), IntegerEntry(totalDepositedKey(), (totalDeposited - userDeposited)), IntegerEntry(lastUpdateKey(), lastBlock.timestamp), ScriptTransfer(i.caller, userDeposited, STAKE_ASSET), ScriptTransfer(i.caller, earnedTokens, EARN_ASSET), StringEntry(rewardPerTokenStoredKey(), toString(calcRewardPerTokenStored())), StringEntry(userRewardPerTokenPaidKey(i.caller), toString(calcRewardPerTokenStored())), IntegerEntry(userRewards(i.caller), 0)]
119119 }
120120
121121
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let STAKE_ASSET = base58'HuV7L2uJ4v2SDS5xqZLWPHhimTUgEMKstmxwfBY17SX3'
55
66 let EARN_ASSET = base58'HuV7L2uJ4v2SDS5xqZLWPHhimTUgEMKstmxwfBY17SX3'
77
88 let TOKENS_PER_MS = 1
99
1010 let SEP = "__"
1111
1212 let DENOMINATOR = 1000000000000000000
1313
1414 func userDepositedKey (user) = makeString(["ud", toBase58String(user.bytes)], SEP)
1515
1616
1717 func userUpdateKey (user) = makeString(["uu", toBase58String(user.bytes)], SEP)
1818
1919
2020 func totalDepositedKey () = "td"
2121
2222
2323 func lastUpdateKey () = "lu"
2424
2525
2626 func rewardPerTokenStoredKey () = "rpts"
2727
2828
2929 func userRewardPerTokenPaidKey (user) = makeString(["urpd", toBase58String(user.bytes)], SEP)
3030
3131
3232 func userRewards (user) = makeString(["ur", toBase58String(user.bytes)], SEP)
3333
3434
3535 func calcRewardPerTokenStored () = {
3636 let totalDeposited = toBigInt( match getInteger(totalDepositedKey()) {
3737 case a: Int =>
3838 a
3939 case _ =>
4040 0
4141 })
4242 let lastUpdate = toBigInt( match getInteger(lastUpdateKey()) {
4343 case a: Int =>
4444 a
4545 case _ =>
4646 lastBlock.timestamp
4747 })
4848 let rewardPerTokenStored = parseBigIntValue( match getString(rewardPerTokenStoredKey()) {
4949 case a: String =>
5050 a
5151 case _ =>
5252 "0"
5353 })
5454 if ((totalDeposited == toBigInt(0)))
5555 then rewardPerTokenStored
5656 else (rewardPerTokenStored + (((toBigInt(TOKENS_PER_MS) * (toBigInt(lastBlock.timestamp) - lastUpdate)) * toBigInt(DENOMINATOR)) / totalDeposited))
5757 }
5858
5959
6060 func earned (user) = {
6161 let userDeposited = toBigInt( match getInteger(userDepositedKey(user)) {
6262 case a: Int =>
6363 a
6464 case _ =>
6565 0
6666 })
6767 let userRewardPerTokenPaid = parseBigIntValue(getStringValue(userRewardPerTokenPaidKey(user)))
6868 let rewards = toBigInt( match getInteger(userRewards(user)) {
6969 case a: Int =>
7070 a
7171 case _ =>
7272 0
7373 })
7474 (fraction(userDeposited, (calcRewardPerTokenStored() - userRewardPerTokenPaid), toBigInt(DENOMINATOR)) + rewards)
7575 }
7676
7777
7878 @Callable(i)
7979 func deposit () = if (if ((size(i.payments) != 1))
8080 then true
8181 else (i.payments[0].assetId != STAKE_ASSET))
8282 then throw("incorrect asset deposits")
8383 else {
8484 let userDeposited = match getInteger(userDepositedKey(i.caller)) {
8585 case a: Int =>
8686 a
8787 case _ =>
8888 0
8989 }
9090 let totalDeposited = match getInteger(totalDepositedKey()) {
9191 case a: Int =>
9292 a
9393 case _ =>
9494 0
9595 }
96-[IntegerEntry(userDepositedKey(i.caller), (userDeposited + i.payments[0].amount)), IntegerEntry(totalDepositedKey(), (totalDeposited + i.payments[0].amount)), StringEntry(rewardPerTokenStoredKey(), toString(calcRewardPerTokenStored())), StringEntry(userRewardPerTokenPaidKey(i.caller), toString(calcRewardPerTokenStored())), IntegerEntry(userRewards(i.caller), if ((userDeposited == 0))
96+[IntegerEntry(userDepositedKey(i.caller), (userDeposited + i.payments[0].amount)), IntegerEntry(totalDepositedKey(), (totalDeposited + i.payments[0].amount)), IntegerEntry(lastUpdateKey(), lastBlock.timestamp), StringEntry(rewardPerTokenStoredKey(), toString(calcRewardPerTokenStored())), StringEntry(userRewardPerTokenPaidKey(i.caller), toString(calcRewardPerTokenStored())), IntegerEntry(userRewards(i.caller), if ((userDeposited == 0))
9797 then 0
9898 else toInt(earned(i.caller)))]
9999 }
100100
101101
102102
103103 @Callable(i)
104104 func withdraw () = {
105105 let userDeposited = match getInteger(userDepositedKey(i.caller)) {
106106 case a: Int =>
107107 a
108108 case _ =>
109109 0
110110 }
111111 let totalDeposited = match getInteger(totalDepositedKey()) {
112112 case a: Int =>
113113 a
114114 case _ =>
115115 0
116116 }
117117 let earnedTokens = toInt(earned(i.caller))
118-[IntegerEntry(userDepositedKey(i.caller), 0), IntegerEntry(totalDepositedKey(), (totalDeposited - userDeposited)), ScriptTransfer(i.caller, userDeposited, STAKE_ASSET), ScriptTransfer(i.caller, earnedTokens, EARN_ASSET), StringEntry(rewardPerTokenStoredKey(), toString(calcRewardPerTokenStored())), StringEntry(userRewardPerTokenPaidKey(i.caller), toString(calcRewardPerTokenStored())), IntegerEntry(userRewards(i.caller), 0)]
118+[IntegerEntry(userDepositedKey(i.caller), 0), IntegerEntry(totalDepositedKey(), (totalDeposited - userDeposited)), IntegerEntry(lastUpdateKey(), lastBlock.timestamp), ScriptTransfer(i.caller, userDeposited, STAKE_ASSET), ScriptTransfer(i.caller, earnedTokens, EARN_ASSET), StringEntry(rewardPerTokenStoredKey(), toString(calcRewardPerTokenStored())), StringEntry(userRewardPerTokenPaidKey(i.caller), toString(calcRewardPerTokenStored())), IntegerEntry(userRewards(i.caller), 0)]
119119 }
120120
121121
122122 @Verifier(tx)
123123 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
124124

github/deemru/w8io/026f985 
33.04 ms