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