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