2021.12.05 20:53 [2886252] smart account 3P984CrEYKGfoBLdwRFiNE2j3gFoYA1cvYp > SELF 0.00000000 Waves
{ "type": 13, "id": "2LiDt5GQ4JpaZG5axmN15WJaAb5TthoP3NpnQpmpuceV", "fee": 1000000, "feeAssetId": null, "timestamp": 1638726832988, "version": 2, "chainId": 87, "sender": "3P984CrEYKGfoBLdwRFiNE2j3gFoYA1cvYp", "senderPublicKey": "9mKotRjaeDuiRhrXqMg55Uh1V1WzwG4kDaAcE7HGzh43", "proofs": [ "4Fctwova8bzVsh87DQz8MjG15Zje1s9Kuhyb8LjyKpSGdTtd9MebuP79EDEUX9SfHKrpuTJVAiR7JLGo1EoJ4s9e" ], "script": "base64:AAIFAAAAAAAAAIEIAhIDCgEBGgwKAmExEgZhbW91bnQaGwoCYTISFWF2YWlsYWJsZVdhdmVzQmFsYW5jZRoRCgJhMxILTGVhc2VBY3Rpb24aDQoCYTQSB2xlYXNlSWQaEgoCYTUSDGxlYXNlZEFtb3VudBoXCgJhNhIRdG90YWxMZWFzZWRBbW91bnQAAAAAAAAAAQAAAAFpAQAAAApzdGFrZVdhdmVzAAAAAQAAAAJhMQQAAAACYTIICQAD7wAAAAEFAAAABHRoaXMAAAAJYXZhaWxhYmxlAwkBAAAAASEAAAABCQAAZwAAAAIJAABlAAAAAgUAAAACYTIAAAAAAAvrwgAFAAAAAmExCQAAAgAAAAECAAAAIG5vdCBlbm91Z2ggd2F2ZXMgYW1vdW50IHRvIGxlYXNlBAAAAAJhMwkABEQAAAACCQEAAAAHQWRkcmVzcwAAAAEBAAAAGgFXT9/NG/sZEUvSrDaeMgE8cMbQOkYnh5y/BQAAAAJhMQQAAAACYTQJAAQ5AAAAAQUAAAACYTMEAAAAAmE1CQEAAAALdmFsdWVPckVsc2UAAAACCQAEGgAAAAIFAAAABHRoaXMCAAAADWxlYXNlZF9hbW91bnQAAAAAAAAAAAAEAAAAAmE2CQAAZAAAAAIFAAAAAmE1BQAAAAJhMQkABRQAAAACCQAETAAAAAIFAAAAAmEzCQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACAgAAAA1sZWFzZWRfYW1vdW50BQAAAAJhNgkABEwAAAACCQEAAAALQmluYXJ5RW50cnkAAAACAgAAAApsZWFzaW5nX2lkBQAAAAJhNAUAAAADbmlsBQAAAAR1bml0AAAAAPdO0XY=", "height": 2886252, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DGFCi85zj2FUaMN9wqJJS9roF6st7ZrZbhJ7XTXxX6bV Next: 4vUziZBMnr6c7YcnBZzZD6xxc57NqoeyPhY2kNFrW9Ho Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let USDN = base58'DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p' | |
5 | - | ||
6 | - | let NEUTRINO = base58'3PNikM6yp4NqcSU8guxQtmR5onr2D4e8yTJ' | |
7 | - | ||
8 | - | @Callable(i) | |
9 | - | func stakeUSDN (amount) = { | |
10 | - | let USDNBalance = assetBalance(this, USDN) | |
11 | - | if (!((USDNBalance > amount))) | |
12 | - | then throw("exceeds the available amount") | |
13 | - | else { | |
14 | - | let result = invoke(Address(NEUTRINO), "lockNeutrino", nil, [AttachedPayment(USDN, amount)]) | |
15 | - | if ((result == result)) | |
16 | - | then { | |
17 | - | let stakedUSDN = valueOrElse(getInteger(this, "staked_usdn_amount"), 0) | |
18 | - | let totalStakedUSDN = (stakedUSDN + amount) | |
19 | - | $Tuple2([IntegerEntry("staked_usdn_amount", totalStakedUSDN)], unit) | |
20 | - | } | |
21 | - | else throw("Strict value is not equal to itself.") | |
22 | - | } | |
23 | - | } | |
24 | - | ||
25 | 4 | ||
26 | 5 | ||
27 | 6 | @Callable(i) | |
28 | - | func unstakeUSDN () = { | |
29 | - | let totalStakedUSDN = getIntegerValue(this, "staked_usdn_amount") | |
30 | - | let totalStakedUSDNNeutrino = getIntegerValue(Address(NEUTRINO), ("rpd_balance_DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p_" + toString(this))) | |
31 | - | if (!((totalStakedUSDN == totalStakedUSDNNeutrino))) | |
32 | - | then throw("amounts are not matching, check it!!!") | |
7 | + | func stakeWaves (amount) = { | |
8 | + | let availableWavesBalance = wavesBalance(this).available | |
9 | + | if (!(((availableWavesBalance - 200000000) >= amount))) | |
10 | + | then throw("not enough waves amount to lease") | |
33 | 11 | else { | |
34 | - | let result = invoke(Address(NEUTRINO), "unlockNeutrino", [totalStakedUSDN, "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p"], nil) | |
35 | - | if ((result == result)) | |
36 | - | then $Tuple2([BooleanEntry("unstaked_usdn", true), IntegerEntry("unstaked_usdn_amount", totalStakedUSDN), IntegerEntry("staked_usdn_amount", 0)], unit) | |
37 | - | else throw("Strict value is not equal to itself.") | |
12 | + | let LeaseAction = Lease(Address(base58'3P9DEDP5VbyXQyKtXDUt2crRPn5B7gs6ujc'), amount) | |
13 | + | let leaseId = calculateLeaseId(LeaseAction) | |
14 | + | let leasedAmount = valueOrElse(getInteger(this, "leased_amount"), 0) | |
15 | + | let totalLeasedAmount = (leasedAmount + amount) | |
16 | + | $Tuple2([LeaseAction, IntegerEntry("leased_amount", totalLeasedAmount), BinaryEntry("leasing_id", leaseId)], unit) | |
38 | 17 | } | |
39 | 18 | } | |
40 | 19 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let USDN = base58'DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p' | |
5 | - | ||
6 | - | let NEUTRINO = base58'3PNikM6yp4NqcSU8guxQtmR5onr2D4e8yTJ' | |
7 | - | ||
8 | - | @Callable(i) | |
9 | - | func stakeUSDN (amount) = { | |
10 | - | let USDNBalance = assetBalance(this, USDN) | |
11 | - | if (!((USDNBalance > amount))) | |
12 | - | then throw("exceeds the available amount") | |
13 | - | else { | |
14 | - | let result = invoke(Address(NEUTRINO), "lockNeutrino", nil, [AttachedPayment(USDN, amount)]) | |
15 | - | if ((result == result)) | |
16 | - | then { | |
17 | - | let stakedUSDN = valueOrElse(getInteger(this, "staked_usdn_amount"), 0) | |
18 | - | let totalStakedUSDN = (stakedUSDN + amount) | |
19 | - | $Tuple2([IntegerEntry("staked_usdn_amount", totalStakedUSDN)], unit) | |
20 | - | } | |
21 | - | else throw("Strict value is not equal to itself.") | |
22 | - | } | |
23 | - | } | |
24 | - | ||
25 | 4 | ||
26 | 5 | ||
27 | 6 | @Callable(i) | |
28 | - | func unstakeUSDN () = { | |
29 | - | let totalStakedUSDN = getIntegerValue(this, "staked_usdn_amount") | |
30 | - | let totalStakedUSDNNeutrino = getIntegerValue(Address(NEUTRINO), ("rpd_balance_DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p_" + toString(this))) | |
31 | - | if (!((totalStakedUSDN == totalStakedUSDNNeutrino))) | |
32 | - | then throw("amounts are not matching, check it!!!") | |
7 | + | func stakeWaves (amount) = { | |
8 | + | let availableWavesBalance = wavesBalance(this).available | |
9 | + | if (!(((availableWavesBalance - 200000000) >= amount))) | |
10 | + | then throw("not enough waves amount to lease") | |
33 | 11 | else { | |
34 | - | let result = invoke(Address(NEUTRINO), "unlockNeutrino", [totalStakedUSDN, "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p"], nil) | |
35 | - | if ((result == result)) | |
36 | - | then $Tuple2([BooleanEntry("unstaked_usdn", true), IntegerEntry("unstaked_usdn_amount", totalStakedUSDN), IntegerEntry("staked_usdn_amount", 0)], unit) | |
37 | - | else throw("Strict value is not equal to itself.") | |
12 | + | let LeaseAction = Lease(Address(base58'3P9DEDP5VbyXQyKtXDUt2crRPn5B7gs6ujc'), amount) | |
13 | + | let leaseId = calculateLeaseId(LeaseAction) | |
14 | + | let leasedAmount = valueOrElse(getInteger(this, "leased_amount"), 0) | |
15 | + | let totalLeasedAmount = (leasedAmount + amount) | |
16 | + | $Tuple2([LeaseAction, IntegerEntry("leased_amount", totalLeasedAmount), BinaryEntry("leasing_id", leaseId)], unit) | |
38 | 17 | } | |
39 | 18 | } | |
40 | 19 | ||
41 | 20 |
github/deemru/w8io/786bc32 26.80 ms ◑