tx · FZPZdns2cWgvkQjdyteNN77MTtKLjxnJosJeijrK53zZ 3NBEuUXKfGqe1ZKUfx8b8YsguJKYLhy2bTJ: -0.03700000 Waves 2023.02.11 09:44 [2444613] smart account 3NBEuUXKfGqe1ZKUfx8b8YsguJKYLhy2bTJ > SELF 0.00000000 Waves
{ "type": 13, "id": "FZPZdns2cWgvkQjdyteNN77MTtKLjxnJosJeijrK53zZ", "fee": 3700000, "feeAssetId": null, "timestamp": 1676097865076, "version": 2, "chainId": 84, "sender": "3NBEuUXKfGqe1ZKUfx8b8YsguJKYLhy2bTJ", "senderPublicKey": "2NgVCitn1k18yzwhrzdQXHDEygzSkjbXS4A1koTt14db", "proofs": [ "YzXxyQEgKufT6oWkXjBkzCZHCjCvcMsRSyCUihkwUmqQA4UEzaWZZYVYqQDAgZfYLjogFADUWDXvJuRRrJ1oZJe" ], "script": "base64:BgIxCAISAwoBCBIAEgMKAQESABIAEgASAwoBARIDCgEBEgASABIDCgEIEgMKAQgSAwoBCFQADWtfdG90YWxTdXBwbHkCDWtfdG90YWxTdXBwbHkAD2tfcmV3YXJkQmFsYW5jZQIPa19yZXdhcmRCYWxhbmNlAA9rX2xvY2tlZEJhbGFuY2UCD2tfbG9ja2VkQmFsYW5jZQANa19mcmVlQmFsYW5jZQINa19mcmVlQmFsYW5jZQAGa19yYXRlAgZrX3JhdGUAEGtfbGFzdFVwZGF0ZVRpbWUCEGtfbGFzdFVwZGF0ZVRpbWUAFmtfcmV3YXJkUGVyVG9rZW5TdG9yZWQCFmtfcmV3YXJkUGVyVG9rZW5TdG9yZWQADGtfcmV3YXJkUmF0ZQIMa19yZXdhcmRSYXRlAA5rX3BlcmlvZEZpbmlzaAIOa19wZXJpb2RGaW5pc2gAFGtfdXNlclJld2FyZFBlclRva2VuAhRrX3VzZXJSZXdhcmRQZXJUb2tlbgAMa191c2VyUmV3YXJkAgxrX3VzZXJSZXdhcmQACWtfYmFsYW5jZQIJa19iYWxhbmNlAA5rX2F2ZXJhZ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3BXUXYqoF97Ef Next: 2QoWuWcA2umuD9Yu51yKg4ebM7PwtNseQGWN3tSmTdMY Diff:
Old | New | Differences | |
---|---|---|---|
173 | 173 | func getWithdrawLimitLeft (_staker) = { | |
174 | 174 | let currentDate = currentTimestamp() | |
175 | 175 | let lastWithdrawDate = lastWithdrawnDate(_staker) | |
176 | - | let $t049645228 = if (((currentDate - lastWithdrawDate) > WITHDRAW_PERIOD)) | |
177 | - | then $Tuple2(currentDate, withdrawLimit(_staker)) | |
178 | - | else $Tuple2(lastWithdrawDate, (withdrawLimit(_staker) - withdrawnInPeriod(_staker))) | |
179 | - | let newLastWithdrawnDate = $t049645228._1 | |
180 | - | let withdrawLimitLeft = $t049645228._2 | |
181 | - | $Tuple2(newLastWithdrawnDate, withdrawLimitLeft) | |
176 | + | let $t049645285 = if (((currentDate - lastWithdrawDate) > WITHDRAW_PERIOD)) | |
177 | + | then $Tuple3(currentDate, withdrawLimit(_staker), 0) | |
178 | + | else $Tuple3(lastWithdrawDate, (withdrawLimit(_staker) - withdrawnInPeriod(_staker)), withdrawnInPeriod(_staker)) | |
179 | + | let newLastWithdrawnDate = $t049645285._1 | |
180 | + | let withdrawLimitLeft = $t049645285._2 | |
181 | + | let alreadyWithdrawnInPeriod = $t049645285._3 | |
182 | + | $Tuple3(newLastWithdrawnDate, withdrawLimitLeft, alreadyWithdrawnInPeriod) | |
182 | 183 | } | |
183 | 184 | ||
184 | 185 | ||
214 | 215 | func updateReward (_staker,_balanceDelta) = { | |
215 | 216 | let newRewardPerTokenStored = rewardPerToken(_balanceDelta) | |
216 | 217 | let newLastUpdateTime = currentTimestampSec() | |
217 | - | let $ | |
218 | + | let $t065076699 = if ((_staker != "")) | |
218 | 219 | then $Tuple2(earned(_staker, _balanceDelta), newRewardPerTokenStored) | |
219 | 220 | else $Tuple2(0, 0) | |
220 | - | let stakerEarned = $ | |
221 | - | let stakerRewardPerTokenPaid = $ | |
221 | + | let stakerEarned = $t065076699._1 | |
222 | + | let stakerRewardPerTokenPaid = $t065076699._2 | |
222 | 223 | $Tuple4(newRewardPerTokenStored, newLastUpdateTime, stakerEarned, stakerRewardPerTokenPaid) | |
223 | 224 | } | |
224 | 225 | ||
292 | 293 | else !(initialized())) | |
293 | 294 | then throw("Invalid call to stake") | |
294 | 295 | else { | |
295 | - | let $ | |
296 | - | let newRewardPerTokenStored = $ | |
297 | - | let newLastUpdateTime = $ | |
298 | - | let stakerEarned = $ | |
299 | - | let stakerRewardPerTokenPaid = $ | |
296 | + | let $t0995210181 = updateReward(_staker, 0) | |
297 | + | let newRewardPerTokenStored = $t0995210181._1 | |
298 | + | let newLastUpdateTime = $t0995210181._2 | |
299 | + | let stakerEarned = $t0995210181._3 | |
300 | + | let stakerRewardPerTokenPaid = $t0995210181._4 | |
300 | 301 | let currentRate = rate() | |
301 | 302 | let prevAverageRate = averageRate(_staker) | |
302 | 303 | let vAmount = divd(_amount, currentRate) | |
323 | 324 | else !(initialized())) | |
324 | 325 | then throw("Invalid call to unStake") | |
325 | 326 | else { | |
326 | - | let $t01145111667 = updateReward(_staker, 0) | |
327 | - | let newRewardPerTokenStored = $t01145111667._1 | |
328 | - | let newLastUpdateTime = $t01145111667._2 | |
329 | - | let stakerEarned = $t01145111667._3 | |
330 | - | let stakerRewardPerTokenPaid = $t01145111667._4 | |
331 | - | let $t01167411815 = getWithdrawLimitLeft(_staker) | |
332 | - | let newLastWithdrawnDate = $t01167411815._1 | |
333 | - | let withdrawLimitLeft = $t01167411815._2 | |
327 | + | let $t01153411750 = updateReward(_staker, 0) | |
328 | + | let newRewardPerTokenStored = $t01153411750._1 | |
329 | + | let newLastUpdateTime = $t01153411750._2 | |
330 | + | let stakerEarned = $t01153411750._3 | |
331 | + | let stakerRewardPerTokenPaid = $t01153411750._4 | |
332 | + | let $t01175711924 = getWithdrawLimitLeft(_staker) | |
333 | + | let newLastWithdrawnDate = $t01175711924._1 | |
334 | + | let withdrawLimitLeft = $t01175711924._2 | |
335 | + | let alreadyWithdrawnInPeriod = $t01175711924._3 | |
334 | 336 | let vAmount = divd(amountOfQuoteAsset, rate()) | |
335 | 337 | if ((vAmount > withdrawLimitLeft)) | |
336 | 338 | then throw("Invalid call to unStake: withdraw over limit") | |
337 | 339 | else { | |
338 | - | let newWithdrawnInPeriod = ( | |
340 | + | let newWithdrawnInPeriod = (alreadyWithdrawnInPeriod + vAmount) | |
339 | 341 | if ((amountOfQuoteAsset > freeBalance())) | |
340 | 342 | then throw("Invalid call to unStake: balance too low") | |
341 | 343 | else { | |
353 | 355 | @Callable(i) | |
354 | 356 | func withdrawRewards () = { | |
355 | 357 | let _staker = toString(i.caller) | |
356 | - | let $ | |
357 | - | let newRewardPerTokenStored = $ | |
358 | - | let newLastUpdateTime = $ | |
359 | - | let stakerEarned = $ | |
360 | - | let stakerRewardPerTokenPaid = $ | |
358 | + | let $t01326013405 = updateReward(_staker, 0) | |
359 | + | let newRewardPerTokenStored = $t01326013405._1 | |
360 | + | let newLastUpdateTime = $t01326013405._2 | |
361 | + | let stakerEarned = $t01326013405._3 | |
362 | + | let stakerRewardPerTokenPaid = $t01326013405._4 | |
361 | 363 | if (if ((0 >= stakerEarned)) | |
362 | 364 | then true | |
363 | 365 | 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_lockedBalance = "k_lockedBalance" | |
9 | 9 | ||
10 | 10 | let k_freeBalance = "k_freeBalance" | |
11 | 11 | ||
12 | 12 | let k_rate = "k_rate" | |
13 | 13 | ||
14 | 14 | let k_lastUpdateTime = "k_lastUpdateTime" | |
15 | 15 | ||
16 | 16 | let k_rewardPerTokenStored = "k_rewardPerTokenStored" | |
17 | 17 | ||
18 | 18 | let k_rewardRate = "k_rewardRate" | |
19 | 19 | ||
20 | 20 | let k_periodFinish = "k_periodFinish" | |
21 | 21 | ||
22 | 22 | let k_userRewardPerToken = "k_userRewardPerToken" | |
23 | 23 | ||
24 | 24 | let k_userReward = "k_userReward" | |
25 | 25 | ||
26 | 26 | let k_balance = "k_balance" | |
27 | 27 | ||
28 | 28 | let k_average_rate = "k_average_rate" | |
29 | 29 | ||
30 | 30 | let k_withdraw_limit = "k_withdraw_limit" | |
31 | 31 | ||
32 | 32 | let k_last_withdraw_date = "k_last_withdraw_date" | |
33 | 33 | ||
34 | 34 | let k_withdraw_in_period = "k_withdraw_in_period" | |
35 | 35 | ||
36 | 36 | let k_initialized = "k_initialized" | |
37 | 37 | ||
38 | 38 | let k_coordinatorAddress = "k_coordinatorAddress" | |
39 | 39 | ||
40 | 40 | let k_amm = "k_amm" | |
41 | 41 | ||
42 | 42 | let k_governance_asset = "k_gov_asset" | |
43 | 43 | ||
44 | 44 | let k_quote_asset = "k_quote_asset" | |
45 | 45 | ||
46 | 46 | let k_admin_address = "k_admin_address" | |
47 | 47 | ||
48 | 48 | let k_manager_address = "k_manager_address" | |
49 | 49 | ||
50 | 50 | let k_collateral_address = "k_collateral_address" | |
51 | 51 | ||
52 | 52 | func toCompositeKey (_key,_address) = ((_key + "_") + _address) | |
53 | 53 | ||
54 | 54 | ||
55 | 55 | func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set") | |
56 | 56 | ||
57 | 57 | ||
58 | 58 | func isWhitelist (_address) = valueOrElse(getBoolean(coordinator(), toCompositeKey(k_amm, _address)), false) | |
59 | 59 | ||
60 | 60 | ||
61 | 61 | func governanceAsset () = fromBase58String(getStringValue(coordinator(), k_governance_asset)) | |
62 | 62 | ||
63 | 63 | ||
64 | 64 | func adminAddress () = addressFromString(valueOrErrorMessage(getString(coordinator(), k_admin_address), "Admin address not set")) | |
65 | 65 | ||
66 | 66 | ||
67 | 67 | func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset)) | |
68 | 68 | ||
69 | 69 | ||
70 | 70 | func managerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_manager_address)), "Manager not set") | |
71 | 71 | ||
72 | 72 | ||
73 | 73 | let DECIMAL_UNIT = (1 * (((((((10 * 10) * 10) * 10) * 10) * 10) * 10) * 10)) | |
74 | 74 | ||
75 | 75 | let DURATION = (((7 * 60) * 60) * 24) | |
76 | 76 | ||
77 | 77 | let NO_ADDRESS = "" | |
78 | 78 | ||
79 | 79 | let NO_STAKER = 0 | |
80 | 80 | ||
81 | 81 | func usdnFromDecimals (_amount) = (_amount / 100) | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | func usdnToDecimals (_amount) = (_amount * 100) | |
85 | 85 | ||
86 | 86 | ||
87 | 87 | func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN) | |
88 | 88 | ||
89 | 89 | ||
90 | 90 | func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN) | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | func abs (_x) = if ((_x > 0)) | |
94 | 94 | then _x | |
95 | 95 | else -(_x) | |
96 | 96 | ||
97 | 97 | ||
98 | 98 | func minv (_x,_y) = if ((_x > _y)) | |
99 | 99 | then _y | |
100 | 100 | else _x | |
101 | 101 | ||
102 | 102 | ||
103 | 103 | let WITHDRAW_PERIOD = (86400 * 1000) | |
104 | 104 | ||
105 | 105 | let WITHDRAW_PER_PERIOD = divd((1 * DECIMAL_UNIT), (4 * DECIMAL_UNIT)) | |
106 | 106 | ||
107 | 107 | func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k)) | |
108 | 108 | ||
109 | 109 | ||
110 | 110 | func int0 (k) = valueOrElse(getInteger(this, k), 0) | |
111 | 111 | ||
112 | 112 | ||
113 | 113 | func int1 (k) = valueOrElse(getInteger(this, k), DECIMAL_UNIT) | |
114 | 114 | ||
115 | 115 | ||
116 | 116 | func totalSupply () = int0(k_totalSupply) | |
117 | 117 | ||
118 | 118 | ||
119 | 119 | func rate () = int1(k_rate) | |
120 | 120 | ||
121 | 121 | ||
122 | 122 | func balanceOf (_staker) = int0(toCompositeKey(k_balance, _staker)) | |
123 | 123 | ||
124 | 124 | ||
125 | 125 | func averageRate (_staker) = int0(toCompositeKey(k_average_rate, _staker)) | |
126 | 126 | ||
127 | 127 | ||
128 | 128 | func withdrawLimit (_staker) = int0(toCompositeKey(k_withdraw_limit, _staker)) | |
129 | 129 | ||
130 | 130 | ||
131 | 131 | func withdrawnInPeriod (_staker) = int0(toCompositeKey(k_withdraw_in_period, _staker)) | |
132 | 132 | ||
133 | 133 | ||
134 | 134 | func lastWithdrawnDate (_staker) = int0(toCompositeKey(k_last_withdraw_date, _staker)) | |
135 | 135 | ||
136 | 136 | ||
137 | 137 | func freeBalance () = int0(k_freeBalance) | |
138 | 138 | ||
139 | 139 | ||
140 | 140 | func lockedBalance () = int0(k_lockedBalance) | |
141 | 141 | ||
142 | 142 | ||
143 | 143 | func rewardPerTokenStored () = int0(k_rewardPerTokenStored) | |
144 | 144 | ||
145 | 145 | ||
146 | 146 | func lastUpdateTime () = int0(k_lastUpdateTime) | |
147 | 147 | ||
148 | 148 | ||
149 | 149 | func rewardRate () = int0(k_rewardRate) | |
150 | 150 | ||
151 | 151 | ||
152 | 152 | func periodFinish () = int0(k_periodFinish) | |
153 | 153 | ||
154 | 154 | ||
155 | 155 | func rewardBalance () = int0(k_rewardBalance) | |
156 | 156 | ||
157 | 157 | ||
158 | 158 | func rewards (_staker) = int0(toCompositeKey(k_userReward, _staker)) | |
159 | 159 | ||
160 | 160 | ||
161 | 161 | func userRewardPerTokenPaid (_staker) = int0(toCompositeKey(k_userRewardPerToken, _staker)) | |
162 | 162 | ||
163 | 163 | ||
164 | 164 | func initialized () = valueOrElse(getBoolean(this, k_initialized), false) | |
165 | 165 | ||
166 | 166 | ||
167 | 167 | func currentTimestamp () = lastBlock.timestamp | |
168 | 168 | ||
169 | 169 | ||
170 | 170 | func currentTimestampSec () = (currentTimestamp() / 1000) | |
171 | 171 | ||
172 | 172 | ||
173 | 173 | func getWithdrawLimitLeft (_staker) = { | |
174 | 174 | let currentDate = currentTimestamp() | |
175 | 175 | let lastWithdrawDate = lastWithdrawnDate(_staker) | |
176 | - | let $t049645228 = if (((currentDate - lastWithdrawDate) > WITHDRAW_PERIOD)) | |
177 | - | then $Tuple2(currentDate, withdrawLimit(_staker)) | |
178 | - | else $Tuple2(lastWithdrawDate, (withdrawLimit(_staker) - withdrawnInPeriod(_staker))) | |
179 | - | let newLastWithdrawnDate = $t049645228._1 | |
180 | - | let withdrawLimitLeft = $t049645228._2 | |
181 | - | $Tuple2(newLastWithdrawnDate, withdrawLimitLeft) | |
176 | + | let $t049645285 = if (((currentDate - lastWithdrawDate) > WITHDRAW_PERIOD)) | |
177 | + | then $Tuple3(currentDate, withdrawLimit(_staker), 0) | |
178 | + | else $Tuple3(lastWithdrawDate, (withdrawLimit(_staker) - withdrawnInPeriod(_staker)), withdrawnInPeriod(_staker)) | |
179 | + | let newLastWithdrawnDate = $t049645285._1 | |
180 | + | let withdrawLimitLeft = $t049645285._2 | |
181 | + | let alreadyWithdrawnInPeriod = $t049645285._3 | |
182 | + | $Tuple3(newLastWithdrawnDate, withdrawLimitLeft, alreadyWithdrawnInPeriod) | |
182 | 183 | } | |
183 | 184 | ||
184 | 185 | ||
185 | 186 | func computeNewRate (_amountOfQuoteAsset) = { | |
186 | 187 | let newRate = if ((totalSupply() > 0)) | |
187 | 188 | then divd((freeBalance() + _amountOfQuoteAsset), totalSupply()) | |
188 | 189 | else DECIMAL_UNIT | |
189 | 190 | newRate | |
190 | 191 | } | |
191 | 192 | ||
192 | 193 | ||
193 | 194 | func lastTimeRewardApplicable () = minv(currentTimestampSec(), periodFinish()) | |
194 | 195 | ||
195 | 196 | ||
196 | 197 | func rewardPerToken (_balanceDelta) = if (((totalSupply() + _balanceDelta) == 0)) | |
197 | 198 | then rewardPerTokenStored() | |
198 | 199 | else { | |
199 | 200 | let timeInterval = (lastTimeRewardApplicable() - lastUpdateTime()) | |
200 | 201 | let actualTimeInterval = if ((0 > timeInterval)) | |
201 | 202 | then 0 | |
202 | 203 | else timeInterval | |
203 | 204 | let diff = divd((rewardRate() * actualTimeInterval), (totalSupply() + _balanceDelta)) | |
204 | 205 | (rewardPerTokenStored() + diff) | |
205 | 206 | } | |
206 | 207 | ||
207 | 208 | ||
208 | 209 | func earned (_staker,_balanceDelta) = { | |
209 | 210 | let rewardDelta = (rewardPerToken(_balanceDelta) - userRewardPerTokenPaid(_staker)) | |
210 | 211 | (muld((balanceOf(_staker) + _balanceDelta), rewardDelta) + rewards(_staker)) | |
211 | 212 | } | |
212 | 213 | ||
213 | 214 | ||
214 | 215 | func updateReward (_staker,_balanceDelta) = { | |
215 | 216 | let newRewardPerTokenStored = rewardPerToken(_balanceDelta) | |
216 | 217 | let newLastUpdateTime = currentTimestampSec() | |
217 | - | let $ | |
218 | + | let $t065076699 = if ((_staker != "")) | |
218 | 219 | then $Tuple2(earned(_staker, _balanceDelta), newRewardPerTokenStored) | |
219 | 220 | else $Tuple2(0, 0) | |
220 | - | let stakerEarned = $ | |
221 | - | let stakerRewardPerTokenPaid = $ | |
221 | + | let stakerEarned = $t065076699._1 | |
222 | + | let stakerRewardPerTokenPaid = $t065076699._2 | |
222 | 223 | $Tuple4(newRewardPerTokenStored, newLastUpdateTime, stakerEarned, stakerRewardPerTokenPaid) | |
223 | 224 | } | |
224 | 225 | ||
225 | 226 | ||
226 | 227 | func updateUserBalance (_user,_change) = [IntegerEntry(toCompositeKey(k_balance, _user), (balanceOf(_user) + _change))] | |
227 | 228 | ||
228 | 229 | ||
229 | 230 | func setUserWithdrawLimit (_user,_rate) = [IntegerEntry(toCompositeKey(k_withdraw_limit, _user), _rate)] | |
230 | 231 | ||
231 | 232 | ||
232 | 233 | func setUserAverageRate (_user,_rate) = [IntegerEntry(toCompositeKey(k_average_rate, _user), _rate)] | |
233 | 234 | ||
234 | 235 | ||
235 | 236 | func updateFreeBalance (_change) = { | |
236 | 237 | let balance = freeBalance() | |
237 | 238 | if (((balance + _change) >= 0)) | |
238 | 239 | then [IntegerEntry(k_freeBalance, (balance + _change))] | |
239 | 240 | else throw(((("Vault: can not update free balance. Balance: " + toString(balance)) + " change: ") + toString(_change))) | |
240 | 241 | } | |
241 | 242 | ||
242 | 243 | ||
243 | 244 | func updateLockedBalance (_change) = { | |
244 | 245 | let balance = lockedBalance() | |
245 | 246 | if (((balance + _change) >= 0)) | |
246 | 247 | then [IntegerEntry(k_lockedBalance, (balance + _change))] | |
247 | 248 | else throw(((("Vault: can not update locked balance. Balance: " + toString(balance)) + " change: ") + toString(_change))) | |
248 | 249 | } | |
249 | 250 | ||
250 | 251 | ||
251 | 252 | func updateTotalSupply (_change) = [IntegerEntry(k_totalSupply, (totalSupply() + _change))] | |
252 | 253 | ||
253 | 254 | ||
254 | 255 | func updateRate (_rate) = [IntegerEntry(k_rate, _rate)] | |
255 | 256 | ||
256 | 257 | ||
257 | 258 | func setUserWithdrawParams (_user,_lastWithdrawDate,_withdrawn) = [IntegerEntry(toCompositeKey(k_last_withdraw_date, _user), _lastWithdrawDate), IntegerEntry(toCompositeKey(k_withdraw_in_period, _user), _withdrawn)] | |
258 | 259 | ||
259 | 260 | ||
260 | 261 | func updateRewardBalance (_delta) = [IntegerEntry(k_rewardBalance, (rewardBalance() + _delta))] | |
261 | 262 | ||
262 | 263 | ||
263 | 264 | func updateRewardRate (_rewardRate) = [IntegerEntry(k_rewardRate, _rewardRate)] | |
264 | 265 | ||
265 | 266 | ||
266 | 267 | func updateTime (_lastUpdateTime,_periodFinish) = [IntegerEntry(k_lastUpdateTime, _lastUpdateTime), IntegerEntry(k_periodFinish, _periodFinish)] | |
267 | 268 | ||
268 | 269 | ||
269 | 270 | func updateRewardPerTokenStored (_rewardPerTokenStored) = [IntegerEntry(k_rewardPerTokenStored, _rewardPerTokenStored)] | |
270 | 271 | ||
271 | 272 | ||
272 | 273 | func updateUserRewards (_staker,_reward,_userRewardPerToken) = [IntegerEntry(toCompositeKey(k_userReward, _staker), _reward), IntegerEntry(toCompositeKey(k_userRewardPerToken, _staker), _userRewardPerToken)] | |
273 | 274 | ||
274 | 275 | ||
275 | 276 | @Callable(i) | |
276 | 277 | func initialize (_coordinator) = if (if (initialized()) | |
277 | 278 | then true | |
278 | 279 | else (i.caller != this)) | |
279 | 280 | then throw("Unable to initialize") | |
280 | 281 | else [StringEntry(k_coordinatorAddress, toString(valueOrErrorMessage(addressFromString(_coordinator), "Invalid coordinator address"))), BooleanEntry(k_initialized, true)] | |
281 | 282 | ||
282 | 283 | ||
283 | 284 | ||
284 | 285 | @Callable(i) | |
285 | 286 | func stake () = { | |
286 | 287 | let _staker = toString(i.caller) | |
287 | 288 | let _amount = usdnToDecimals(i.payments[0].amount) | |
288 | 289 | if (if (if ((i.payments[0].assetId != quoteAsset())) | |
289 | 290 | then true | |
290 | 291 | else (size(i.payments) != 1)) | |
291 | 292 | then true | |
292 | 293 | else !(initialized())) | |
293 | 294 | then throw("Invalid call to stake") | |
294 | 295 | else { | |
295 | - | let $ | |
296 | - | let newRewardPerTokenStored = $ | |
297 | - | let newLastUpdateTime = $ | |
298 | - | let stakerEarned = $ | |
299 | - | let stakerRewardPerTokenPaid = $ | |
296 | + | let $t0995210181 = updateReward(_staker, 0) | |
297 | + | let newRewardPerTokenStored = $t0995210181._1 | |
298 | + | let newLastUpdateTime = $t0995210181._2 | |
299 | + | let stakerEarned = $t0995210181._3 | |
300 | + | let stakerRewardPerTokenPaid = $t0995210181._4 | |
300 | 301 | let currentRate = rate() | |
301 | 302 | let prevAverageRate = averageRate(_staker) | |
302 | 303 | let vAmount = divd(_amount, currentRate) | |
303 | 304 | let newAverageRate = divd((muld(vAmount, currentRate) + muld(balanceOf(_staker), prevAverageRate)), (vAmount + balanceOf(_staker))) | |
304 | 305 | let newTotalBalance = (vAmount + balanceOf(_staker)) | |
305 | 306 | let newWithdrawLimit = muld(newTotalBalance, WITHDRAW_PER_PERIOD) | |
306 | 307 | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), usdnFromDecimals(_amount))]) | |
307 | 308 | if ((stake == stake)) | |
308 | 309 | then (((((((updateUserRewards(_staker, stakerEarned, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateFreeBalance(_amount)) ++ updateUserBalance(_staker, vAmount)) ++ setUserAverageRate(_staker, newAverageRate)) ++ setUserWithdrawLimit(_staker, newWithdrawLimit)) ++ updateTotalSupply(vAmount)) | |
309 | 310 | else throw("Strict value is not equal to itself.") | |
310 | 311 | } | |
311 | 312 | } | |
312 | 313 | ||
313 | 314 | ||
314 | 315 | ||
315 | 316 | @Callable(i) | |
316 | 317 | func unStake (_amount) = { | |
317 | 318 | let _staker = toString(i.caller) | |
318 | 319 | let amountOfQuoteAsset = usdnToDecimals(_amount) | |
319 | 320 | if (if (if ((i.payments != nil)) | |
320 | 321 | then true | |
321 | 322 | else (0 >= amountOfQuoteAsset)) | |
322 | 323 | then true | |
323 | 324 | else !(initialized())) | |
324 | 325 | then throw("Invalid call to unStake") | |
325 | 326 | else { | |
326 | - | let $t01145111667 = updateReward(_staker, 0) | |
327 | - | let newRewardPerTokenStored = $t01145111667._1 | |
328 | - | let newLastUpdateTime = $t01145111667._2 | |
329 | - | let stakerEarned = $t01145111667._3 | |
330 | - | let stakerRewardPerTokenPaid = $t01145111667._4 | |
331 | - | let $t01167411815 = getWithdrawLimitLeft(_staker) | |
332 | - | let newLastWithdrawnDate = $t01167411815._1 | |
333 | - | let withdrawLimitLeft = $t01167411815._2 | |
327 | + | let $t01153411750 = updateReward(_staker, 0) | |
328 | + | let newRewardPerTokenStored = $t01153411750._1 | |
329 | + | let newLastUpdateTime = $t01153411750._2 | |
330 | + | let stakerEarned = $t01153411750._3 | |
331 | + | let stakerRewardPerTokenPaid = $t01153411750._4 | |
332 | + | let $t01175711924 = getWithdrawLimitLeft(_staker) | |
333 | + | let newLastWithdrawnDate = $t01175711924._1 | |
334 | + | let withdrawLimitLeft = $t01175711924._2 | |
335 | + | let alreadyWithdrawnInPeriod = $t01175711924._3 | |
334 | 336 | let vAmount = divd(amountOfQuoteAsset, rate()) | |
335 | 337 | if ((vAmount > withdrawLimitLeft)) | |
336 | 338 | then throw("Invalid call to unStake: withdraw over limit") | |
337 | 339 | else { | |
338 | - | let newWithdrawnInPeriod = ( | |
340 | + | let newWithdrawnInPeriod = (alreadyWithdrawnInPeriod + vAmount) | |
339 | 341 | if ((amountOfQuoteAsset > freeBalance())) | |
340 | 342 | then throw("Invalid call to unStake: balance too low") | |
341 | 343 | else { | |
342 | 344 | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), usdnFromDecimals(amountOfQuoteAsset)], nil) | |
343 | 345 | if ((unstake == unstake)) | |
344 | 346 | then (((((((updateUserRewards(_staker, stakerEarned, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateFreeBalance(-(amountOfQuoteAsset))) ++ updateUserBalance(_staker, -(vAmount))) ++ updateTotalSupply(-(vAmount))) ++ setUserWithdrawParams(_staker, newLastWithdrawnDate, newWithdrawnInPeriod)) ++ [ScriptTransfer(i.caller, usdnFromDecimals(amountOfQuoteAsset), quoteAsset())]) | |
345 | 347 | else throw("Strict value is not equal to itself.") | |
346 | 348 | } | |
347 | 349 | } | |
348 | 350 | } | |
349 | 351 | } | |
350 | 352 | ||
351 | 353 | ||
352 | 354 | ||
353 | 355 | @Callable(i) | |
354 | 356 | func withdrawRewards () = { | |
355 | 357 | let _staker = toString(i.caller) | |
356 | - | let $ | |
357 | - | let newRewardPerTokenStored = $ | |
358 | - | let newLastUpdateTime = $ | |
359 | - | let stakerEarned = $ | |
360 | - | let stakerRewardPerTokenPaid = $ | |
358 | + | let $t01326013405 = updateReward(_staker, 0) | |
359 | + | let newRewardPerTokenStored = $t01326013405._1 | |
360 | + | let newLastUpdateTime = $t01326013405._2 | |
361 | + | let stakerEarned = $t01326013405._3 | |
362 | + | let stakerRewardPerTokenPaid = $t01326013405._4 | |
361 | 363 | if (if ((0 >= stakerEarned)) | |
362 | 364 | then true | |
363 | 365 | else !(initialized())) | |
364 | 366 | then throw("No reward: Vault") | |
365 | 367 | else ((((updateUserRewards(_staker, 0, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateRewardBalance(-(stakerEarned))) ++ [ScriptTransfer(i.caller, stakerEarned, governanceAsset())]) | |
366 | 368 | } | |
367 | 369 | ||
368 | 370 | ||
369 | 371 | ||
370 | 372 | @Callable(i) | |
371 | 373 | func addFree () = { | |
372 | 374 | let _amount = usdnToDecimals(i.payments[0].amount) | |
373 | 375 | if (if (if (if ((i.payments[0].assetId != quoteAsset())) | |
374 | 376 | then true | |
375 | 377 | else (size(i.payments) != 1)) | |
376 | 378 | then true | |
377 | 379 | else !(initialized())) | |
378 | 380 | then true | |
379 | 381 | else !(if (isWhitelist(toString(i.caller))) | |
380 | 382 | then true | |
381 | 383 | else (i.caller == adminAddress()))) | |
382 | 384 | then throw("Invalid addFree params") | |
383 | 385 | else { | |
384 | 386 | let newRate = computeNewRate(_amount) | |
385 | 387 | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), usdnFromDecimals(_amount))]) | |
386 | 388 | if ((stake == stake)) | |
387 | 389 | then (updateFreeBalance(_amount) ++ updateRate(newRate)) | |
388 | 390 | else throw("Strict value is not equal to itself.") | |
389 | 391 | } | |
390 | 392 | } | |
391 | 393 | ||
392 | 394 | ||
393 | 395 | ||
394 | 396 | @Callable(i) | |
395 | 397 | func addLocked () = { | |
396 | 398 | let _amount = usdnToDecimals(i.payments[0].amount) | |
397 | 399 | if (if (if (if ((i.payments[0].assetId != quoteAsset())) | |
398 | 400 | then true | |
399 | 401 | else (size(i.payments) != 1)) | |
400 | 402 | then true | |
401 | 403 | else !(initialized())) | |
402 | 404 | then true | |
403 | 405 | else !(if (isWhitelist(toString(i.caller))) | |
404 | 406 | then true | |
405 | 407 | else (i.caller == adminAddress()))) | |
406 | 408 | then throw("Invalid addLocked params") | |
407 | 409 | else { | |
408 | 410 | let unstake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), usdnFromDecimals(_amount))]) | |
409 | 411 | if ((unstake == unstake)) | |
410 | 412 | then updateLockedBalance(_amount) | |
411 | 413 | else throw("Strict value is not equal to itself.") | |
412 | 414 | } | |
413 | 415 | } | |
414 | 416 | ||
415 | 417 | ||
416 | 418 | ||
417 | 419 | @Callable(i) | |
418 | 420 | func exchangeFreeAndLocked (_amount) = if (if (!(initialized())) | |
419 | 421 | then true | |
420 | 422 | else !(isWhitelist(toString(i.caller)))) | |
421 | 423 | then throw("Invalid exchangeFreeAndLocked params") | |
422 | 424 | else { | |
423 | 425 | let amountOfQuoteAsset = usdnToDecimals(_amount) | |
424 | 426 | let newRate = computeNewRate(-(amountOfQuoteAsset)) | |
425 | 427 | ((updateLockedBalance(amountOfQuoteAsset) ++ updateFreeBalance(-(amountOfQuoteAsset))) ++ updateRate(newRate)) | |
426 | 428 | } | |
427 | 429 | ||
428 | 430 | ||
429 | 431 | ||
430 | 432 | @Callable(i) | |
431 | 433 | func withdrawLocked (_amount) = if (if (if (!(initialized())) | |
432 | 434 | then true | |
433 | 435 | else (0 >= _amount)) | |
434 | 436 | then true | |
435 | 437 | else !(isWhitelist(toString(i.caller)))) | |
436 | 438 | then throw("Invalid withdrawLocked params") | |
437 | 439 | else { | |
438 | 440 | let amountOfQuoteAsset = usdnToDecimals(_amount) | |
439 | 441 | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), usdnFromDecimals(amountOfQuoteAsset)], nil) | |
440 | 442 | if ((unstake == unstake)) | |
441 | 443 | then (updateLockedBalance(-(amountOfQuoteAsset)) ++ [ScriptTransfer(i.caller, usdnFromDecimals(amountOfQuoteAsset), quoteAsset())]) | |
442 | 444 | else throw("Strict value is not equal to itself.") | |
443 | 445 | } | |
444 | 446 | ||
445 | 447 | ||
446 | 448 | ||
447 | 449 | @Callable(i) | |
448 | 450 | func addRewards () = if (if (if ((i.payments[0].assetId != governanceAsset())) | |
449 | 451 | then true | |
450 | 452 | else (size(i.payments) != 1)) | |
451 | 453 | then true | |
452 | 454 | else !(initialized())) | |
453 | 455 | then throw("Invalid addRewards params") | |
454 | 456 | else { | |
455 | 457 | let _reward = i.payments[0].amount | |
456 | 458 | let newRewardPerTokenStored = updateReward(NO_ADDRESS, NO_STAKER)._1 | |
457 | 459 | let timestamp = currentTimestampSec() | |
458 | 460 | let newRewardRate = if ((timestamp > periodFinish())) | |
459 | 461 | then (_reward / DURATION) | |
460 | 462 | else { | |
461 | 463 | let remainingTime = (periodFinish() - timestamp) | |
462 | 464 | let leftover = (rewardRate() * remainingTime) | |
463 | 465 | ((_reward + leftover) / DURATION) | |
464 | 466 | } | |
465 | 467 | (((updateRewardRate(newRewardRate) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateRewardBalance(_reward)) ++ updateTime(timestamp, (timestamp + DURATION))) | |
466 | 468 | } | |
467 | 469 | ||
468 | 470 | ||
469 | 471 | ||
470 | 472 | @Callable(i) | |
471 | 473 | func ackRewards () = { | |
472 | 474 | let profitResp = invoke(managerAddress(), "claimProfit", [toBase58String(quoteAsset())], nil) | |
473 | 475 | if ((profitResp == profitResp)) | |
474 | 476 | then { | |
475 | 477 | let profit = match profitResp { | |
476 | 478 | case p: Int => | |
477 | 479 | usdnToDecimals(p) | |
478 | 480 | case _ => | |
479 | 481 | throw("Invalid claimProfit response") | |
480 | 482 | } | |
481 | 483 | let result = if ((profit > 0)) | |
482 | 484 | then { | |
483 | 485 | let newRate = computeNewRate(profit) | |
484 | 486 | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), usdnFromDecimals(profit))]) | |
485 | 487 | if ((stake == stake)) | |
486 | 488 | then (updateFreeBalance(profit) ++ updateRate(newRate)) | |
487 | 489 | else throw("Strict value is not equal to itself.") | |
488 | 490 | } | |
489 | 491 | else nil | |
490 | 492 | if ((result == result)) | |
491 | 493 | then result | |
492 | 494 | else throw("Strict value is not equal to itself.") | |
493 | 495 | } | |
494 | 496 | else throw("Strict value is not equal to itself.") | |
495 | 497 | } | |
496 | 498 | ||
497 | 499 | ||
498 | 500 | ||
499 | 501 | @Callable(i) | |
500 | 502 | func view_reward (_staker) = { | |
501 | 503 | let balance = balanceOf(_staker) | |
502 | 504 | let depositedAmount = muld(averageRate(_staker), balance) | |
503 | 505 | let currentAmount = muld(rate(), balance) | |
504 | 506 | let earnedQuote = (currentAmount - depositedAmount) | |
505 | 507 | throw(toString(earnedQuote)) | |
506 | 508 | } | |
507 | 509 | ||
508 | 510 | ||
509 | 511 | ||
510 | 512 | @Callable(i) | |
511 | 513 | func view_stakingReward (_staker) = { | |
512 | 514 | let stakerEarned = updateReward(_staker, 0)._3 | |
513 | 515 | throw(toString(usdnFromDecimals(stakerEarned))) | |
514 | 516 | } | |
515 | 517 | ||
516 | 518 | ||
517 | 519 | ||
518 | 520 | @Callable(i) | |
519 | 521 | func view_withdrawLimit (_staker) = { | |
520 | 522 | let withdrawLimitLeft = getWithdrawLimitLeft(_staker)._2 | |
521 | 523 | let limitInUsdn = usdnFromDecimals(muld(withdrawLimitLeft, rate())) | |
522 | 524 | throw(toString(limitInUsdn)) | |
523 | 525 | } | |
524 | 526 | ||
525 | 527 | ||
526 | 528 | @Verifier(tx) | |
527 | 529 | func verify () = { | |
528 | 530 | let coordinatorStr = getString(this, k_coordinatorAddress) | |
529 | 531 | if (isDefined(coordinatorStr)) | |
530 | 532 | then { | |
531 | 533 | let admin = getString(addressFromStringValue(value(coordinatorStr)), k_admin_address) | |
532 | 534 | if (isDefined(admin)) | |
533 | 535 | then valueOrElse(getBoolean(addressFromStringValue(value(admin)), ((("status_" + toString(this)) + "_") + toBase58String(tx.id))), false) | |
534 | 536 | else throw("unable to verify: admin not set in coordinator") | |
535 | 537 | } | |
536 | 538 | else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
537 | 539 | } | |
538 | 540 |
github/deemru/w8io/169f3d6 63.56 ms ◑