tx · HXhCWcTPfxBjG9SJEiqG3XwWDgfubBxrWKxoe55NwkKR 3N5rNyYSAsaP9QL2eQq286RhevB8msHFffu: -0.05000000 Waves 2020.11.18 09:59 [1270466] smart account 3N5rNyYSAsaP9QL2eQq286RhevB8msHFffu > SELF 0.00000000 Waves
{ "type": 13, "id": "HXhCWcTPfxBjG9SJEiqG3XwWDgfubBxrWKxoe55NwkKR", "fee": 5000000, "feeAssetId": null, "timestamp": 1605682819142, "version": 2, "chainId": 84, "sender": "3N5rNyYSAsaP9QL2eQq286RhevB8msHFffu", "senderPublicKey": "CBTEuFN6ku1LNaPuGHHTMh2CBb3kPa5D73XXTJvKydun", "proofs": [ "4KSva7rSG7962k1VFizNgUgHVLKJ4hjfYm5seypGGaTWQJud4P7v2nS9xYFUjXk5iyZ3JircbxN6nMNZ6d2x3jfd" ], "script": "base64:AAIDAAAAAAAAACcIARIHCgUICAgICBIECgIICBIDCgEIEgMKAQgSABIDCgEBEgMKAQEAAAAQAAAAAAZ1cFZvdGUCAAAABnVwdm90ZQAAAAAMYWRtaW5BZGRyZXNzAQAAABoBVDi2IViANlgIPSCUAVQpoGSXhJ2Tw/Y0iwAAAAAFZHl6SWQBAAAAIH6rQdnOUsq3YY00nk9jVDL2OOQ/e846gXAImq8xTxZrAQAAAA9nZXRTdGFrZVBvb2xLZXkAAAAAAgAAAApzdGFrZV9wb29sAQAAAAxnZXRTdGFrZVBvb2wAAAAABAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMJAQAAAA9nZXRTdGFrZVBvb2xLZXkAAAAAAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAABAAAADGdldFN0YWtlcktleQAAAAEAAAAGc3Rha2VyCQABLAAAAAIFAAAABnN0YWtlcgIAAAAGX3N0YWtlAQAAAA9nZXRDdXJyZW50U3Rha2UAAAABAAAABnN0YWtlcgQAAAAHJG1hdGNoMAkABB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dhaW4gbGF0ZXIDCQAAZgAAAAIFAAAABnJld2FyZAUAAAAJc3Rha2VQb29sCQAAAgAAAAECAAAAF05vIHJld2FyZHMgYXQgdGhpcyB0aW1lBAAAAAxuZXdTdGFrZVBvb2wJAABlAAAAAgUAAAAJc3Rha2VQb29sBQAAAAZyZXdhcmQEAAAADm5ld1N0YWtlQW1vdW50CQAAZQAAAAIFAAAADGN1cnJlbnRTdGFrZQUAAAAGcmV3YXJkCQEAAAAMU2NyaXB0UmVzdWx0AAAAAgkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAADGdldFN0YWtlcktleQAAAAEFAAAABnN0YWtlcgUAAAAObmV3U3Rha2VBbW91bnQJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAAA9nZXRTdGFrZVBvb2xLZXkAAAAABQAAAAxuZXdTdGFrZVBvb2wFAAAAA25pbAkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIFAAAABnJld2FyZAUAAAAFZHl6SWQFAAAAA25pbAAAAACRSpmW", "height": 1270466, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: HiW16mYq6KyiLmdMS3vLGTRWu8widLEP9dKFYCw9kpxg Next: 6XH57mNapFhK5QeFe4fpMET2nkXmFf9d3z95KVKQVR9D Diff:
Old | New | Differences | |
---|---|---|---|
145 | 145 | then throw("You can only stake with DYZRUPT token") | |
146 | 146 | else { | |
147 | 147 | let currentStake = getCurrentStake(staker) | |
148 | - | let stakeableAmount = fraction(pmt.amount, | |
148 | + | let stakeableAmount = fraction(pmt.amount, 5, 100) | |
149 | 149 | let amountToStake = (pmt.amount - stakeableAmount) | |
150 | 150 | let newStakedAmount = (currentStake + amountToStake) | |
151 | 151 | let stakePool = getStakePool() | |
165 | 165 | else if ((amount > currentStake)) | |
166 | 166 | then throw("You can't withdraw an amount higher than you staked") | |
167 | 167 | else { | |
168 | - | let unstakeableAmount = fraction(amount, | |
168 | + | let unstakeableAmount = fraction(amount, 10, 100) | |
169 | 169 | let amountToUnstake = (amount - unstakeableAmount) | |
170 | 170 | let newUnstakedAmount = (currentStake - amount) | |
171 | 171 | let stakePool = getStakePool() |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let upVote = "upvote" | |
5 | 5 | ||
6 | 6 | let adminAddress = base58'3Mu5woJ54s7vHJgaeNcJ4C9ByfdmMF2jpjC' | |
7 | 7 | ||
8 | 8 | let dyzId = base58'9XTqBQeJvdMs8VNHv6rXiJLJichg2acG7wCfYcTajQ1G' | |
9 | 9 | ||
10 | 10 | func getStakePoolKey () = "stake_pool" | |
11 | 11 | ||
12 | 12 | ||
13 | 13 | func getStakePool () = match getInteger(this, getStakePoolKey()) { | |
14 | 14 | case a: Int => | |
15 | 15 | a | |
16 | 16 | case _ => | |
17 | 17 | 0 | |
18 | 18 | } | |
19 | 19 | ||
20 | 20 | ||
21 | 21 | func getStakerKey (staker) = (staker + "_stake") | |
22 | 22 | ||
23 | 23 | ||
24 | 24 | func getCurrentStake (staker) = match getInteger(this, getStakerKey(staker)) { | |
25 | 25 | case a: Int => | |
26 | 26 | a | |
27 | 27 | case _ => | |
28 | 28 | 0 | |
29 | 29 | } | |
30 | 30 | ||
31 | 31 | ||
32 | 32 | func getProfileKey (id) = (id + "_entrepreneurProfile") | |
33 | 33 | ||
34 | 34 | ||
35 | 35 | func getStatusKey (id) = (id + "_status") | |
36 | 36 | ||
37 | 37 | ||
38 | 38 | func getVoteKey (id,type) = if ((type == "upvote")) | |
39 | 39 | then (id + "_upvote") | |
40 | 40 | else throw("Invalid vote type") | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | func profileExist (id) = match getString(this, getProfileKey(id)) { | |
44 | 44 | case a: String => | |
45 | 45 | true | |
46 | 46 | case _ => | |
47 | 47 | false | |
48 | 48 | } | |
49 | 49 | ||
50 | 50 | ||
51 | 51 | func getVoteStatus (voteId) = match getString(this, getStatusKey(voteId)) { | |
52 | 52 | case a: String => | |
53 | 53 | a | |
54 | 54 | case _ => | |
55 | 55 | false | |
56 | 56 | } | |
57 | 57 | ||
58 | 58 | ||
59 | 59 | func getVoteCount (voteId,vote) = match getInteger(this, getVoteKey(voteId, vote)) { | |
60 | 60 | case a: Int => | |
61 | 61 | a | |
62 | 62 | case _ => | |
63 | 63 | throw("Not a valid vote ID") | |
64 | 64 | } | |
65 | 65 | ||
66 | 66 | ||
67 | 67 | func getVoterKey (address,voteId) = ((((address + "_") + voteId) + "_") + "vote") | |
68 | 68 | ||
69 | 69 | ||
70 | 70 | func getVoter (address,voteId) = match getString(this, getVoterKey(address, voteId)) { | |
71 | 71 | case a: String => | |
72 | 72 | a | |
73 | 73 | case _ => | |
74 | 74 | "" | |
75 | 75 | } | |
76 | 76 | ||
77 | 77 | ||
78 | 78 | func canVote (address,voteId) = { | |
79 | 79 | let voter = getVoter(address, voteId) | |
80 | 80 | if ((voter == "")) | |
81 | 81 | then true | |
82 | 82 | else false | |
83 | 83 | } | |
84 | 84 | ||
85 | 85 | ||
86 | 86 | @Callable(i) | |
87 | 87 | func addEntrepreneurProfile (name,avatar,bio,gender,location) = if ((i.caller.bytes != adminAddress)) | |
88 | 88 | then throw("Only Dyzrupt Admin can call this dApp function") | |
89 | 89 | else { | |
90 | 90 | let transactionId = toBase58String(i.transactionId) | |
91 | 91 | WriteSet([DataEntry(getProfileKey(transactionId), ((((((((name + "_") + avatar) + "_") + bio) + "_") + gender) + "_") + location)), DataEntry(getVoteKey(transactionId, "upvote"), 0), DataEntry(getStatusKey(transactionId), "open")]) | |
92 | 92 | } | |
93 | 93 | ||
94 | 94 | ||
95 | 95 | ||
96 | 96 | @Callable(i) | |
97 | 97 | func vote (voteId,vote) = { | |
98 | 98 | let pmt = extract(i.payment) | |
99 | 99 | if ((pmt.amount == 0)) | |
100 | 100 | then throw("You cannot vote without paying voting fee") | |
101 | 101 | else if ((pmt.assetId != base58'9XTqBQeJvdMs8VNHv6rXiJLJichg2acG7wCfYcTajQ1G')) | |
102 | 102 | then throw("You can only vote with DYZRUPT token") | |
103 | 103 | else if (canVote(toBase58String(i.caller.bytes), voteId)) | |
104 | 104 | then if (profileExist(voteId)) | |
105 | 105 | then if ((getVoteStatus(voteId) == "open")) | |
106 | 106 | then if ((vote == upVote)) | |
107 | 107 | then { | |
108 | 108 | let voteCount = getVoteCount(voteId, vote) | |
109 | 109 | let newVoteCount = (voteCount + 1) | |
110 | 110 | ScriptResult(WriteSet([DataEntry(getVoteKey(voteId, vote), newVoteCount), DataEntry(getVoterKey(toBase58String(i.caller.bytes), voteId), voteId)]), TransferSet([ScriptTransfer(this, pmt.amount, dyzId)])) | |
111 | 111 | } | |
112 | 112 | else throw("Not a valid vote value") | |
113 | 113 | else throw("This profile is not open for voting") | |
114 | 114 | else throw("Invalid Profile") | |
115 | 115 | else throw("You can't vote twice") | |
116 | 116 | } | |
117 | 117 | ||
118 | 118 | ||
119 | 119 | ||
120 | 120 | @Callable(i) | |
121 | 121 | func openVote (voteId) = if ((i.caller.bytes != adminAddress)) | |
122 | 122 | then throw("Only Dyzrupt Admin can call this dApp function") | |
123 | 123 | else if (profileExist(voteId)) | |
124 | 124 | then WriteSet([DataEntry(getStatusKey(voteId), "open")]) | |
125 | 125 | else throw("Invalid ID") | |
126 | 126 | ||
127 | 127 | ||
128 | 128 | ||
129 | 129 | @Callable(i) | |
130 | 130 | func closeVote (voteId) = if ((i.caller.bytes != adminAddress)) | |
131 | 131 | then throw("Only Dyzrupt Admin can call this dApp function") | |
132 | 132 | else if (profileExist(voteId)) | |
133 | 133 | then WriteSet([DataEntry(getStatusKey(voteId), "closed")]) | |
134 | 134 | else throw("Invalid ID") | |
135 | 135 | ||
136 | 136 | ||
137 | 137 | ||
138 | 138 | @Callable(i) | |
139 | 139 | func stake () = { | |
140 | 140 | let staker = toBase58String(i.caller.bytes) | |
141 | 141 | let pmt = extract(i.payment) | |
142 | 142 | if ((pmt.amount == 0)) | |
143 | 143 | then throw("Stake amount too low") | |
144 | 144 | else if ((pmt.assetId != base58'9XTqBQeJvdMs8VNHv6rXiJLJichg2acG7wCfYcTajQ1G')) | |
145 | 145 | then throw("You can only stake with DYZRUPT token") | |
146 | 146 | else { | |
147 | 147 | let currentStake = getCurrentStake(staker) | |
148 | - | let stakeableAmount = fraction(pmt.amount, | |
148 | + | let stakeableAmount = fraction(pmt.amount, 5, 100) | |
149 | 149 | let amountToStake = (pmt.amount - stakeableAmount) | |
150 | 150 | let newStakedAmount = (currentStake + amountToStake) | |
151 | 151 | let stakePool = getStakePool() | |
152 | 152 | let newStakePool = (stakePool + stakeableAmount) | |
153 | 153 | ScriptResult(WriteSet([DataEntry(getStakerKey(staker), newStakedAmount), DataEntry(getStakePoolKey(), newStakePool)]), TransferSet(nil)) | |
154 | 154 | } | |
155 | 155 | } | |
156 | 156 | ||
157 | 157 | ||
158 | 158 | ||
159 | 159 | @Callable(i) | |
160 | 160 | func unstake (amount) = { | |
161 | 161 | let staker = toBase58String(i.caller.bytes) | |
162 | 162 | let currentStake = getCurrentStake(staker) | |
163 | 163 | if ((currentStake == 0)) | |
164 | 164 | then throw("You don't have any stakes") | |
165 | 165 | else if ((amount > currentStake)) | |
166 | 166 | then throw("You can't withdraw an amount higher than you staked") | |
167 | 167 | else { | |
168 | - | let unstakeableAmount = fraction(amount, | |
168 | + | let unstakeableAmount = fraction(amount, 10, 100) | |
169 | 169 | let amountToUnstake = (amount - unstakeableAmount) | |
170 | 170 | let newUnstakedAmount = (currentStake - amount) | |
171 | 171 | let stakePool = getStakePool() | |
172 | 172 | let newStakePool = (stakePool + unstakeableAmount) | |
173 | 173 | ScriptResult(WriteSet([DataEntry(getStakerKey(staker), newUnstakedAmount), DataEntry(getStakePoolKey(), newStakePool)]), TransferSet([ScriptTransfer(i.caller, amountToUnstake, dyzId)])) | |
174 | 174 | } | |
175 | 175 | } | |
176 | 176 | ||
177 | 177 | ||
178 | 178 | ||
179 | 179 | @Callable(i) | |
180 | 180 | func claimDailyStakeReward (reward) = { | |
181 | 181 | let staker = toBase58String(i.caller.bytes) | |
182 | 182 | let currentStake = getCurrentStake(staker) | |
183 | 183 | let stakePool = getStakePool() | |
184 | 184 | if ((currentStake == 0)) | |
185 | 185 | then throw("You don't have any stakes") | |
186 | 186 | else if ((stakePool == 0)) | |
187 | 187 | then throw("Nothing in Stake pool at this time. Try again later") | |
188 | 188 | else if ((reward > stakePool)) | |
189 | 189 | then throw("No rewards at this time") | |
190 | 190 | else { | |
191 | 191 | let newStakePool = (stakePool - reward) | |
192 | 192 | let newStakeAmount = (currentStake - reward) | |
193 | 193 | ScriptResult(WriteSet([DataEntry(getStakerKey(staker), newStakeAmount), DataEntry(getStakePoolKey(), newStakePool)]), TransferSet([ScriptTransfer(i.caller, reward, dyzId)])) | |
194 | 194 | } | |
195 | 195 | } | |
196 | 196 | ||
197 | 197 |
github/deemru/w8io/026f985 36.09 ms ◑