tx · 9WuKFsBKfaTj5KYgpfCURDoNxAEUhqxnm2p4jvSWL1b2

3MxG4YrGTaE2HCEXdf9gFbHUXZnYGz8GLKP:  -0.03200000 Waves

2022.06.12 08:24 [2092736] smart account 3MxG4YrGTaE2HCEXdf9gFbHUXZnYGz8GLKP > SELF 0.00000000 Waves

{ "type": 13, "id": "9WuKFsBKfaTj5KYgpfCURDoNxAEUhqxnm2p4jvSWL1b2", "fee": 3200000, "feeAssetId": null, "timestamp": 1655011558591, "version": 2, "chainId": 84, "sender": "3MxG4YrGTaE2HCEXdf9gFbHUXZnYGz8GLKP", "senderPublicKey": "BQNvsnp8X7CUPEnwNfCXuivgYCpP9uAwoRVA1Hb4Gov3", "proofs": [ "4QZHYpcAECjF9LJ5Wb95kednxkcU97UvYbrSJqBMDNVUGH18i8rm2qp6CPeLZeL2ENiGjgq3BJYimS8FRzKxf8fP" ], "script": "base64:AAIFAAAAAAAAABIIAhIAEgMKAQESABIAEgMKAQgAAAAmAAAAAA1rX3RvdGFsU3VwcGx5AgAAAA1rX3RvdGFsU3VwcGx5AAAAABBrX2xhc3RVcGRhdGVUaW1lAgAAABBrX2xhc3RVcGRhdGVUaW1lAAAAABZrX3Jld2FyZFBlclRva2VuU3RvcmVkAgAAABZrX3Jld2FyZFBlclRva2VuU3RvcmVkAAAAAAxrX3Jld2FyZFJhdGUCAAAADGtfcmV3YXJkUmF0ZQAAAAAOa19wZXJpb2RGaW5pc2gCAAAADmtfcGVyaW9kRmluaXNoAAAAAAlrX2JhbGFuY2UCAAAACWtfYmFsYW5jZQAAAAAUa191c2VyUmV3YXJkUGVyVG9rZW4CAAAAFGtfdXNlclJld2FyZFBlclRva2VuAAAAAAxrX3VzZXJSZXdhcmQCAAAADGtfdXNlclJld2FyZAAAAAANQURNSU5fQUREUkVTUwkBAAAAB0FkZHJlc3MAAAABAQAAABoBVJxZXUDM/NfdUcw/nzLBhDapbI3ghaPxbgAAAAAEVVNETgEAAAAg93bq9/eDymXbbhPuAjvP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AB19zdGFrZXIEAAAADHN0YWtlckVhcm5lZAgJAQAAAAx1cGRhdGVSZXdhcmQAAAACBQAAAAdfc3Rha2VyCQEAAAAJYmFsYW5jZU9mAAAAAQUAAAAHX3N0YWtlcgAAAAJfMwkAAAIAAAABCQABpAAAAAEFAAAADHN0YWtlckVhcm5lZAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5FiOoIA==", "height": 2092736, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
OldNewDifferences
1-# no script
1+{-# STDLIB_VERSION 5 #-}
2+{-# SCRIPT_TYPE ACCOUNT #-}
3+{-# CONTENT_TYPE DAPP #-}
4+let k_totalSupply = "k_totalSupply"
5+
6+let k_lastUpdateTime = "k_lastUpdateTime"
7+
8+let k_rewardPerTokenStored = "k_rewardPerTokenStored"
9+
10+let k_rewardRate = "k_rewardRate"
11+
12+let k_periodFinish = "k_periodFinish"
13+
14+let k_balance = "k_balance"
15+
16+let k_userRewardPerToken = "k_userRewardPerToken"
17+
18+let k_userReward = "k_userReward"
19+
20+let ADMIN_ADDRESS = Address(base58'3N4AnEz3rJ5K4SUoqy3Xu4FYYTLViyuCvSR')
21+
22+let USDN = base58'HezsdQuRDtzksAYUy97gfhKy7Z1NW2uXYSHA3bgqenNZ'
23+
24+let TSN = base58'HL6bTgU1e5SoaSDxp9PV1Bj8WvKAk8jReNwgax44d5S6'
25+
26+let DECIMAL_UNIT = (1 * (((((10 * 10) * 10) * 10) * 10) * 10))
27+
28+let DURATION = ((60 * 60) * 24)
29+
30+let NO_ADDDRESS = ""
31+
32+let NO_STAKER = 0
33+
34+func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN)
35+
36+
37+func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN)
38+
39+
40+func abs (_x) = if ((_x > 0))
41+ then _x
42+ else -(_x)
43+
44+
45+func toCompositeKey (_key,_address) = ((_key + "_") + _address)
46+
47+
48+func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k))
49+
50+
51+func int0 (k) = valueOrElse(getInteger(this, k), 0)
52+
53+
54+func totalSupply () = int0(k_totalSupply)
55+
56+
57+func rewardPerTokenStored () = int0(k_rewardPerTokenStored)
58+
59+
60+func lastUpdateTime () = int0(k_lastUpdateTime)
61+
62+
63+func rewardRate () = int0(k_rewardRate)
64+
65+
66+func periodFinish () = int0(k_periodFinish)
67+
68+
69+func rewards (_staker) = int0(toCompositeKey(k_userReward, _staker))
70+
71+
72+func userRewardPerTokenPaid (_staker) = int0(toCompositeKey(k_userRewardPerToken, _staker))
73+
74+
75+func balanceOf (_staker) = int0(toCompositeKey(k_balance, _staker))
76+
77+
78+func updateRewardRate (_rewardRate) = [IntegerEntry(k_rewardRate, _rewardRate)]
79+
80+
81+func updateTime (_lastUpdateTime,_periodFinish) = [IntegerEntry(k_lastUpdateTime, _lastUpdateTime), IntegerEntry(k_periodFinish, _periodFinish)]
82+
83+
84+func updateRewardPerTokenStored (_rewardPerTokenStored) = [IntegerEntry(k_rewardPerTokenStored, _rewardPerTokenStored)]
85+
86+
87+func updateUserRewards (_staker,_reward,_userRewardPerToken) = [IntegerEntry(toCompositeKey(k_userReward, _staker), _reward), IntegerEntry(toCompositeKey(k_userRewardPerToken, _staker), _userRewardPerToken)]
88+
89+
90+func updateBalance (_staker,_delta) = [IntegerEntry(toCompositeKey(k_balance, _staker), (balanceOf(_staker) + _delta))]
91+
92+
93+func currentTimestampSec () = (lastBlock.timestamp / 1000)
94+
95+
96+func rewardPerToken () = if ((totalSupply() == 0))
97+ then rewardPerTokenStored()
98+ else (rewardPerTokenStored() + (((currentTimestampSec() - lastUpdateTime()) * rewardRate()) / totalSupply()))
99+
100+
101+func earned (_staker,_balance) = {
102+ let rewardDelta = (rewardPerToken() - userRewardPerTokenPaid(_staker))
103+ ((_balance * rewardDelta) + rewards(_staker))
104+ }
105+
106+
107+func updateReward (_staker,_balance) = {
108+ let newRewardPerTokenStored = rewardPerToken()
109+ let newLastUpdateTime = currentTimestampSec()
110+ let $t033173490 = if ((_staker != ""))
111+ then $Tuple2(earned(_staker, _balance), newRewardPerTokenStored)
112+ else $Tuple2(0, 0)
113+ let stakerEarned = $t033173490._1
114+ let stakerRewardPerTokenPaid = $t033173490._2
115+ $Tuple4(newRewardPerTokenStored, newLastUpdateTime, stakerEarned, stakerRewardPerTokenPaid)
116+ }
117+
118+
119+@Callable(i)
120+func stake () = {
121+ let _staker = toString(i.caller)
122+ let _amount = i.payments[0].amount
123+ if ((i.payments[0].assetId != TSN))
124+ then throw("Invalid staking asset")
125+ else {
126+ let $t038003982 = updateReward(_staker, (balanceOf(_staker) + _amount))
127+ let newRewardPerTokenStored = $t038003982._1
128+ let newLastUpdateTime = $t038003982._2
129+ let stakerEarned = $t038003982._3
130+ let stakerRewardPerTokenPaid = $t038003982._4
131+ (((updateUserRewards(_staker, 0, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateBalance(_staker, _amount))
132+ }
133+ }
134+
135+
136+
137+@Callable(i)
138+func unStake (_amount) = {
139+ let _staker = toString(i.caller)
140+ if ((_amount > balanceOf(_staker)))
141+ then throw("Invalid balance")
142+ else {
143+ let $t043974579 = updateReward(_staker, (balanceOf(_staker) - _amount))
144+ let newRewardPerTokenStored = $t043974579._1
145+ let newLastUpdateTime = $t043974579._2
146+ let stakerEarned = $t043974579._3
147+ let stakerRewardPerTokenPaid = $t043974579._4
148+ ((((updateUserRewards(_staker, 0, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateBalance(_staker, -(_amount))) ++ [ScriptTransfer(i.caller, _amount, TSN)])
149+ }
150+ }
151+
152+
153+
154+@Callable(i)
155+func withdrawRewards () = {
156+ let _staker = toString(i.caller)
157+ let $t049945146 = updateReward(_staker, balanceOf(_staker))
158+ let newRewardPerTokenStored = $t049945146._1
159+ let newLastUpdateTime = $t049945146._2
160+ let stakerEarned = $t049945146._3
161+ let stakerRewardPerTokenPaid = $t049945146._4
162+ if ((0 >= stakerEarned))
163+ then throw("No reward")
164+ else (((updateUserRewards(_staker, 0, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ [ScriptTransfer(i.caller, stakerEarned, USDN)])
165+ }
166+
167+
168+
169+@Callable(i)
170+func addRewards () = if ((i.payments[0].assetId != USDN))
171+ then throw("Invaliid addRewards params")
172+ else {
173+ let _reward = i.payments[0].amount
174+ let newRewardPerTokenStored = updateReward(NO_ADDDRESS, NO_STAKER)._1
175+ let timestamp = currentTimestampSec()
176+ let newRewardRate = if ((timestamp > periodFinish()))
177+ then (_reward / DURATION)
178+ else {
179+ let remainingTime = (periodFinish() - timestamp)
180+ let leftover = (rewardRate() * remainingTime)
181+ ((_reward + leftover) / DURATION)
182+ }
183+ ((updateRewardRate(newRewardRate) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(timestamp, (timestamp + DURATION)))
184+ }
185+
186+
187+
188+@Callable(i)
189+func view_reward (_staker) = {
190+ let stakerEarned = updateReward(_staker, balanceOf(_staker))._3
191+ throw(toString(stakerEarned))
192+ }
193+
194+
195+@Verifier(tx)
196+func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
197+

github/deemru/w8io/169f3d6 
26.16 ms