tx · 3CHyyt5jbdWJLwefWPdFLsoULr7esVBNzRjDoaREYCPy 3N5rNyYSAsaP9QL2eQq286RhevB8msHFffu: -0.05000000 Waves 2020.11.25 18:22 [1281111] smart account 3N5rNyYSAsaP9QL2eQq286RhevB8msHFffu > SELF 0.00000000 Waves
{ "type": 13, "id": "3CHyyt5jbdWJLwefWPdFLsoULr7esVBNzRjDoaREYCPy", "fee": 5000000, "feeAssetId": null, "timestamp": 1606317806440, "version": 2, "chainId": 84, "sender": "3N5rNyYSAsaP9QL2eQq286RhevB8msHFffu", "senderPublicKey": "CBTEuFN6ku1LNaPuGHHTMh2CBb3kPa5D73XXTJvKydun", "proofs": [ "2e1EsmAuAg28NDnoRwUyzPrcyZqdzAb3WyiLZTQGMHncpJQfGAe48Ci47tg5FvL9FcGCjb4Yj8WqWT7KVvvV97db" ], "script": "base64:AAIDAAAAAAAAACcIARIHCgUICAgICBIECgIICBIDCgEIEgMKAQgSABIDCgEBEgMKAQEAAAARAAAAAAZ1cFZvdGUCAAAABnVwdm90ZQAAAAAMYWRtaW5BZGRyZXNzAQAAABoBVKwsfOull8+XvAKI3oesQVhDOp0+0MrSkgAAAAAFZHl6SWQBAAAAIH6rQdnOUsq3YY00nk9jVDL2OOQ/e846gXAImq8xTxZrAQAAAA9nZXRTdGFrZVBvb2xLZXkAAAAAAgAAAApzdGFrZV9wb29sAQAAAAxnZXRTdGFrZVBvb2wAAAAABAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMJAQAAAA9nZXRTdGFrZVBvb2xLZXkAAAAAAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAABAAAADGdldFN0YWtlcktleQAAAAEAAAAGc3Rha2VyCQABLAAAAAIFAAAABnN0YWtlcgIAAAAGX3N0YWtlAQAAAA9nZXRDdXJyZW50U3Rha2UAAAABAAAABnN0YWtlcgQAAAAHJG1hdGNoMAkABBoAAAACB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N0YWtlUG9vbEtleQAAAAAFAAAADG5ld1N0YWtlUG9vbAUAAAADbmlsCQEAAAALVHJhbnNmZXJTZXQAAAABCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFpAAAABmNhbGxlcgUAAAAGcmV3YXJkBQAAAAVkeXpJZAUAAAADbmlsAAAAAE3lltY=", "height": 1281111, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: GXakgudwXb6iNeXLgPb2CrJxYW48UHHTSKQDJCuZNP26 Next: none Diff:
Old | New | Differences | |
---|---|---|---|
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let upVote = "upvote" | |
5 | 5 | ||
6 | - | let adminAddress1 = base58'3Mu5woJ54s7vHJgaeNcJ4C9ByfdmMF2jpjC' | |
7 | - | ||
8 | - | let adminAddress2 = base58'3NAqtCScgFynCuRLUoXm2BHTdu8suatCe7b' | |
9 | - | ||
10 | - | let adminAddress3 = base58'3Mucpi1K4FMVrZKnYEgjxQf5DkkBX7QrHoJ' | |
6 | + | let adminAddress = base58'3N5cTHzbHc9dyQuBfKMjFKaxcrmRq54XDLu' | |
11 | 7 | ||
12 | 8 | let dyzId = base58'9XTqBQeJvdMs8VNHv6rXiJLJichg2acG7wCfYcTajQ1G' | |
9 | + | ||
10 | + | func getStakePoolKey () = "stake_pool" | |
11 | + | ||
12 | + | ||
13 | + | func getStakePool () = match getInteger(this, getStakePoolKey()) { | |
14 | + | case a: Int => | |
15 | + | a | |
16 | + | case _ => | |
17 | + | 0 | |
18 | + | } | |
19 | + | ||
20 | + | ||
21 | + | func getStakerKey (staker) = (staker + "_stake") | |
22 | + | ||
23 | + | ||
24 | + | func getCurrentStake (staker) = match getInteger(this, getStakerKey(staker)) { | |
25 | + | case a: Int => | |
26 | + | a | |
27 | + | case _ => | |
28 | + | 0 | |
29 | + | } | |
30 | + | ||
13 | 31 | ||
14 | 32 | func getProfileKey (id) = (id + "_entrepreneurProfile") | |
15 | 33 | ||
17 | 35 | func getStatusKey (id) = (id + "_status") | |
18 | 36 | ||
19 | 37 | ||
20 | - | func getVoterAmountKey (id,voteId) = (((id + "_") + voteId) + "_amount") | |
21 | - | ||
22 | - | ||
23 | 38 | func getVoteKey (id,type) = if ((type == "upvote")) | |
24 | 39 | then (id + "_upvote") | |
25 | - | else throw("Invalid vote type") | |
26 | - | ||
27 | - | ||
28 | - | func getVoteAmountKey (id,type) = if ((type == "upvote")) | |
29 | - | then (((id + "_") + type) + "_amount") | |
30 | 40 | else throw("Invalid vote type") | |
31 | 41 | ||
32 | 42 | ||
46 | 56 | } | |
47 | 57 | ||
48 | 58 | ||
59 | + | func getLastClaimHeight (pubKey) = match getInteger(this, ("last_claim_" + pubKey)) { | |
60 | + | case a: Int => | |
61 | + | a | |
62 | + | case _ => | |
63 | + | 0 | |
64 | + | } | |
65 | + | ||
66 | + | ||
49 | 67 | func getVoteCount (voteId,vote) = match getInteger(this, getVoteKey(voteId, vote)) { | |
50 | 68 | case a: Int => | |
51 | 69 | a | |
52 | 70 | case _ => | |
53 | 71 | throw("Not a valid vote ID") | |
54 | - | } | |
55 | - | ||
56 | - | ||
57 | - | func getVoteAmountCount (voteId,vote) = match getInteger(this, getVoteAmountKey(voteId, vote)) { | |
58 | - | case a: Int => | |
59 | - | a | |
60 | - | case _ => | |
61 | - | 0 | |
62 | 72 | } | |
63 | 73 | ||
64 | 74 | ||
81 | 91 | } | |
82 | 92 | ||
83 | 93 | ||
84 | - | func getStakerKey (staker) = (staker + "_stake") | |
85 | - | ||
86 | - | ||
87 | - | func getCurrentStake (staker) = match getInteger(this, getStakerKey(staker)) { | |
88 | - | case a: Int => | |
89 | - | a | |
90 | - | case _ => | |
91 | - | 0 | |
92 | - | } | |
93 | - | ||
94 | - | ||
95 | - | func getStakePoolKey () = "stake_pool" | |
96 | - | ||
97 | - | ||
98 | - | func getStakePool () = match getInteger(this, getStakePoolKey()) { | |
99 | - | case a: Int => | |
100 | - | a | |
101 | - | case _ => | |
102 | - | 0 | |
103 | - | } | |
104 | - | ||
105 | - | ||
106 | 94 | @Callable(i) | |
107 | - | func addEntrepreneurProfile (name,avatar,bio,gender,location) = if (if (if ((i.caller.bytes == adminAddress1)) | |
108 | - | then true | |
109 | - | else (i.caller.bytes == adminAddress2)) | |
110 | - | then true | |
111 | - | else (i.caller.bytes == adminAddress3)) | |
112 | - | then { | |
95 | + | func addEntrepreneurProfile (name,avatar,bio,gender,location) = if ((i.caller.bytes != adminAddress)) | |
96 | + | then throw("Only Dyzrupt Admin can call this dApp function") | |
97 | + | else { | |
113 | 98 | let transactionId = toBase58String(i.transactionId) | |
114 | - | WriteSet([DataEntry(getProfileKey(transactionId), ((((((((name + "_") + avatar) + "_") + bio) + "_") + gender) + "_") + location)), DataEntry(getVoteKey(transactionId, "upvote"), 0), DataEntry( | |
99 | + | WriteSet([DataEntry(getProfileKey(transactionId), ((((((((name + "_") + avatar) + "_") + bio) + "_") + gender) + "_") + location)), DataEntry(getVoteKey(transactionId, "upvote"), 0), DataEntry(getStatusKey(transactionId), "open")]) | |
115 | 100 | } | |
116 | - | else throw("Only Dyzrupt Admin can call this dApp function") | |
117 | 101 | ||
118 | 102 | ||
119 | 103 | ||
120 | 104 | @Callable(i) | |
121 | 105 | func vote (voteId,vote) = { | |
122 | 106 | let pmt = extract(i.payment) | |
123 | - | let voter = toBase58String(i.caller.bytes) | |
124 | 107 | if ((pmt.amount == 0)) | |
125 | 108 | then throw("You cannot vote without paying voting fee") | |
126 | 109 | else if ((pmt.assetId != base58'9XTqBQeJvdMs8VNHv6rXiJLJichg2acG7wCfYcTajQ1G')) | |
127 | 110 | then throw("You can only vote with DYZRUPT token") | |
128 | - | else if (canVote( | |
111 | + | else if (canVote(toBase58String(i.caller.bytes), voteId)) | |
129 | 112 | then if (profileExist(voteId)) | |
130 | 113 | then if ((getVoteStatus(voteId) == "open")) | |
131 | 114 | then if ((vote == upVote)) | |
132 | 115 | then { | |
133 | 116 | let voteCount = getVoteCount(voteId, vote) | |
134 | - | let voteAmountCount = getVoteAmountCount(voteId, vote) | |
135 | 117 | let newVoteCount = (voteCount + 1) | |
136 | - | let newVoteAmountCount = (voteAmountCount + pmt.amount) | |
137 | - | ScriptResult(WriteSet([DataEntry(getVoteKey(voteId, vote), newVoteCount), DataEntry(getVoterKey(voter, voteId), voteId), DataEntry(getVoterAmountKey(voter, voteId), pmt.amount), DataEntry(getVoteAmountKey(voteId, vote), newVoteAmountCount)]), TransferSet([ScriptTransfer(this, pmt.amount, dyzId)])) | |
118 | + | ScriptResult(WriteSet([DataEntry(getVoteKey(voteId, vote), newVoteCount), DataEntry(getVoterKey(toBase58String(i.caller.bytes), voteId), voteId)]), TransferSet([ScriptTransfer(this, pmt.amount, dyzId)])) | |
138 | 119 | } | |
139 | 120 | else throw("Not a valid vote value") | |
140 | 121 | else throw("This profile is not open for voting") | |
145 | 126 | ||
146 | 127 | ||
147 | 128 | @Callable(i) | |
148 | - | func openVote (voteId) = if (if (if ((i.caller.bytes == adminAddress1)) | |
149 | - | then true | |
150 | - | else (i.caller.bytes == adminAddress2)) | |
151 | - | then true | |
152 | - | else (i.caller.bytes == adminAddress3)) | |
153 | - | then if (profileExist(voteId)) | |
129 | + | func openVote (voteId) = if ((i.caller.bytes != adminAddress)) | |
130 | + | then throw("Only Dyzrupt Admin can call this dApp function") | |
131 | + | else if (profileExist(voteId)) | |
154 | 132 | then WriteSet([DataEntry(getStatusKey(voteId), "open")]) | |
155 | 133 | else throw("Invalid ID") | |
156 | - | else throw("Only Dyzrupt Admin can call this dApp function") | |
157 | 134 | ||
158 | 135 | ||
159 | 136 | ||
160 | 137 | @Callable(i) | |
161 | - | func closeVote (voteId) = if (if (if ((i.caller.bytes == adminAddress1)) | |
162 | - | then true | |
163 | - | else (i.caller.bytes == adminAddress2)) | |
164 | - | then true | |
165 | - | else (i.caller.bytes == adminAddress3)) | |
166 | - | then if (profileExist(voteId)) | |
138 | + | func closeVote (voteId) = if ((i.caller.bytes != adminAddress)) | |
139 | + | then throw("Only Dyzrupt Admin can call this dApp function") | |
140 | + | else if (profileExist(voteId)) | |
167 | 141 | then WriteSet([DataEntry(getStatusKey(voteId), "closed")]) | |
168 | 142 | else throw("Invalid ID") | |
169 | - | else throw("Only Dyzrupt Admin can call this dApp function") | |
170 | - | ||
171 | - | ||
172 | - | ||
173 | - | @Callable(i) | |
174 | - | func withdraw (voteId) = { | |
175 | - | let voter = toBase58String(i.caller.bytes) | |
176 | - | if ((getVoter(voter, voteId) != "")) | |
177 | - | then if ((getVoteStatus(voteId) == "closed")) | |
178 | - | then { | |
179 | - | let currentKey = getVoterAmountKey(voter, voteId) | |
180 | - | let currentAmount = match getInteger(this, currentKey) { | |
181 | - | case a: Int => | |
182 | - | a | |
183 | - | case _ => | |
184 | - | throw("You didn't vote for this entrepreneur") | |
185 | - | } | |
186 | - | if ((currentAmount == 0)) | |
187 | - | then throw("Seems you have previously withdrawn.") | |
188 | - | else ScriptResult(WriteSet([DataEntry(currentKey, 0)]), TransferSet([ScriptTransfer(i.caller, currentAmount, dyzId)])) | |
189 | - | } | |
190 | - | else throw("Can't withdraw vote amount while voting is still open.") | |
191 | - | else throw("You didn't vote for this entrepreneur") | |
192 | - | } | |
193 | 143 | ||
194 | 144 | ||
195 | 145 | ||
203 | 153 | then throw("You can only stake with DYZRUPT token") | |
204 | 154 | else { | |
205 | 155 | let currentStake = getCurrentStake(staker) | |
206 | - | let stakePercent = (20 / 100) | |
207 | - | let stakeableAmount = (pmt.amount * stakePercent) | |
156 | + | let stakeableAmount = fraction(pmt.amount, 5, 100) | |
208 | 157 | let amountToStake = (pmt.amount - stakeableAmount) | |
209 | 158 | let newStakedAmount = (currentStake + amountToStake) | |
210 | - | ScriptResult(WriteSet([DataEntry(getStakerKey(staker), newStakedAmount)]), TransferSet([ScriptTransfer(this, pmt.amount, dyzId)])) | |
159 | + | let stakePool = getStakePool() | |
160 | + | let newStakePool = (stakePool + stakeableAmount) | |
161 | + | ScriptResult(WriteSet([DataEntry(getStakerKey(staker), newStakedAmount), DataEntry(getStakePoolKey(), newStakePool)]), TransferSet(nil)) | |
211 | 162 | } | |
212 | 163 | } | |
213 | 164 | ||
222 | 173 | else if ((amount > currentStake)) | |
223 | 174 | then throw("You can't withdraw an amount higher than you staked") | |
224 | 175 | else { | |
225 | - | let newStakedAmount = (currentStake - amount) | |
226 | - | ScriptResult(WriteSet([DataEntry(getStakerKey(staker), newStakedAmount)]), TransferSet([ScriptTransfer(i.caller, amount, dyzId)])) | |
176 | + | let unstakeableAmount = fraction(amount, 10, 100) | |
177 | + | let amountToUnstake = (amount - unstakeableAmount) | |
178 | + | let newUnstakedAmount = (currentStake - amount) | |
179 | + | let stakePool = getStakePool() | |
180 | + | let newStakePool = (stakePool + unstakeableAmount) | |
181 | + | ScriptResult(WriteSet([DataEntry(getStakerKey(staker), newUnstakedAmount), DataEntry(getStakePoolKey(), newStakePool)]), TransferSet([ScriptTransfer(i.caller, amountToUnstake, dyzId)])) | |
227 | 182 | } | |
228 | 183 | } | |
229 | 184 | ||
234 | 189 | let staker = toBase58String(i.caller.bytes) | |
235 | 190 | let currentStake = getCurrentStake(staker) | |
236 | 191 | let stakePool = getStakePool() | |
192 | + | let currentHeight = height | |
193 | + | let lastClaimHeight = getLastClaimHeight(staker) | |
237 | 194 | if ((currentStake == 0)) | |
238 | 195 | then throw("You don't have any stakes") | |
239 | 196 | else if ((stakePool == 0)) | |
240 | 197 | then throw("Nothing in Stake pool at this time. Try again later") | |
241 | 198 | else if ((reward > stakePool)) | |
242 | 199 | then throw("No rewards at this time") | |
243 | - | else { | |
244 | - | let newStakePool = (stakePool - reward) | |
245 | - | let newStakeAmount = (currentStake - reward) | |
246 | - | ScriptResult(WriteSet([DataEntry(getStakerKey(staker), newStakeAmount), DataEntry(getStakePoolKey(), newStakePool)]), TransferSet([ScriptTransfer(i.caller, reward, dyzId)])) | |
247 | - | } | |
200 | + | else if (((lastClaimHeight + 1440) > currentHeight)) | |
201 | + | then throw("You can only claim once a day") | |
202 | + | else { | |
203 | + | let newStakePool = (stakePool - reward) | |
204 | + | let newStakeAmount = (currentStake - reward) | |
205 | + | ScriptResult(WriteSet([DataEntry(("last_claim_" + staker), currentHeight), DataEntry(getStakerKey(staker), newStakeAmount), DataEntry(getStakePoolKey(), newStakePool)]), TransferSet([ScriptTransfer(i.caller, reward, dyzId)])) | |
206 | + | } | |
248 | 207 | } | |
249 | 208 | ||
250 | 209 |
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 | - | let adminAddress1 = base58'3Mu5woJ54s7vHJgaeNcJ4C9ByfdmMF2jpjC' | |
7 | - | ||
8 | - | let adminAddress2 = base58'3NAqtCScgFynCuRLUoXm2BHTdu8suatCe7b' | |
9 | - | ||
10 | - | let adminAddress3 = base58'3Mucpi1K4FMVrZKnYEgjxQf5DkkBX7QrHoJ' | |
6 | + | let adminAddress = base58'3N5cTHzbHc9dyQuBfKMjFKaxcrmRq54XDLu' | |
11 | 7 | ||
12 | 8 | let dyzId = base58'9XTqBQeJvdMs8VNHv6rXiJLJichg2acG7wCfYcTajQ1G' | |
9 | + | ||
10 | + | func getStakePoolKey () = "stake_pool" | |
11 | + | ||
12 | + | ||
13 | + | func getStakePool () = match getInteger(this, getStakePoolKey()) { | |
14 | + | case a: Int => | |
15 | + | a | |
16 | + | case _ => | |
17 | + | 0 | |
18 | + | } | |
19 | + | ||
20 | + | ||
21 | + | func getStakerKey (staker) = (staker + "_stake") | |
22 | + | ||
23 | + | ||
24 | + | func getCurrentStake (staker) = match getInteger(this, getStakerKey(staker)) { | |
25 | + | case a: Int => | |
26 | + | a | |
27 | + | case _ => | |
28 | + | 0 | |
29 | + | } | |
30 | + | ||
13 | 31 | ||
14 | 32 | func getProfileKey (id) = (id + "_entrepreneurProfile") | |
15 | 33 | ||
16 | 34 | ||
17 | 35 | func getStatusKey (id) = (id + "_status") | |
18 | 36 | ||
19 | 37 | ||
20 | - | func getVoterAmountKey (id,voteId) = (((id + "_") + voteId) + "_amount") | |
21 | - | ||
22 | - | ||
23 | 38 | func getVoteKey (id,type) = if ((type == "upvote")) | |
24 | 39 | then (id + "_upvote") | |
25 | - | else throw("Invalid vote type") | |
26 | - | ||
27 | - | ||
28 | - | func getVoteAmountKey (id,type) = if ((type == "upvote")) | |
29 | - | then (((id + "_") + type) + "_amount") | |
30 | 40 | else throw("Invalid vote type") | |
31 | 41 | ||
32 | 42 | ||
33 | 43 | func profileExist (id) = match getString(this, getProfileKey(id)) { | |
34 | 44 | case a: String => | |
35 | 45 | true | |
36 | 46 | case _ => | |
37 | 47 | false | |
38 | 48 | } | |
39 | 49 | ||
40 | 50 | ||
41 | 51 | func getVoteStatus (voteId) = match getString(this, getStatusKey(voteId)) { | |
42 | 52 | case a: String => | |
43 | 53 | a | |
44 | 54 | case _ => | |
45 | 55 | false | |
46 | 56 | } | |
47 | 57 | ||
48 | 58 | ||
59 | + | func getLastClaimHeight (pubKey) = match getInteger(this, ("last_claim_" + pubKey)) { | |
60 | + | case a: Int => | |
61 | + | a | |
62 | + | case _ => | |
63 | + | 0 | |
64 | + | } | |
65 | + | ||
66 | + | ||
49 | 67 | func getVoteCount (voteId,vote) = match getInteger(this, getVoteKey(voteId, vote)) { | |
50 | 68 | case a: Int => | |
51 | 69 | a | |
52 | 70 | case _ => | |
53 | 71 | throw("Not a valid vote ID") | |
54 | - | } | |
55 | - | ||
56 | - | ||
57 | - | func getVoteAmountCount (voteId,vote) = match getInteger(this, getVoteAmountKey(voteId, vote)) { | |
58 | - | case a: Int => | |
59 | - | a | |
60 | - | case _ => | |
61 | - | 0 | |
62 | 72 | } | |
63 | 73 | ||
64 | 74 | ||
65 | 75 | func getVoterKey (address,voteId) = ((((address + "_") + voteId) + "_") + "vote") | |
66 | 76 | ||
67 | 77 | ||
68 | 78 | func getVoter (address,voteId) = match getString(this, getVoterKey(address, voteId)) { | |
69 | 79 | case a: String => | |
70 | 80 | a | |
71 | 81 | case _ => | |
72 | 82 | "" | |
73 | 83 | } | |
74 | 84 | ||
75 | 85 | ||
76 | 86 | func canVote (address,voteId) = { | |
77 | 87 | let voter = getVoter(address, voteId) | |
78 | 88 | if ((voter == "")) | |
79 | 89 | then true | |
80 | 90 | else false | |
81 | 91 | } | |
82 | 92 | ||
83 | 93 | ||
84 | - | func getStakerKey (staker) = (staker + "_stake") | |
85 | - | ||
86 | - | ||
87 | - | func getCurrentStake (staker) = match getInteger(this, getStakerKey(staker)) { | |
88 | - | case a: Int => | |
89 | - | a | |
90 | - | case _ => | |
91 | - | 0 | |
92 | - | } | |
93 | - | ||
94 | - | ||
95 | - | func getStakePoolKey () = "stake_pool" | |
96 | - | ||
97 | - | ||
98 | - | func getStakePool () = match getInteger(this, getStakePoolKey()) { | |
99 | - | case a: Int => | |
100 | - | a | |
101 | - | case _ => | |
102 | - | 0 | |
103 | - | } | |
104 | - | ||
105 | - | ||
106 | 94 | @Callable(i) | |
107 | - | func addEntrepreneurProfile (name,avatar,bio,gender,location) = if (if (if ((i.caller.bytes == adminAddress1)) | |
108 | - | then true | |
109 | - | else (i.caller.bytes == adminAddress2)) | |
110 | - | then true | |
111 | - | else (i.caller.bytes == adminAddress3)) | |
112 | - | then { | |
95 | + | func addEntrepreneurProfile (name,avatar,bio,gender,location) = if ((i.caller.bytes != adminAddress)) | |
96 | + | then throw("Only Dyzrupt Admin can call this dApp function") | |
97 | + | else { | |
113 | 98 | let transactionId = toBase58String(i.transactionId) | |
114 | - | WriteSet([DataEntry(getProfileKey(transactionId), ((((((((name + "_") + avatar) + "_") + bio) + "_") + gender) + "_") + location)), DataEntry(getVoteKey(transactionId, "upvote"), 0), DataEntry( | |
99 | + | WriteSet([DataEntry(getProfileKey(transactionId), ((((((((name + "_") + avatar) + "_") + bio) + "_") + gender) + "_") + location)), DataEntry(getVoteKey(transactionId, "upvote"), 0), DataEntry(getStatusKey(transactionId), "open")]) | |
115 | 100 | } | |
116 | - | else throw("Only Dyzrupt Admin can call this dApp function") | |
117 | 101 | ||
118 | 102 | ||
119 | 103 | ||
120 | 104 | @Callable(i) | |
121 | 105 | func vote (voteId,vote) = { | |
122 | 106 | let pmt = extract(i.payment) | |
123 | - | let voter = toBase58String(i.caller.bytes) | |
124 | 107 | if ((pmt.amount == 0)) | |
125 | 108 | then throw("You cannot vote without paying voting fee") | |
126 | 109 | else if ((pmt.assetId != base58'9XTqBQeJvdMs8VNHv6rXiJLJichg2acG7wCfYcTajQ1G')) | |
127 | 110 | then throw("You can only vote with DYZRUPT token") | |
128 | - | else if (canVote( | |
111 | + | else if (canVote(toBase58String(i.caller.bytes), voteId)) | |
129 | 112 | then if (profileExist(voteId)) | |
130 | 113 | then if ((getVoteStatus(voteId) == "open")) | |
131 | 114 | then if ((vote == upVote)) | |
132 | 115 | then { | |
133 | 116 | let voteCount = getVoteCount(voteId, vote) | |
134 | - | let voteAmountCount = getVoteAmountCount(voteId, vote) | |
135 | 117 | let newVoteCount = (voteCount + 1) | |
136 | - | let newVoteAmountCount = (voteAmountCount + pmt.amount) | |
137 | - | ScriptResult(WriteSet([DataEntry(getVoteKey(voteId, vote), newVoteCount), DataEntry(getVoterKey(voter, voteId), voteId), DataEntry(getVoterAmountKey(voter, voteId), pmt.amount), DataEntry(getVoteAmountKey(voteId, vote), newVoteAmountCount)]), TransferSet([ScriptTransfer(this, pmt.amount, dyzId)])) | |
118 | + | ScriptResult(WriteSet([DataEntry(getVoteKey(voteId, vote), newVoteCount), DataEntry(getVoterKey(toBase58String(i.caller.bytes), voteId), voteId)]), TransferSet([ScriptTransfer(this, pmt.amount, dyzId)])) | |
138 | 119 | } | |
139 | 120 | else throw("Not a valid vote value") | |
140 | 121 | else throw("This profile is not open for voting") | |
141 | 122 | else throw("Invalid Profile") | |
142 | 123 | else throw("You can't vote twice") | |
143 | 124 | } | |
144 | 125 | ||
145 | 126 | ||
146 | 127 | ||
147 | 128 | @Callable(i) | |
148 | - | func openVote (voteId) = if (if (if ((i.caller.bytes == adminAddress1)) | |
149 | - | then true | |
150 | - | else (i.caller.bytes == adminAddress2)) | |
151 | - | then true | |
152 | - | else (i.caller.bytes == adminAddress3)) | |
153 | - | then if (profileExist(voteId)) | |
129 | + | func openVote (voteId) = if ((i.caller.bytes != adminAddress)) | |
130 | + | then throw("Only Dyzrupt Admin can call this dApp function") | |
131 | + | else if (profileExist(voteId)) | |
154 | 132 | then WriteSet([DataEntry(getStatusKey(voteId), "open")]) | |
155 | 133 | else throw("Invalid ID") | |
156 | - | else throw("Only Dyzrupt Admin can call this dApp function") | |
157 | 134 | ||
158 | 135 | ||
159 | 136 | ||
160 | 137 | @Callable(i) | |
161 | - | func closeVote (voteId) = if (if (if ((i.caller.bytes == adminAddress1)) | |
162 | - | then true | |
163 | - | else (i.caller.bytes == adminAddress2)) | |
164 | - | then true | |
165 | - | else (i.caller.bytes == adminAddress3)) | |
166 | - | then if (profileExist(voteId)) | |
138 | + | func closeVote (voteId) = if ((i.caller.bytes != adminAddress)) | |
139 | + | then throw("Only Dyzrupt Admin can call this dApp function") | |
140 | + | else if (profileExist(voteId)) | |
167 | 141 | then WriteSet([DataEntry(getStatusKey(voteId), "closed")]) | |
168 | 142 | else throw("Invalid ID") | |
169 | - | else throw("Only Dyzrupt Admin can call this dApp function") | |
170 | - | ||
171 | - | ||
172 | - | ||
173 | - | @Callable(i) | |
174 | - | func withdraw (voteId) = { | |
175 | - | let voter = toBase58String(i.caller.bytes) | |
176 | - | if ((getVoter(voter, voteId) != "")) | |
177 | - | then if ((getVoteStatus(voteId) == "closed")) | |
178 | - | then { | |
179 | - | let currentKey = getVoterAmountKey(voter, voteId) | |
180 | - | let currentAmount = match getInteger(this, currentKey) { | |
181 | - | case a: Int => | |
182 | - | a | |
183 | - | case _ => | |
184 | - | throw("You didn't vote for this entrepreneur") | |
185 | - | } | |
186 | - | if ((currentAmount == 0)) | |
187 | - | then throw("Seems you have previously withdrawn.") | |
188 | - | else ScriptResult(WriteSet([DataEntry(currentKey, 0)]), TransferSet([ScriptTransfer(i.caller, currentAmount, dyzId)])) | |
189 | - | } | |
190 | - | else throw("Can't withdraw vote amount while voting is still open.") | |
191 | - | else throw("You didn't vote for this entrepreneur") | |
192 | - | } | |
193 | 143 | ||
194 | 144 | ||
195 | 145 | ||
196 | 146 | @Callable(i) | |
197 | 147 | func stake () = { | |
198 | 148 | let staker = toBase58String(i.caller.bytes) | |
199 | 149 | let pmt = extract(i.payment) | |
200 | 150 | if ((pmt.amount == 0)) | |
201 | 151 | then throw("Stake amount too low") | |
202 | 152 | else if ((pmt.assetId != base58'9XTqBQeJvdMs8VNHv6rXiJLJichg2acG7wCfYcTajQ1G')) | |
203 | 153 | then throw("You can only stake with DYZRUPT token") | |
204 | 154 | else { | |
205 | 155 | let currentStake = getCurrentStake(staker) | |
206 | - | let stakePercent = (20 / 100) | |
207 | - | let stakeableAmount = (pmt.amount * stakePercent) | |
156 | + | let stakeableAmount = fraction(pmt.amount, 5, 100) | |
208 | 157 | let amountToStake = (pmt.amount - stakeableAmount) | |
209 | 158 | let newStakedAmount = (currentStake + amountToStake) | |
210 | - | ScriptResult(WriteSet([DataEntry(getStakerKey(staker), newStakedAmount)]), TransferSet([ScriptTransfer(this, pmt.amount, dyzId)])) | |
159 | + | let stakePool = getStakePool() | |
160 | + | let newStakePool = (stakePool + stakeableAmount) | |
161 | + | ScriptResult(WriteSet([DataEntry(getStakerKey(staker), newStakedAmount), DataEntry(getStakePoolKey(), newStakePool)]), TransferSet(nil)) | |
211 | 162 | } | |
212 | 163 | } | |
213 | 164 | ||
214 | 165 | ||
215 | 166 | ||
216 | 167 | @Callable(i) | |
217 | 168 | func unstake (amount) = { | |
218 | 169 | let staker = toBase58String(i.caller.bytes) | |
219 | 170 | let currentStake = getCurrentStake(staker) | |
220 | 171 | if ((currentStake == 0)) | |
221 | 172 | then throw("You don't have any stakes") | |
222 | 173 | else if ((amount > currentStake)) | |
223 | 174 | then throw("You can't withdraw an amount higher than you staked") | |
224 | 175 | else { | |
225 | - | let newStakedAmount = (currentStake - amount) | |
226 | - | ScriptResult(WriteSet([DataEntry(getStakerKey(staker), newStakedAmount)]), TransferSet([ScriptTransfer(i.caller, amount, dyzId)])) | |
176 | + | let unstakeableAmount = fraction(amount, 10, 100) | |
177 | + | let amountToUnstake = (amount - unstakeableAmount) | |
178 | + | let newUnstakedAmount = (currentStake - amount) | |
179 | + | let stakePool = getStakePool() | |
180 | + | let newStakePool = (stakePool + unstakeableAmount) | |
181 | + | ScriptResult(WriteSet([DataEntry(getStakerKey(staker), newUnstakedAmount), DataEntry(getStakePoolKey(), newStakePool)]), TransferSet([ScriptTransfer(i.caller, amountToUnstake, dyzId)])) | |
227 | 182 | } | |
228 | 183 | } | |
229 | 184 | ||
230 | 185 | ||
231 | 186 | ||
232 | 187 | @Callable(i) | |
233 | 188 | func claimDailyStakeReward (reward) = { | |
234 | 189 | let staker = toBase58String(i.caller.bytes) | |
235 | 190 | let currentStake = getCurrentStake(staker) | |
236 | 191 | let stakePool = getStakePool() | |
192 | + | let currentHeight = height | |
193 | + | let lastClaimHeight = getLastClaimHeight(staker) | |
237 | 194 | if ((currentStake == 0)) | |
238 | 195 | then throw("You don't have any stakes") | |
239 | 196 | else if ((stakePool == 0)) | |
240 | 197 | then throw("Nothing in Stake pool at this time. Try again later") | |
241 | 198 | else if ((reward > stakePool)) | |
242 | 199 | then throw("No rewards at this time") | |
243 | - | else { | |
244 | - | let newStakePool = (stakePool - reward) | |
245 | - | let newStakeAmount = (currentStake - reward) | |
246 | - | ScriptResult(WriteSet([DataEntry(getStakerKey(staker), newStakeAmount), DataEntry(getStakePoolKey(), newStakePool)]), TransferSet([ScriptTransfer(i.caller, reward, dyzId)])) | |
247 | - | } | |
200 | + | else if (((lastClaimHeight + 1440) > currentHeight)) | |
201 | + | then throw("You can only claim once a day") | |
202 | + | else { | |
203 | + | let newStakePool = (stakePool - reward) | |
204 | + | let newStakeAmount = (currentStake - reward) | |
205 | + | ScriptResult(WriteSet([DataEntry(("last_claim_" + staker), currentHeight), DataEntry(getStakerKey(staker), newStakeAmount), DataEntry(getStakePoolKey(), newStakePool)]), TransferSet([ScriptTransfer(i.caller, reward, dyzId)])) | |
206 | + | } | |
248 | 207 | } | |
249 | 208 | ||
250 | 209 |
github/deemru/w8io/169f3d6 44.38 ms ◑