tx · Ca1iEJr8YzvRHkuLtYZgUMzDtp2RJH64mx86HfdtEzH7 3N3y7DVmszkgFYMGoDtNnPjrNmLTf1rRUKJ: -0.01990000 Waves 2020.10.20 19:50 [1229145] smart account 3N3y7DVmszkgFYMGoDtNnPjrNmLTf1rRUKJ > SELF 0.00000000 Waves
{ "type": 13, "id": "Ca1iEJr8YzvRHkuLtYZgUMzDtp2RJH64mx86HfdtEzH7", "fee": 1990000, "feeAssetId": null, "timestamp": 1603212514403, "version": 2, "chainId": 84, "sender": "3N3y7DVmszkgFYMGoDtNnPjrNmLTf1rRUKJ", "senderPublicKey": "EPmZCX2H4AC1hUmAFRUfWrhzXrNjf3wPaybY6jHZQphj", "proofs": [ "3PYDPteDQAsVXvmuijs1iAkNiBoicbj96WUcUjUyDApQph3Jc4PMzx1XhmDfJLgi4pbrHJuWGRT7xGoJxtm4kUPX" ], "script": "base64:AAIDAAAAAAAAABEIARIAEgASABIAEgMKAQESAAAAAAAAAAAGAAAAAWkBAAAAFFJlYWRNYXhHb3Zlcm5EZXBvc2l0AAAAAAQAAAAOR292ZXJuVG9rZW5LZXkCAAAAFUdvdmVyblRva2VuTWF4RGVwb3NpdAQAAAAaTWF4R292ZXJuVG9rZW5EZXBvc2l0ZXJLZXkCAAAAGk1heEdvdmVyblRva2VuRGVwb3NpdGVyS2V5BAAAAAZXaW5uZXIJAQAAABFAZXh0ck5hdGl2ZSgxMDUzKQAAAAIFAAAABHRoaXMFAAAAGk1heEdvdmVyblRva2VuRGVwb3NpdGVyS2V5BAAAABVNYXhHb3Zlcm5Ub2tlbkRlcG9zaXQEAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAAOR292ZXJuVG9rZW5LZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAkAAAIAAAABCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAABJXaW5uZXIgaXMuLi4u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VzZXJHb3Zlcm5Ub2tlbkFtb3VudAAAAAAAAAAAZAkBAAAADFNjcmlwdFJlc3VsdAAAAAIJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAAC1ByaXplV2lubmVyBQAAAAtQcml6ZUFtb3VudAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAASRnVuZEJveFN0YWtlZFRva2VuAAAAAAAAAAAACQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAABJVc2VyR292ZXJuVG9rZW5LZXkAAAAAAAAAAGQFAAAAA25pbAkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIFAAAAC1ByaXplQW1vdW50BQAAAAtTdGFrZWRUb2tlbgkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIAAAAAAAAAAGQFAAAAC0dvdmVyblRva2VuBQAAAANuaWwJAAACAAAAAQkAASwAAAACAgAAAEdZb3UgaGF2ZSB0byBkZXBvc2l0IDEwMCBHb3Zlcm5Ub2tlbiB0byBjbGFpbSBSZXdhcmQgCiBZb3VyIEJhbGFuY2UgaXM6IAkAAaQAAAABBQAAABVVc2VyR292ZXJuVG9rZW5BbW91bnQAAAAA02yMyQ==", "height": 1229145, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7UQxc8Qq9mdSyiTfmVcRpsfRUB1TkKDT3etK5Gr8MFip Next: AnsQJFbGC5wDvtzp3MBwnh2GMezS2nGKteGEVbKXWnbY Diff:
Old | New | Differences | |
---|---|---|---|
14 | 14 | case _ => | |
15 | 15 | 0 | |
16 | 16 | } | |
17 | - | throw(((("Winner is.....: " + Winner) + " ") + toString(MaxGovernTokenDeposit))) | |
17 | + | throw(((("Winner is.....: " + Winner) + " | |
18 | + | Total GovernToken: ") + toString(MaxGovernTokenDeposit))) | |
18 | 19 | } | |
19 | 20 | ||
20 | 21 | ||
43 | 44 | ||
44 | 45 | @Callable(i) | |
45 | 46 | func Stake () = { | |
46 | - | let | |
47 | + | let StakedToken = base58'5hHK64aujiyn7cNrTBwhe5yJQuxs119KTPbE9nFjLoUN' | |
47 | 48 | let GovernToken = base58'DeyMK8USWs9ijzAXNy2azA3soajfrXjUNiJBdSJJsvMJ' | |
48 | 49 | let pmt = extract(i.payment) | |
49 | 50 | if (if (isDefined(pmt.assetId)) | |
50 | - | then (extract(pmt.assetId) == | |
51 | + | then (extract(pmt.assetId) == StakedToken) | |
51 | 52 | else false) | |
52 | 53 | then { | |
53 | - | let currentKey = ((toBase58String(i.caller.bytes) + "_") + toBase58String(CollateralToken)) | |
54 | - | let currentAmount = match getInteger(this, currentKey) { | |
54 | + | let UserStakedTokenKey = ((toBase58String(i.caller.bytes) + "_") + toBase58String(StakedToken)) | |
55 | + | let UserGovernTokenKey = ((toBase58String(i.caller.bytes) + "_") + toBase58String(GovernToken)) | |
56 | + | let currentAmount = match getInteger(this, UserStakedTokenKey) { | |
55 | 57 | case a: Int => | |
56 | 58 | a | |
57 | 59 | case _ => | |
58 | 60 | 0 | |
59 | 61 | } | |
60 | 62 | let newAmount = (currentAmount + pmt.amount) | |
61 | - | let | |
62 | - | if ((1 > | |
63 | + | let GovernTokenSmartContractBalance = assetBalance(this, GovernToken) | |
64 | + | if ((1 > GovernTokenSmartContractBalance)) | |
63 | 65 | then throw("No enough GovernToken In Contract") | |
64 | - | else ScriptResult(WriteSet([DataEntry( | |
66 | + | else ScriptResult(WriteSet([DataEntry(UserGovernTokenKey, 10), DataEntry(UserStakedTokenKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, 10, GovernToken)])) | |
65 | 67 | } | |
66 | 68 | else throw("Can deposit only StakeToken") | |
67 | 69 | } | |
135 | 137 | let StakedToken = base58'5hHK64aujiyn7cNrTBwhe5yJQuxs119KTPbE9nFjLoUN' | |
136 | 138 | let GovernToken = base58'DeyMK8USWs9ijzAXNy2azA3soajfrXjUNiJBdSJJsvMJ' | |
137 | 139 | let FundBoxAddress58 = base58'3NCMrhPAVqXgtLdpi2BhFWpJkMBUAFrozbD' | |
138 | - | let winnerPrize = (("3N1QzUHdfyXmKVFAn9TPHG7iuW4uK53pfXA" + "_") + toBase58String(StakedToken)) | |
139 | - | let winAddress = Address(base58'3N1QzUHdfyXmKVFAn9TPHG7iuW4uK53pfXA') | |
140 | - | let FundBoxAddress = Address(base58'3NCMrhPAVqXgtLdpi2BhFWpJkMBUAFrozbD') | |
141 | - | let FundBox = "3NCMrhPAVqXgtLdpi2BhFWpJkMBUAFrozbD" | |
140 | + | let UserStakedTokenKey = ((toBase58String(i.caller.bytes) + "_") + toBase58String(StakedToken)) | |
142 | 141 | let UserGovernTokenKey = ((toBase58String(i.caller.bytes) + "_") + toBase58String(GovernToken)) | |
143 | - | let UserStakedToken = ((toBase58String(i.caller.bytes) + "_") + toBase58String(StakedToken)) | |
144 | 142 | let FundBoxStakedToken = ((toBase58String(FundBoxAddress58) + "_") + toBase58String(StakedToken)) | |
145 | 143 | let UserGovernTokenAmount = match getInteger(this, UserGovernTokenKey) { | |
146 | 144 | case a: Int => | |
148 | 146 | case _ => | |
149 | 147 | 0 | |
150 | 148 | } | |
151 | - | let UserStakedTokenAmount = match getInteger(this, | |
149 | + | let UserStakedTokenAmount = match getInteger(this, UserStakedTokenKey) { | |
152 | 150 | case a: Int => | |
153 | 151 | a | |
154 | 152 | case _ => | |
160 | 158 | case _ => | |
161 | 159 | 0 | |
162 | 160 | } | |
161 | + | let MaxGovernTokenDepositerKey = "MaxGovernTokenDepositerKey" | |
162 | + | let PrizeWinner = getStringValue(this, MaxGovernTokenDepositerKey) | |
163 | 163 | if ((PrizeAmount == 0)) | |
164 | 164 | then throw("No prize to Claim") | |
165 | - | else if (( | |
165 | + | else if ((toBase58String(i.caller.bytes) != PrizeWinner)) | |
166 | 166 | then throw("You are not the winner hence cannot claim the reward ") | |
167 | 167 | else if ((1 > UserStakedTokenAmount)) | |
168 | 168 | then throw(("You have to Stake StakedToken to claim reward | |
169 | 169 | Your Balance of Staked Tokens is: " + toString(UserStakedTokenAmount))) | |
170 | 170 | else if ((UserGovernTokenAmount > 100)) | |
171 | - | then ScriptResult(WriteSet([DataEntry( | |
171 | + | then ScriptResult(WriteSet([DataEntry(PrizeWinner, PrizeAmount), DataEntry(FundBoxStakedToken, 0), DataEntry(UserGovernTokenKey, 100)]), TransferSet([ScriptTransfer(i.caller, PrizeAmount, StakedToken), ScriptTransfer(i.caller, 100, GovernToken)])) | |
172 | 172 | else throw(("You have to deposit 100 GovernToken to claim Reward | |
173 | 173 | Your Balance is: " + toString(UserGovernTokenAmount))) | |
174 | 174 | } |
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 ReadMaxGovernDeposit () = { | |
8 | 8 | let GovernTokenKey = "GovernTokenMaxDeposit" | |
9 | 9 | let MaxGovernTokenDepositerKey = "MaxGovernTokenDepositerKey" | |
10 | 10 | let Winner = getStringValue(this, MaxGovernTokenDepositerKey) | |
11 | 11 | let MaxGovernTokenDeposit = match getInteger(this, GovernTokenKey) { | |
12 | 12 | case a: Int => | |
13 | 13 | a | |
14 | 14 | case _ => | |
15 | 15 | 0 | |
16 | 16 | } | |
17 | - | throw(((("Winner is.....: " + Winner) + " ") + toString(MaxGovernTokenDeposit))) | |
17 | + | throw(((("Winner is.....: " + Winner) + " | |
18 | + | Total GovernToken: ") + toString(MaxGovernTokenDeposit))) | |
18 | 19 | } | |
19 | 20 | ||
20 | 21 | ||
21 | 22 | ||
22 | 23 | @Callable(i) | |
23 | 24 | func payYield () = { | |
24 | 25 | let GovernToken = base58'DeyMK8USWs9ijzAXNy2azA3soajfrXjUNiJBdSJJsvMJ' | |
25 | 26 | let currentKey = toBase58String(i.caller.bytes) | |
26 | 27 | let currentAmount = match getInteger(this, currentKey) { | |
27 | 28 | case a: Int => | |
28 | 29 | a | |
29 | 30 | case _ => | |
30 | 31 | 0 | |
31 | 32 | } | |
32 | 33 | if ((currentAmount > 0)) | |
33 | 34 | then { | |
34 | 35 | let GovernTokenAmount = assetBalance(this, GovernToken) | |
35 | 36 | if ((1 > GovernTokenAmount)) | |
36 | 37 | then throw("No enough GovernToken In Contract") | |
37 | 38 | else ScriptResult(WriteSet([DataEntry(currentKey, 10)]), TransferSet([ScriptTransfer(i.caller, 1, GovernToken)])) | |
38 | 39 | } | |
39 | 40 | else throw("You need to deposit Collateral Token to receive Govern Token") | |
40 | 41 | } | |
41 | 42 | ||
42 | 43 | ||
43 | 44 | ||
44 | 45 | @Callable(i) | |
45 | 46 | func Stake () = { | |
46 | - | let | |
47 | + | let StakedToken = base58'5hHK64aujiyn7cNrTBwhe5yJQuxs119KTPbE9nFjLoUN' | |
47 | 48 | let GovernToken = base58'DeyMK8USWs9ijzAXNy2azA3soajfrXjUNiJBdSJJsvMJ' | |
48 | 49 | let pmt = extract(i.payment) | |
49 | 50 | if (if (isDefined(pmt.assetId)) | |
50 | - | then (extract(pmt.assetId) == | |
51 | + | then (extract(pmt.assetId) == StakedToken) | |
51 | 52 | else false) | |
52 | 53 | then { | |
53 | - | let currentKey = ((toBase58String(i.caller.bytes) + "_") + toBase58String(CollateralToken)) | |
54 | - | let currentAmount = match getInteger(this, currentKey) { | |
54 | + | let UserStakedTokenKey = ((toBase58String(i.caller.bytes) + "_") + toBase58String(StakedToken)) | |
55 | + | let UserGovernTokenKey = ((toBase58String(i.caller.bytes) + "_") + toBase58String(GovernToken)) | |
56 | + | let currentAmount = match getInteger(this, UserStakedTokenKey) { | |
55 | 57 | case a: Int => | |
56 | 58 | a | |
57 | 59 | case _ => | |
58 | 60 | 0 | |
59 | 61 | } | |
60 | 62 | let newAmount = (currentAmount + pmt.amount) | |
61 | - | let | |
62 | - | if ((1 > | |
63 | + | let GovernTokenSmartContractBalance = assetBalance(this, GovernToken) | |
64 | + | if ((1 > GovernTokenSmartContractBalance)) | |
63 | 65 | then throw("No enough GovernToken In Contract") | |
64 | - | else ScriptResult(WriteSet([DataEntry( | |
66 | + | else ScriptResult(WriteSet([DataEntry(UserGovernTokenKey, 10), DataEntry(UserStakedTokenKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, 10, GovernToken)])) | |
65 | 67 | } | |
66 | 68 | else throw("Can deposit only StakeToken") | |
67 | 69 | } | |
68 | 70 | ||
69 | 71 | ||
70 | 72 | ||
71 | 73 | @Callable(i) | |
72 | 74 | func DepositGovernToken () = { | |
73 | 75 | let GovernToken = base58'DeyMK8USWs9ijzAXNy2azA3soajfrXjUNiJBdSJJsvMJ' | |
74 | 76 | let GovernTokenMaxDeposit = toBase58String(GovernToken) | |
75 | 77 | let pmt = extract(i.payment) | |
76 | 78 | if (if (isDefined(pmt.assetId)) | |
77 | 79 | then (extract(pmt.assetId) == GovernToken) | |
78 | 80 | else false) | |
79 | 81 | then { | |
80 | 82 | let currentKey = toBase58String(i.caller.bytes) | |
81 | 83 | let currentAmount = match getInteger(this, currentKey) { | |
82 | 84 | case a: Int => | |
83 | 85 | a | |
84 | 86 | case _ => | |
85 | 87 | 0 | |
86 | 88 | } | |
87 | 89 | let CurrrentGovernTokenDeposit = (currentAmount + pmt.amount) | |
88 | 90 | let GovernTokenKey = "GovernTokenMaxDeposit" | |
89 | 91 | let MaxGovernTokenDepositerKey = "MaxGovernTokenDepositerKey" | |
90 | 92 | let MaxGovernTokenDeposit = match getInteger(this, GovernTokenKey) { | |
91 | 93 | case a: Int => | |
92 | 94 | a | |
93 | 95 | case _ => | |
94 | 96 | 0 | |
95 | 97 | } | |
96 | 98 | if (if ((CurrrentGovernTokenDeposit > MaxGovernTokenDeposit)) | |
97 | 99 | then true | |
98 | 100 | else (MaxGovernTokenDeposit == 0)) | |
99 | 101 | then WriteSet([DataEntry(currentKey, CurrrentGovernTokenDeposit), DataEntry(GovernTokenKey, CurrrentGovernTokenDeposit), DataEntry(MaxGovernTokenDepositerKey, currentKey)]) | |
100 | 102 | else WriteSet([DataEntry(currentKey, CurrrentGovernTokenDeposit)]) | |
101 | 103 | } | |
102 | 104 | else throw("Can deposit only Govern Token") | |
103 | 105 | } | |
104 | 106 | ||
105 | 107 | ||
106 | 108 | ||
107 | 109 | @Callable(i) | |
108 | 110 | func WithdrawStakedFunds (amount) = { | |
109 | 111 | let CollateralToken = base58'5hHK64aujiyn7cNrTBwhe5yJQuxs119KTPbE9nFjLoUN' | |
110 | 112 | let GovernToken = base58'DeyMK8USWs9ijzAXNy2azA3soajfrXjUNiJBdSJJsvMJ' | |
111 | 113 | let currentKey = toBase58String(i.caller.bytes) | |
112 | 114 | let currentAmount = match getInteger(this, currentKey) { | |
113 | 115 | case a: Int => | |
114 | 116 | a | |
115 | 117 | case _ => | |
116 | 118 | 0 | |
117 | 119 | } | |
118 | 120 | let newAmount = (currentAmount - amount) | |
119 | 121 | if ((0 > amount)) | |
120 | 122 | then throw("Can't withdraw negative amount") | |
121 | 123 | else if ((0 > newAmount)) | |
122 | 124 | then throw("User cannot withdraw more than deposited funds") | |
123 | 125 | else { | |
124 | 126 | let GovernTokenAmount = assetBalance(this, GovernToken) | |
125 | 127 | if ((1 > GovernTokenAmount)) | |
126 | 128 | then throw("No enough GovernToken In Contract") | |
127 | 129 | else ScriptResult(WriteSet([DataEntry(currentKey, 1), DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, 1, GovernToken), ScriptTransfer(i.caller, amount, CollateralToken)])) | |
128 | 130 | } | |
129 | 131 | } | |
130 | 132 | ||
131 | 133 | ||
132 | 134 | ||
133 | 135 | @Callable(i) | |
134 | 136 | func ClaimPrize () = { | |
135 | 137 | let StakedToken = base58'5hHK64aujiyn7cNrTBwhe5yJQuxs119KTPbE9nFjLoUN' | |
136 | 138 | let GovernToken = base58'DeyMK8USWs9ijzAXNy2azA3soajfrXjUNiJBdSJJsvMJ' | |
137 | 139 | let FundBoxAddress58 = base58'3NCMrhPAVqXgtLdpi2BhFWpJkMBUAFrozbD' | |
138 | - | let winnerPrize = (("3N1QzUHdfyXmKVFAn9TPHG7iuW4uK53pfXA" + "_") + toBase58String(StakedToken)) | |
139 | - | let winAddress = Address(base58'3N1QzUHdfyXmKVFAn9TPHG7iuW4uK53pfXA') | |
140 | - | let FundBoxAddress = Address(base58'3NCMrhPAVqXgtLdpi2BhFWpJkMBUAFrozbD') | |
141 | - | let FundBox = "3NCMrhPAVqXgtLdpi2BhFWpJkMBUAFrozbD" | |
140 | + | let UserStakedTokenKey = ((toBase58String(i.caller.bytes) + "_") + toBase58String(StakedToken)) | |
142 | 141 | let UserGovernTokenKey = ((toBase58String(i.caller.bytes) + "_") + toBase58String(GovernToken)) | |
143 | - | let UserStakedToken = ((toBase58String(i.caller.bytes) + "_") + toBase58String(StakedToken)) | |
144 | 142 | let FundBoxStakedToken = ((toBase58String(FundBoxAddress58) + "_") + toBase58String(StakedToken)) | |
145 | 143 | let UserGovernTokenAmount = match getInteger(this, UserGovernTokenKey) { | |
146 | 144 | case a: Int => | |
147 | 145 | a | |
148 | 146 | case _ => | |
149 | 147 | 0 | |
150 | 148 | } | |
151 | - | let UserStakedTokenAmount = match getInteger(this, | |
149 | + | let UserStakedTokenAmount = match getInteger(this, UserStakedTokenKey) { | |
152 | 150 | case a: Int => | |
153 | 151 | a | |
154 | 152 | case _ => | |
155 | 153 | 0 | |
156 | 154 | } | |
157 | 155 | let PrizeAmount = match getInteger(this, FundBoxStakedToken) { | |
158 | 156 | case a: Int => | |
159 | 157 | a | |
160 | 158 | case _ => | |
161 | 159 | 0 | |
162 | 160 | } | |
161 | + | let MaxGovernTokenDepositerKey = "MaxGovernTokenDepositerKey" | |
162 | + | let PrizeWinner = getStringValue(this, MaxGovernTokenDepositerKey) | |
163 | 163 | if ((PrizeAmount == 0)) | |
164 | 164 | then throw("No prize to Claim") | |
165 | - | else if (( | |
165 | + | else if ((toBase58String(i.caller.bytes) != PrizeWinner)) | |
166 | 166 | then throw("You are not the winner hence cannot claim the reward ") | |
167 | 167 | else if ((1 > UserStakedTokenAmount)) | |
168 | 168 | then throw(("You have to Stake StakedToken to claim reward | |
169 | 169 | Your Balance of Staked Tokens is: " + toString(UserStakedTokenAmount))) | |
170 | 170 | else if ((UserGovernTokenAmount > 100)) | |
171 | - | then ScriptResult(WriteSet([DataEntry( | |
171 | + | then ScriptResult(WriteSet([DataEntry(PrizeWinner, PrizeAmount), DataEntry(FundBoxStakedToken, 0), DataEntry(UserGovernTokenKey, 100)]), TransferSet([ScriptTransfer(i.caller, PrizeAmount, StakedToken), ScriptTransfer(i.caller, 100, GovernToken)])) | |
172 | 172 | else throw(("You have to deposit 100 GovernToken to claim Reward | |
173 | 173 | Your Balance is: " + toString(UserGovernTokenAmount))) | |
174 | 174 | } | |
175 | 175 | ||
176 | 176 |
github/deemru/w8io/169f3d6 36.67 ms ◑