tx · BS2Kj2aJ7qKMCqBgpk31hUX8YUitXf1eQKcb1MNa9tmA

3N1HdGqmcf4nVsUgmWiwB8p6p8ErWBmvQua:  -0.01000000 Waves

2023.11.16 02:46 [2845149] smart account 3N1HdGqmcf4nVsUgmWiwB8p6p8ErWBmvQua > SELF 0.00000000 Waves

{ "type": 13, "id": "BS2Kj2aJ7qKMCqBgpk31hUX8YUitXf1eQKcb1MNa9tmA", "fee": 1000000, "feeAssetId": null, "timestamp": 1700091998464, "version": 2, "chainId": 84, "sender": "3N1HdGqmcf4nVsUgmWiwB8p6p8ErWBmvQua", "senderPublicKey": "JAEVvs5E9kGyXWx3YQaivUpUP3vb3pgr2eS6UrYr1A8P", "proofs": [ "3PBSWuoC8XfTYApHeHoD9ZHMYcJaydPuh3GFcc2NQSijtuBedGNEfnjWT4qSMfe94XVt3XC3i45HiHfUiGdZsUKU" ], "script": "base64:AAIFAAAAAAAAAAYIAhIAEgAAAAAOAAAAAAtTVEFLRV9BU1NFVAEAAAAg+yz52JX9bMBBBD7WcJozZ6kHlw3R1qS6Jzk7Sn1TrCIAAAAACkVBUk5fQVNTRVQBAAAAIPss+diV/WzAQQQ+1nCaM2epB5cN0dakuic5O0p9U6wiAAAAAA1UT0tFTlNfUEVSX01TAAAAAAAAAAABAAAAAANTRVACAAAAAl9fAAAAAAtERU5PTUlOQVRPUgAN4Lazp2QAAAEAAAAQdXNlckRlcG9zaXRlZEtleQAAAAEAAAAEdXNlcgkABLkAAAACCQAETAAAAAICAAAAAnVkCQAETAAAAAIJAAJYAAAAAQgFAAAABHVzZXIAAAAFYnl0ZXMFAAAAA25pbAUAAAADU0VQAQAAAA11c2VyVXBkYXRlS2V5AAAAAQAAAAR1c2VyCQAEuQAAAAIJAARMAAAAAgIAAAACdXUJAARMAAAAAgkAAlgAAAABCAUAAAAEdXNlcgAAAAVieXRlcwUAAAADbmlsBQAAAANTRVABAAAAEXRvdGFsRGVwb3NpdGVkS2V5AAAAAAIAAAACdGQBAAAADWx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AAAABmNhbGxlcgUAAAAMZWFybmVkVG9rZW5zBQAAAApFQVJOX0FTU0VUCQAETAAAAAIJAQAAAAtTdHJpbmdFbnRyeQAAAAIJAQAAABdyZXdhcmRQZXJUb2tlblN0b3JlZEtleQAAAAAJAAGmAAAAAQkBAAAAGGNhbGNSZXdhcmRQZXJUb2tlblN0b3JlZAAAAAAJAARMAAAAAgkBAAAAC1N0cmluZ0VudHJ5AAAAAgkBAAAAGXVzZXJSZXdhcmRQZXJUb2tlblBhaWRLZXkAAAABCAUAAAABaQAAAAZjYWxsZXIJAAGmAAAAAQkBAAAAGGNhbGNSZXdhcmRQZXJUb2tlblN0b3JlZAAAAAAJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAQAAAAt1c2VyUmV3YXJkcwAAAAEIBQAAAAFpAAAABmNhbGxlcgAAAAAAAAAAAAUAAAADbmlsAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXk/SLWU", "height": 2845149, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: hah8iB6uvj4swZWNkirWF9SkAwovKTnrUK474VyKF2s Next: 2Ttcy21yJr8BQHRSCEaF63MYFf1nxa8ryBUW86J9z1UM 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(getIntegerValue(userDepositedKey(user)))
6262 let userRewardPerTokenPaid = toBigInt(getIntegerValue(userRewardPerTokenPaidKey(user)))
6363 let rewards = toBigInt( match getInteger(userRewards(user)) {
6464 case a: Int =>
6565 a
6666 case _ =>
6767 0
6868 })
6969 (fraction(userDeposited, (calcRewardPerTokenStored() - userRewardPerTokenPaid), toBigInt(DENOMINATOR)) + rewards)
7070 }
7171
7272
7373 @Callable(i)
7474 func deposit () = if (if ((size(i.payments) != 1))
7575 then true
7676 else (i.payments[0].assetId != STAKE_ASSET))
7777 then throw("incorrect asset deposits")
7878 else {
7979 let userDeposited = match getInteger(userDepositedKey(i.caller)) {
8080 case a: Int =>
8181 a
8282 case _ =>
8383 0
8484 }
8585 let totalDeposited = match getInteger(totalDepositedKey()) {
8686 case a: Int =>
8787 a
8888 case _ =>
8989 0
9090 }
9191 [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), toInt(earned(i.caller)))]
9292 }
9393
9494
9595
9696 @Callable(i)
9797 func withdraw () = {
9898 let userDeposited = match getInteger(userDepositedKey(i.caller)) {
9999 case a: Int =>
100100 a
101101 case _ =>
102102 0
103103 }
104104 let totalDeposited = match getInteger(totalDepositedKey()) {
105105 case a: Int =>
106106 a
107107 case _ =>
108108 0
109109 }
110110 let earnedTokens = toInt(earned(i.caller))
111111 [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)]
112112 }
113113
114114
115115 @Verifier(tx)
116116 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
117117

github/deemru/w8io/026f985 
24.82 ms