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