tx · 9WJktdE62BH7CJFxNKo9hJjbBoy1gUgnTTy5R5i39caW

3NADcxHXbecCheinqFbvhDjfzZhsMFZJUuH:  -0.03700000 Waves

2023.02.11 09:49 [2444617] smart account 3NADcxHXbecCheinqFbvhDjfzZhsMFZJUuH > SELF 0.00000000 Waves

{ "type": 13, "id": "9WJktdE62BH7CJFxNKo9hJjbBoy1gUgnTTy5R5i39caW", "fee": 3700000, "feeAssetId": null, "timestamp": 1676098206262, "version": 2, "chainId": 84, "sender": "3NADcxHXbecCheinqFbvhDjfzZhsMFZJUuH", "senderPublicKey": "DKfzQgvVdTqPHgGbdZptWYA8G5xVfmSMAwL3UnhwQmdy", "proofs": [ "48pQQF7YVrq9S6xBbavJwAyPtod1SBsvHH8uqp4LPssJxSpsVQZKXHcXGSQiER895ig395NJ1EvQkJcbuMVR4SGb" ], "script": "base64:BgIxCAISAwoBCBIAEgMKAQESABIAEgASAwoBARIDCgEBEgASABIDCgEIEgMKAQgSAwoBCFQADWtfdG90YWxTdXBwbHkCDWtfdG90YWxTdXBwbHkAD2tfcmV3YXJkQmFsYW5jZQIPa19yZXdhcmRCYWxhbmNlAA9rX2xvY2tlZEJhbGFuY2UCD2tfbG9ja2VkQmFsYW5jZQANa19mcmVlQmFsYW5jZQINa19mcmVlQmFsYW5jZQAGa19yYXRlAgZrX3JhdGUAEGtfbGFzdFVwZGF0ZVRpbWUCEGtfbGFzdFVwZGF0ZVRpbWUAFmtfcmV3YXJkUGVyVG9rZW5TdG9yZWQCFmtfcmV3YXJkUGVyVG9rZW5TdG9yZWQADGtfcmV3YXJkUmF0ZQIMa19yZXdhcmRSYXRlAA5rX3BlcmlvZEZpbmlzaAIOa19wZXJpb2RGaW5pc2gAFGtfdXNlclJld2FyZFBlclRva2VuAhRrX3VzZXJSZXdhcmRQZXJUb2tlbgAMa191c2VyUmV3YXJkAgxrX3VzZXJSZXdhcmQACWtfYmFsYW5jZQIJa19iYWxhbmNlAA5rX2F2ZXJhZ2VfcmF0ZQ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Zs6 Next: none Diff:
OldNewDifferences
4343
4444 let k_quote_asset = "k_quote_asset"
4545
46-let k_admin_public_key = "k_admin_public_key"
47-
4846 let k_admin_address = "k_admin_address"
4947
5048 let k_manager_address = "k_manager_address"
5856
5957
6058 func isWhitelist (_address) = valueOrElse(getBoolean(coordinator(), toCompositeKey(k_amm, _address)), false)
61-
62-
63-func adminPublicKey () = fromBase58String(getStringValue(coordinator(), k_admin_public_key))
6459
6560
6661 func governanceAsset () = fromBase58String(getStringValue(coordinator(), k_governance_asset))
178173 func getWithdrawLimitLeft (_staker) = {
179174 let currentDate = currentTimestamp()
180175 let lastWithdrawDate = lastWithdrawnDate(_staker)
181- let $t051085372 = if (((currentDate - lastWithdrawDate) > WITHDRAW_PERIOD))
182- then $Tuple2(currentDate, withdrawLimit(_staker))
183- else $Tuple2(lastWithdrawDate, (withdrawLimit(_staker) - withdrawnInPeriod(_staker)))
184- let newLastWithdrawnDate = $t051085372._1
185- let withdrawLimitLeft = $t051085372._2
186- $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)
187183 }
188184
189185
219215 func updateReward (_staker,_balanceDelta) = {
220216 let newRewardPerTokenStored = rewardPerToken(_balanceDelta)
221217 let newLastUpdateTime = currentTimestampSec()
222- let $t065686760 = if ((_staker != ""))
218+ let $t065076699 = if ((_staker != ""))
223219 then $Tuple2(earned(_staker, _balanceDelta), newRewardPerTokenStored)
224220 else $Tuple2(0, 0)
225- let stakerEarned = $t065686760._1
226- let stakerRewardPerTokenPaid = $t065686760._2
221+ let stakerEarned = $t065076699._1
222+ let stakerRewardPerTokenPaid = $t065076699._2
227223 $Tuple4(newRewardPerTokenStored, newLastUpdateTime, stakerEarned, stakerRewardPerTokenPaid)
228224 }
229225
237233 func setUserAverageRate (_user,_rate) = [IntegerEntry(toCompositeKey(k_average_rate, _user), _rate)]
238234
239235
240-func updateFreeBalance (_change) = [IntegerEntry(k_freeBalance, (freeBalance() + _change))]
236+func updateFreeBalance (_change) = {
237+ let balance = freeBalance()
238+ if (((balance + _change) >= 0))
239+ then [IntegerEntry(k_freeBalance, (balance + _change))]
240+ else throw(((("Vault: can not update free balance. Balance: " + toString(balance)) + " change: ") + toString(_change)))
241+ }
241242
242243
243244 func updateLockedBalance (_change) = {
245246 if (((balance + _change) >= 0))
246247 then [IntegerEntry(k_lockedBalance, (balance + _change))]
247248 else throw(((("Vault: can not update locked balance. Balance: " + toString(balance)) + " change: ") + toString(_change)))
248- }
249-
250-
251-func updateLockedBalanceUnchecked (_change) = {
252- let balance = lockedBalance()
253- if (((balance + _change) >= 0))
254- then [IntegerEntry(k_lockedBalance, (balance + _change))]
255- else [IntegerEntry(k_lockedBalance, 0)]
256249 }
257250
258251
281274
282275
283276 @Callable(i)
284-func initialize (_coordinator) = if (initialized())
285- then throw("Already initialized")
286- else [StringEntry(k_coordinatorAddress, _coordinator), BooleanEntry(k_initialized, true)]
277+func initialize (_coordinator) = if (if (initialized())
278+ then true
279+ else (i.caller != this))
280+ then throw("Unable to initialize")
281+ else [StringEntry(k_coordinatorAddress, toString(valueOrErrorMessage(addressFromString(_coordinator), "Invalid coordinator address"))), BooleanEntry(k_initialized, true)]
287282
288283
289284
291286 func stake () = {
292287 let _staker = toString(i.caller)
293288 let _amount = usdnToDecimals(i.payments[0].amount)
294- if (if ((i.payments[0].assetId != quoteAsset()))
289+ if (if (if ((i.payments[0].assetId != quoteAsset()))
290+ then true
291+ else (size(i.payments) != 1))
295292 then true
296293 else !(initialized()))
297294 then throw("Invalid call to stake")
298295 else {
299- let $t0994610175 = updateReward(_staker, 0)
300- let newRewardPerTokenStored = $t0994610175._1
301- let newLastUpdateTime = $t0994610175._2
302- let stakerEarned = $t0994610175._3
303- let stakerRewardPerTokenPaid = $t0994610175._4
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
304301 let currentRate = rate()
305302 let prevAverageRate = averageRate(_staker)
306303 let vAmount = divd(_amount, currentRate)
327324 else !(initialized()))
328325 then throw("Invalid call to unStake")
329326 else {
330- let $t01152811744 = updateReward(_staker, 0)
331- let newRewardPerTokenStored = $t01152811744._1
332- let newLastUpdateTime = $t01152811744._2
333- let stakerEarned = $t01152811744._3
334- let stakerRewardPerTokenPaid = $t01152811744._4
335- let $t01175111892 = getWithdrawLimitLeft(_staker)
336- let newLastWithdrawnDate = $t01175111892._1
337- let withdrawLimitLeft = $t01175111892._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
338336 let vAmount = divd(amountOfQuoteAsset, rate())
339337 if ((vAmount > withdrawLimitLeft))
340338 then throw("Invalid call to unStake: withdraw over limit")
341339 else {
342- let newWithdrawnInPeriod = (withdrawnInPeriod(_staker) + vAmount)
340+ let newWithdrawnInPeriod = (alreadyWithdrawnInPeriod + vAmount)
343341 if ((amountOfQuoteAsset > freeBalance()))
344342 then throw("Invalid call to unStake: balance too low")
345343 else {
357355 @Callable(i)
358356 func withdrawRewards () = {
359357 let _staker = toString(i.caller)
360- let $t01323013375 = updateReward(_staker, 0)
361- let newRewardPerTokenStored = $t01323013375._1
362- let newLastUpdateTime = $t01323013375._2
363- let stakerEarned = $t01323013375._3
364- let stakerRewardPerTokenPaid = $t01323013375._4
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
365363 if (if ((0 >= stakerEarned))
366364 then true
367365 else !(initialized()))
374372 @Callable(i)
375373 func addFree () = {
376374 let _amount = usdnToDecimals(i.payments[0].amount)
377- if (if (if ((i.payments[0].assetId != quoteAsset()))
375+ if (if (if (if ((i.payments[0].assetId != quoteAsset()))
376+ then true
377+ else (size(i.payments) != 1))
378378 then true
379379 else !(initialized()))
380380 then true
383383 else (i.caller == adminAddress())))
384384 then throw("Invalid addFree params")
385385 else {
386- let newRate = if ((totalSupply() > 0))
387- then divd((freeBalance() + _amount), totalSupply())
388- else DECIMAL_UNIT
389- let unstake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), usdnFromDecimals(_amount))])
390- if ((unstake == unstake))
386+ let newRate = computeNewRate(_amount)
387+ let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), usdnFromDecimals(_amount))])
388+ if ((stake == stake))
391389 then (updateFreeBalance(_amount) ++ updateRate(newRate))
392390 else throw("Strict value is not equal to itself.")
393391 }
398396 @Callable(i)
399397 func addLocked () = {
400398 let _amount = usdnToDecimals(i.payments[0].amount)
401- if (if (if ((i.payments[0].assetId != quoteAsset()))
399+ if (if (if (if ((i.payments[0].assetId != quoteAsset()))
400+ then true
401+ else (size(i.payments) != 1))
402402 then true
403403 else !(initialized()))
404404 then true
419419 @Callable(i)
420420 func exchangeFreeAndLocked (_amount) = if (if (!(initialized()))
421421 then true
422- else !(if (isWhitelist(toString(i.caller)))
423- then true
424- else (i.caller == adminAddress())))
422+ else !(isWhitelist(toString(i.caller))))
425423 then throw("Invalid exchangeFreeAndLocked params")
426424 else {
427425 let amountOfQuoteAsset = usdnToDecimals(_amount)
428- let freeUpdate = -(amountOfQuoteAsset)
429- let newRate = computeNewRate(freeUpdate)
430- ((updateLockedBalanceUnchecked(amountOfQuoteAsset) ++ updateFreeBalance(freeUpdate)) ++ updateRate(newRate))
426+ let newRate = computeNewRate(-(amountOfQuoteAsset))
427+ ((updateLockedBalance(amountOfQuoteAsset) ++ updateFreeBalance(-(amountOfQuoteAsset))) ++ updateRate(newRate))
431428 }
432429
433430
443440 let amountOfQuoteAsset = usdnToDecimals(_amount)
444441 let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), usdnFromDecimals(amountOfQuoteAsset)], nil)
445442 if ((unstake == unstake))
446- then {
447- let lockBalanceNow = lockedBalance()
448- let $t01627616469 = if ((amountOfQuoteAsset > lockBalanceNow))
449- then $Tuple2(lockBalanceNow, (amountOfQuoteAsset - lockBalanceNow))
450- else $Tuple2(amountOfQuoteAsset, 0)
451- let fromLocked = $t01627616469._1
452- let fromFree = $t01627616469._2
453- (((if ((fromFree > 0))
454- then {
455- let newRate = computeNewRate(-(fromFree))
456- (updateFreeBalance(-(fromFree)) ++ updateRate(newRate))
457- }
458- else nil) ++ updateLockedBalance(-(fromLocked))) ++ [ScriptTransfer(i.caller, usdnFromDecimals(amountOfQuoteAsset), quoteAsset())])
459- }
443+ then (updateLockedBalance(-(amountOfQuoteAsset)) ++ [ScriptTransfer(i.caller, usdnFromDecimals(amountOfQuoteAsset), quoteAsset())])
460444 else throw("Strict value is not equal to itself.")
461445 }
462446
463447
464448
465449 @Callable(i)
466-func addRewards () = if (if ((i.payments[0].assetId != governanceAsset()))
450+func addRewards () = if (if (if ((i.payments[0].assetId != governanceAsset()))
451+ then true
452+ else (size(i.payments) != 1))
467453 then true
468454 else !(initialized()))
469455 then throw("Invalid addRewards params")
480466 }
481467 (((updateRewardRate(newRewardRate) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateRewardBalance(_reward)) ++ updateTime(timestamp, (timestamp + DURATION)))
482468 }
469+
470+
471+
472+@Callable(i)
473+func ackRewards () = {
474+ let profitResp = invoke(managerAddress(), "claimProfit", [toBase58String(quoteAsset())], nil)
475+ if ((profitResp == profitResp))
476+ then {
477+ let profit = match profitResp {
478+ case p: Int =>
479+ usdnToDecimals(p)
480+ case _ =>
481+ throw("Invalid claimProfit response")
482+ }
483+ let result = if ((profit > 0))
484+ then {
485+ let newRate = computeNewRate(profit)
486+ let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), usdnFromDecimals(profit))])
487+ if ((stake == stake))
488+ then (updateFreeBalance(profit) ++ updateRate(newRate))
489+ else throw("Strict value is not equal to itself.")
490+ }
491+ else nil
492+ if ((result == result))
493+ then result
494+ else throw("Strict value is not equal to itself.")
495+ }
496+ else throw("Strict value is not equal to itself.")
497+ }
483498
484499
485500
511526
512527
513528 @Verifier(tx)
514-func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey())
529+func verify () = {
530+ let coordinatorStr = getString(this, k_coordinatorAddress)
531+ if (isDefined(coordinatorStr))
532+ then {
533+ let admin = getString(addressFromStringValue(value(coordinatorStr)), k_admin_address)
534+ if (isDefined(admin))
535+ then valueOrElse(getBoolean(addressFromStringValue(value(admin)), ((("status_" + toString(this)) + "_") + toBase58String(tx.id))), false)
536+ else throw("unable to verify: admin not set in coordinator")
537+ }
538+ else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
539+ }
515540
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let k_totalSupply = "k_totalSupply"
55
66 let k_rewardBalance = "k_rewardBalance"
77
88 let k_lockedBalance = "k_lockedBalance"
99
1010 let k_freeBalance = "k_freeBalance"
1111
1212 let k_rate = "k_rate"
1313
1414 let k_lastUpdateTime = "k_lastUpdateTime"
1515
1616 let k_rewardPerTokenStored = "k_rewardPerTokenStored"
1717
1818 let k_rewardRate = "k_rewardRate"
1919
2020 let k_periodFinish = "k_periodFinish"
2121
2222 let k_userRewardPerToken = "k_userRewardPerToken"
2323
2424 let k_userReward = "k_userReward"
2525
2626 let k_balance = "k_balance"
2727
2828 let k_average_rate = "k_average_rate"
2929
3030 let k_withdraw_limit = "k_withdraw_limit"
3131
3232 let k_last_withdraw_date = "k_last_withdraw_date"
3333
3434 let k_withdraw_in_period = "k_withdraw_in_period"
3535
3636 let k_initialized = "k_initialized"
3737
3838 let k_coordinatorAddress = "k_coordinatorAddress"
3939
4040 let k_amm = "k_amm"
4141
4242 let k_governance_asset = "k_gov_asset"
4343
4444 let k_quote_asset = "k_quote_asset"
4545
46-let k_admin_public_key = "k_admin_public_key"
47-
4846 let k_admin_address = "k_admin_address"
4947
5048 let k_manager_address = "k_manager_address"
5149
5250 let k_collateral_address = "k_collateral_address"
5351
5452 func toCompositeKey (_key,_address) = ((_key + "_") + _address)
5553
5654
5755 func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set")
5856
5957
6058 func isWhitelist (_address) = valueOrElse(getBoolean(coordinator(), toCompositeKey(k_amm, _address)), false)
61-
62-
63-func adminPublicKey () = fromBase58String(getStringValue(coordinator(), k_admin_public_key))
6459
6560
6661 func governanceAsset () = fromBase58String(getStringValue(coordinator(), k_governance_asset))
6762
6863
6964 func adminAddress () = addressFromString(valueOrErrorMessage(getString(coordinator(), k_admin_address), "Admin address not set"))
7065
7166
7267 func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset))
7368
7469
7570 func managerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_manager_address)), "Manager not set")
7671
7772
7873 let DECIMAL_UNIT = (1 * (((((((10 * 10) * 10) * 10) * 10) * 10) * 10) * 10))
7974
8075 let DURATION = (((7 * 60) * 60) * 24)
8176
8277 let NO_ADDRESS = ""
8378
8479 let NO_STAKER = 0
8580
8681 func usdnFromDecimals (_amount) = (_amount / 100)
8782
8883
8984 func usdnToDecimals (_amount) = (_amount * 100)
9085
9186
9287 func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN)
9388
9489
9590 func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN)
9691
9792
9893 func abs (_x) = if ((_x > 0))
9994 then _x
10095 else -(_x)
10196
10297
10398 func minv (_x,_y) = if ((_x > _y))
10499 then _y
105100 else _x
106101
107102
108103 let WITHDRAW_PERIOD = (86400 * 1000)
109104
110105 let WITHDRAW_PER_PERIOD = divd((1 * DECIMAL_UNIT), (4 * DECIMAL_UNIT))
111106
112107 func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k))
113108
114109
115110 func int0 (k) = valueOrElse(getInteger(this, k), 0)
116111
117112
118113 func int1 (k) = valueOrElse(getInteger(this, k), DECIMAL_UNIT)
119114
120115
121116 func totalSupply () = int0(k_totalSupply)
122117
123118
124119 func rate () = int1(k_rate)
125120
126121
127122 func balanceOf (_staker) = int0(toCompositeKey(k_balance, _staker))
128123
129124
130125 func averageRate (_staker) = int0(toCompositeKey(k_average_rate, _staker))
131126
132127
133128 func withdrawLimit (_staker) = int0(toCompositeKey(k_withdraw_limit, _staker))
134129
135130
136131 func withdrawnInPeriod (_staker) = int0(toCompositeKey(k_withdraw_in_period, _staker))
137132
138133
139134 func lastWithdrawnDate (_staker) = int0(toCompositeKey(k_last_withdraw_date, _staker))
140135
141136
142137 func freeBalance () = int0(k_freeBalance)
143138
144139
145140 func lockedBalance () = int0(k_lockedBalance)
146141
147142
148143 func rewardPerTokenStored () = int0(k_rewardPerTokenStored)
149144
150145
151146 func lastUpdateTime () = int0(k_lastUpdateTime)
152147
153148
154149 func rewardRate () = int0(k_rewardRate)
155150
156151
157152 func periodFinish () = int0(k_periodFinish)
158153
159154
160155 func rewardBalance () = int0(k_rewardBalance)
161156
162157
163158 func rewards (_staker) = int0(toCompositeKey(k_userReward, _staker))
164159
165160
166161 func userRewardPerTokenPaid (_staker) = int0(toCompositeKey(k_userRewardPerToken, _staker))
167162
168163
169164 func initialized () = valueOrElse(getBoolean(this, k_initialized), false)
170165
171166
172167 func currentTimestamp () = lastBlock.timestamp
173168
174169
175170 func currentTimestampSec () = (currentTimestamp() / 1000)
176171
177172
178173 func getWithdrawLimitLeft (_staker) = {
179174 let currentDate = currentTimestamp()
180175 let lastWithdrawDate = lastWithdrawnDate(_staker)
181- let $t051085372 = if (((currentDate - lastWithdrawDate) > WITHDRAW_PERIOD))
182- then $Tuple2(currentDate, withdrawLimit(_staker))
183- else $Tuple2(lastWithdrawDate, (withdrawLimit(_staker) - withdrawnInPeriod(_staker)))
184- let newLastWithdrawnDate = $t051085372._1
185- let withdrawLimitLeft = $t051085372._2
186- $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)
187183 }
188184
189185
190186 func computeNewRate (_amountOfQuoteAsset) = {
191187 let newRate = if ((totalSupply() > 0))
192188 then divd((freeBalance() + _amountOfQuoteAsset), totalSupply())
193189 else DECIMAL_UNIT
194190 newRate
195191 }
196192
197193
198194 func lastTimeRewardApplicable () = minv(currentTimestampSec(), periodFinish())
199195
200196
201197 func rewardPerToken (_balanceDelta) = if (((totalSupply() + _balanceDelta) == 0))
202198 then rewardPerTokenStored()
203199 else {
204200 let timeInterval = (lastTimeRewardApplicable() - lastUpdateTime())
205201 let actualTimeInterval = if ((0 > timeInterval))
206202 then 0
207203 else timeInterval
208204 let diff = divd((rewardRate() * actualTimeInterval), (totalSupply() + _balanceDelta))
209205 (rewardPerTokenStored() + diff)
210206 }
211207
212208
213209 func earned (_staker,_balanceDelta) = {
214210 let rewardDelta = (rewardPerToken(_balanceDelta) - userRewardPerTokenPaid(_staker))
215211 (muld((balanceOf(_staker) + _balanceDelta), rewardDelta) + rewards(_staker))
216212 }
217213
218214
219215 func updateReward (_staker,_balanceDelta) = {
220216 let newRewardPerTokenStored = rewardPerToken(_balanceDelta)
221217 let newLastUpdateTime = currentTimestampSec()
222- let $t065686760 = if ((_staker != ""))
218+ let $t065076699 = if ((_staker != ""))
223219 then $Tuple2(earned(_staker, _balanceDelta), newRewardPerTokenStored)
224220 else $Tuple2(0, 0)
225- let stakerEarned = $t065686760._1
226- let stakerRewardPerTokenPaid = $t065686760._2
221+ let stakerEarned = $t065076699._1
222+ let stakerRewardPerTokenPaid = $t065076699._2
227223 $Tuple4(newRewardPerTokenStored, newLastUpdateTime, stakerEarned, stakerRewardPerTokenPaid)
228224 }
229225
230226
231227 func updateUserBalance (_user,_change) = [IntegerEntry(toCompositeKey(k_balance, _user), (balanceOf(_user) + _change))]
232228
233229
234230 func setUserWithdrawLimit (_user,_rate) = [IntegerEntry(toCompositeKey(k_withdraw_limit, _user), _rate)]
235231
236232
237233 func setUserAverageRate (_user,_rate) = [IntegerEntry(toCompositeKey(k_average_rate, _user), _rate)]
238234
239235
240-func updateFreeBalance (_change) = [IntegerEntry(k_freeBalance, (freeBalance() + _change))]
236+func updateFreeBalance (_change) = {
237+ let balance = freeBalance()
238+ if (((balance + _change) >= 0))
239+ then [IntegerEntry(k_freeBalance, (balance + _change))]
240+ else throw(((("Vault: can not update free balance. Balance: " + toString(balance)) + " change: ") + toString(_change)))
241+ }
241242
242243
243244 func updateLockedBalance (_change) = {
244245 let balance = lockedBalance()
245246 if (((balance + _change) >= 0))
246247 then [IntegerEntry(k_lockedBalance, (balance + _change))]
247248 else throw(((("Vault: can not update locked balance. Balance: " + toString(balance)) + " change: ") + toString(_change)))
248- }
249-
250-
251-func updateLockedBalanceUnchecked (_change) = {
252- let balance = lockedBalance()
253- if (((balance + _change) >= 0))
254- then [IntegerEntry(k_lockedBalance, (balance + _change))]
255- else [IntegerEntry(k_lockedBalance, 0)]
256249 }
257250
258251
259252 func updateTotalSupply (_change) = [IntegerEntry(k_totalSupply, (totalSupply() + _change))]
260253
261254
262255 func updateRate (_rate) = [IntegerEntry(k_rate, _rate)]
263256
264257
265258 func setUserWithdrawParams (_user,_lastWithdrawDate,_withdrawn) = [IntegerEntry(toCompositeKey(k_last_withdraw_date, _user), _lastWithdrawDate), IntegerEntry(toCompositeKey(k_withdraw_in_period, _user), _withdrawn)]
266259
267260
268261 func updateRewardBalance (_delta) = [IntegerEntry(k_rewardBalance, (rewardBalance() + _delta))]
269262
270263
271264 func updateRewardRate (_rewardRate) = [IntegerEntry(k_rewardRate, _rewardRate)]
272265
273266
274267 func updateTime (_lastUpdateTime,_periodFinish) = [IntegerEntry(k_lastUpdateTime, _lastUpdateTime), IntegerEntry(k_periodFinish, _periodFinish)]
275268
276269
277270 func updateRewardPerTokenStored (_rewardPerTokenStored) = [IntegerEntry(k_rewardPerTokenStored, _rewardPerTokenStored)]
278271
279272
280273 func updateUserRewards (_staker,_reward,_userRewardPerToken) = [IntegerEntry(toCompositeKey(k_userReward, _staker), _reward), IntegerEntry(toCompositeKey(k_userRewardPerToken, _staker), _userRewardPerToken)]
281274
282275
283276 @Callable(i)
284-func initialize (_coordinator) = if (initialized())
285- then throw("Already initialized")
286- else [StringEntry(k_coordinatorAddress, _coordinator), BooleanEntry(k_initialized, true)]
277+func initialize (_coordinator) = if (if (initialized())
278+ then true
279+ else (i.caller != this))
280+ then throw("Unable to initialize")
281+ else [StringEntry(k_coordinatorAddress, toString(valueOrErrorMessage(addressFromString(_coordinator), "Invalid coordinator address"))), BooleanEntry(k_initialized, true)]
287282
288283
289284
290285 @Callable(i)
291286 func stake () = {
292287 let _staker = toString(i.caller)
293288 let _amount = usdnToDecimals(i.payments[0].amount)
294- if (if ((i.payments[0].assetId != quoteAsset()))
289+ if (if (if ((i.payments[0].assetId != quoteAsset()))
290+ then true
291+ else (size(i.payments) != 1))
295292 then true
296293 else !(initialized()))
297294 then throw("Invalid call to stake")
298295 else {
299- let $t0994610175 = updateReward(_staker, 0)
300- let newRewardPerTokenStored = $t0994610175._1
301- let newLastUpdateTime = $t0994610175._2
302- let stakerEarned = $t0994610175._3
303- let stakerRewardPerTokenPaid = $t0994610175._4
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
304301 let currentRate = rate()
305302 let prevAverageRate = averageRate(_staker)
306303 let vAmount = divd(_amount, currentRate)
307304 let newAverageRate = divd((muld(vAmount, currentRate) + muld(balanceOf(_staker), prevAverageRate)), (vAmount + balanceOf(_staker)))
308305 let newTotalBalance = (vAmount + balanceOf(_staker))
309306 let newWithdrawLimit = muld(newTotalBalance, WITHDRAW_PER_PERIOD)
310307 let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), usdnFromDecimals(_amount))])
311308 if ((stake == stake))
312309 then (((((((updateUserRewards(_staker, stakerEarned, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateFreeBalance(_amount)) ++ updateUserBalance(_staker, vAmount)) ++ setUserAverageRate(_staker, newAverageRate)) ++ setUserWithdrawLimit(_staker, newWithdrawLimit)) ++ updateTotalSupply(vAmount))
313310 else throw("Strict value is not equal to itself.")
314311 }
315312 }
316313
317314
318315
319316 @Callable(i)
320317 func unStake (_amount) = {
321318 let _staker = toString(i.caller)
322319 let amountOfQuoteAsset = usdnToDecimals(_amount)
323320 if (if (if ((i.payments != nil))
324321 then true
325322 else (0 >= amountOfQuoteAsset))
326323 then true
327324 else !(initialized()))
328325 then throw("Invalid call to unStake")
329326 else {
330- let $t01152811744 = updateReward(_staker, 0)
331- let newRewardPerTokenStored = $t01152811744._1
332- let newLastUpdateTime = $t01152811744._2
333- let stakerEarned = $t01152811744._3
334- let stakerRewardPerTokenPaid = $t01152811744._4
335- let $t01175111892 = getWithdrawLimitLeft(_staker)
336- let newLastWithdrawnDate = $t01175111892._1
337- let withdrawLimitLeft = $t01175111892._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
338336 let vAmount = divd(amountOfQuoteAsset, rate())
339337 if ((vAmount > withdrawLimitLeft))
340338 then throw("Invalid call to unStake: withdraw over limit")
341339 else {
342- let newWithdrawnInPeriod = (withdrawnInPeriod(_staker) + vAmount)
340+ let newWithdrawnInPeriod = (alreadyWithdrawnInPeriod + vAmount)
343341 if ((amountOfQuoteAsset > freeBalance()))
344342 then throw("Invalid call to unStake: balance too low")
345343 else {
346344 let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), usdnFromDecimals(amountOfQuoteAsset)], nil)
347345 if ((unstake == unstake))
348346 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())])
349347 else throw("Strict value is not equal to itself.")
350348 }
351349 }
352350 }
353351 }
354352
355353
356354
357355 @Callable(i)
358356 func withdrawRewards () = {
359357 let _staker = toString(i.caller)
360- let $t01323013375 = updateReward(_staker, 0)
361- let newRewardPerTokenStored = $t01323013375._1
362- let newLastUpdateTime = $t01323013375._2
363- let stakerEarned = $t01323013375._3
364- let stakerRewardPerTokenPaid = $t01323013375._4
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
365363 if (if ((0 >= stakerEarned))
366364 then true
367365 else !(initialized()))
368366 then throw("No reward: Vault")
369367 else ((((updateUserRewards(_staker, 0, stakerRewardPerTokenPaid) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateTime(newLastUpdateTime, periodFinish())) ++ updateRewardBalance(-(stakerEarned))) ++ [ScriptTransfer(i.caller, stakerEarned, governanceAsset())])
370368 }
371369
372370
373371
374372 @Callable(i)
375373 func addFree () = {
376374 let _amount = usdnToDecimals(i.payments[0].amount)
377- if (if (if ((i.payments[0].assetId != quoteAsset()))
375+ if (if (if (if ((i.payments[0].assetId != quoteAsset()))
376+ then true
377+ else (size(i.payments) != 1))
378378 then true
379379 else !(initialized()))
380380 then true
381381 else !(if (isWhitelist(toString(i.caller)))
382382 then true
383383 else (i.caller == adminAddress())))
384384 then throw("Invalid addFree params")
385385 else {
386- let newRate = if ((totalSupply() > 0))
387- then divd((freeBalance() + _amount), totalSupply())
388- else DECIMAL_UNIT
389- let unstake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), usdnFromDecimals(_amount))])
390- if ((unstake == unstake))
386+ let newRate = computeNewRate(_amount)
387+ let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), usdnFromDecimals(_amount))])
388+ if ((stake == stake))
391389 then (updateFreeBalance(_amount) ++ updateRate(newRate))
392390 else throw("Strict value is not equal to itself.")
393391 }
394392 }
395393
396394
397395
398396 @Callable(i)
399397 func addLocked () = {
400398 let _amount = usdnToDecimals(i.payments[0].amount)
401- if (if (if ((i.payments[0].assetId != quoteAsset()))
399+ if (if (if (if ((i.payments[0].assetId != quoteAsset()))
400+ then true
401+ else (size(i.payments) != 1))
402402 then true
403403 else !(initialized()))
404404 then true
405405 else !(if (isWhitelist(toString(i.caller)))
406406 then true
407407 else (i.caller == adminAddress())))
408408 then throw("Invalid addLocked params")
409409 else {
410410 let unstake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), usdnFromDecimals(_amount))])
411411 if ((unstake == unstake))
412412 then updateLockedBalance(_amount)
413413 else throw("Strict value is not equal to itself.")
414414 }
415415 }
416416
417417
418418
419419 @Callable(i)
420420 func exchangeFreeAndLocked (_amount) = if (if (!(initialized()))
421421 then true
422- else !(if (isWhitelist(toString(i.caller)))
423- then true
424- else (i.caller == adminAddress())))
422+ else !(isWhitelist(toString(i.caller))))
425423 then throw("Invalid exchangeFreeAndLocked params")
426424 else {
427425 let amountOfQuoteAsset = usdnToDecimals(_amount)
428- let freeUpdate = -(amountOfQuoteAsset)
429- let newRate = computeNewRate(freeUpdate)
430- ((updateLockedBalanceUnchecked(amountOfQuoteAsset) ++ updateFreeBalance(freeUpdate)) ++ updateRate(newRate))
426+ let newRate = computeNewRate(-(amountOfQuoteAsset))
427+ ((updateLockedBalance(amountOfQuoteAsset) ++ updateFreeBalance(-(amountOfQuoteAsset))) ++ updateRate(newRate))
431428 }
432429
433430
434431
435432 @Callable(i)
436433 func withdrawLocked (_amount) = if (if (if (!(initialized()))
437434 then true
438435 else (0 >= _amount))
439436 then true
440437 else !(isWhitelist(toString(i.caller))))
441438 then throw("Invalid withdrawLocked params")
442439 else {
443440 let amountOfQuoteAsset = usdnToDecimals(_amount)
444441 let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), usdnFromDecimals(amountOfQuoteAsset)], nil)
445442 if ((unstake == unstake))
446- then {
447- let lockBalanceNow = lockedBalance()
448- let $t01627616469 = if ((amountOfQuoteAsset > lockBalanceNow))
449- then $Tuple2(lockBalanceNow, (amountOfQuoteAsset - lockBalanceNow))
450- else $Tuple2(amountOfQuoteAsset, 0)
451- let fromLocked = $t01627616469._1
452- let fromFree = $t01627616469._2
453- (((if ((fromFree > 0))
454- then {
455- let newRate = computeNewRate(-(fromFree))
456- (updateFreeBalance(-(fromFree)) ++ updateRate(newRate))
457- }
458- else nil) ++ updateLockedBalance(-(fromLocked))) ++ [ScriptTransfer(i.caller, usdnFromDecimals(amountOfQuoteAsset), quoteAsset())])
459- }
443+ then (updateLockedBalance(-(amountOfQuoteAsset)) ++ [ScriptTransfer(i.caller, usdnFromDecimals(amountOfQuoteAsset), quoteAsset())])
460444 else throw("Strict value is not equal to itself.")
461445 }
462446
463447
464448
465449 @Callable(i)
466-func addRewards () = if (if ((i.payments[0].assetId != governanceAsset()))
450+func addRewards () = if (if (if ((i.payments[0].assetId != governanceAsset()))
451+ then true
452+ else (size(i.payments) != 1))
467453 then true
468454 else !(initialized()))
469455 then throw("Invalid addRewards params")
470456 else {
471457 let _reward = i.payments[0].amount
472458 let newRewardPerTokenStored = updateReward(NO_ADDRESS, NO_STAKER)._1
473459 let timestamp = currentTimestampSec()
474460 let newRewardRate = if ((timestamp > periodFinish()))
475461 then (_reward / DURATION)
476462 else {
477463 let remainingTime = (periodFinish() - timestamp)
478464 let leftover = (rewardRate() * remainingTime)
479465 ((_reward + leftover) / DURATION)
480466 }
481467 (((updateRewardRate(newRewardRate) ++ updateRewardPerTokenStored(newRewardPerTokenStored)) ++ updateRewardBalance(_reward)) ++ updateTime(timestamp, (timestamp + DURATION)))
482468 }
469+
470+
471+
472+@Callable(i)
473+func ackRewards () = {
474+ let profitResp = invoke(managerAddress(), "claimProfit", [toBase58String(quoteAsset())], nil)
475+ if ((profitResp == profitResp))
476+ then {
477+ let profit = match profitResp {
478+ case p: Int =>
479+ usdnToDecimals(p)
480+ case _ =>
481+ throw("Invalid claimProfit response")
482+ }
483+ let result = if ((profit > 0))
484+ then {
485+ let newRate = computeNewRate(profit)
486+ let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), usdnFromDecimals(profit))])
487+ if ((stake == stake))
488+ then (updateFreeBalance(profit) ++ updateRate(newRate))
489+ else throw("Strict value is not equal to itself.")
490+ }
491+ else nil
492+ if ((result == result))
493+ then result
494+ else throw("Strict value is not equal to itself.")
495+ }
496+ else throw("Strict value is not equal to itself.")
497+ }
483498
484499
485500
486501 @Callable(i)
487502 func view_reward (_staker) = {
488503 let balance = balanceOf(_staker)
489504 let depositedAmount = muld(averageRate(_staker), balance)
490505 let currentAmount = muld(rate(), balance)
491506 let earnedQuote = (currentAmount - depositedAmount)
492507 throw(toString(earnedQuote))
493508 }
494509
495510
496511
497512 @Callable(i)
498513 func view_stakingReward (_staker) = {
499514 let stakerEarned = updateReward(_staker, 0)._3
500515 throw(toString(usdnFromDecimals(stakerEarned)))
501516 }
502517
503518
504519
505520 @Callable(i)
506521 func view_withdrawLimit (_staker) = {
507522 let withdrawLimitLeft = getWithdrawLimitLeft(_staker)._2
508523 let limitInUsdn = usdnFromDecimals(muld(withdrawLimitLeft, rate()))
509524 throw(toString(limitInUsdn))
510525 }
511526
512527
513528 @Verifier(tx)
514-func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey())
529+func verify () = {
530+ let coordinatorStr = getString(this, k_coordinatorAddress)
531+ if (isDefined(coordinatorStr))
532+ then {
533+ let admin = getString(addressFromStringValue(value(coordinatorStr)), k_admin_address)
534+ if (isDefined(admin))
535+ then valueOrElse(getBoolean(addressFromStringValue(value(admin)), ((("status_" + toString(this)) + "_") + toBase58String(tx.id))), false)
536+ else throw("unable to verify: admin not set in coordinator")
537+ }
538+ else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
539+ }
515540

github/deemru/w8io/169f3d6 
79.10 ms