tx · CoSnShRbEYaTKsKRLMDT9vzqAy66izyZHP62wyt21Tci 3N2PjXqef29HexCE7PeGZa9eRjS2jVeaFe4: -0.01500000 Waves 2023.09.05 16:29 [2742138] smart account 3N2PjXqef29HexCE7PeGZa9eRjS2jVeaFe4 > SELF 0.00000000 Waves
{ "type": 13, "id": "CoSnShRbEYaTKsKRLMDT9vzqAy66izyZHP62wyt21Tci", "fee": 1500000, "feeAssetId": null, "timestamp": 1693920578018, "version": 2, "chainId": 84, "sender": "3N2PjXqef29HexCE7PeGZa9eRjS2jVeaFe4", "senderPublicKey": "DU1U4j8FqHUMRr9WgfF3yo67ULEFkjp7dtMWMpjBK1ar", "proofs": [ "2GD8BTwXx4mFZiybjxH4WxKKfdZ8778bh7hxiA3ndqVHpvHkzSTszr6x7qEDY3tZi6Z5wCVwrEgXH4VmW5RzA1h7", "4xskaqrytp1mrgtYc84bdN4SbvP3wPtM84fd1bAZT8Tbrwg3cLwJXEphyoTEzK6XEAXA6X9m7dW8ZZBennHzU9kc" ], "script": "base64:BgIvCAISAwoBCBIHCgUICAgIARIAEgMKAQESABIAEgMKAQgSABIFCgMICAgSABIAEgAhAAZTQ0FMRTgAgMLXLwANUEVSQ0VOVF9TQ0FMRQCQTgAJU0VQQVJBVE9SAgJfXwAJa0ludGVyZXN0AghpbnRlcmVzdAANa1VzZXJJbnRlcmVzdAINX3VzZXJJbnRlcmVzdAAOa1VzZXJBdmFpbGFibGUCE191c2VyQXZhaWxhYmxlQ2xhaW0AEGtVc2VyVG9rZW5TdGFrZWQCEF91c2VyVG9rZW5TdGFrZWQAEWtUb3RhbFRva2VuU3Rha2VkAhB0b3RhbFRva2VuU3Rha2VkAAxrTkZUSW50ZXJlc3QCC05GVEludGVyZXN0ABBrTkZUVXNlckludGVyZXN0AhBfTkZUVXNlckludGVyZXN0ABZrTkZUVXNlckF2YWlsYWJsZUNsYWltAhZfTkZUVXNlckF2YWlsYWJsZUNsYWltAA9rTkZUVG90YWxTdGFrZWQCDk5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zBwYFE211bHRpU2lnbmVkQnlBZG1pbnMFE211bHRpU2lnbmVkQnlBZG1pbnOhtlfi", "height": 2742138, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BFikV3gGw5x6eVhrTx6y2Fm26S7mSk4gwT8qAGsE5jVM Next: XPeLieLgFx5Htg62rhiuVn2b6WPxHBUJ2Qa2Gf8uZEc Diff:
Old | New | Differences | |
---|---|---|---|
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SCALE8 = 100000000 | |
5 | + | ||
6 | + | let PERCENT_SCALE = 10000 | |
7 | + | ||
8 | + | let SEPARATOR = "__" | |
5 | 9 | ||
6 | 10 | let kInterest = "interest" | |
7 | 11 | ||
27 | 31 | ||
28 | 32 | let kNFTCreated = "_NFTCreated" | |
29 | 33 | ||
34 | + | let kLastAirdrop = "_lastAirdrop" | |
35 | + | ||
30 | 36 | let kTokenid = "tokenId" | |
31 | 37 | ||
32 | 38 | let kPersentForNFT = "percentForNFT" | |
39 | + | ||
40 | + | let kActive = "active" | |
33 | 41 | ||
34 | 42 | let kAdmin1PK = "admin_pub_1" | |
35 | 43 | ||
53 | 61 | func isSelfCall (i) = if ((i.caller == this)) | |
54 | 62 | then unit | |
55 | 63 | else throw("Only contract itself can call this function") | |
64 | + | ||
65 | + | ||
66 | + | func isActive () = if (valueOrElse(getBoolean(this, kActive), true)) | |
67 | + | then unit | |
68 | + | else throw("DApp is inactive at this moment") | |
56 | 69 | ||
57 | 70 | ||
58 | 71 | func assetIdToStr (assetId) = match assetId { | |
87 | 100 | } | |
88 | 101 | ||
89 | 102 | ||
103 | + | func calcTokenApr () = { | |
104 | + | let lastAirdrop = valueOrElse(getInteger(this, kLastAirdrop), 0) | |
105 | + | let totalTokenStaked = valueOrElse(getInteger(this, kTotalTokenStaked), 0) | |
106 | + | let totalNFTStaked = valueOrElse(getInteger(this, kNFTTotalStaked), 0) | |
107 | + | let percentForNFT = getIntegerValue(this, kPersentForNFT) | |
108 | + | let tokenAirdrop = if ((totalNFTStaked == 0)) | |
109 | + | then lastAirdrop | |
110 | + | else fraction(lastAirdrop, percentForNFT, 100) | |
111 | + | (fraction(tokenAirdrop, PERCENT_SCALE, totalTokenStaked) * 52) | |
112 | + | } | |
113 | + | ||
114 | + | ||
115 | + | @Callable(i) | |
116 | + | func getUserStatsREADONLY (user) = { | |
117 | + | let apr = calcTokenApr() | |
118 | + | let $t035603998 = if ((user == "")) | |
119 | + | then $Tuple3(0, 0, 0) | |
120 | + | else { | |
121 | + | let userAddr = valueOrErrorMessage(addressFromString(user), "Wrong user address") | |
122 | + | let $t037693865 = claimCalc(user) | |
123 | + | let userNewInterest = $t037693865._1 | |
124 | + | let claimAmountAvailable = $t037693865._2 | |
125 | + | let userTokenStaked = $t037693865._3 | |
126 | + | let totalTokenStaked = $t037693865._4 | |
127 | + | let userBalance = assetBalance(userAddr, fromBase58String(tokenId)) | |
128 | + | $Tuple3(userBalance, userTokenStaked, claimAmountAvailable) | |
129 | + | } | |
130 | + | let userTokenBalance = $t035603998._1 | |
131 | + | let userTokenStaked = $t035603998._2 | |
132 | + | let claimAmountAvailable = $t035603998._3 | |
133 | + | $Tuple2(nil, makeString(["%d%d%d%d", toString(apr), toString(userTokenBalance), toString(userTokenStaked), toString(claimAmountAvailable)], SEPARATOR)) | |
134 | + | } | |
135 | + | ||
136 | + | ||
137 | + | ||
90 | 138 | @Callable(i) | |
91 | 139 | func init (tokenId,adm1Pub,adm2Pub,adm3Pub,toNFTPercent) = valueOrElse(isSelfCall(i), if (isDefined(getString(this, kTokenid))) | |
92 | 140 | then throw("DApp already inited") | |
103 | 151 | ||
104 | 152 | ||
105 | 153 | @Callable(i) | |
106 | - | func stake () = if ((size(i.payments) != 1)) | |
154 | + | func stake () = valueOrElse(isActive(), if ((size(i.payments) != 1)) | |
107 | 155 | then throw("One payment expected") | |
108 | 156 | else { | |
109 | - | let $ | |
110 | - | let pmtAmount = $ | |
111 | - | let pmtAssetId = $ | |
157 | + | let $t051575232 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
158 | + | let pmtAmount = $t051575232._1 | |
159 | + | let pmtAssetId = $t051575232._2 | |
112 | 160 | if ((pmtAssetId != fromBase58String(tokenId))) | |
113 | 161 | then throw("Wrong payment asset") | |
114 | 162 | else { | |
115 | 163 | let user = toString(i.caller) | |
116 | - | let $ | |
117 | - | let userNewInterest = $ | |
118 | - | let claimAmountAvailable = $ | |
119 | - | let userTokenStaked = $ | |
120 | - | let totalTokenStaked = $ | |
164 | + | let $t053535449 = claimCalc(user) | |
165 | + | let userNewInterest = $t053535449._1 | |
166 | + | let claimAmountAvailable = $t053535449._2 | |
167 | + | let userTokenStaked = $t053535449._3 | |
168 | + | let totalTokenStaked = $t053535449._4 | |
121 | 169 | [IntegerEntry((user + kUserInterest), userNewInterest), IntegerEntry((user + kUserAvailable), claimAmountAvailable), IntegerEntry((user + kUserTokenStaked), (userTokenStaked + pmtAmount)), IntegerEntry(kTotalTokenStaked, (totalTokenStaked + pmtAmount))] | |
122 | 170 | } | |
123 | - | } | |
171 | + | }) | |
124 | 172 | ||
125 | 173 | ||
126 | 174 | ||
127 | 175 | @Callable(i) | |
128 | - | func unstake (amount) = { | |
176 | + | func unstake (amount) = valueOrElse(isActive(), { | |
129 | 177 | let user = toString(i.caller) | |
130 | 178 | if ((0 >= amount)) | |
131 | 179 | then throw("Amount must be greater than 0") | |
132 | 180 | else { | |
133 | - | let $ | |
134 | - | let userNewInterest = $ | |
135 | - | let claimAmountAvailable = $ | |
136 | - | let userTokenStaked = $ | |
137 | - | let totalTokenStaked = $ | |
181 | + | let $t058875983 = claimCalc(user) | |
182 | + | let userNewInterest = $t058875983._1 | |
183 | + | let claimAmountAvailable = $t058875983._2 | |
184 | + | let userTokenStaked = $t058875983._3 | |
185 | + | let totalTokenStaked = $t058875983._4 | |
138 | 186 | if ((amount > userTokenStaked)) | |
139 | 187 | then throw("You can't unstake more than staked") | |
140 | - | else [IntegerEntry((user + kUserInterest), userNewInterest), IntegerEntry((user + kUserAvailable), claimAmountAvailable), IntegerEntry((user + kUserTokenStaked), (userTokenStaked - amount)), IntegerEntry(kTotalTokenStaked, (totalTokenStaked - amount))] | |
188 | + | else [IntegerEntry((user + kUserInterest), userNewInterest), IntegerEntry((user + kUserAvailable), claimAmountAvailable), IntegerEntry((user + kUserTokenStaked), (userTokenStaked - amount)), IntegerEntry(kTotalTokenStaked, (totalTokenStaked - amount)), ScriptTransfer(i.caller, amount, fromBase58String(tokenId))] | |
141 | 189 | } | |
142 | - | } | |
190 | + | }) | |
143 | 191 | ||
144 | 192 | ||
145 | 193 | ||
146 | 194 | @Callable(i) | |
147 | - | func claim () = { | |
195 | + | func claim () = valueOrElse(isActive(), { | |
148 | 196 | let user = toString(i.caller) | |
149 | - | let $ | |
150 | - | let userNewInterest = $ | |
151 | - | let claimAmountAvailable = $ | |
152 | - | let userTokenStaked = $ | |
153 | - | let totalTokenStaked = $ | |
197 | + | let $t064896585 = claimCalc(user) | |
198 | + | let userNewInterest = $t064896585._1 | |
199 | + | let claimAmountAvailable = $t064896585._2 | |
200 | + | let userTokenStaked = $t064896585._3 | |
201 | + | let totalTokenStaked = $t064896585._4 | |
154 | 202 | if ((claimAmountAvailable == 0)) | |
155 | 203 | then throw("Nothing to claim") | |
156 | 204 | else [IntegerEntry((user + kUserInterest), userNewInterest), IntegerEntry((user + kUserAvailable), 0), ScriptTransfer(i.caller, claimAmountAvailable, fromBase58String(tokenId))] | |
157 | - | } | |
205 | + | }) | |
158 | 206 | ||
159 | 207 | ||
160 | 208 | ||
161 | 209 | @Callable(i) | |
162 | - | func stakeNFT () = if ((size(i.payments) != 1)) | |
210 | + | func stakeNFT () = valueOrElse(isActive(), if ((size(i.payments) != 1)) | |
163 | 211 | then throw("One payment expected") | |
164 | 212 | else { | |
165 | - | let $ | |
166 | - | let pmtAmount = $ | |
167 | - | let pmtAssetId = $ | |
213 | + | let $t069747049 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
214 | + | let pmtAmount = $t069747049._1 | |
215 | + | let pmtAssetId = $t069747049._2 | |
168 | 216 | let pmtAssetIdStr = assetIdToStr(pmtAssetId) | |
169 | 217 | if (!(isDefined(getString(this, (pmtAssetIdStr + kNFTCreated))))) | |
170 | 218 | then throw("Wrong nft asset") | |
171 | 219 | else { | |
172 | 220 | let user = toString(i.caller) | |
173 | - | let $ | |
174 | - | let userNewInterest = $ | |
175 | - | let claimAmountAvailable = $ | |
176 | - | let userNFTStaked = $ | |
177 | - | let totalNFTStaked = $ | |
221 | + | let $t072307325 = claimCalcNft(user) | |
222 | + | let userNewInterest = $t072307325._1 | |
223 | + | let claimAmountAvailable = $t072307325._2 | |
224 | + | let userNFTStaked = $t072307325._3 | |
225 | + | let totalNFTStaked = $t072307325._4 | |
178 | 226 | [IntegerEntry((user + kNFTUserInterest), userNewInterest), IntegerEntry((user + kNFTUserAvailableClaim), claimAmountAvailable), IntegerEntry((user + kuserNFTStaked), (userNFTStaked + pmtAmount)), IntegerEntry(kNFTTotalStaked, (totalNFTStaked + pmtAmount)), IntegerEntry((((user + "_") + pmtAssetIdStr) + kuserNFTStakedId), 1)] | |
179 | 227 | } | |
180 | - | } | |
228 | + | }) | |
181 | 229 | ||
182 | 230 | ||
183 | 231 | ||
184 | 232 | @Callable(i) | |
185 | - | func unstakeNFT (id) = { | |
233 | + | func unstakeNFT (id) = valueOrElse(isActive(), { | |
186 | 234 | let user = toString(i.caller) | |
187 | 235 | if (isDefined(getString(this, (((user + id) + "_") + kuserNFTStakedId)))) | |
188 | 236 | then throw("You didn't staked") | |
189 | 237 | else { | |
190 | - | let $ | |
191 | - | let userNewInterest = $ | |
192 | - | let claimAmountAvailable = $ | |
193 | - | let userNFTStaked = $ | |
194 | - | let totalNFTStaked = $ | |
238 | + | let $t078747969 = claimCalcNft(user) | |
239 | + | let userNewInterest = $t078747969._1 | |
240 | + | let claimAmountAvailable = $t078747969._2 | |
241 | + | let userNFTStaked = $t078747969._3 | |
242 | + | let totalNFTStaked = $t078747969._4 | |
195 | 243 | [IntegerEntry((user + kNFTUserInterest), userNewInterest), IntegerEntry((user + kNFTUserAvailableClaim), claimAmountAvailable), IntegerEntry((user + kuserNFTStaked), (userNFTStaked - 1)), IntegerEntry(kNFTTotalStaked, (totalNFTStaked - 1)), DeleteEntry((((user + "_") + id) + kuserNFTStakedId)), ScriptTransfer(i.caller, 1, fromBase58String(id))] | |
196 | 244 | } | |
197 | - | } | |
198 | - | ||
199 | - | ||
200 | - | ||
201 | - | @Callable(i) | |
202 | - | func claimNFT () = { | |
203 | - | let user = toString(i.caller) | |
204 | - | let $t067646859 = claimCalcNft(user) | |
205 | - | let userNewInterest = $t067646859._1 | |
206 | - | let claimAmountAvailable = $t067646859._2 | |
207 | - | let userNFTStaked = $t067646859._3 | |
208 | - | let totalNFTStaked = $t067646859._4 | |
209 | - | if ((claimAmountAvailable == 0)) | |
210 | - | then throw("Nothing to claim") | |
211 | - | else [IntegerEntry((user + kNFTUserInterest), userNewInterest), IntegerEntry((user + kNFTUserAvailableClaim), 0), ScriptTransfer(i.caller, claimAmountAvailable, fromBase58String(tokenId))] | |
212 | - | } | |
213 | - | ||
214 | - | ||
215 | - | ||
216 | - | @Callable(i) | |
217 | - | func issueNFT (userAddr,name,descr) = valueOrElse(isAdminCall(i), { | |
218 | - | let uAddr = valueOrErrorMessage(addressFromString(userAddr), "Wrong user address") | |
219 | - | let issue = Issue(name, descr, 1, 0, false) | |
220 | - | let nftId = calculateAssetId(issue) | |
221 | - | [issue, StringEntry((toBase58String(nftId) + kNFTCreated), userAddr), ScriptTransfer(uAddr, 1, nftId)] | |
222 | 245 | }) | |
223 | 246 | ||
224 | 247 | ||
225 | 248 | ||
226 | 249 | @Callable(i) | |
227 | - | func airdrop () = valueOrElse(isAdminCall(i), if ((size(i.payments) != 1)) | |
250 | + | func claimNFT () = valueOrElse(isActive(), { | |
251 | + | let user = toString(i.caller) | |
252 | + | let $t084278522 = claimCalcNft(user) | |
253 | + | let userNewInterest = $t084278522._1 | |
254 | + | let claimAmountAvailable = $t084278522._2 | |
255 | + | let userNFTStaked = $t084278522._3 | |
256 | + | let totalNFTStaked = $t084278522._4 | |
257 | + | if ((claimAmountAvailable == 0)) | |
258 | + | then throw("Nothing to claim") | |
259 | + | else [IntegerEntry((user + kNFTUserInterest), userNewInterest), IntegerEntry((user + kNFTUserAvailableClaim), 0), ScriptTransfer(i.caller, claimAmountAvailable, fromBase58String(tokenId))] | |
260 | + | }) | |
261 | + | ||
262 | + | ||
263 | + | ||
264 | + | @Callable(i) | |
265 | + | func issueNFT (userAddr,name,descr) = valueOrElse(isActive(), valueOrElse(isAdminCall(i), { | |
266 | + | let uAddr = valueOrErrorMessage(addressFromString(userAddr), "Wrong user address") | |
267 | + | let issue = Issue(name, descr, 1, 0, false) | |
268 | + | let nftId = calculateAssetId(issue) | |
269 | + | [issue, StringEntry((toBase58String(nftId) + kNFTCreated), userAddr), ScriptTransfer(uAddr, 1, nftId)] | |
270 | + | })) | |
271 | + | ||
272 | + | ||
273 | + | ||
274 | + | @Callable(i) | |
275 | + | func airdrop () = valueOrElse(isActive(), valueOrElse(isAdminCall(i), if ((size(i.payments) != 1)) | |
228 | 276 | then throw("One payment expected") | |
229 | 277 | else { | |
230 | - | let $ | |
231 | - | let pmtAmount = $ | |
232 | - | let pmtAssetId = $ | |
278 | + | let $t093709445 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
279 | + | let pmtAmount = $t093709445._1 | |
280 | + | let pmtAssetId = $t093709445._2 | |
233 | 281 | if ((pmtAssetId != fromBase58String(tokenId))) | |
234 | 282 | then throw("Wrong payment asset") | |
235 | 283 | else { | |
238 | 286 | let totalNFTStaked = valueOrElse(getInteger(this, kNFTTotalStaked), 0) | |
239 | 287 | let curInterest = valueOrElse(getInteger(this, kInterest), 0) | |
240 | 288 | let curNFTInterest = valueOrElse(getInteger(this, kNFTInterest), 0) | |
241 | - | let $ | |
289 | + | let $t0986810043 = if ((totalNFTStaked == 0)) | |
242 | 290 | then $Tuple2(0, pmtAmount) | |
243 | 291 | else { | |
244 | 292 | let nftP = fraction(pmtAmount, percentForNFT, 100) | |
245 | 293 | $Tuple2(nftP, (pmtAmount - nftP)) | |
246 | 294 | } | |
247 | - | let pmtNFT = $ | |
248 | - | let pmtToken = $ | |
295 | + | let pmtNFT = $t0986810043._1 | |
296 | + | let pmtToken = $t0986810043._2 | |
249 | 297 | let interestNew = if ((totalTokenStaked > 0)) | |
250 | 298 | then (curInterest + fraction(pmtToken, SCALE8, totalTokenStaked)) | |
251 | 299 | else curInterest | |
252 | 300 | let interestNFTNew = if ((totalNFTStaked > 0)) | |
253 | 301 | then (curNFTInterest + (pmtNFT / totalNFTStaked)) | |
254 | 302 | else curNFTInterest | |
255 | - | [IntegerEntry(kInterest, interestNew), IntegerEntry(kNFTInterest, interestNFTNew)] | |
303 | + | [IntegerEntry(kInterest, interestNew), IntegerEntry(kNFTInterest, interestNFTNew), IntegerEntry(kLastAirdrop, pmtAmount)] | |
256 | 304 | } | |
257 | - | }) | |
305 | + | })) | |
306 | + | ||
307 | + | ||
308 | + | ||
309 | + | @Callable(i) | |
310 | + | func activate () = valueOrElse(isAdminCall(i), if (valueOrElse(getBoolean(this, kActive), true)) | |
311 | + | then throw("dApp already active") | |
312 | + | else [BooleanEntry(kActive, true)]) | |
313 | + | ||
314 | + | ||
315 | + | ||
316 | + | @Callable(i) | |
317 | + | func shutdown () = valueOrElse(isAdminCall(i), if (!(valueOrElse(getBoolean(this, kActive), true))) | |
318 | + | then throw("dApp already shutdown") | |
319 | + | else [BooleanEntry(kActive, false)]) | |
258 | 320 | ||
259 | 321 | ||
260 | 322 | @Verifier(tx) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SCALE8 = 100000000 | |
5 | + | ||
6 | + | let PERCENT_SCALE = 10000 | |
7 | + | ||
8 | + | let SEPARATOR = "__" | |
5 | 9 | ||
6 | 10 | let kInterest = "interest" | |
7 | 11 | ||
8 | 12 | let kUserInterest = "_userInterest" | |
9 | 13 | ||
10 | 14 | let kUserAvailable = "_userAvailableClaim" | |
11 | 15 | ||
12 | 16 | let kUserTokenStaked = "_userTokenStaked" | |
13 | 17 | ||
14 | 18 | let kTotalTokenStaked = "totalTokenStaked" | |
15 | 19 | ||
16 | 20 | let kNFTInterest = "NFTInterest" | |
17 | 21 | ||
18 | 22 | let kNFTUserInterest = "_NFTUserInterest" | |
19 | 23 | ||
20 | 24 | let kNFTUserAvailableClaim = "_NFTUserAvailableClaim" | |
21 | 25 | ||
22 | 26 | let kNFTTotalStaked = "NFTTotalStaked" | |
23 | 27 | ||
24 | 28 | let kuserNFTStaked = "_userNFTStaked" | |
25 | 29 | ||
26 | 30 | let kuserNFTStakedId = "_userNFTStakedId" | |
27 | 31 | ||
28 | 32 | let kNFTCreated = "_NFTCreated" | |
29 | 33 | ||
34 | + | let kLastAirdrop = "_lastAirdrop" | |
35 | + | ||
30 | 36 | let kTokenid = "tokenId" | |
31 | 37 | ||
32 | 38 | let kPersentForNFT = "percentForNFT" | |
39 | + | ||
40 | + | let kActive = "active" | |
33 | 41 | ||
34 | 42 | let kAdmin1PK = "admin_pub_1" | |
35 | 43 | ||
36 | 44 | let kAdmin2PK = "admin_pub_2" | |
37 | 45 | ||
38 | 46 | let kAdmin3PK = "admin_pub_3" | |
39 | 47 | ||
40 | 48 | let admin1PK = fromBase58String(valueOrErrorMessage(getString(this, kAdmin1PK), "Can't get admin1PK")) | |
41 | 49 | ||
42 | 50 | let admin2PK = fromBase58String(valueOrErrorMessage(getString(this, kAdmin2PK), "Can't get admin2PK")) | |
43 | 51 | ||
44 | 52 | let admin3PK = fromBase58String(valueOrErrorMessage(getString(this, kAdmin3PK), "Can't get operatorPK")) | |
45 | 53 | ||
46 | 54 | let tokenId = valueOrErrorMessage(getString(this, kTokenid), "Can't get staking token") | |
47 | 55 | ||
48 | 56 | func isAdminCall (i) = if (containsElement([admin1PK, admin2PK, admin3PK], i.callerPublicKey)) | |
49 | 57 | then unit | |
50 | 58 | else throw("Only admin can call this function") | |
51 | 59 | ||
52 | 60 | ||
53 | 61 | func isSelfCall (i) = if ((i.caller == this)) | |
54 | 62 | then unit | |
55 | 63 | else throw("Only contract itself can call this function") | |
64 | + | ||
65 | + | ||
66 | + | func isActive () = if (valueOrElse(getBoolean(this, kActive), true)) | |
67 | + | then unit | |
68 | + | else throw("DApp is inactive at this moment") | |
56 | 69 | ||
57 | 70 | ||
58 | 71 | func assetIdToStr (assetId) = match assetId { | |
59 | 72 | case id: ByteVector => | |
60 | 73 | toBase58String(id) | |
61 | 74 | case waves: Unit => | |
62 | 75 | "WAVES" | |
63 | 76 | case _ => | |
64 | 77 | throw("Not Asset id") | |
65 | 78 | } | |
66 | 79 | ||
67 | 80 | ||
68 | 81 | func claimCalc (user) = { | |
69 | 82 | let totalTokenStaked = valueOrElse(getInteger(this, kTotalTokenStaked), 0) | |
70 | 83 | let curInterest = valueOrElse(getInteger(this, kInterest), 0) | |
71 | 84 | let availableForClaim = valueOrElse(getInteger(this, (user + kUserAvailable)), 0) | |
72 | 85 | let userInterest = valueOrElse(getInteger(this, (user + kUserInterest)), curInterest) | |
73 | 86 | let userTokenStaked = valueOrElse(getInteger(this, (user + kUserTokenStaked)), 0) | |
74 | 87 | let claimAmount = fraction(userTokenStaked, (curInterest - userInterest), SCALE8) | |
75 | 88 | $Tuple4(curInterest, (claimAmount + availableForClaim), userTokenStaked, totalTokenStaked) | |
76 | 89 | } | |
77 | 90 | ||
78 | 91 | ||
79 | 92 | func claimCalcNft (user) = { | |
80 | 93 | let totalNftStaked = valueOrElse(getInteger(this, kNFTTotalStaked), 0) | |
81 | 94 | let curInterest = valueOrElse(getInteger(this, kNFTInterest), 0) | |
82 | 95 | let availableForClaim = valueOrElse(getInteger(this, (user + kNFTUserAvailableClaim)), 0) | |
83 | 96 | let userInterest = valueOrElse(getInteger(this, (user + kNFTUserInterest)), curInterest) | |
84 | 97 | let userNftStaked = valueOrElse(getInteger(this, (user + kuserNFTStaked)), 0) | |
85 | 98 | let claimAmount = (userNftStaked * (curInterest - userInterest)) | |
86 | 99 | $Tuple4(curInterest, (claimAmount + availableForClaim), userNftStaked, totalNftStaked) | |
87 | 100 | } | |
88 | 101 | ||
89 | 102 | ||
103 | + | func calcTokenApr () = { | |
104 | + | let lastAirdrop = valueOrElse(getInteger(this, kLastAirdrop), 0) | |
105 | + | let totalTokenStaked = valueOrElse(getInteger(this, kTotalTokenStaked), 0) | |
106 | + | let totalNFTStaked = valueOrElse(getInteger(this, kNFTTotalStaked), 0) | |
107 | + | let percentForNFT = getIntegerValue(this, kPersentForNFT) | |
108 | + | let tokenAirdrop = if ((totalNFTStaked == 0)) | |
109 | + | then lastAirdrop | |
110 | + | else fraction(lastAirdrop, percentForNFT, 100) | |
111 | + | (fraction(tokenAirdrop, PERCENT_SCALE, totalTokenStaked) * 52) | |
112 | + | } | |
113 | + | ||
114 | + | ||
115 | + | @Callable(i) | |
116 | + | func getUserStatsREADONLY (user) = { | |
117 | + | let apr = calcTokenApr() | |
118 | + | let $t035603998 = if ((user == "")) | |
119 | + | then $Tuple3(0, 0, 0) | |
120 | + | else { | |
121 | + | let userAddr = valueOrErrorMessage(addressFromString(user), "Wrong user address") | |
122 | + | let $t037693865 = claimCalc(user) | |
123 | + | let userNewInterest = $t037693865._1 | |
124 | + | let claimAmountAvailable = $t037693865._2 | |
125 | + | let userTokenStaked = $t037693865._3 | |
126 | + | let totalTokenStaked = $t037693865._4 | |
127 | + | let userBalance = assetBalance(userAddr, fromBase58String(tokenId)) | |
128 | + | $Tuple3(userBalance, userTokenStaked, claimAmountAvailable) | |
129 | + | } | |
130 | + | let userTokenBalance = $t035603998._1 | |
131 | + | let userTokenStaked = $t035603998._2 | |
132 | + | let claimAmountAvailable = $t035603998._3 | |
133 | + | $Tuple2(nil, makeString(["%d%d%d%d", toString(apr), toString(userTokenBalance), toString(userTokenStaked), toString(claimAmountAvailable)], SEPARATOR)) | |
134 | + | } | |
135 | + | ||
136 | + | ||
137 | + | ||
90 | 138 | @Callable(i) | |
91 | 139 | func init (tokenId,adm1Pub,adm2Pub,adm3Pub,toNFTPercent) = valueOrElse(isSelfCall(i), if (isDefined(getString(this, kTokenid))) | |
92 | 140 | then throw("DApp already inited") | |
93 | 141 | else if (!(isDefined(assetInfo(fromBase58String(tokenId))))) | |
94 | 142 | then throw("asset id is not correct asset id") | |
95 | 143 | else if ((size(fromBase58String(adm1Pub)) != 32)) | |
96 | 144 | then throw("group1Admin1PubKey is not correct") | |
97 | 145 | else if ((size(fromBase58String(adm2Pub)) != 32)) | |
98 | 146 | then throw("group1Admin1PubKey is not correct") | |
99 | 147 | else if ((size(fromBase58String(adm3Pub)) != 32)) | |
100 | 148 | then throw("group1Admin1PubKey is not correct") | |
101 | 149 | else [StringEntry(kTokenid, tokenId), StringEntry(kAdmin1PK, adm1Pub), StringEntry(kAdmin2PK, adm2Pub), StringEntry(kAdmin3PK, adm3Pub), IntegerEntry(kPersentForNFT, toNFTPercent)]) | |
102 | 150 | ||
103 | 151 | ||
104 | 152 | ||
105 | 153 | @Callable(i) | |
106 | - | func stake () = if ((size(i.payments) != 1)) | |
154 | + | func stake () = valueOrElse(isActive(), if ((size(i.payments) != 1)) | |
107 | 155 | then throw("One payment expected") | |
108 | 156 | else { | |
109 | - | let $ | |
110 | - | let pmtAmount = $ | |
111 | - | let pmtAssetId = $ | |
157 | + | let $t051575232 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
158 | + | let pmtAmount = $t051575232._1 | |
159 | + | let pmtAssetId = $t051575232._2 | |
112 | 160 | if ((pmtAssetId != fromBase58String(tokenId))) | |
113 | 161 | then throw("Wrong payment asset") | |
114 | 162 | else { | |
115 | 163 | let user = toString(i.caller) | |
116 | - | let $ | |
117 | - | let userNewInterest = $ | |
118 | - | let claimAmountAvailable = $ | |
119 | - | let userTokenStaked = $ | |
120 | - | let totalTokenStaked = $ | |
164 | + | let $t053535449 = claimCalc(user) | |
165 | + | let userNewInterest = $t053535449._1 | |
166 | + | let claimAmountAvailable = $t053535449._2 | |
167 | + | let userTokenStaked = $t053535449._3 | |
168 | + | let totalTokenStaked = $t053535449._4 | |
121 | 169 | [IntegerEntry((user + kUserInterest), userNewInterest), IntegerEntry((user + kUserAvailable), claimAmountAvailable), IntegerEntry((user + kUserTokenStaked), (userTokenStaked + pmtAmount)), IntegerEntry(kTotalTokenStaked, (totalTokenStaked + pmtAmount))] | |
122 | 170 | } | |
123 | - | } | |
171 | + | }) | |
124 | 172 | ||
125 | 173 | ||
126 | 174 | ||
127 | 175 | @Callable(i) | |
128 | - | func unstake (amount) = { | |
176 | + | func unstake (amount) = valueOrElse(isActive(), { | |
129 | 177 | let user = toString(i.caller) | |
130 | 178 | if ((0 >= amount)) | |
131 | 179 | then throw("Amount must be greater than 0") | |
132 | 180 | else { | |
133 | - | let $ | |
134 | - | let userNewInterest = $ | |
135 | - | let claimAmountAvailable = $ | |
136 | - | let userTokenStaked = $ | |
137 | - | let totalTokenStaked = $ | |
181 | + | let $t058875983 = claimCalc(user) | |
182 | + | let userNewInterest = $t058875983._1 | |
183 | + | let claimAmountAvailable = $t058875983._2 | |
184 | + | let userTokenStaked = $t058875983._3 | |
185 | + | let totalTokenStaked = $t058875983._4 | |
138 | 186 | if ((amount > userTokenStaked)) | |
139 | 187 | then throw("You can't unstake more than staked") | |
140 | - | else [IntegerEntry((user + kUserInterest), userNewInterest), IntegerEntry((user + kUserAvailable), claimAmountAvailable), IntegerEntry((user + kUserTokenStaked), (userTokenStaked - amount)), IntegerEntry(kTotalTokenStaked, (totalTokenStaked - amount))] | |
188 | + | else [IntegerEntry((user + kUserInterest), userNewInterest), IntegerEntry((user + kUserAvailable), claimAmountAvailable), IntegerEntry((user + kUserTokenStaked), (userTokenStaked - amount)), IntegerEntry(kTotalTokenStaked, (totalTokenStaked - amount)), ScriptTransfer(i.caller, amount, fromBase58String(tokenId))] | |
141 | 189 | } | |
142 | - | } | |
190 | + | }) | |
143 | 191 | ||
144 | 192 | ||
145 | 193 | ||
146 | 194 | @Callable(i) | |
147 | - | func claim () = { | |
195 | + | func claim () = valueOrElse(isActive(), { | |
148 | 196 | let user = toString(i.caller) | |
149 | - | let $ | |
150 | - | let userNewInterest = $ | |
151 | - | let claimAmountAvailable = $ | |
152 | - | let userTokenStaked = $ | |
153 | - | let totalTokenStaked = $ | |
197 | + | let $t064896585 = claimCalc(user) | |
198 | + | let userNewInterest = $t064896585._1 | |
199 | + | let claimAmountAvailable = $t064896585._2 | |
200 | + | let userTokenStaked = $t064896585._3 | |
201 | + | let totalTokenStaked = $t064896585._4 | |
154 | 202 | if ((claimAmountAvailable == 0)) | |
155 | 203 | then throw("Nothing to claim") | |
156 | 204 | else [IntegerEntry((user + kUserInterest), userNewInterest), IntegerEntry((user + kUserAvailable), 0), ScriptTransfer(i.caller, claimAmountAvailable, fromBase58String(tokenId))] | |
157 | - | } | |
205 | + | }) | |
158 | 206 | ||
159 | 207 | ||
160 | 208 | ||
161 | 209 | @Callable(i) | |
162 | - | func stakeNFT () = if ((size(i.payments) != 1)) | |
210 | + | func stakeNFT () = valueOrElse(isActive(), if ((size(i.payments) != 1)) | |
163 | 211 | then throw("One payment expected") | |
164 | 212 | else { | |
165 | - | let $ | |
166 | - | let pmtAmount = $ | |
167 | - | let pmtAssetId = $ | |
213 | + | let $t069747049 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
214 | + | let pmtAmount = $t069747049._1 | |
215 | + | let pmtAssetId = $t069747049._2 | |
168 | 216 | let pmtAssetIdStr = assetIdToStr(pmtAssetId) | |
169 | 217 | if (!(isDefined(getString(this, (pmtAssetIdStr + kNFTCreated))))) | |
170 | 218 | then throw("Wrong nft asset") | |
171 | 219 | else { | |
172 | 220 | let user = toString(i.caller) | |
173 | - | let $ | |
174 | - | let userNewInterest = $ | |
175 | - | let claimAmountAvailable = $ | |
176 | - | let userNFTStaked = $ | |
177 | - | let totalNFTStaked = $ | |
221 | + | let $t072307325 = claimCalcNft(user) | |
222 | + | let userNewInterest = $t072307325._1 | |
223 | + | let claimAmountAvailable = $t072307325._2 | |
224 | + | let userNFTStaked = $t072307325._3 | |
225 | + | let totalNFTStaked = $t072307325._4 | |
178 | 226 | [IntegerEntry((user + kNFTUserInterest), userNewInterest), IntegerEntry((user + kNFTUserAvailableClaim), claimAmountAvailable), IntegerEntry((user + kuserNFTStaked), (userNFTStaked + pmtAmount)), IntegerEntry(kNFTTotalStaked, (totalNFTStaked + pmtAmount)), IntegerEntry((((user + "_") + pmtAssetIdStr) + kuserNFTStakedId), 1)] | |
179 | 227 | } | |
180 | - | } | |
228 | + | }) | |
181 | 229 | ||
182 | 230 | ||
183 | 231 | ||
184 | 232 | @Callable(i) | |
185 | - | func unstakeNFT (id) = { | |
233 | + | func unstakeNFT (id) = valueOrElse(isActive(), { | |
186 | 234 | let user = toString(i.caller) | |
187 | 235 | if (isDefined(getString(this, (((user + id) + "_") + kuserNFTStakedId)))) | |
188 | 236 | then throw("You didn't staked") | |
189 | 237 | else { | |
190 | - | let $ | |
191 | - | let userNewInterest = $ | |
192 | - | let claimAmountAvailable = $ | |
193 | - | let userNFTStaked = $ | |
194 | - | let totalNFTStaked = $ | |
238 | + | let $t078747969 = claimCalcNft(user) | |
239 | + | let userNewInterest = $t078747969._1 | |
240 | + | let claimAmountAvailable = $t078747969._2 | |
241 | + | let userNFTStaked = $t078747969._3 | |
242 | + | let totalNFTStaked = $t078747969._4 | |
195 | 243 | [IntegerEntry((user + kNFTUserInterest), userNewInterest), IntegerEntry((user + kNFTUserAvailableClaim), claimAmountAvailable), IntegerEntry((user + kuserNFTStaked), (userNFTStaked - 1)), IntegerEntry(kNFTTotalStaked, (totalNFTStaked - 1)), DeleteEntry((((user + "_") + id) + kuserNFTStakedId)), ScriptTransfer(i.caller, 1, fromBase58String(id))] | |
196 | 244 | } | |
197 | - | } | |
198 | - | ||
199 | - | ||
200 | - | ||
201 | - | @Callable(i) | |
202 | - | func claimNFT () = { | |
203 | - | let user = toString(i.caller) | |
204 | - | let $t067646859 = claimCalcNft(user) | |
205 | - | let userNewInterest = $t067646859._1 | |
206 | - | let claimAmountAvailable = $t067646859._2 | |
207 | - | let userNFTStaked = $t067646859._3 | |
208 | - | let totalNFTStaked = $t067646859._4 | |
209 | - | if ((claimAmountAvailable == 0)) | |
210 | - | then throw("Nothing to claim") | |
211 | - | else [IntegerEntry((user + kNFTUserInterest), userNewInterest), IntegerEntry((user + kNFTUserAvailableClaim), 0), ScriptTransfer(i.caller, claimAmountAvailable, fromBase58String(tokenId))] | |
212 | - | } | |
213 | - | ||
214 | - | ||
215 | - | ||
216 | - | @Callable(i) | |
217 | - | func issueNFT (userAddr,name,descr) = valueOrElse(isAdminCall(i), { | |
218 | - | let uAddr = valueOrErrorMessage(addressFromString(userAddr), "Wrong user address") | |
219 | - | let issue = Issue(name, descr, 1, 0, false) | |
220 | - | let nftId = calculateAssetId(issue) | |
221 | - | [issue, StringEntry((toBase58String(nftId) + kNFTCreated), userAddr), ScriptTransfer(uAddr, 1, nftId)] | |
222 | 245 | }) | |
223 | 246 | ||
224 | 247 | ||
225 | 248 | ||
226 | 249 | @Callable(i) | |
227 | - | func airdrop () = valueOrElse(isAdminCall(i), if ((size(i.payments) != 1)) | |
250 | + | func claimNFT () = valueOrElse(isActive(), { | |
251 | + | let user = toString(i.caller) | |
252 | + | let $t084278522 = claimCalcNft(user) | |
253 | + | let userNewInterest = $t084278522._1 | |
254 | + | let claimAmountAvailable = $t084278522._2 | |
255 | + | let userNFTStaked = $t084278522._3 | |
256 | + | let totalNFTStaked = $t084278522._4 | |
257 | + | if ((claimAmountAvailable == 0)) | |
258 | + | then throw("Nothing to claim") | |
259 | + | else [IntegerEntry((user + kNFTUserInterest), userNewInterest), IntegerEntry((user + kNFTUserAvailableClaim), 0), ScriptTransfer(i.caller, claimAmountAvailable, fromBase58String(tokenId))] | |
260 | + | }) | |
261 | + | ||
262 | + | ||
263 | + | ||
264 | + | @Callable(i) | |
265 | + | func issueNFT (userAddr,name,descr) = valueOrElse(isActive(), valueOrElse(isAdminCall(i), { | |
266 | + | let uAddr = valueOrErrorMessage(addressFromString(userAddr), "Wrong user address") | |
267 | + | let issue = Issue(name, descr, 1, 0, false) | |
268 | + | let nftId = calculateAssetId(issue) | |
269 | + | [issue, StringEntry((toBase58String(nftId) + kNFTCreated), userAddr), ScriptTransfer(uAddr, 1, nftId)] | |
270 | + | })) | |
271 | + | ||
272 | + | ||
273 | + | ||
274 | + | @Callable(i) | |
275 | + | func airdrop () = valueOrElse(isActive(), valueOrElse(isAdminCall(i), if ((size(i.payments) != 1)) | |
228 | 276 | then throw("One payment expected") | |
229 | 277 | else { | |
230 | - | let $ | |
231 | - | let pmtAmount = $ | |
232 | - | let pmtAssetId = $ | |
278 | + | let $t093709445 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
279 | + | let pmtAmount = $t093709445._1 | |
280 | + | let pmtAssetId = $t093709445._2 | |
233 | 281 | if ((pmtAssetId != fromBase58String(tokenId))) | |
234 | 282 | then throw("Wrong payment asset") | |
235 | 283 | else { | |
236 | 284 | let percentForNFT = getIntegerValue(this, kPersentForNFT) | |
237 | 285 | let totalTokenStaked = valueOrElse(getInteger(this, kTotalTokenStaked), 0) | |
238 | 286 | let totalNFTStaked = valueOrElse(getInteger(this, kNFTTotalStaked), 0) | |
239 | 287 | let curInterest = valueOrElse(getInteger(this, kInterest), 0) | |
240 | 288 | let curNFTInterest = valueOrElse(getInteger(this, kNFTInterest), 0) | |
241 | - | let $ | |
289 | + | let $t0986810043 = if ((totalNFTStaked == 0)) | |
242 | 290 | then $Tuple2(0, pmtAmount) | |
243 | 291 | else { | |
244 | 292 | let nftP = fraction(pmtAmount, percentForNFT, 100) | |
245 | 293 | $Tuple2(nftP, (pmtAmount - nftP)) | |
246 | 294 | } | |
247 | - | let pmtNFT = $ | |
248 | - | let pmtToken = $ | |
295 | + | let pmtNFT = $t0986810043._1 | |
296 | + | let pmtToken = $t0986810043._2 | |
249 | 297 | let interestNew = if ((totalTokenStaked > 0)) | |
250 | 298 | then (curInterest + fraction(pmtToken, SCALE8, totalTokenStaked)) | |
251 | 299 | else curInterest | |
252 | 300 | let interestNFTNew = if ((totalNFTStaked > 0)) | |
253 | 301 | then (curNFTInterest + (pmtNFT / totalNFTStaked)) | |
254 | 302 | else curNFTInterest | |
255 | - | [IntegerEntry(kInterest, interestNew), IntegerEntry(kNFTInterest, interestNFTNew)] | |
303 | + | [IntegerEntry(kInterest, interestNew), IntegerEntry(kNFTInterest, interestNFTNew), IntegerEntry(kLastAirdrop, pmtAmount)] | |
256 | 304 | } | |
257 | - | }) | |
305 | + | })) | |
306 | + | ||
307 | + | ||
308 | + | ||
309 | + | @Callable(i) | |
310 | + | func activate () = valueOrElse(isAdminCall(i), if (valueOrElse(getBoolean(this, kActive), true)) | |
311 | + | then throw("dApp already active") | |
312 | + | else [BooleanEntry(kActive, true)]) | |
313 | + | ||
314 | + | ||
315 | + | ||
316 | + | @Callable(i) | |
317 | + | func shutdown () = valueOrElse(isAdminCall(i), if (!(valueOrElse(getBoolean(this, kActive), true))) | |
318 | + | then throw("dApp already shutdown") | |
319 | + | else [BooleanEntry(kActive, false)]) | |
258 | 320 | ||
259 | 321 | ||
260 | 322 | @Verifier(tx) | |
261 | 323 | func verify () = { | |
262 | 324 | let multiSignedByAdmins = { | |
263 | 325 | let adminPubKey1Signed = if (sigVerify(tx.bodyBytes, tx.proofs[0], admin1PK)) | |
264 | 326 | then 1 | |
265 | 327 | else 0 | |
266 | 328 | let adminPubKey2Signed = if (sigVerify(tx.bodyBytes, tx.proofs[1], admin2PK)) | |
267 | 329 | then 1 | |
268 | 330 | else 0 | |
269 | 331 | let adminPubKey3Signed = if (sigVerify(tx.bodyBytes, tx.proofs[2], admin3PK)) | |
270 | 332 | then 1 | |
271 | 333 | else 0 | |
272 | 334 | (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 2) | |
273 | 335 | } | |
274 | 336 | match tx { | |
275 | 337 | case inv: InvokeScriptTransaction => | |
276 | 338 | let isSelf = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
277 | 339 | let isRightFee = if ((inv.fee == 900000)) | |
278 | 340 | then (inv.feeAssetId == unit) | |
279 | 341 | else false | |
280 | 342 | let isInitCall = (inv.function == "init") | |
281 | 343 | let isnoPayments = (size(inv.payments) == 0) | |
282 | 344 | if (if (if (if (isRightFee) | |
283 | 345 | then isInitCall | |
284 | 346 | else false) | |
285 | 347 | then isSelf | |
286 | 348 | else false) | |
287 | 349 | then isnoPayments | |
288 | 350 | else false) | |
289 | 351 | then true | |
290 | 352 | else multiSignedByAdmins | |
291 | 353 | case _ => | |
292 | 354 | multiSignedByAdmins | |
293 | 355 | } | |
294 | 356 | } | |
295 | 357 |
github/deemru/w8io/fabc49c 59.40 ms ◑