tx · 38oUCppTN1697dWaSxEb5JqSRB3QHYHotB8y13y47m8o 3MrrZRV6F9ywSejcyd9foJV5ZWXRhiDD6yo: -0.03700000 Waves 2022.10.14 17:36 [2272146] smart account 3MrrZRV6F9ywSejcyd9foJV5ZWXRhiDD6yo > SELF 0.00000000 Waves
{ "type": 13, "id": "38oUCppTN1697dWaSxEb5JqSRB3QHYHotB8y13y47m8o", "fee": 3700000, "feeAssetId": null, "timestamp": 1665758239076, "version": 2, "chainId": 84, "sender": "3MrrZRV6F9ywSejcyd9foJV5ZWXRhiDD6yo", "senderPublicKey": "AzkmMXb1TBA8jfijtZ5hFHMEC6p5hm3e5prwCk1cTVCh", "proofs": [ "2y6LkVJ66NPGrFcYphQwYi542Lx51VEhmpjVSCkn7yVsfNp9V8SuTaWq2uYedmg4GjtrsEki7ACDRRUNXTTaV4TF" ], "script": "base64:BgIdCAISBAoCCAgSAwoBCBIAEgMKAQESABIAEgMKAQg4AA1rX3RvdGFsU3VwcGx5Ag1rX3RvdGFsU3VwcGx5AA9rX3Jld2FyZEJhbGFuY2UCD2tfcmV3YXJkQmFsYW5jZQANa19zd2FwQWRkcmVzcwINa19zd2FwQWRkcmVzcwAQa19sYXN0VXBkYXRlVGltZQIQa19sYXN0VXBkYXRlVGltZQAWa19yZXdhcmRQZXJUb2tlblN0b3JlZAIWa19yZXdhcmRQZXJUb2tlblN0b3JlZAAMa19yZXdhcmRSYXRlAgxrX3Jld2FyZFJhdGUADmtfcGVyaW9kRmluaXNoAg5rX3BlcmlvZEZpbmlzaAAJa19iYWxhbmNlAglrX2JhbGFuY2UAFGtfdXNlclJld2FyZFBlclRva2VuAhRrX3VzZXJSZXdhcmRQZXJUb2tlbgAMa191c2VyUmV3YXJkAgxrX3VzZXJSZXdhcmQADWtfaW5pdGlhbGl6ZWQCDWtfaW5pdGlhbGl6ZWQAFGtfY29vcmRpbmF0b3JBZGRyZXNzAhRrX2Nvb3JkaW5hdG9yQWRkcmVzcwARa19zdGFraW5nX2F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2luZ0FkZHJlc3MAAgVzdGFrZQUDbmlsCQDMCAIJAQ9BdHRhY2hlZFBheW1lbnQCCQEPZ292ZXJuYW5jZUFzc2V0AAULcmV3YXJkRGVsdGEFA25pbAMJAAACBQdkb1N0YWtlBQdkb1N0YWtlCQDOCAIJAM4IAgkAzggCCQEQdXBkYXRlUmV3YXJkUmF0ZQEFDW5ld1Jld2FyZFJhdGUJARp1cGRhdGVSZXdhcmRQZXJUb2tlblN0b3JlZAEFF25ld1Jld2FyZFBlclRva2VuU3RvcmVkCQETdXBkYXRlUmV3YXJkQmFsYW5jZQEFB19yZXdhcmQJAQp1cGRhdGVUaW1lAgUJdGltZXN0YW1wCQBkAgUJdGltZXN0YW1wBQhEVVJBVElPTgkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgFpAQt2aWV3X3Jld2FyZAEHX3N0YWtlcgQMc3Rha2VyRWFybmVkCAkBDHVwZGF0ZVJld2FyZAIFB19zdGFrZXIAAAJfMwkAAgEJAKQDAQUMc3Rha2VyRWFybmVkAQJ0eAEGdmVyaWZ5AAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAkBDmFkbWluUHVibGljS2V5APbOBaE=", "height": 2272146, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 96LbARFKoWchdvkfKGtFivVxhCAhBNZEm6entdLkM3gt Next: FARS8CStsiJ5UHkhXxGtM5poXeby4YJHo2K5aAVahN9Y Diff:
Old | New | Differences | |
---|---|---|---|
216 | 216 | if ((doAckRewards == doAckRewards)) | |
217 | 217 | then { | |
218 | 218 | let _staker = toString(i.caller) | |
219 | - | if (if (if ((_amount > balanceOf(_staker))) | |
220 | - | then true | |
221 | - | else (i.payments != nil)) | |
219 | + | if (if ((i.payments != nil)) | |
222 | 220 | then true | |
223 | 221 | else !(initialized())) | |
224 | 222 | then throw("Invalid unStake parameters") | |
225 | 223 | else { | |
226 | - | let $t072887453 = updateReward(_staker, 0) | |
227 | - | let newRewardPerTokenStored = $t072887453._1 | |
228 | - | let newLastUpdateTime = $t072887453._2 | |
229 | - | let stakerEarned = $t072887453._3 | |
230 | - | let stakerRewardPerTokenPaid = $t072887453._4 | |
231 | - | let doUnStake = invoke(stakingAddress(), "unStake", [_amount], nil) | |
232 | - | if ((doUnStake == doUnStake)) | |
233 | - | then ((((updateUserRewards(_staker, stakerEarned, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateBalance(_staker, -(_amount))) ++ [ScriptTransfer(i.caller, _amount, governanceAsset())]) | |
234 | - | else throw("Strict value is not equal to itself.") | |
224 | + | let $t072507415 = updateReward(_staker, 0) | |
225 | + | let newRewardPerTokenStored = $t072507415._1 | |
226 | + | let newLastUpdateTime = $t072507415._2 | |
227 | + | let stakerEarned = $t072507415._3 | |
228 | + | let stakerRewardPerTokenPaid = $t072507415._4 | |
229 | + | if ((_amount > (balanceOf(_staker) + stakerEarned))) | |
230 | + | then throw("Invalid unStake parameters") | |
231 | + | else { | |
232 | + | let doUnStake = invoke(stakingAddress(), "unStake", [_amount], nil) | |
233 | + | if ((doUnStake == doUnStake)) | |
234 | + | then { | |
235 | + | let rewardChange = if ((balanceOf(_staker) >= _amount)) | |
236 | + | then 0 | |
237 | + | else (_amount - balanceOf(_staker)) | |
238 | + | let balanceChange = if ((balanceOf(_staker) >= _amount)) | |
239 | + | then _amount | |
240 | + | else balanceOf(_staker) | |
241 | + | (((((updateUserRewards(_staker, (stakerEarned - rewardChange), stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateBalance(_staker, -(balanceChange))) ++ updateRewardBalance(-(rewardChange))) ++ [ScriptTransfer(i.caller, _amount, governanceAsset())]) | |
242 | + | } | |
243 | + | else throw("Strict value is not equal to itself.") | |
244 | + | } | |
235 | 245 | } | |
236 | 246 | } | |
237 | 247 | else throw("Strict value is not equal to itself.") | |
245 | 255 | if ((doAckRewards == doAckRewards)) | |
246 | 256 | then { | |
247 | 257 | let _staker = toString(i.caller) | |
248 | - | let $ | |
249 | - | let newRewardPerTokenStored = $ | |
250 | - | let newLastUpdateTime = $ | |
251 | - | let stakerEarned = $ | |
252 | - | let stakerRewardPerTokenPaid = $ | |
258 | + | let $t087538898 = updateReward(_staker, 0) | |
259 | + | let newRewardPerTokenStored = $t087538898._1 | |
260 | + | let newLastUpdateTime = $t087538898._2 | |
261 | + | let stakerEarned = $t087538898._3 | |
262 | + | let stakerRewardPerTokenPaid = $t087538898._4 | |
253 | 263 | if (if ((0 >= stakerEarned)) | |
254 | 264 | then true | |
255 | 265 | else !(initialized())) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let k_totalSupply = "k_totalSupply" | |
5 | 5 | ||
6 | 6 | let k_rewardBalance = "k_rewardBalance" | |
7 | 7 | ||
8 | 8 | let k_swapAddress = "k_swapAddress" | |
9 | 9 | ||
10 | 10 | let k_lastUpdateTime = "k_lastUpdateTime" | |
11 | 11 | ||
12 | 12 | let k_rewardPerTokenStored = "k_rewardPerTokenStored" | |
13 | 13 | ||
14 | 14 | let k_rewardRate = "k_rewardRate" | |
15 | 15 | ||
16 | 16 | let k_periodFinish = "k_periodFinish" | |
17 | 17 | ||
18 | 18 | let k_balance = "k_balance" | |
19 | 19 | ||
20 | 20 | let k_userRewardPerToken = "k_userRewardPerToken" | |
21 | 21 | ||
22 | 22 | let k_userReward = "k_userReward" | |
23 | 23 | ||
24 | 24 | let k_initialized = "k_initialized" | |
25 | 25 | ||
26 | 26 | let k_coordinatorAddress = "k_coordinatorAddress" | |
27 | 27 | ||
28 | 28 | let k_staking_address = "k_staking_address" | |
29 | 29 | ||
30 | 30 | let k_governance_asset = "k_gov_asset" | |
31 | 31 | ||
32 | 32 | let k_quote_asset = "k_quote_asset" | |
33 | 33 | ||
34 | 34 | let k_admin_public_key = "k_admin_public_key" | |
35 | 35 | ||
36 | 36 | let k_admin_address = "k_admin_address" | |
37 | 37 | ||
38 | 38 | func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set") | |
39 | 39 | ||
40 | 40 | ||
41 | 41 | func adminAddress () = addressFromString(getStringValue(coordinator(), k_admin_address)) | |
42 | 42 | ||
43 | 43 | ||
44 | 44 | func adminPublicKey () = fromBase58String(getStringValue(coordinator(), k_admin_public_key)) | |
45 | 45 | ||
46 | 46 | ||
47 | 47 | func governanceAsset () = fromBase58String(getStringValue(coordinator(), k_governance_asset)) | |
48 | 48 | ||
49 | 49 | ||
50 | 50 | func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset)) | |
51 | 51 | ||
52 | 52 | ||
53 | 53 | func stakingAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_staking_address)), "Staking not set") | |
54 | 54 | ||
55 | 55 | ||
56 | 56 | let DECIMAL_UNIT = (1 * (((((((10 * 10) * 10) * 10) * 10) * 10) * 10) * 10)) | |
57 | 57 | ||
58 | 58 | let DURATION = ((60 * 60) * 24) | |
59 | 59 | ||
60 | 60 | let NO_ADDRESS = "" | |
61 | 61 | ||
62 | 62 | let NO_STAKER = 0 | |
63 | 63 | ||
64 | 64 | func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN) | |
65 | 65 | ||
66 | 66 | ||
67 | 67 | func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN) | |
68 | 68 | ||
69 | 69 | ||
70 | 70 | func abs (_x) = if ((_x > 0)) | |
71 | 71 | then _x | |
72 | 72 | else -(_x) | |
73 | 73 | ||
74 | 74 | ||
75 | 75 | func minv (_x,_y) = if ((_x > _y)) | |
76 | 76 | then _y | |
77 | 77 | else _x | |
78 | 78 | ||
79 | 79 | ||
80 | 80 | func toCompositeKey (_key,_address) = ((_key + "_") + _address) | |
81 | 81 | ||
82 | 82 | ||
83 | 83 | func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k)) | |
84 | 84 | ||
85 | 85 | ||
86 | 86 | func int0 (k) = valueOrElse(getInteger(this, k), 0) | |
87 | 87 | ||
88 | 88 | ||
89 | 89 | func totalSupply () = int0(k_totalSupply) | |
90 | 90 | ||
91 | 91 | ||
92 | 92 | func rewardPerTokenStored () = int0(k_rewardPerTokenStored) | |
93 | 93 | ||
94 | 94 | ||
95 | 95 | func lastUpdateTime () = int0(k_lastUpdateTime) | |
96 | 96 | ||
97 | 97 | ||
98 | 98 | func rewardRate () = int0(k_rewardRate) | |
99 | 99 | ||
100 | 100 | ||
101 | 101 | func periodFinish () = int0(k_periodFinish) | |
102 | 102 | ||
103 | 103 | ||
104 | 104 | func rewardBalance () = int0(k_rewardBalance) | |
105 | 105 | ||
106 | 106 | ||
107 | 107 | func swapAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(this, k_swapAddress), "Now swap address")), "Invalid swap address") | |
108 | 108 | ||
109 | 109 | ||
110 | 110 | func rewards (_staker) = int0(toCompositeKey(k_userReward, _staker)) | |
111 | 111 | ||
112 | 112 | ||
113 | 113 | func userRewardPerTokenPaid (_staker) = int0(toCompositeKey(k_userRewardPerToken, _staker)) | |
114 | 114 | ||
115 | 115 | ||
116 | 116 | func balanceOf (_staker) = int0(toCompositeKey(k_balance, _staker)) | |
117 | 117 | ||
118 | 118 | ||
119 | 119 | func initialized () = valueOrElse(getBoolean(this, k_initialized), false) | |
120 | 120 | ||
121 | 121 | ||
122 | 122 | func updateRewardBalance (_delta) = [IntegerEntry(k_rewardBalance, (rewardBalance() + _delta))] | |
123 | 123 | ||
124 | 124 | ||
125 | 125 | func updateRewardRate (_rewardRate) = [IntegerEntry(k_rewardRate, _rewardRate)] | |
126 | 126 | ||
127 | 127 | ||
128 | 128 | func updateTime (_lastUpdateTime,_periodFinish) = [IntegerEntry(k_lastUpdateTime, _lastUpdateTime), IntegerEntry(k_periodFinish, _periodFinish)] | |
129 | 129 | ||
130 | 130 | ||
131 | 131 | func updateRewardPerTokenStored (_rewardPerTokenStored) = [IntegerEntry(k_rewardPerTokenStored, _rewardPerTokenStored)] | |
132 | 132 | ||
133 | 133 | ||
134 | 134 | func updateUserRewards (_staker,_reward,_userRewardPerToken) = [IntegerEntry(toCompositeKey(k_userReward, _staker), _reward), IntegerEntry(toCompositeKey(k_userRewardPerToken, _staker), _userRewardPerToken)] | |
135 | 135 | ||
136 | 136 | ||
137 | 137 | func updateBalance (_staker,_delta) = [IntegerEntry(toCompositeKey(k_balance, _staker), (balanceOf(_staker) + _delta)), IntegerEntry(k_totalSupply, (totalSupply() + _delta))] | |
138 | 138 | ||
139 | 139 | ||
140 | 140 | func currentTimestampSec () = (lastBlock.timestamp / 1000) | |
141 | 141 | ||
142 | 142 | ||
143 | 143 | func lastTimeRewardApplicable () = minv(currentTimestampSec(), periodFinish()) | |
144 | 144 | ||
145 | 145 | ||
146 | 146 | func rewardPerToken (_balanceDelta) = if (((totalSupply() + _balanceDelta) == 0)) | |
147 | 147 | then rewardPerTokenStored() | |
148 | 148 | else { | |
149 | 149 | let timeInterval = (lastTimeRewardApplicable() - lastUpdateTime()) | |
150 | 150 | let actualTimeInterval = if ((0 > timeInterval)) | |
151 | 151 | then 0 | |
152 | 152 | else timeInterval | |
153 | 153 | let diff = divd((rewardRate() * actualTimeInterval), (totalSupply() + _balanceDelta)) | |
154 | 154 | (rewardPerTokenStored() + diff) | |
155 | 155 | } | |
156 | 156 | ||
157 | 157 | ||
158 | 158 | func earned (_staker,_balanceDelta) = { | |
159 | 159 | let rewardDelta = (rewardPerToken(_balanceDelta) - userRewardPerTokenPaid(_staker)) | |
160 | 160 | (muld((balanceOf(_staker) + _balanceDelta), rewardDelta) + rewards(_staker)) | |
161 | 161 | } | |
162 | 162 | ||
163 | 163 | ||
164 | 164 | func updateReward (_staker,_balanceDelta) = { | |
165 | 165 | let newRewardPerTokenStored = rewardPerToken(_balanceDelta) | |
166 | 166 | let newLastUpdateTime = currentTimestampSec() | |
167 | 167 | let $t052055397 = if ((_staker != "")) | |
168 | 168 | then $Tuple2(earned(_staker, _balanceDelta), newRewardPerTokenStored) | |
169 | 169 | else $Tuple2(0, 0) | |
170 | 170 | let stakerEarned = $t052055397._1 | |
171 | 171 | let stakerRewardPerTokenPaid = $t052055397._2 | |
172 | 172 | $Tuple4(newRewardPerTokenStored, newLastUpdateTime, stakerEarned, stakerRewardPerTokenPaid) | |
173 | 173 | } | |
174 | 174 | ||
175 | 175 | ||
176 | 176 | @Callable(i) | |
177 | 177 | func initialize (_coordinator,_swapAddress) = if (initialized()) | |
178 | 178 | then throw("Already initialized") | |
179 | 179 | else [StringEntry(k_coordinatorAddress, _coordinator), StringEntry(k_swapAddress, _swapAddress), BooleanEntry(k_initialized, true)] | |
180 | 180 | ||
181 | 181 | ||
182 | 182 | ||
183 | 183 | @Callable(i) | |
184 | 184 | func setSwap (_swapAddress) = if ((i.caller != adminAddress())) | |
185 | 185 | then throw("Invalid setSwap params") | |
186 | 186 | else [StringEntry(k_swapAddress, _swapAddress)] | |
187 | 187 | ||
188 | 188 | ||
189 | 189 | ||
190 | 190 | @Callable(i) | |
191 | 191 | func stake () = { | |
192 | 192 | let _staker = toString(i.caller) | |
193 | 193 | let _amount = i.payments[0].amount | |
194 | 194 | if (if ((i.payments[0].assetId != governanceAsset())) | |
195 | 195 | then true | |
196 | 196 | else !(initialized())) | |
197 | 197 | then throw("Invalid call to stake") | |
198 | 198 | else { | |
199 | 199 | let $t063396504 = updateReward(_staker, 0) | |
200 | 200 | let newRewardPerTokenStored = $t063396504._1 | |
201 | 201 | let newLastUpdateTime = $t063396504._2 | |
202 | 202 | let stakerEarned = $t063396504._3 | |
203 | 203 | let stakerRewardPerTokenPaid = $t063396504._4 | |
204 | 204 | let doStake = invoke(stakingAddress(), "stake", nil, [AttachedPayment(governanceAsset(), _amount)]) | |
205 | 205 | if ((doStake == doStake)) | |
206 | 206 | then (((updateUserRewards(_staker, stakerEarned, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateBalance(_staker, _amount)) | |
207 | 207 | else throw("Strict value is not equal to itself.") | |
208 | 208 | } | |
209 | 209 | } | |
210 | 210 | ||
211 | 211 | ||
212 | 212 | ||
213 | 213 | @Callable(i) | |
214 | 214 | func unStake (_amount) = { | |
215 | 215 | let doAckRewards = invoke(this, "ackRewards", nil, nil) | |
216 | 216 | if ((doAckRewards == doAckRewards)) | |
217 | 217 | then { | |
218 | 218 | let _staker = toString(i.caller) | |
219 | - | if (if (if ((_amount > balanceOf(_staker))) | |
220 | - | then true | |
221 | - | else (i.payments != nil)) | |
219 | + | if (if ((i.payments != nil)) | |
222 | 220 | then true | |
223 | 221 | else !(initialized())) | |
224 | 222 | then throw("Invalid unStake parameters") | |
225 | 223 | else { | |
226 | - | let $t072887453 = updateReward(_staker, 0) | |
227 | - | let newRewardPerTokenStored = $t072887453._1 | |
228 | - | let newLastUpdateTime = $t072887453._2 | |
229 | - | let stakerEarned = $t072887453._3 | |
230 | - | let stakerRewardPerTokenPaid = $t072887453._4 | |
231 | - | let doUnStake = invoke(stakingAddress(), "unStake", [_amount], nil) | |
232 | - | if ((doUnStake == doUnStake)) | |
233 | - | then ((((updateUserRewards(_staker, stakerEarned, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateBalance(_staker, -(_amount))) ++ [ScriptTransfer(i.caller, _amount, governanceAsset())]) | |
234 | - | else throw("Strict value is not equal to itself.") | |
224 | + | let $t072507415 = updateReward(_staker, 0) | |
225 | + | let newRewardPerTokenStored = $t072507415._1 | |
226 | + | let newLastUpdateTime = $t072507415._2 | |
227 | + | let stakerEarned = $t072507415._3 | |
228 | + | let stakerRewardPerTokenPaid = $t072507415._4 | |
229 | + | if ((_amount > (balanceOf(_staker) + stakerEarned))) | |
230 | + | then throw("Invalid unStake parameters") | |
231 | + | else { | |
232 | + | let doUnStake = invoke(stakingAddress(), "unStake", [_amount], nil) | |
233 | + | if ((doUnStake == doUnStake)) | |
234 | + | then { | |
235 | + | let rewardChange = if ((balanceOf(_staker) >= _amount)) | |
236 | + | then 0 | |
237 | + | else (_amount - balanceOf(_staker)) | |
238 | + | let balanceChange = if ((balanceOf(_staker) >= _amount)) | |
239 | + | then _amount | |
240 | + | else balanceOf(_staker) | |
241 | + | (((((updateUserRewards(_staker, (stakerEarned - rewardChange), stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateBalance(_staker, -(balanceChange))) ++ updateRewardBalance(-(rewardChange))) ++ [ScriptTransfer(i.caller, _amount, governanceAsset())]) | |
242 | + | } | |
243 | + | else throw("Strict value is not equal to itself.") | |
244 | + | } | |
235 | 245 | } | |
236 | 246 | } | |
237 | 247 | else throw("Strict value is not equal to itself.") | |
238 | 248 | } | |
239 | 249 | ||
240 | 250 | ||
241 | 251 | ||
242 | 252 | @Callable(i) | |
243 | 253 | func withdrawRewards () = { | |
244 | 254 | let doAckRewards = invoke(this, "ackRewards", nil, nil) | |
245 | 255 | if ((doAckRewards == doAckRewards)) | |
246 | 256 | then { | |
247 | 257 | let _staker = toString(i.caller) | |
248 | - | let $ | |
249 | - | let newRewardPerTokenStored = $ | |
250 | - | let newLastUpdateTime = $ | |
251 | - | let stakerEarned = $ | |
252 | - | let stakerRewardPerTokenPaid = $ | |
258 | + | let $t087538898 = updateReward(_staker, 0) | |
259 | + | let newRewardPerTokenStored = $t087538898._1 | |
260 | + | let newLastUpdateTime = $t087538898._2 | |
261 | + | let stakerEarned = $t087538898._3 | |
262 | + | let stakerRewardPerTokenPaid = $t087538898._4 | |
253 | 263 | if (if ((0 >= stakerEarned)) | |
254 | 264 | then true | |
255 | 265 | else !(initialized())) | |
256 | 266 | then throw("No farming reward") | |
257 | 267 | else { | |
258 | 268 | let doUnStake = invoke(stakingAddress(), "unStake", [stakerEarned], nil) | |
259 | 269 | if ((doUnStake == doUnStake)) | |
260 | 270 | then ((((updateUserRewards(_staker, 0, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateRewardBalance(-(stakerEarned))) ++ [ScriptTransfer(i.caller, stakerEarned, governanceAsset())]) | |
261 | 271 | else throw("Strict value is not equal to itself.") | |
262 | 272 | } | |
263 | 273 | } | |
264 | 274 | else throw("Strict value is not equal to itself.") | |
265 | 275 | } | |
266 | 276 | ||
267 | 277 | ||
268 | 278 | ||
269 | 279 | @Callable(i) | |
270 | 280 | func ackRewards () = { | |
271 | 281 | let _rewardAmount = invoke(stakingAddress(), "computeReward", [toString(this)], nil) | |
272 | 282 | if ((_rewardAmount == _rewardAmount)) | |
273 | 283 | then { | |
274 | 284 | let rewardAmount = match _rewardAmount { | |
275 | 285 | case t: Int => | |
276 | 286 | t | |
277 | 287 | case _ => | |
278 | 288 | throw("Reward amount not a number") | |
279 | 289 | } | |
280 | 290 | if ((rewardAmount == 0)) | |
281 | 291 | then nil | |
282 | 292 | else { | |
283 | 293 | let doClaimRewards = invoke(stakingAddress(), "withdrawRewards", nil, nil) | |
284 | 294 | if ((doClaimRewards == doClaimRewards)) | |
285 | 295 | then { | |
286 | 296 | let rewardsAmount = assetBalance(this, quoteAsset()) | |
287 | 297 | let doSwap = invoke(swapAddress(), "swap", [toBase58String(governanceAsset()), 0], [AttachedPayment(quoteAsset(), rewardsAmount)]) | |
288 | 298 | if ((doSwap == doSwap)) | |
289 | 299 | then { | |
290 | 300 | let rewardDelta = assetBalance(this, governanceAsset()) | |
291 | 301 | if ((rewardDelta == rewardDelta)) | |
292 | 302 | then if ((0 >= rewardDelta)) | |
293 | 303 | then throw("Invalid ackRewards params") | |
294 | 304 | else { | |
295 | 305 | let _reward = rewardDelta | |
296 | 306 | let newRewardPerTokenStored = updateReward(NO_ADDRESS, NO_STAKER)._1 | |
297 | 307 | let timestamp = currentTimestampSec() | |
298 | 308 | let newRewardRate = if ((timestamp > periodFinish())) | |
299 | 309 | then (_reward / DURATION) | |
300 | 310 | else { | |
301 | 311 | let remainingTime = (periodFinish() - timestamp) | |
302 | 312 | let leftover = (rewardRate() * remainingTime) | |
303 | 313 | ((_reward + leftover) / DURATION) | |
304 | 314 | } | |
305 | 315 | let doStake = invoke(stakingAddress(), "stake", nil, [AttachedPayment(governanceAsset(), rewardDelta)]) | |
306 | 316 | if ((doStake == doStake)) | |
307 | 317 | then (((updateRewardRate(newRewardRate) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateRewardBalance(_reward)) ++ updateTime(timestamp, (timestamp + DURATION))) | |
308 | 318 | else throw("Strict value is not equal to itself.") | |
309 | 319 | } | |
310 | 320 | else throw("Strict value is not equal to itself.") | |
311 | 321 | } | |
312 | 322 | else throw("Strict value is not equal to itself.") | |
313 | 323 | } | |
314 | 324 | else throw("Strict value is not equal to itself.") | |
315 | 325 | } | |
316 | 326 | } | |
317 | 327 | else throw("Strict value is not equal to itself.") | |
318 | 328 | } | |
319 | 329 | ||
320 | 330 | ||
321 | 331 | ||
322 | 332 | @Callable(i) | |
323 | 333 | func view_reward (_staker) = { | |
324 | 334 | let stakerEarned = updateReward(_staker, 0)._3 | |
325 | 335 | throw(toString(stakerEarned)) | |
326 | 336 | } | |
327 | 337 | ||
328 | 338 | ||
329 | 339 | @Verifier(tx) | |
330 | 340 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey()) | |
331 | 341 |
github/deemru/w8io/026f985 36.61 ms ◑