tx · G8PPjDoVTucoiTTZmikHFVkxRAmUtf9aKmTzp9uKSVJz 3N1HdGqmcf4nVsUgmWiwB8p6p8ErWBmvQua: -0.01000000 Waves 2023.11.16 16:04 [2845975] smart account 3N1HdGqmcf4nVsUgmWiwB8p6p8ErWBmvQua > SELF 0.00000000 Waves
{ "type": 13, "id": "G8PPjDoVTucoiTTZmikHFVkxRAmUtf9aKmTzp9uKSVJz", "fee": 1000000, "feeAssetId": null, "timestamp": 1700139916894, "version": 2, "chainId": 84, "sender": "3N1HdGqmcf4nVsUgmWiwB8p6p8ErWBmvQua", "senderPublicKey": "JAEVvs5E9kGyXWx3YQaivUpUP3vb3pgr2eS6UrYr1A8P", "proofs": [ "4Qk3wezqf7wUPoUQUkoFMFDnByKn8MpFDYhWxvtfwaxNBoNEAc11tXEcxsM5W36ZiVXB2QhYUYTCsesiX5bUAtv5" ], "script": "base64:AAIFAAAAAAAAAAgIAhIAEgASAAAAAA4AAAAACE9XTkVSX1BLAQAAACD+9CsLFiFJC8RGtLCwzR0ek1aKw5ef/3Hp6vXrubt/IAAAAAALU1RBS0VfQVNTRVQBAAAAIPss+diV/WzAQQQ+1nCaM2epB5cN0dakuic5O0p9U6wiAAAAAApFQVJOX0FTU0VUAQAAACD7LPnYlf1swEEEPtZwmjNnqQeXDdHWpLonOTtKfVOsIgAAAAANVE9LRU5TX1BFUl9NUwAAAAAAAAAAAQAAAAADU0VQAgAAAAJfXwAAAAALREVOT01JTkFUT1IADeC2s6dkAAABAAAAEHVzZXJEZXBvc2l0ZWRLZXkAAAABAAAABHVzZXIJAAS5AAAAAgkABEwAAAACAgAAAAJ1ZAkABEwAAAACCQACWAAAAAEIBQAAAAR1c2VyAAAABWJ5dGVzBQAAAANuaWwFAAAAA1NFUAEAAAARdG90YWxEZXBvc2l0ZWRLZXkAAAAAAgAAAAJ0ZAEAAAANbGFzdFVwZGF0ZUtleQAAAAACAAAAAmx1AQAAABdyZXdhcmRQZXJUb2tlblN0b3JlZEtleQAAA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AAAWkAAAAGY2FsbGVyAAAAAAAAAAAABQAAAANuaWwAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAACQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAUAAAAIT1dORVJfUEv33ITa", "height": 2845975, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4Dqtd1ucyeBYQGnhd2rjxCgyLSiKGrYLdSKynpGHaN5A Next: 9aXKVK5LNruHXzZrUVaz5R8z93pEDHP4wjJRXXKKEPde Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let OWNER_PK = base58'JAEVvs5E9kGyXWx3YQaivUpUP3vb3pgr2eS6UrYr1A8P' | |
5 | + | ||
4 | 6 | let STAKE_ASSET = base58'HuV7L2uJ4v2SDS5xqZLWPHhimTUgEMKstmxwfBY17SX3' | |
5 | 7 | ||
6 | 8 | let EARN_ASSET = base58'HuV7L2uJ4v2SDS5xqZLWPHhimTUgEMKstmxwfBY17SX3' | |
124 | 126 | ||
125 | 127 | ||
126 | 128 | @Verifier(tx) | |
127 | - | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], | |
129 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], OWNER_PK) | |
128 | 130 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let OWNER_PK = base58'JAEVvs5E9kGyXWx3YQaivUpUP3vb3pgr2eS6UrYr1A8P' | |
5 | + | ||
4 | 6 | let STAKE_ASSET = base58'HuV7L2uJ4v2SDS5xqZLWPHhimTUgEMKstmxwfBY17SX3' | |
5 | 7 | ||
6 | 8 | let EARN_ASSET = base58'HuV7L2uJ4v2SDS5xqZLWPHhimTUgEMKstmxwfBY17SX3' | |
7 | 9 | ||
8 | 10 | let TOKENS_PER_MS = 1 | |
9 | 11 | ||
10 | 12 | let SEP = "__" | |
11 | 13 | ||
12 | 14 | let DENOMINATOR = 1000000000000000000 | |
13 | 15 | ||
14 | 16 | func userDepositedKey (user) = makeString(["ud", toBase58String(user.bytes)], SEP) | |
15 | 17 | ||
16 | 18 | ||
17 | 19 | func totalDepositedKey () = "td" | |
18 | 20 | ||
19 | 21 | ||
20 | 22 | func lastUpdateKey () = "lu" | |
21 | 23 | ||
22 | 24 | ||
23 | 25 | func rewardPerTokenStoredKey () = "rpts" | |
24 | 26 | ||
25 | 27 | ||
26 | 28 | func userRewardPerTokenPaidKey (user) = makeString(["urpd", toBase58String(user.bytes)], SEP) | |
27 | 29 | ||
28 | 30 | ||
29 | 31 | func userRewards (user) = makeString(["ur", toBase58String(user.bytes)], SEP) | |
30 | 32 | ||
31 | 33 | ||
32 | 34 | func calcRewardPerTokenStored () = { | |
33 | 35 | let totalDeposited = toBigInt( match getInteger(totalDepositedKey()) { | |
34 | 36 | case a: Int => | |
35 | 37 | a | |
36 | 38 | case _ => | |
37 | 39 | 0 | |
38 | 40 | }) | |
39 | 41 | let lastUpdate = toBigInt( match getInteger(lastUpdateKey()) { | |
40 | 42 | case a: Int => | |
41 | 43 | a | |
42 | 44 | case _ => | |
43 | 45 | lastBlock.timestamp | |
44 | 46 | }) | |
45 | 47 | let rewardPerTokenStored = parseBigIntValue( match getString(rewardPerTokenStoredKey()) { | |
46 | 48 | case a: String => | |
47 | 49 | a | |
48 | 50 | case _ => | |
49 | 51 | "0" | |
50 | 52 | }) | |
51 | 53 | if ((totalDeposited == toBigInt(0))) | |
52 | 54 | then rewardPerTokenStored | |
53 | 55 | else (rewardPerTokenStored + (((toBigInt(TOKENS_PER_MS) * (toBigInt(lastBlock.timestamp) - lastUpdate)) * toBigInt(DENOMINATOR)) / totalDeposited)) | |
54 | 56 | } | |
55 | 57 | ||
56 | 58 | ||
57 | 59 | func earned (user) = { | |
58 | 60 | let userDeposited = toBigInt( match getInteger(userDepositedKey(user)) { | |
59 | 61 | case a: Int => | |
60 | 62 | a | |
61 | 63 | case _ => | |
62 | 64 | 0 | |
63 | 65 | }) | |
64 | 66 | let userRewardPerTokenPaid = parseBigIntValue(getStringValue(userRewardPerTokenPaidKey(user))) | |
65 | 67 | let rewards = toBigInt( match getInteger(userRewards(user)) { | |
66 | 68 | case a: Int => | |
67 | 69 | a | |
68 | 70 | case _ => | |
69 | 71 | 0 | |
70 | 72 | }) | |
71 | 73 | (fraction(userDeposited, (calcRewardPerTokenStored() - userRewardPerTokenPaid), toBigInt(DENOMINATOR)) + rewards) | |
72 | 74 | } | |
73 | 75 | ||
74 | 76 | ||
75 | 77 | @Callable(i) | |
76 | 78 | func update () = [IntegerEntry(lastUpdateKey(), lastBlock.timestamp), StringEntry(rewardPerTokenStoredKey(), toString(calcRewardPerTokenStored()))] | |
77 | 79 | ||
78 | 80 | ||
79 | 81 | ||
80 | 82 | @Callable(i) | |
81 | 83 | func deposit () = if (if ((size(i.payments) != 1)) | |
82 | 84 | then true | |
83 | 85 | else (i.payments[0].assetId != STAKE_ASSET)) | |
84 | 86 | then throw("incorrect asset deposits") | |
85 | 87 | else { | |
86 | 88 | let userDeposited = match getInteger(userDepositedKey(i.caller)) { | |
87 | 89 | case a: Int => | |
88 | 90 | a | |
89 | 91 | case _ => | |
90 | 92 | 0 | |
91 | 93 | } | |
92 | 94 | let totalDeposited = match getInteger(totalDepositedKey()) { | |
93 | 95 | case a: Int => | |
94 | 96 | a | |
95 | 97 | case _ => | |
96 | 98 | 0 | |
97 | 99 | } | |
98 | 100 | [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)) | |
99 | 101 | then 0 | |
100 | 102 | else toInt(earned(i.caller)))] | |
101 | 103 | } | |
102 | 104 | ||
103 | 105 | ||
104 | 106 | ||
105 | 107 | @Callable(i) | |
106 | 108 | func withdraw () = { | |
107 | 109 | let userDeposited = match getInteger(userDepositedKey(i.caller)) { | |
108 | 110 | case a: Int => | |
109 | 111 | a | |
110 | 112 | case _ => | |
111 | 113 | 0 | |
112 | 114 | } | |
113 | 115 | let totalDeposited = match getInteger(totalDepositedKey()) { | |
114 | 116 | case a: Int => | |
115 | 117 | a | |
116 | 118 | case _ => | |
117 | 119 | 0 | |
118 | 120 | } | |
119 | 121 | let earnedTokens = toInt(earned(i.caller)) | |
120 | 122 | if ((userDeposited == 0)) | |
121 | 123 | then throw("empty deposit") | |
122 | 124 | 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)] | |
123 | 125 | } | |
124 | 126 | ||
125 | 127 | ||
126 | 128 | @Verifier(tx) | |
127 | - | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], | |
129 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], OWNER_PK) | |
128 | 130 |
github/deemru/w8io/026f985 27.65 ms ◑