tx · 2ZACk6Q92aY5sDKH3xZk6VAey3o1ch3FFb2kFU1DtSgt 3Mt4pmCGGRuWGuNy3pyyRij45rySapd44Mw: -0.01000000 Waves 2022.05.05 19:34 [2038642] smart account 3Mt4pmCGGRuWGuNy3pyyRij45rySapd44Mw > SELF 0.00000000 Waves
{ "type": 13, "id": "2ZACk6Q92aY5sDKH3xZk6VAey3o1ch3FFb2kFU1DtSgt", "fee": 1000000, "feeAssetId": null, "timestamp": 1651768531679, "version": 2, "chainId": 84, "sender": "3Mt4pmCGGRuWGuNy3pyyRij45rySapd44Mw", "senderPublicKey": "88pVWRX5DjU6wHFa5a8qeFQ3fuykBy1BXq7Z8pjdxhsc", "proofs": [ "5gRntVNjmocLH2476gujv8W7drPCzuBnMoVmat8qfWRZYKCbQojL1CnEUA6ujTSFhk7AgdhFPq4JjJHYyKEmqQ2k" ], "script": "base64:AAIDAAAAAAAAATsIARIAEgAaBgoBYRIBaRoQCgFiEgtTdGFrZWRUb2tlbhoICgFjEgNwbXQaFwoBZBISVXNlclN0YWtlZFRva2VuS2V5GhcKAWUSElVzZXJHb3Zlcm5Ub2tlbktleRoXCgFmEhJVc2VyTGFzdFN0YWtlQmxvY2saHQoBZxIYY3VycmVudEFtb3VudFN0YWtlZFRva2VuGgwKAWgSByRtYXRjaDAaBgoBaRIBYRoZCgFqEhRuZXdBbW91bnRTdGFrZWRUb2tlbhofCgFrEhpDb250cmFjdFdhbGxldFN0YWtlQmFsYW5jZRoQCgFsEgtBY3R1YWxEZWxheRocCgFtEhdVc2VyTGFzdFN0YWtlQmxvY2tWYWx1ZRoPCgFuEgpjdXJyZW50S2V5GhIKAW8SDWN1cnJlbnRBbW91bnQAAAAAAAAAAgAAAAFhAQAAAAVTdGFrZQAAAAAEAAAAAWIBAAAAIDuWMw0Cl6r3boWUBaO2GhLrBr0cYVyuuqg+TPg3fGFFBAAAAAFjCQEAAAAHZXh0cmFjdAAAAAEIBQAAAAFhAAAAB3BheW1lbnQDAwkAAGYAA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FtBAAAAAFoCQAEGgAAAAIFAAAABHRoaXMFAAAAAWYDCQAAAQAAAAIFAAAAAWgCAAAAA0ludAQAAAABaQUAAAABaAUAAAABaQAAAAAAAAAAAAQAAAABbgkAAlgAAAABCAgFAAAAAWEAAAAGY2FsbGVyAAAABWJ5dGVzBAAAAAFvBAAAAAFoCQAEGgAAAAIFAAAABHRoaXMFAAAAAWQDCQAAAQAAAAIFAAAAAWgCAAAAA0ludAQAAAABaQUAAAABaAUAAAABaQAAAAAAAAAAAAMJAABmAAAAAgAAAAAAAAAAAAUAAAABbwkAAAIAAAABAgAAAB5DYW4ndCB3aXRoZHJhdyBuZWdhdGl2ZSBhbW91bnQDCQAAZgAAAAIAAAAAAAAAAAAFAAAAAW8JAAACAAAAAQkAASwAAAACAgAAAEFVc2VyIGNhbm5vdCB3aXRoZHJhdyBtb3JlIHRoYW4gZGVwb3NpdGVkIGZ1bmRzLCBZb3VyIGRlcG9zaXQgaXM6IAkAAaQAAAABCQAAaQAAAAIFAAAAAW8AAAAAAAX14QADCQAAZgAAAAIJAABkAAAAAgUAAAABbQUAAAABbAUAAAAGaGVpZ2h0CQEAAAAMU2NyaXB0UmVzdWx0AAAAAgkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAABZAUAAAABbwkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAABZgAAAAAAAAAAAAUAAAADbmlsCQEAAAALVHJhbnNmZXJTZXQAAAABCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFhAAAABmNhbGxlcgUAAAABbwUAAAABYgUAAAADbmlsCQAAAgAAAAEJAAEsAAAAAgIAAAAqQ2Fubm90IHVuc3Rha2UgYmVmb3JlIHRoZSBtaW5pbXVtIHBlcmlvZDogCQABpAAAAAEFAAAAAWwAAAAAeg8+Kw==", "height": 2038642, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: AqxJ4u6KLXSx265bKFU6AJBpH8Ab8ZiEFZpxQeRL86UL Next: GzhR8NLsR8q5iyotfuQbrgSTYxzUSvSwWUMPVSvS1Dav Diff:
Old | New | Differences | |
---|---|---|---|
30 | 30 | ||
31 | 31 | ||
32 | 32 | @Callable(i) | |
33 | - | func WithdrawStakedFunds ( | |
33 | + | func WithdrawStakedFunds () = { | |
34 | 34 | let StakedToken = base58'51bthK9ab3y4G4gj88qeoQ4XuYM2ex2hape7yc6QzAyS' | |
35 | 35 | let UserLastStakeBlock = (toBase58String(i.caller.bytes) + "_UserLastStakeBlock") | |
36 | 36 | let UserStakedTokenKey = (toBase58String(i.caller.bytes) + "_Staking") | |
48 | 48 | case _ => | |
49 | 49 | 0 | |
50 | 50 | } | |
51 | - | let newAmount = (currentAmount - amount) | |
52 | - | if ((0 > amount)) | |
51 | + | if ((0 > currentAmount)) | |
53 | 52 | then throw("Can't withdraw negative amount") | |
54 | - | else if ((0 > | |
53 | + | else if ((0 > currentAmount)) | |
55 | 54 | then throw(("User cannot withdraw more than deposited funds, Your deposit is: " + toString((currentAmount / 100000000)))) | |
56 | 55 | else if (((UserLastStakeBlockValue + ActualDelay) > height)) | |
57 | - | then ScriptResult(WriteSet([DataEntry(UserStakedTokenKey, | |
56 | + | then ScriptResult(WriteSet([DataEntry(UserStakedTokenKey, currentAmount), DataEntry(UserLastStakeBlock, 0)]), TransferSet([ScriptTransfer(i.caller, currentAmount, StakedToken)])) | |
58 | 57 | else throw(("Cannot unstake before the minimum period: " + toString(ActualDelay))) | |
59 | 58 | } | |
60 | 59 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | ||
5 | 5 | ||
6 | 6 | @Callable(i) | |
7 | 7 | func Stake () = { | |
8 | 8 | let StakedToken = base58'51bthK9ab3y4G4gj88qeoQ4XuYM2ex2hape7yc6QzAyS' | |
9 | 9 | let pmt = extract(i.payment) | |
10 | 10 | if (if ((pmt.amount > 0)) | |
11 | 11 | then (pmt.assetId == StakedToken) | |
12 | 12 | else false) | |
13 | 13 | then { | |
14 | 14 | let UserStakedTokenKey = (toBase58String(i.caller.bytes) + "_Stake") | |
15 | 15 | let UserGovernTokenKey = (toBase58String(i.caller.bytes) + "_Earnings") | |
16 | 16 | let UserLastStakeBlock = (toBase58String(i.caller.bytes) + "_UserLastStakeBlock") | |
17 | 17 | let currentAmountStakedToken = match getInteger(this, UserStakedTokenKey) { | |
18 | 18 | case a: Int => | |
19 | 19 | a | |
20 | 20 | case _ => | |
21 | 21 | 0 | |
22 | 22 | } | |
23 | 23 | let newAmountStakedToken = (currentAmountStakedToken + pmt.amount) | |
24 | 24 | let ContractWalletStakeBalance = assetBalance(this, StakedToken) | |
25 | 25 | WriteSet([DataEntry(UserStakedTokenKey, newAmountStakedToken), DataEntry(UserLastStakeBlock, height)]) | |
26 | 26 | } | |
27 | 27 | else throw("Can deposit only StakeToken") | |
28 | 28 | } | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | ||
32 | 32 | @Callable(i) | |
33 | - | func WithdrawStakedFunds ( | |
33 | + | func WithdrawStakedFunds () = { | |
34 | 34 | let StakedToken = base58'51bthK9ab3y4G4gj88qeoQ4XuYM2ex2hape7yc6QzAyS' | |
35 | 35 | let UserLastStakeBlock = (toBase58String(i.caller.bytes) + "_UserLastStakeBlock") | |
36 | 36 | let UserStakedTokenKey = (toBase58String(i.caller.bytes) + "_Staking") | |
37 | 37 | let ActualDelay = (1440 * 7) | |
38 | 38 | let UserLastStakeBlockValue = match getInteger(this, UserLastStakeBlock) { | |
39 | 39 | case a: Int => | |
40 | 40 | a | |
41 | 41 | case _ => | |
42 | 42 | 0 | |
43 | 43 | } | |
44 | 44 | let currentKey = toBase58String(i.caller.bytes) | |
45 | 45 | let currentAmount = match getInteger(this, UserStakedTokenKey) { | |
46 | 46 | case a: Int => | |
47 | 47 | a | |
48 | 48 | case _ => | |
49 | 49 | 0 | |
50 | 50 | } | |
51 | - | let newAmount = (currentAmount - amount) | |
52 | - | if ((0 > amount)) | |
51 | + | if ((0 > currentAmount)) | |
53 | 52 | then throw("Can't withdraw negative amount") | |
54 | - | else if ((0 > | |
53 | + | else if ((0 > currentAmount)) | |
55 | 54 | then throw(("User cannot withdraw more than deposited funds, Your deposit is: " + toString((currentAmount / 100000000)))) | |
56 | 55 | else if (((UserLastStakeBlockValue + ActualDelay) > height)) | |
57 | - | then ScriptResult(WriteSet([DataEntry(UserStakedTokenKey, | |
56 | + | then ScriptResult(WriteSet([DataEntry(UserStakedTokenKey, currentAmount), DataEntry(UserLastStakeBlock, 0)]), TransferSet([ScriptTransfer(i.caller, currentAmount, StakedToken)])) | |
58 | 57 | else throw(("Cannot unstake before the minimum period: " + toString(ActualDelay))) | |
59 | 58 | } | |
60 | 59 | ||
61 | 60 |
github/deemru/w8io/026f985 42.52 ms ◑