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