tx · 4Dqtd1ucyeBYQGnhd2rjxCgyLSiKGrYLdSKynpGHaN5A

3N1HdGqmcf4nVsUgmWiwB8p6p8ErWBmvQua:  -0.01000000 Waves

2023.11.16 15:47 [2845957] smart account 3N1HdGqmcf4nVsUgmWiwB8p6p8ErWBmvQua > SELF 0.00000000 Waves

{ "type": 13, "id": "4Dqtd1ucyeBYQGnhd2rjxCgyLSiKGrYLdSKynpGHaN5A", "fee": 1000000, "feeAssetId": null, "timestamp": 1700138882110, "version": 2, "chainId": 84, "sender": "3N1HdGqmcf4nVsUgmWiwB8p6p8ErWBmvQua", "senderPublicKey": "JAEVvs5E9kGyXWx3YQaivUpUP3vb3pgr2eS6UrYr1A8P", "proofs": [ "2Rhe8J2yq87ymfzBbe2mobXioKhqgfzPjQjK7CUUw9Y9FUg5NhKSCo3mj9xYaFDonQTMLYKpGgixRxekLVkiYFWp", "4119BBjn5TVQPKgcpKykKK8X3q5psh2cSGEVRUXfKTujvPqHn7hQ3yN57McLUxDoP7ayGNn6d4jTq7m1LELZETw4" ], "script": "base64:AAIFAAAAAAAAAAgIAhIAEgASAAAAAA0AAAAAC1NUQUtFX0FTU0VUAQAAACD7LPnYlf1swEEEPtZwmjNnqQeXDdHWpLonOTtKfVOsIgAAAAAKRUFSTl9BU1NFVAEAAAAg+yz52JX9bMBBBD7WcJozZ6kHlw3R1qS6Jzk7Sn1TrCIAAAAADVRPS0VOU19QRVJfTVMAAAAAAAAAAAEAAAAAA1NFUAIAAAACX18AAAAAC0RFTk9NSU5BVE9SAA3gtrOnZAAAAQAAABB1c2VyRGVwb3NpdGVkS2V5AAAAAQAAAAR1c2VyCQAEuQAAAAIJAARMAAAAAgIAAAACdWQJAARMAAAAAgkAAlgAAAABCAUAAAAEdXNlcgAAAAVieXRlcwUAAAADbmlsBQAAAANTRVABAAAAEXRvdGFsRGVwb3NpdGVkS2V5AAAAAAIAAAACdGQBAAAADWxhc3RVcGRhdGVLZXkAAAAAAgAAAAJsdQEAAAAXcmV3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AAAt1c2VyUmV3YXJkcwAAAAEIBQAAAAFpAAAABmNhbGxlcgAAAAAAAAAAAAUAAAADbmlsAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXnKGAYQ", "height": 2845957, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Ga8ix3Wcaf4Hr4JJR7B1r4T3TtmjmwKU4yRqNorkHQGZ Next: G8PPjDoVTucoiTTZmikHFVkxRAmUtf9aKmTzp9uKSVJz Diff:
OldNewDifferences
7373
7474
7575 @Callable(i)
76+func update () = [IntegerEntry(lastUpdateKey(), lastBlock.timestamp), StringEntry(rewardPerTokenStoredKey(), toString(calcRewardPerTokenStored()))]
77+
78+
79+
80+@Callable(i)
7681 func deposit () = if (if ((size(i.payments) != 1))
7782 then true
7883 else (i.payments[0].assetId != STAKE_ASSET))
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 totalDepositedKey () = "td"
1818
1919
2020 func lastUpdateKey () = "lu"
2121
2222
2323 func rewardPerTokenStoredKey () = "rpts"
2424
2525
2626 func userRewardPerTokenPaidKey (user) = makeString(["urpd", toBase58String(user.bytes)], SEP)
2727
2828
2929 func userRewards (user) = makeString(["ur", toBase58String(user.bytes)], SEP)
3030
3131
3232 func calcRewardPerTokenStored () = {
3333 let totalDeposited = toBigInt( match getInteger(totalDepositedKey()) {
3434 case a: Int =>
3535 a
3636 case _ =>
3737 0
3838 })
3939 let lastUpdate = toBigInt( match getInteger(lastUpdateKey()) {
4040 case a: Int =>
4141 a
4242 case _ =>
4343 lastBlock.timestamp
4444 })
4545 let rewardPerTokenStored = parseBigIntValue( match getString(rewardPerTokenStoredKey()) {
4646 case a: String =>
4747 a
4848 case _ =>
4949 "0"
5050 })
5151 if ((totalDeposited == toBigInt(0)))
5252 then rewardPerTokenStored
5353 else (rewardPerTokenStored + (((toBigInt(TOKENS_PER_MS) * (toBigInt(lastBlock.timestamp) - lastUpdate)) * toBigInt(DENOMINATOR)) / totalDeposited))
5454 }
5555
5656
5757 func earned (user) = {
5858 let userDeposited = toBigInt( match getInteger(userDepositedKey(user)) {
5959 case a: Int =>
6060 a
6161 case _ =>
6262 0
6363 })
6464 let userRewardPerTokenPaid = parseBigIntValue(getStringValue(userRewardPerTokenPaidKey(user)))
6565 let rewards = toBigInt( match getInteger(userRewards(user)) {
6666 case a: Int =>
6767 a
6868 case _ =>
6969 0
7070 })
7171 (fraction(userDeposited, (calcRewardPerTokenStored() - userRewardPerTokenPaid), toBigInt(DENOMINATOR)) + rewards)
7272 }
7373
7474
7575 @Callable(i)
76+func update () = [IntegerEntry(lastUpdateKey(), lastBlock.timestamp), StringEntry(rewardPerTokenStoredKey(), toString(calcRewardPerTokenStored()))]
77+
78+
79+
80+@Callable(i)
7681 func deposit () = if (if ((size(i.payments) != 1))
7782 then true
7883 else (i.payments[0].assetId != STAKE_ASSET))
7984 then throw("incorrect asset deposits")
8085 else {
8186 let userDeposited = match getInteger(userDepositedKey(i.caller)) {
8287 case a: Int =>
8388 a
8489 case _ =>
8590 0
8691 }
8792 let totalDeposited = match getInteger(totalDepositedKey()) {
8893 case a: Int =>
8994 a
9095 case _ =>
9196 0
9297 }
9398 [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))
9499 then 0
95100 else toInt(earned(i.caller)))]
96101 }
97102
98103
99104
100105 @Callable(i)
101106 func withdraw () = {
102107 let userDeposited = match getInteger(userDepositedKey(i.caller)) {
103108 case a: Int =>
104109 a
105110 case _ =>
106111 0
107112 }
108113 let totalDeposited = match getInteger(totalDepositedKey()) {
109114 case a: Int =>
110115 a
111116 case _ =>
112117 0
113118 }
114119 let earnedTokens = toInt(earned(i.caller))
115120 if ((userDeposited == 0))
116121 then throw("empty deposit")
117122 else [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)]
118123 }
119124
120125
121126 @Verifier(tx)
122127 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
123128

github/deemru/w8io/026f985 
28.22 ms