tx · EjmR64ZPXm8eHGmWYqr2BP4G7A4DoujZBkqdkQF1xQ3e 3N5Z4dAWzfkEp4kNJZKQk6zf3uTVFFz5MFF: -0.01800000 Waves 2024.06.14 18:32 [3150602] smart account 3N5Z4dAWzfkEp4kNJZKQk6zf3uTVFFz5MFF > SELF 0.00000000 Waves
{ "type": 13, "id": "EjmR64ZPXm8eHGmWYqr2BP4G7A4DoujZBkqdkQF1xQ3e", "fee": 1800000, "feeAssetId": null, "timestamp": 1718378578965, "version": 2, "chainId": 84, "sender": "3N5Z4dAWzfkEp4kNJZKQk6zf3uTVFFz5MFF", "senderPublicKey": "8Vp8fmB3ZGVRre7Cw5j9z6qXo3yD8ohPQ6agZ9mtVY5E", "proofs": [ "2C42j6HgiaNmG3qJrczLuhLF61uVf6ZKMngS3xk2Tc6WJxRrC6zhCJhNdiWwtJxhiYmPN3XFLCdSRfWqX8tLr4d3" ], "script": "base64:BwJCCAISBgoEAQgICBIAEgMKAQgSBQoDAQgIEgMKAQESBQoDCAgIEgMKAQgSBAoCCAgSAwoBCBIAEgASAwoBCBIDCgEIRQAJU0VQQVJBVE9SAgJfXwAMS0VZX01VTFRJU0lHAghNVUxUSVNJRwAKS0VZX1NUQVRVUwIGU1RBVFVTAAhLRVlfSU5JVAIESU5JVAAKS0VZX1BBVVNFRAIGUEFVU0VEAApLRVlfUEFVU0VSAgZQQVVTRVIACUtFWV9DSEFJTgIFQ0hBSU4AFEtFWV9HQVRFV0FZX0NPTlRSQUNUAhBHQVRFV0FZX0NPTlRSQUNUABNLRVlfU1dBVkVTX0NPTlRSQUNUAg9TV0FWRVNfQ09OVFJBQ1QAEEtFWV9TV0FWRVNfQVNTRVQCBUFTU0VUAAxLRVlfUkVTRVJWRVMCCFJFU0VSVkVTABJLRVlfU1RBS0lOR19BU1NFVFMCDlNUQUtJTkdfQVNTRVRTABRLRVlfU1RBS0lOR19DT05UUkFDVAIQU1RBS0lOR19DT05UUkFDVAAMRlVOQ19ERVBPU0lUAgdkZ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ggFAnR4BnByb29mcwAACAUCdHgPc2VuZGVyUHVibGljS2V5cgk9Ng==", "height": 3150602, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: EzydaTK6rzUmknGewLy9YWPQxjW3yL3SAZFYnmsB9YE9 Next: none Diff:
Old | New | Differences | |
---|---|---|---|
23 | 23 | ||
24 | 24 | let KEY_RESERVES = "RESERVES" | |
25 | 25 | ||
26 | + | let KEY_STAKING_ASSETS = "STAKING_ASSETS" | |
27 | + | ||
28 | + | let KEY_STAKING_CONTRACT = "STAKING_CONTRACT" | |
29 | + | ||
26 | 30 | let FUNC_DEPOSIT = "deposit" | |
27 | 31 | ||
28 | 32 | let FUNC_REQUEST_WITHDRAWAL = "requestWithdrawal" | |
32 | 36 | let FUNC_GET_RATE = "getRate" | |
33 | 37 | ||
34 | 38 | let FUNC_WITHDRAW = "withdraw" | |
39 | + | ||
40 | + | let FUNC_STAKE = "stake" | |
41 | + | ||
42 | + | let FUNC_UNSTAKE = "unstake" | |
43 | + | ||
44 | + | let FUNC_CLAIM_ALL = "claimAll" | |
45 | + | ||
46 | + | let FUNC_DEPOSIT_STAKING_REWARD = "depositStakingReward" | |
35 | 47 | ||
36 | 48 | let WAVES = "WAVES" | |
37 | 49 | ||
213 | 225 | func _saveReserves (asset_,reserves_) = [IntegerEntry(makeString([KEY_RESERVES, asset_], SEPARATOR), reserves_)] | |
214 | 226 | ||
215 | 227 | ||
228 | + | func _loadStakingAssets () = match getString(KEY_STAKING_ASSETS) { | |
229 | + | case a: String => | |
230 | + | if ((size(a) > 0)) | |
231 | + | then split_51C(a, SEPARATOR) | |
232 | + | else nil | |
233 | + | case _ => | |
234 | + | nil | |
235 | + | } | |
236 | + | ||
237 | + | ||
238 | + | func _saveStakingAssets (assets_) = [StringEntry(KEY_STAKING_ASSETS, makeString(assets_, SEPARATOR))] | |
239 | + | ||
240 | + | ||
241 | + | func _loadStakingContract (asset_) = match getString(makeString([KEY_STAKING_CONTRACT, asset_], SEPARATOR)) { | |
242 | + | case a: String => | |
243 | + | addressFromStringValue(a) | |
244 | + | case _ => | |
245 | + | Address(base58'') | |
246 | + | } | |
247 | + | ||
248 | + | ||
249 | + | func _saveStakingContract (asset_,contract_) = [StringEntry(makeString([KEY_STAKING_CONTRACT, asset_], SEPARATOR), toString(contract_))] | |
250 | + | ||
251 | + | ||
216 | 252 | func _onlyThisContract (caller_) = if ((caller_ != this)) | |
217 | 253 | then throw("_onlyThisContract: revert") | |
218 | 254 | else true | |
253 | 289 | else true | |
254 | 290 | ||
255 | 291 | ||
292 | + | func _deposit (from_,to_,asset_,amount_) = { | |
293 | + | let assetDecimals = _getDecimals(asset_) | |
294 | + | let amount = _normalizeDecimals(amount_, assetDecimals, DEX_DECIMALS) | |
295 | + | let err = _validateInt(amount, 1, MAX_INT, "_deposit: invalid payment amount") | |
296 | + | if ((err == err)) | |
297 | + | then { | |
298 | + | let gatewayInvocation = invoke(_loadGatewayContract(), FUNC_DEPOSIT, [toString(this), from_, to_, toString(_loadChainId()), asset_, toString(amount)], nil) | |
299 | + | if ((gatewayInvocation == gatewayInvocation)) | |
300 | + | then { | |
301 | + | let stakingAssets = _loadStakingAssets() | |
302 | + | let stakingInvocation = if ((asset_ == WAVES)) | |
303 | + | then invoke(_loadSWavesContract(), FUNC_DEPOSIT, nil, [AttachedPayment(unit, amount_)]) | |
304 | + | else if (containsElement(stakingAssets, asset_)) | |
305 | + | then invoke(_loadStakingContract(asset_), FUNC_STAKE, nil, [AttachedPayment(_strToAsset(asset_), amount_)]) | |
306 | + | else unit | |
307 | + | if ((stakingInvocation == stakingInvocation)) | |
308 | + | then _saveReserves(asset_, (_loadReserves(asset_) + amount)) | |
309 | + | else throw("Strict value is not equal to itself.") | |
310 | + | } | |
311 | + | else throw("Strict value is not equal to itself.") | |
312 | + | } | |
313 | + | else throw("Strict value is not equal to itself.") | |
314 | + | } | |
315 | + | ||
316 | + | ||
256 | 317 | @Callable(i) | |
257 | 318 | func init (chainId_,pauser_,gatewayContract_,sWavesContract_) = { | |
258 | 319 | let err = if (if (if (if (if (if (_onlyThisContract(i.caller)) | |
285 | 346 | then _validateInt(i.payments[0].amount, 0, MAX_INT, "deposit: negative payment") | |
286 | 347 | else false | |
287 | 348 | if ((err == err)) | |
288 | - | then { | |
289 | - | let caller = toString(i.caller) | |
290 | - | let asset = _assetToStr(i.payments[0].assetId) | |
291 | - | let assetDecimals = _getDecimals(asset) | |
292 | - | let amount = _normalizeDecimals(i.payments[0].amount, assetDecimals, DEX_DECIMALS) | |
293 | - | let err1 = _validateInt(amount, 1, MAX_INT, "deposit: invalid payment amount") | |
294 | - | if ((err1 == err1)) | |
295 | - | then { | |
296 | - | let gatewayInvocation = invoke(_loadGatewayContract(), FUNC_DEPOSIT, [toString(this), caller, caller, toString(_loadChainId()), asset, toString(amount)], nil) | |
297 | - | if ((gatewayInvocation == gatewayInvocation)) | |
298 | - | then { | |
299 | - | let stakingInvocation = if ((asset == WAVES)) | |
300 | - | then invoke(_loadSWavesContract(), FUNC_DEPOSIT, nil, [AttachedPayment(unit, i.payments[0].amount)]) | |
301 | - | else unit | |
302 | - | if ((stakingInvocation == stakingInvocation)) | |
303 | - | then $Tuple2(_saveReserves(asset, (_loadReserves(asset) + amount)), unit) | |
304 | - | else throw("Strict value is not equal to itself.") | |
305 | - | } | |
306 | - | else throw("Strict value is not equal to itself.") | |
307 | - | } | |
308 | - | else throw("Strict value is not equal to itself.") | |
309 | - | } | |
349 | + | then $Tuple2(_deposit(toString(i.caller), toString(i.caller), _assetToStr(i.payments[0].assetId), i.payments[0].amount), unit) | |
310 | 350 | else throw("Strict value is not equal to itself.") | |
311 | 351 | } | |
312 | 352 | ||
324 | 364 | then _validateString(to_, "depositTo: invalid to") | |
325 | 365 | else false | |
326 | 366 | if ((err == err)) | |
327 | - | then { | |
328 | - | let caller = toString(i.caller) | |
329 | - | let asset = _assetToStr(i.payments[0].assetId) | |
330 | - | let assetDecimals = _getDecimals(asset) | |
331 | - | let amount = _normalizeDecimals(i.payments[0].amount, assetDecimals, DEX_DECIMALS) | |
332 | - | let err1 = _validateInt(amount, 1, MAX_INT, "depositTo: invalid payment amount") | |
333 | - | if ((err1 == err1)) | |
334 | - | then { | |
335 | - | let gatewayInvocation = invoke(_loadGatewayContract(), FUNC_DEPOSIT, [toString(this), caller, to_, toString(_loadChainId()), asset, toString(amount)], nil) | |
336 | - | if ((gatewayInvocation == gatewayInvocation)) | |
337 | - | then { | |
338 | - | let stakingInvocation = if ((asset == WAVES)) | |
339 | - | then invoke(_loadSWavesContract(), FUNC_DEPOSIT, nil, [AttachedPayment(unit, i.payments[0].amount)]) | |
340 | - | else unit | |
341 | - | if ((stakingInvocation == stakingInvocation)) | |
342 | - | then $Tuple2(_saveReserves(asset, (_loadReserves(asset) + amount)), unit) | |
343 | - | else throw("Strict value is not equal to itself.") | |
344 | - | } | |
345 | - | else throw("Strict value is not equal to itself.") | |
346 | - | } | |
347 | - | else throw("Strict value is not equal to itself.") | |
348 | - | } | |
367 | + | then $Tuple2(_deposit(toString(i.caller), to_, _assetToStr(i.payments[0].assetId), i.payments[0].amount), unit) | |
349 | 368 | else throw("Strict value is not equal to itself.") | |
350 | 369 | } | |
351 | 370 | ||
418 | 437 | else false | |
419 | 438 | if ((err1 == err1)) | |
420 | 439 | then { | |
440 | + | let stakingAssets = _loadStakingAssets() | |
421 | 441 | let unstakingInvocation = if ((asset_ == WAVES)) | |
422 | 442 | then { | |
423 | 443 | let sWavesContract = _loadSWavesContract() | |
432 | 452 | let sWavesToWithdraw = toInt(fraction(toBigInt(amountNormalized), SWAVES_RATE_FACTOR, rate, CEILING)) | |
433 | 453 | invoke(sWavesContract, FUNC_WITHDRAW, nil, [AttachedPayment(sWavesAsset, sWavesToWithdraw)]) | |
434 | 454 | } | |
435 | - | else unit | |
455 | + | else if (containsElement(stakingAssets, asset_)) | |
456 | + | then invoke(_loadStakingContract(asset_), FUNC_UNSTAKE, [amountNormalized], nil) | |
457 | + | else unit | |
436 | 458 | if ((unstakingInvocation == unstakingInvocation)) | |
437 | 459 | then $Tuple2(([ScriptTransfer(addressFromStringValue(to_), amountNormalized, _strToAsset(asset_))] ++ _saveReserves(asset_, newReserves)), unit) | |
438 | 460 | else throw("Strict value is not equal to itself.") | |
461 | + | } | |
462 | + | else throw("Strict value is not equal to itself.") | |
463 | + | } | |
464 | + | else throw("Strict value is not equal to itself.") | |
465 | + | } | |
466 | + | ||
467 | + | ||
468 | + | ||
469 | + | @Callable(i) | |
470 | + | func depositStakingReward (asset_) = { | |
471 | + | let err = if (_whenInitialized()) | |
472 | + | then _validateAsset(asset_, "depositStakingReward: invalid asset") | |
473 | + | else false | |
474 | + | if ((err == err)) | |
475 | + | then { | |
476 | + | let stakingAssets = _loadStakingAssets() | |
477 | + | let updatedReserves = if ((asset_ == WAVES)) | |
478 | + | then { | |
479 | + | let sWavesContract = _loadSWavesContract() | |
480 | + | let sWavesAsset = _loadSWavesAsset(sWavesContract) | |
481 | + | let invocation = invoke(sWavesContract, FUNC_GET_RATE, nil, nil) | |
482 | + | let rate = match invocation { | |
483 | + | case a: String => | |
484 | + | parseBigIntValue(a) | |
485 | + | case _ => | |
486 | + | throw("depositStakingReward: sWaves getRate() revert") | |
487 | + | } | |
488 | + | let swavesAmount = assetBalance(this, sWavesAsset) | |
489 | + | toInt(fraction(toBigInt(swavesAmount), rate, SWAVES_RATE_FACTOR, DOWN)) | |
490 | + | } | |
491 | + | else if (containsElement(stakingAssets, asset_)) | |
492 | + | then { | |
493 | + | let invocation = invoke(_loadStakingContract(asset_), FUNC_CLAIM_ALL, [toString(this)], nil) | |
494 | + | if ((invocation == invocation)) | |
495 | + | then assetBalance(this, fromBase58String(asset_)) | |
496 | + | else throw("Strict value is not equal to itself.") | |
497 | + | } | |
498 | + | else throw("depositStakingReward: no staking for asset") | |
499 | + | let assetDecimals = _getDecimals(asset_) | |
500 | + | let updatedReservesNormalized = _normalizeDecimals(updatedReserves, assetDecimals, DEX_DECIMALS) | |
501 | + | let stakingProfit = (updatedReservesNormalized - _loadReserves(asset_)) | |
502 | + | let err1 = _validateInt(stakingProfit, 1, MAX_INT, "depositStakingReward: no reward") | |
503 | + | if ((err1 == err1)) | |
504 | + | then { | |
505 | + | let gatewayInvocation = invoke(_loadGatewayContract(), FUNC_DEPOSIT_STAKING_REWARD, [toString(this), toString(_loadChainId()), asset_, toString(stakingProfit)], nil) | |
506 | + | if ((gatewayInvocation == gatewayInvocation)) | |
507 | + | then $Tuple2(_saveReserves(asset_, updatedReservesNormalized), unit) | |
508 | + | else throw("Strict value is not equal to itself.") | |
509 | + | } | |
510 | + | else throw("Strict value is not equal to itself.") | |
511 | + | } | |
512 | + | else throw("Strict value is not equal to itself.") | |
513 | + | } | |
514 | + | ||
515 | + | ||
516 | + | ||
517 | + | @Callable(i) | |
518 | + | func addStakingAsset (asset_,contract_) = { | |
519 | + | let err = if (if (_onlyThisContract(i.caller)) | |
520 | + | then _validateAsset(asset_, "addStakingAsset: invalid asset") | |
521 | + | else false) | |
522 | + | then _validateAddress(contract_, "addStakingAsset: invalid contract") | |
523 | + | else false | |
524 | + | if ((err == err)) | |
525 | + | then { | |
526 | + | let assets = _loadStakingAssets() | |
527 | + | let err1 = if (containsElement(assets, asset_)) | |
528 | + | then throw("addStakingAsset: duplicate asset") | |
529 | + | else unit | |
530 | + | if ((err1 == err1)) | |
531 | + | then $Tuple2((_saveStakingAssets((assets :+ asset_)) ++ _saveStakingContract(asset_, addressFromStringValue(contract_))), unit) | |
532 | + | else throw("Strict value is not equal to itself.") | |
533 | + | } | |
534 | + | else throw("Strict value is not equal to itself.") | |
535 | + | } | |
536 | + | ||
537 | + | ||
538 | + | ||
539 | + | @Callable(i) | |
540 | + | func rmStakingAsset (asset_) = { | |
541 | + | let err = if (_onlyThisContract(i.caller)) | |
542 | + | then _validateAsset(asset_, "rmStakingAsset: invalid asset") | |
543 | + | else false | |
544 | + | if ((err == err)) | |
545 | + | then { | |
546 | + | let assets = _loadStakingAssets() | |
547 | + | let err1 = if (!(containsElement(assets, asset_))) | |
548 | + | then throw("rmStakingAsset: no asset") | |
549 | + | else unit | |
550 | + | if ((err1 == err1)) | |
551 | + | then { | |
552 | + | let index = value(indexOf(assets, asset_)) | |
553 | + | $Tuple2(_saveStakingAssets(removeByIndex(assets, index)), unit) | |
439 | 554 | } | |
440 | 555 | else throw("Strict value is not equal to itself.") | |
441 | 556 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 7 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEPARATOR = "__" | |
5 | 5 | ||
6 | 6 | let KEY_MULTISIG = "MULTISIG" | |
7 | 7 | ||
8 | 8 | let KEY_STATUS = "STATUS" | |
9 | 9 | ||
10 | 10 | let KEY_INIT = "INIT" | |
11 | 11 | ||
12 | 12 | let KEY_PAUSED = "PAUSED" | |
13 | 13 | ||
14 | 14 | let KEY_PAUSER = "PAUSER" | |
15 | 15 | ||
16 | 16 | let KEY_CHAIN = "CHAIN" | |
17 | 17 | ||
18 | 18 | let KEY_GATEWAY_CONTRACT = "GATEWAY_CONTRACT" | |
19 | 19 | ||
20 | 20 | let KEY_SWAVES_CONTRACT = "SWAVES_CONTRACT" | |
21 | 21 | ||
22 | 22 | let KEY_SWAVES_ASSET = "ASSET" | |
23 | 23 | ||
24 | 24 | let KEY_RESERVES = "RESERVES" | |
25 | 25 | ||
26 | + | let KEY_STAKING_ASSETS = "STAKING_ASSETS" | |
27 | + | ||
28 | + | let KEY_STAKING_CONTRACT = "STAKING_CONTRACT" | |
29 | + | ||
26 | 30 | let FUNC_DEPOSIT = "deposit" | |
27 | 31 | ||
28 | 32 | let FUNC_REQUEST_WITHDRAWAL = "requestWithdrawal" | |
29 | 33 | ||
30 | 34 | let FUNC_EXECUTE_WITHDRAWAL = "executeWithdrawal" | |
31 | 35 | ||
32 | 36 | let FUNC_GET_RATE = "getRate" | |
33 | 37 | ||
34 | 38 | let FUNC_WITHDRAW = "withdraw" | |
39 | + | ||
40 | + | let FUNC_STAKE = "stake" | |
41 | + | ||
42 | + | let FUNC_UNSTAKE = "unstake" | |
43 | + | ||
44 | + | let FUNC_CLAIM_ALL = "claimAll" | |
45 | + | ||
46 | + | let FUNC_DEPOSIT_STAKING_REWARD = "depositStakingReward" | |
35 | 47 | ||
36 | 48 | let WAVES = "WAVES" | |
37 | 49 | ||
38 | 50 | let WAVES_DECIMALS = 8 | |
39 | 51 | ||
40 | 52 | let DEX_DECIMALS = 8 | |
41 | 53 | ||
42 | 54 | let MAX_INT = 9223372036854775807 | |
43 | 55 | ||
44 | 56 | let ZERO_BIGINT = toBigInt(0) | |
45 | 57 | ||
46 | 58 | let ONE_BIGINT = toBigInt(1) | |
47 | 59 | ||
48 | 60 | let SWAVES_RATE_FACTOR = toBigInt(1000000000000) | |
49 | 61 | ||
50 | 62 | func _validateAddress (address_,err_) = match addressFromString(address_) { | |
51 | 63 | case a: Address => | |
52 | 64 | true | |
53 | 65 | case _ => | |
54 | 66 | throw(err_) | |
55 | 67 | } | |
56 | 68 | ||
57 | 69 | ||
58 | 70 | func _validateAsset (assetId_,err_) = if ((assetId_ == WAVES)) | |
59 | 71 | then true | |
60 | 72 | else match assetInfo(fromBase58String(assetId_)) { | |
61 | 73 | case a: Asset => | |
62 | 74 | true | |
63 | 75 | case _ => | |
64 | 76 | throw(err_) | |
65 | 77 | } | |
66 | 78 | ||
67 | 79 | ||
68 | 80 | func _validateInt (val_,lowerBoundary_,upperBoundary_,err_) = if (if ((lowerBoundary_ > val_)) | |
69 | 81 | then true | |
70 | 82 | else (val_ > upperBoundary_)) | |
71 | 83 | then throw(err_) | |
72 | 84 | else true | |
73 | 85 | ||
74 | 86 | ||
75 | 87 | func _validateBigInt (val_,lowerBoundary_,err_) = if ((lowerBoundary_ > val_)) | |
76 | 88 | then throw(err_) | |
77 | 89 | else true | |
78 | 90 | ||
79 | 91 | ||
80 | 92 | func _validateString (val_,err_) = if (if ((0 >= size(val_))) | |
81 | 93 | then true | |
82 | 94 | else contains(val_, SEPARATOR)) | |
83 | 95 | then throw(err_) | |
84 | 96 | else true | |
85 | 97 | ||
86 | 98 | ||
87 | 99 | func _validatePaymentsSize (payments_,target_,err_) = if ((size(payments_) != target_)) | |
88 | 100 | then throw(err_) | |
89 | 101 | else true | |
90 | 102 | ||
91 | 103 | ||
92 | 104 | func _assetToStr (asset_) = match asset_ { | |
93 | 105 | case a: ByteVector => | |
94 | 106 | toBase58String(a) | |
95 | 107 | case _ => | |
96 | 108 | WAVES | |
97 | 109 | } | |
98 | 110 | ||
99 | 111 | ||
100 | 112 | func _strToAsset (asset_) = if ((asset_ == WAVES)) | |
101 | 113 | then unit | |
102 | 114 | else fromBase58String(asset_) | |
103 | 115 | ||
104 | 116 | ||
105 | 117 | func _getDecimals (assetId_) = if ((assetId_ == WAVES)) | |
106 | 118 | then WAVES_DECIMALS | |
107 | 119 | else match assetInfo(fromBase58String(assetId_)) { | |
108 | 120 | case a: Asset => | |
109 | 121 | a.decimals | |
110 | 122 | case _ => | |
111 | 123 | throw(("_getDecimals: no asset=" + assetId_)) | |
112 | 124 | } | |
113 | 125 | ||
114 | 126 | ||
115 | 127 | func _normalizeDecimals (amount_,sourceDecimals_,targetDecimals_) = if ((sourceDecimals_ >= targetDecimals_)) | |
116 | 128 | then (amount_ / pow(10, 0, (sourceDecimals_ - targetDecimals_), 0, 0, DOWN)) | |
117 | 129 | else (amount_ * pow(10, 0, (targetDecimals_ - sourceDecimals_), 0, 0, DOWN)) | |
118 | 130 | ||
119 | 131 | ||
120 | 132 | func _loadInit () = match getBoolean(KEY_INIT) { | |
121 | 133 | case a: Boolean => | |
122 | 134 | a | |
123 | 135 | case _ => | |
124 | 136 | false | |
125 | 137 | } | |
126 | 138 | ||
127 | 139 | ||
128 | 140 | func _saveInit (isInit_) = [BooleanEntry(KEY_INIT, isInit_)] | |
129 | 141 | ||
130 | 142 | ||
131 | 143 | func _loadPause () = match getBoolean(KEY_PAUSED) { | |
132 | 144 | case a: Boolean => | |
133 | 145 | a | |
134 | 146 | case _ => | |
135 | 147 | false | |
136 | 148 | } | |
137 | 149 | ||
138 | 150 | ||
139 | 151 | func _savePause (isPaused_) = [BooleanEntry(KEY_PAUSED, isPaused_)] | |
140 | 152 | ||
141 | 153 | ||
142 | 154 | func _loadPauser () = match getString(KEY_PAUSER) { | |
143 | 155 | case a: String => | |
144 | 156 | addressFromStringValue(a) | |
145 | 157 | case _ => | |
146 | 158 | Address(base58'') | |
147 | 159 | } | |
148 | 160 | ||
149 | 161 | ||
150 | 162 | func _savePauser (pauser_) = [StringEntry(KEY_PAUSER, toString(pauser_))] | |
151 | 163 | ||
152 | 164 | ||
153 | 165 | func _loadMultisig () = match getString(KEY_MULTISIG) { | |
154 | 166 | case a: String => | |
155 | 167 | addressFromStringValue(a) | |
156 | 168 | case _ => | |
157 | 169 | Address(base58'') | |
158 | 170 | } | |
159 | 171 | ||
160 | 172 | ||
161 | 173 | func _saveMultisig (multisig_) = [StringEntry(KEY_MULTISIG, toString(multisig_))] | |
162 | 174 | ||
163 | 175 | ||
164 | 176 | func _loadChainId () = match getInteger(KEY_CHAIN) { | |
165 | 177 | case a: Int => | |
166 | 178 | a | |
167 | 179 | case _ => | |
168 | 180 | 0 | |
169 | 181 | } | |
170 | 182 | ||
171 | 183 | ||
172 | 184 | func _saveChainId (chainId_) = [IntegerEntry(KEY_CHAIN, chainId_)] | |
173 | 185 | ||
174 | 186 | ||
175 | 187 | func _loadGatewayContract () = match getString(KEY_GATEWAY_CONTRACT) { | |
176 | 188 | case a: String => | |
177 | 189 | addressFromStringValue(a) | |
178 | 190 | case _ => | |
179 | 191 | Address(base58'') | |
180 | 192 | } | |
181 | 193 | ||
182 | 194 | ||
183 | 195 | func _saveGatewayContract (gatewayContract_) = [StringEntry(KEY_GATEWAY_CONTRACT, toString(gatewayContract_))] | |
184 | 196 | ||
185 | 197 | ||
186 | 198 | func _loadSWavesContract () = match getString(KEY_SWAVES_CONTRACT) { | |
187 | 199 | case a: String => | |
188 | 200 | addressFromStringValue(a) | |
189 | 201 | case _ => | |
190 | 202 | Address(base58'') | |
191 | 203 | } | |
192 | 204 | ||
193 | 205 | ||
194 | 206 | func _saveSWavesContract (sWavesContract_) = [StringEntry(KEY_SWAVES_CONTRACT, toString(sWavesContract_))] | |
195 | 207 | ||
196 | 208 | ||
197 | 209 | func _loadSWavesAsset (contract_) = match getString(contract_, KEY_SWAVES_ASSET) { | |
198 | 210 | case a: String => | |
199 | 211 | fromBase58String(a) | |
200 | 212 | case _ => | |
201 | 213 | throw("_loadSWavesAsset: revert") | |
202 | 214 | } | |
203 | 215 | ||
204 | 216 | ||
205 | 217 | func _loadReserves (asset_) = match getInteger(makeString([KEY_RESERVES, asset_], SEPARATOR)) { | |
206 | 218 | case a: Int => | |
207 | 219 | a | |
208 | 220 | case _ => | |
209 | 221 | 0 | |
210 | 222 | } | |
211 | 223 | ||
212 | 224 | ||
213 | 225 | func _saveReserves (asset_,reserves_) = [IntegerEntry(makeString([KEY_RESERVES, asset_], SEPARATOR), reserves_)] | |
214 | 226 | ||
215 | 227 | ||
228 | + | func _loadStakingAssets () = match getString(KEY_STAKING_ASSETS) { | |
229 | + | case a: String => | |
230 | + | if ((size(a) > 0)) | |
231 | + | then split_51C(a, SEPARATOR) | |
232 | + | else nil | |
233 | + | case _ => | |
234 | + | nil | |
235 | + | } | |
236 | + | ||
237 | + | ||
238 | + | func _saveStakingAssets (assets_) = [StringEntry(KEY_STAKING_ASSETS, makeString(assets_, SEPARATOR))] | |
239 | + | ||
240 | + | ||
241 | + | func _loadStakingContract (asset_) = match getString(makeString([KEY_STAKING_CONTRACT, asset_], SEPARATOR)) { | |
242 | + | case a: String => | |
243 | + | addressFromStringValue(a) | |
244 | + | case _ => | |
245 | + | Address(base58'') | |
246 | + | } | |
247 | + | ||
248 | + | ||
249 | + | func _saveStakingContract (asset_,contract_) = [StringEntry(makeString([KEY_STAKING_CONTRACT, asset_], SEPARATOR), toString(contract_))] | |
250 | + | ||
251 | + | ||
216 | 252 | func _onlyThisContract (caller_) = if ((caller_ != this)) | |
217 | 253 | then throw("_onlyThisContract: revert") | |
218 | 254 | else true | |
219 | 255 | ||
220 | 256 | ||
221 | 257 | func _whenMultisigSet () = if ((_loadMultisig() == Address(base58''))) | |
222 | 258 | then throw("_whenMultisigSet: revert") | |
223 | 259 | else true | |
224 | 260 | ||
225 | 261 | ||
226 | 262 | func _whenNotInitialized () = if (_loadInit()) | |
227 | 263 | then throw("_whenNotInitialized: revert") | |
228 | 264 | else true | |
229 | 265 | ||
230 | 266 | ||
231 | 267 | func _whenInitialized () = if (!(_loadInit())) | |
232 | 268 | then throw("_whenInitialized: revert") | |
233 | 269 | else true | |
234 | 270 | ||
235 | 271 | ||
236 | 272 | func _whenNotPaused () = if (_loadPause()) | |
237 | 273 | then throw("_whenNotPaused: revert") | |
238 | 274 | else true | |
239 | 275 | ||
240 | 276 | ||
241 | 277 | func _whenPaused () = if (!(_loadPause())) | |
242 | 278 | then throw("_whenPaused: revert") | |
243 | 279 | else true | |
244 | 280 | ||
245 | 281 | ||
246 | 282 | func _onlyPauser (caller_) = if ((caller_ != _loadPauser())) | |
247 | 283 | then throw("_onlyPauser: revert") | |
248 | 284 | else true | |
249 | 285 | ||
250 | 286 | ||
251 | 287 | func _validateGateway (caller,err_) = if ((_loadGatewayContract() != caller)) | |
252 | 288 | then throw(err_) | |
253 | 289 | else true | |
254 | 290 | ||
255 | 291 | ||
292 | + | func _deposit (from_,to_,asset_,amount_) = { | |
293 | + | let assetDecimals = _getDecimals(asset_) | |
294 | + | let amount = _normalizeDecimals(amount_, assetDecimals, DEX_DECIMALS) | |
295 | + | let err = _validateInt(amount, 1, MAX_INT, "_deposit: invalid payment amount") | |
296 | + | if ((err == err)) | |
297 | + | then { | |
298 | + | let gatewayInvocation = invoke(_loadGatewayContract(), FUNC_DEPOSIT, [toString(this), from_, to_, toString(_loadChainId()), asset_, toString(amount)], nil) | |
299 | + | if ((gatewayInvocation == gatewayInvocation)) | |
300 | + | then { | |
301 | + | let stakingAssets = _loadStakingAssets() | |
302 | + | let stakingInvocation = if ((asset_ == WAVES)) | |
303 | + | then invoke(_loadSWavesContract(), FUNC_DEPOSIT, nil, [AttachedPayment(unit, amount_)]) | |
304 | + | else if (containsElement(stakingAssets, asset_)) | |
305 | + | then invoke(_loadStakingContract(asset_), FUNC_STAKE, nil, [AttachedPayment(_strToAsset(asset_), amount_)]) | |
306 | + | else unit | |
307 | + | if ((stakingInvocation == stakingInvocation)) | |
308 | + | then _saveReserves(asset_, (_loadReserves(asset_) + amount)) | |
309 | + | else throw("Strict value is not equal to itself.") | |
310 | + | } | |
311 | + | else throw("Strict value is not equal to itself.") | |
312 | + | } | |
313 | + | else throw("Strict value is not equal to itself.") | |
314 | + | } | |
315 | + | ||
316 | + | ||
256 | 317 | @Callable(i) | |
257 | 318 | func init (chainId_,pauser_,gatewayContract_,sWavesContract_) = { | |
258 | 319 | let err = if (if (if (if (if (if (_onlyThisContract(i.caller)) | |
259 | 320 | then _whenNotInitialized() | |
260 | 321 | else false) | |
261 | 322 | then _whenMultisigSet() | |
262 | 323 | else false) | |
263 | 324 | then _validateInt(chainId_, 0, MAX_INT, "init: invalid chainId") | |
264 | 325 | else false) | |
265 | 326 | then _validateAddress(pauser_, "init: invalid pauser") | |
266 | 327 | else false) | |
267 | 328 | then _validateAddress(gatewayContract_, "init: invalid gatewayContract") | |
268 | 329 | else false) | |
269 | 330 | then _validateAddress(sWavesContract_, "init: invalid sWavesContract") | |
270 | 331 | else false | |
271 | 332 | if ((err == err)) | |
272 | 333 | then $Tuple2(((((_saveInit(true) ++ _saveChainId(chainId_)) ++ _savePauser(addressFromStringValue(pauser_))) ++ _saveGatewayContract(addressFromStringValue(gatewayContract_))) ++ _saveSWavesContract(addressFromStringValue(sWavesContract_))), unit) | |
273 | 334 | else throw("Strict value is not equal to itself.") | |
274 | 335 | } | |
275 | 336 | ||
276 | 337 | ||
277 | 338 | ||
278 | 339 | @Callable(i) | |
279 | 340 | func deposit () = { | |
280 | 341 | let err = if (if (if (_whenInitialized()) | |
281 | 342 | then _whenNotPaused() | |
282 | 343 | else false) | |
283 | 344 | then _validatePaymentsSize(i.payments, 1, "deposit: no payment") | |
284 | 345 | else false) | |
285 | 346 | then _validateInt(i.payments[0].amount, 0, MAX_INT, "deposit: negative payment") | |
286 | 347 | else false | |
287 | 348 | if ((err == err)) | |
288 | - | then { | |
289 | - | let caller = toString(i.caller) | |
290 | - | let asset = _assetToStr(i.payments[0].assetId) | |
291 | - | let assetDecimals = _getDecimals(asset) | |
292 | - | let amount = _normalizeDecimals(i.payments[0].amount, assetDecimals, DEX_DECIMALS) | |
293 | - | let err1 = _validateInt(amount, 1, MAX_INT, "deposit: invalid payment amount") | |
294 | - | if ((err1 == err1)) | |
295 | - | then { | |
296 | - | let gatewayInvocation = invoke(_loadGatewayContract(), FUNC_DEPOSIT, [toString(this), caller, caller, toString(_loadChainId()), asset, toString(amount)], nil) | |
297 | - | if ((gatewayInvocation == gatewayInvocation)) | |
298 | - | then { | |
299 | - | let stakingInvocation = if ((asset == WAVES)) | |
300 | - | then invoke(_loadSWavesContract(), FUNC_DEPOSIT, nil, [AttachedPayment(unit, i.payments[0].amount)]) | |
301 | - | else unit | |
302 | - | if ((stakingInvocation == stakingInvocation)) | |
303 | - | then $Tuple2(_saveReserves(asset, (_loadReserves(asset) + amount)), unit) | |
304 | - | else throw("Strict value is not equal to itself.") | |
305 | - | } | |
306 | - | else throw("Strict value is not equal to itself.") | |
307 | - | } | |
308 | - | else throw("Strict value is not equal to itself.") | |
309 | - | } | |
349 | + | then $Tuple2(_deposit(toString(i.caller), toString(i.caller), _assetToStr(i.payments[0].assetId), i.payments[0].amount), unit) | |
310 | 350 | else throw("Strict value is not equal to itself.") | |
311 | 351 | } | |
312 | 352 | ||
313 | 353 | ||
314 | 354 | ||
315 | 355 | @Callable(i) | |
316 | 356 | func depositTo (to_) = { | |
317 | 357 | let err = if (if (if (if (_whenInitialized()) | |
318 | 358 | then _whenNotPaused() | |
319 | 359 | else false) | |
320 | 360 | then _validatePaymentsSize(i.payments, 1, "depositTo: no payment") | |
321 | 361 | else false) | |
322 | 362 | then _validateInt(i.payments[0].amount, 0, MAX_INT, "depositTo: negative payment") | |
323 | 363 | else false) | |
324 | 364 | then _validateString(to_, "depositTo: invalid to") | |
325 | 365 | else false | |
326 | 366 | if ((err == err)) | |
327 | - | then { | |
328 | - | let caller = toString(i.caller) | |
329 | - | let asset = _assetToStr(i.payments[0].assetId) | |
330 | - | let assetDecimals = _getDecimals(asset) | |
331 | - | let amount = _normalizeDecimals(i.payments[0].amount, assetDecimals, DEX_DECIMALS) | |
332 | - | let err1 = _validateInt(amount, 1, MAX_INT, "depositTo: invalid payment amount") | |
333 | - | if ((err1 == err1)) | |
334 | - | then { | |
335 | - | let gatewayInvocation = invoke(_loadGatewayContract(), FUNC_DEPOSIT, [toString(this), caller, to_, toString(_loadChainId()), asset, toString(amount)], nil) | |
336 | - | if ((gatewayInvocation == gatewayInvocation)) | |
337 | - | then { | |
338 | - | let stakingInvocation = if ((asset == WAVES)) | |
339 | - | then invoke(_loadSWavesContract(), FUNC_DEPOSIT, nil, [AttachedPayment(unit, i.payments[0].amount)]) | |
340 | - | else unit | |
341 | - | if ((stakingInvocation == stakingInvocation)) | |
342 | - | then $Tuple2(_saveReserves(asset, (_loadReserves(asset) + amount)), unit) | |
343 | - | else throw("Strict value is not equal to itself.") | |
344 | - | } | |
345 | - | else throw("Strict value is not equal to itself.") | |
346 | - | } | |
347 | - | else throw("Strict value is not equal to itself.") | |
348 | - | } | |
367 | + | then $Tuple2(_deposit(toString(i.caller), to_, _assetToStr(i.payments[0].assetId), i.payments[0].amount), unit) | |
349 | 368 | else throw("Strict value is not equal to itself.") | |
350 | 369 | } | |
351 | 370 | ||
352 | 371 | ||
353 | 372 | ||
354 | 373 | @Callable(i) | |
355 | 374 | func requestWithdrawal (toChainId_,asset_,amount_) = { | |
356 | 375 | let amount = valueOrErrorMessage(parseBigInt(amount_), "requestWithdrawal: amount not int") | |
357 | 376 | let err = if (if (if (_whenInitialized()) | |
358 | 377 | then _validateInt(toChainId_, 0, MAX_INT, "requestWithdrawal: invalid toChainId") | |
359 | 378 | else false) | |
360 | 379 | then _validateString(asset_, "requestWithdrawal: invalid asset") | |
361 | 380 | else false) | |
362 | 381 | then _validateBigInt(amount, ONE_BIGINT, "requestWithdrawal: negative amount") | |
363 | 382 | else false | |
364 | 383 | if ((err == err)) | |
365 | 384 | then { | |
366 | 385 | let caller = toString(i.caller) | |
367 | 386 | let requestWithdrawalId = match invoke(_loadGatewayContract(), FUNC_REQUEST_WITHDRAWAL, [toString(this), caller, caller, toString(_loadChainId()), toString(toChainId_), asset_, amount_], nil) { | |
368 | 387 | case a: Int => | |
369 | 388 | a | |
370 | 389 | case _ => | |
371 | 390 | throw("requestWithdrawal: call reverted from gw") | |
372 | 391 | } | |
373 | 392 | if ((requestWithdrawalId == requestWithdrawalId)) | |
374 | 393 | then $Tuple2(nil, requestWithdrawalId) | |
375 | 394 | else throw("Strict value is not equal to itself.") | |
376 | 395 | } | |
377 | 396 | else throw("Strict value is not equal to itself.") | |
378 | 397 | } | |
379 | 398 | ||
380 | 399 | ||
381 | 400 | ||
382 | 401 | @Callable(i) | |
383 | 402 | func executeWithdrawal (requestWithdrawalId_) = { | |
384 | 403 | let err = if (_whenInitialized()) | |
385 | 404 | then _validateInt(requestWithdrawalId_, 0, MAX_INT, "executeWithdrawal: invalid requestId") | |
386 | 405 | else false | |
387 | 406 | if ((err == err)) | |
388 | 407 | then { | |
389 | 408 | let gatewayInvocation = reentrantInvoke(_loadGatewayContract(), FUNC_EXECUTE_WITHDRAWAL, [toString(this), toString(_loadChainId()), toString(requestWithdrawalId_)], nil) | |
390 | 409 | if ((gatewayInvocation == gatewayInvocation)) | |
391 | 410 | then $Tuple2(nil, unit) | |
392 | 411 | else throw("Strict value is not equal to itself.") | |
393 | 412 | } | |
394 | 413 | else throw("Strict value is not equal to itself.") | |
395 | 414 | } | |
396 | 415 | ||
397 | 416 | ||
398 | 417 | ||
399 | 418 | @Callable(i) | |
400 | 419 | func withdraw (to_,asset_,amount_) = { | |
401 | 420 | let amount = valueOrErrorMessage(parseInt(amount_), "withdraw: amount not int") | |
402 | 421 | let err = if (if (if (if (_whenInitialized()) | |
403 | 422 | then _validateGateway(i.caller, "withdraw: invalid gateway") | |
404 | 423 | else false) | |
405 | 424 | then _validateAddress(to_, "withdraw: invalid address") | |
406 | 425 | else false) | |
407 | 426 | then _validateAsset(asset_, "withdraw: invalid asset") | |
408 | 427 | else false) | |
409 | 428 | then _validateInt(amount, 0, MAX_INT, "withdraw: negative amount") | |
410 | 429 | else false | |
411 | 430 | if ((err == err)) | |
412 | 431 | then { | |
413 | 432 | let assetDecimals = _getDecimals(asset_) | |
414 | 433 | let amountNormalized = _normalizeDecimals(amount, DEX_DECIMALS, assetDecimals) | |
415 | 434 | let newReserves = (_loadReserves(asset_) - amount) | |
416 | 435 | let err1 = if (_validateInt(amountNormalized, 1, MAX_INT, "withdraw: invalid amount")) | |
417 | 436 | then _validateInt(newReserves, 0, MAX_INT, "withdraw: negative newReserves") | |
418 | 437 | else false | |
419 | 438 | if ((err1 == err1)) | |
420 | 439 | then { | |
440 | + | let stakingAssets = _loadStakingAssets() | |
421 | 441 | let unstakingInvocation = if ((asset_ == WAVES)) | |
422 | 442 | then { | |
423 | 443 | let sWavesContract = _loadSWavesContract() | |
424 | 444 | let sWavesAsset = _loadSWavesAsset(sWavesContract) | |
425 | 445 | let invocation = invoke(sWavesContract, FUNC_GET_RATE, nil, nil) | |
426 | 446 | let rate = match invocation { | |
427 | 447 | case a: String => | |
428 | 448 | parseBigIntValue(a) | |
429 | 449 | case _ => | |
430 | 450 | throw("withdraw: sWaves getRate() revert") | |
431 | 451 | } | |
432 | 452 | let sWavesToWithdraw = toInt(fraction(toBigInt(amountNormalized), SWAVES_RATE_FACTOR, rate, CEILING)) | |
433 | 453 | invoke(sWavesContract, FUNC_WITHDRAW, nil, [AttachedPayment(sWavesAsset, sWavesToWithdraw)]) | |
434 | 454 | } | |
435 | - | else unit | |
455 | + | else if (containsElement(stakingAssets, asset_)) | |
456 | + | then invoke(_loadStakingContract(asset_), FUNC_UNSTAKE, [amountNormalized], nil) | |
457 | + | else unit | |
436 | 458 | if ((unstakingInvocation == unstakingInvocation)) | |
437 | 459 | then $Tuple2(([ScriptTransfer(addressFromStringValue(to_), amountNormalized, _strToAsset(asset_))] ++ _saveReserves(asset_, newReserves)), unit) | |
438 | 460 | else throw("Strict value is not equal to itself.") | |
461 | + | } | |
462 | + | else throw("Strict value is not equal to itself.") | |
463 | + | } | |
464 | + | else throw("Strict value is not equal to itself.") | |
465 | + | } | |
466 | + | ||
467 | + | ||
468 | + | ||
469 | + | @Callable(i) | |
470 | + | func depositStakingReward (asset_) = { | |
471 | + | let err = if (_whenInitialized()) | |
472 | + | then _validateAsset(asset_, "depositStakingReward: invalid asset") | |
473 | + | else false | |
474 | + | if ((err == err)) | |
475 | + | then { | |
476 | + | let stakingAssets = _loadStakingAssets() | |
477 | + | let updatedReserves = if ((asset_ == WAVES)) | |
478 | + | then { | |
479 | + | let sWavesContract = _loadSWavesContract() | |
480 | + | let sWavesAsset = _loadSWavesAsset(sWavesContract) | |
481 | + | let invocation = invoke(sWavesContract, FUNC_GET_RATE, nil, nil) | |
482 | + | let rate = match invocation { | |
483 | + | case a: String => | |
484 | + | parseBigIntValue(a) | |
485 | + | case _ => | |
486 | + | throw("depositStakingReward: sWaves getRate() revert") | |
487 | + | } | |
488 | + | let swavesAmount = assetBalance(this, sWavesAsset) | |
489 | + | toInt(fraction(toBigInt(swavesAmount), rate, SWAVES_RATE_FACTOR, DOWN)) | |
490 | + | } | |
491 | + | else if (containsElement(stakingAssets, asset_)) | |
492 | + | then { | |
493 | + | let invocation = invoke(_loadStakingContract(asset_), FUNC_CLAIM_ALL, [toString(this)], nil) | |
494 | + | if ((invocation == invocation)) | |
495 | + | then assetBalance(this, fromBase58String(asset_)) | |
496 | + | else throw("Strict value is not equal to itself.") | |
497 | + | } | |
498 | + | else throw("depositStakingReward: no staking for asset") | |
499 | + | let assetDecimals = _getDecimals(asset_) | |
500 | + | let updatedReservesNormalized = _normalizeDecimals(updatedReserves, assetDecimals, DEX_DECIMALS) | |
501 | + | let stakingProfit = (updatedReservesNormalized - _loadReserves(asset_)) | |
502 | + | let err1 = _validateInt(stakingProfit, 1, MAX_INT, "depositStakingReward: no reward") | |
503 | + | if ((err1 == err1)) | |
504 | + | then { | |
505 | + | let gatewayInvocation = invoke(_loadGatewayContract(), FUNC_DEPOSIT_STAKING_REWARD, [toString(this), toString(_loadChainId()), asset_, toString(stakingProfit)], nil) | |
506 | + | if ((gatewayInvocation == gatewayInvocation)) | |
507 | + | then $Tuple2(_saveReserves(asset_, updatedReservesNormalized), unit) | |
508 | + | else throw("Strict value is not equal to itself.") | |
509 | + | } | |
510 | + | else throw("Strict value is not equal to itself.") | |
511 | + | } | |
512 | + | else throw("Strict value is not equal to itself.") | |
513 | + | } | |
514 | + | ||
515 | + | ||
516 | + | ||
517 | + | @Callable(i) | |
518 | + | func addStakingAsset (asset_,contract_) = { | |
519 | + | let err = if (if (_onlyThisContract(i.caller)) | |
520 | + | then _validateAsset(asset_, "addStakingAsset: invalid asset") | |
521 | + | else false) | |
522 | + | then _validateAddress(contract_, "addStakingAsset: invalid contract") | |
523 | + | else false | |
524 | + | if ((err == err)) | |
525 | + | then { | |
526 | + | let assets = _loadStakingAssets() | |
527 | + | let err1 = if (containsElement(assets, asset_)) | |
528 | + | then throw("addStakingAsset: duplicate asset") | |
529 | + | else unit | |
530 | + | if ((err1 == err1)) | |
531 | + | then $Tuple2((_saveStakingAssets((assets :+ asset_)) ++ _saveStakingContract(asset_, addressFromStringValue(contract_))), unit) | |
532 | + | else throw("Strict value is not equal to itself.") | |
533 | + | } | |
534 | + | else throw("Strict value is not equal to itself.") | |
535 | + | } | |
536 | + | ||
537 | + | ||
538 | + | ||
539 | + | @Callable(i) | |
540 | + | func rmStakingAsset (asset_) = { | |
541 | + | let err = if (_onlyThisContract(i.caller)) | |
542 | + | then _validateAsset(asset_, "rmStakingAsset: invalid asset") | |
543 | + | else false | |
544 | + | if ((err == err)) | |
545 | + | then { | |
546 | + | let assets = _loadStakingAssets() | |
547 | + | let err1 = if (!(containsElement(assets, asset_))) | |
548 | + | then throw("rmStakingAsset: no asset") | |
549 | + | else unit | |
550 | + | if ((err1 == err1)) | |
551 | + | then { | |
552 | + | let index = value(indexOf(assets, asset_)) | |
553 | + | $Tuple2(_saveStakingAssets(removeByIndex(assets, index)), unit) | |
439 | 554 | } | |
440 | 555 | else throw("Strict value is not equal to itself.") | |
441 | 556 | } | |
442 | 557 | else throw("Strict value is not equal to itself.") | |
443 | 558 | } | |
444 | 559 | ||
445 | 560 | ||
446 | 561 | ||
447 | 562 | @Callable(i) | |
448 | 563 | func pause () = { | |
449 | 564 | let err = if (if (_onlyPauser(i.caller)) | |
450 | 565 | then _whenInitialized() | |
451 | 566 | else false) | |
452 | 567 | then _whenNotPaused() | |
453 | 568 | else false | |
454 | 569 | if ((err == err)) | |
455 | 570 | then $Tuple2(_savePause(true), unit) | |
456 | 571 | else throw("Strict value is not equal to itself.") | |
457 | 572 | } | |
458 | 573 | ||
459 | 574 | ||
460 | 575 | ||
461 | 576 | @Callable(i) | |
462 | 577 | func unpause () = { | |
463 | 578 | let err = if (if (_onlyPauser(i.caller)) | |
464 | 579 | then _whenInitialized() | |
465 | 580 | else false) | |
466 | 581 | then _whenPaused() | |
467 | 582 | else false | |
468 | 583 | if ((err == err)) | |
469 | 584 | then $Tuple2(_savePause(false), unit) | |
470 | 585 | else throw("Strict value is not equal to itself.") | |
471 | 586 | } | |
472 | 587 | ||
473 | 588 | ||
474 | 589 | ||
475 | 590 | @Callable(i) | |
476 | 591 | func updatePauser (pauser_) = { | |
477 | 592 | let err = if (if (_onlyThisContract(i.caller)) | |
478 | 593 | then _whenInitialized() | |
479 | 594 | else false) | |
480 | 595 | then _validateAddress(pauser_, "updatePauser: invalid pauser") | |
481 | 596 | else false | |
482 | 597 | if ((err == err)) | |
483 | 598 | then $Tuple2(_savePauser(addressFromStringValue(pauser_)), unit) | |
484 | 599 | else throw("Strict value is not equal to itself.") | |
485 | 600 | } | |
486 | 601 | ||
487 | 602 | ||
488 | 603 | ||
489 | 604 | @Callable(i) | |
490 | 605 | func setMultisig (multisig_) = { | |
491 | 606 | let err = if (_onlyThisContract(i.caller)) | |
492 | 607 | then _validateAddress(multisig_, "setMultisig: invalid multisig") | |
493 | 608 | else false | |
494 | 609 | if ((err == err)) | |
495 | 610 | then $Tuple2(_saveMultisig(addressFromStringValue(multisig_)), unit) | |
496 | 611 | else throw("Strict value is not equal to itself.") | |
497 | 612 | } | |
498 | 613 | ||
499 | 614 | ||
500 | 615 | @Verifier(tx) | |
501 | 616 | func verify () = match getString(KEY_MULTISIG) { | |
502 | 617 | case multisig: String => | |
503 | 618 | valueOrElse(getBoolean(addressFromStringValue(multisig), makeString([KEY_STATUS, toString(this), toBase58String(tx.id)], SEPARATOR)), false) | |
504 | 619 | case _ => | |
505 | 620 | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
506 | 621 | } | |
507 | 622 |
github/deemru/w8io/026f985 61.84 ms ◑