/
ventuary-dao.ride
582 lines (554 loc) · 22.3 KB
/
ventuary-dao.ride
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
{-# STDLIB_VERSION 3 #-}
{-# CONTENT_TYPE DAPP #-}
{-# SCRIPT_TYPE ACCOUNT #-}
let NONE = "none"
func getNumberByKey(key: String) = {
let num = match getInteger(this, key) {
case a:Int => a
case _ => 0
}
num
}
func getStrByKey(key: String) = {
let str = match getString(this, key) {
case a:String => a
case _ => NONE
}
str
}
func getKeyWhitelistRef(account: String) = {
"wl_ref_" + account
}
func getKeyWhitelistStatus(account: String) = {
"wl_sts_" + account
}
func getKeyBalance(account: String) = {
"balance_" + account
}
func getKeyWhitelistBio(account: String) = {
"wl_bio_" + account
}
func getKeyWhitelistBlock(account: String) = {
"wl_blk_" + account
}
func getKeyItemAuthor(item: String) = {
"author_" + item
}
func getKeyItemBlock(item: String) = {
"block_" + item
}
func getKeyItemVotingExpiration(item: String) = {
"expiration_block_" + item
}
func getKeyItemBank(item: String) = {
"bank_" + item
}
func getKeyItemStatus(item: String) = {
"status_" + item
}
func getKeyItemData(item: String) = {
"datajson_" + item
}
func getKeyContestData(item: String) = {
"contest_datajson_" + item
}
func getKeyItemCrowdExpiration(item: String) = {
"expiration_one_" + item
}
func getKeyItemWhaleExpiration(item: String) = {
"expiration_two_" + item
}
func getKeyItemNCommits(item: String) = {
"ncommits_" + item
}
func getKeyItemAccReportData(item: String, account: String) = {
"report_" + item + "_" + account
}
func getKeyItemAccCommit(item: String, account: String) = {
"commit_" + item + "_" + account
}
func getKeyItemAccReveal(item: String, account: String) = {
"reveal_" + item + "_" + account
}
func getKeyItemVotesYes(item: String) = {
"cnt_yes_" + item
}
func getKeyItemVotesNo(item: String) = {
"cnt_no_" + item
}
func getKeyItemAccFinal(item: String, account: String) = {
"final_" + item + "_" + account
}
func getKeyItemFundPositive(item: String) = {
"positive_fund_" + item
}
func getKeyItemFundNegative(item: String) = {
"negative_fund_" + item
}
func getKeyItemAccFundPositive(item: String, account: String) = {
getKeyItemFundPositive(item) + "_" + account
}
func getKeyItemAccFundNegative(item: String, account: String) = {
getKeyItemFundNegative(item) + "_" + account
}
func getKeyItemAccReviewsCnt(item: String, account: String) = {
"reviews_cnt_" + item + "_" + account
}
func getKeyItemAccReview(item: String, account: String) = {
"review_" + item + "_" + account
}
func getKeyTransferLink(hash: String) = {
"transfer_link_" + hash
}
func getKeyItemAccReviewText(item: String, account: String, cnt: String) = {
getKeyItemAccReview(item, account) + "_text_id:" + cnt
}
func getKeyItemAccReviewMode(item: String, account: String, cnt: String) = {
getKeyItemAccReview(item, account) + "_mode_id:" + cnt
}
func getKeyItemAccReviewTier(item: String, account: String, cnt: String) = {
getKeyItemAccReview(item, account) + "_tier_id:" + cnt
}
func getKeyItemAccVoteReviewText(item: String, account: String) = {
getKeyItemAccReview(item, account) + "_votereview"
}
func getKeyItemAccWhaleReviewText(item: String, account: String) = {
getKeyItemAccReview(item, account) + "_whalereview"
}
func getKeyItemBuyoutAmount(item: String) = {
"buyout_amount_" + item
}
func getKeyItemAccWinnings(item: String, account: String) = {
"winnings_" + item + "_" + account
}
func getKeyFreeInviteCount() = {
"free_invite_count"
}
func getKeyFreeInviteBlock() = {
"free_invite_block"
}
func getValueWhitelistRef(account: String) = {
getStrByKey(getKeyWhitelistRef(account))
}
func getValueWhitelistStatus(account: String) = {
getStrByKey(getKeyWhitelistStatus(account))
}
func getValueBalance(account: String) = {
getNumberByKey(getKeyBalance(account))
}
func getValueWhitelistBio(account: String) = {
getStrByKey(getKeyWhitelistBio(account))
}
func getValueWhitelistBlock(account: String) = {
getStrByKey(getKeyWhitelistBlock(account))
}
func getValueItemAuthor(item: String) = {
getStrByKey(getKeyItemAuthor(item))
}
func getValueItemBlock(item: String) = {
getNumberByKey(getKeyItemBlock(item))
}
func getValueItemVotingExpiration(item: String) = {
getNumberByKey(getKeyItemVotingExpiration(item))
}
func getValueItemBank(item: String) = {
getNumberByKey(getKeyItemBank(item))
}
func getValueItemStatus(item: String) = {
getStrByKey(getKeyItemStatus(item))
}
func getValueItemData(item: String) = {
getStrByKey(getKeyItemData(item))
}
func getValueItemCrowdExpiration(item: String) = {
getNumberByKey(getKeyItemCrowdExpiration(item))
}
func getValueItemWhaleExpiration(item: String) = {
getNumberByKey(getKeyItemWhaleExpiration(item))
}
func getValueItemNCommits(item: String) = {
getNumberByKey(getKeyItemNCommits(item))
}
func getValueItemAccCommit(item: String, account: String) = {
getStrByKey(getKeyItemAccCommit(item, account))
}
func getValueItemAccReveal(item: String, account: String) = {
getStrByKey(getKeyItemAccReveal(item, account))
}
func getValueItemVotesYes(item: String) = {
getNumberByKey(getKeyItemVotesYes(item))
}
func getValueItemVotesNo(item: String) = {
getNumberByKey(getKeyItemVotesNo(item))
}
func getValueItemAccFinal(item: String, account: String) = {
getStrByKey(getKeyItemAccFinal(item, account))
}
func getValueItemFundPositive(item: String) = {
getNumberByKey(getKeyItemFundPositive(item))
}
func getValueItemFundNegative(item: String) = {
getNumberByKey(getKeyItemFundNegative(item))
}
func getValueItemAccFundPositive(item: String, account: String) = {
getNumberByKey(getKeyItemAccFundPositive(item, account))
}
func getValueItemAccFundNegative(item: String, account: String) = {
getNumberByKey(getKeyItemAccFundNegative(item, account))
}
func getValueItemAccReviewsCnt(item: String, account: String) = {
getNumberByKey(getKeyItemAccReviewsCnt(item, account))
}
func getValueItemAccReviewText(item: String, account: String, cnt: String) = {
getStrByKey(getKeyItemAccReviewText(item, account, cnt))
}
func getValueItemAccReviewMode(item: String, account: String, cnt: String) = {
getStrByKey(getKeyItemAccReviewMode(item, account, cnt))
}
func getValueItemAccReviewTier(item: String, account: String, cnt: String) = {
getNumberByKey(getKeyItemAccReviewTier(item, account, cnt))
}
func getValueItemBuyoutAmount(item: String) = {
getNumberByKey(getKeyItemBuyoutAmount(item))
}
func getValueItemAccWinnings(item: String, account: String) = {
getNumberByKey(getKeyItemAccWinnings(item, account))
}
let WHITELISTED = "registered"
let INVITED = "invited"
let WHALE = "whale"
let SPENDINVITE = "spend_invite"
let COMMIT = "voting_commit"
let REVEAL = "voting_reveal"
let FEATURED = "featured"
let DELISTED = "delisted"
let CASHOUT = "cashout"
let BUYOUT = "buyout"
let FINISHED = "finished"
let CLAIMED = "claimed"
let POSITIVE = "positive"
let NEGATIVE = "negative"
let GENESIS = "3P8Fvy1yDwNHvVrabe4ek5b9dAwxFjDKV7R"
let ADMIN = "3P9NDxt9Y6ePfM9hkQysgSvbHJvihr56Z18"
let LABS = "3P3MUCvJjviJaxMUe743LVez3qThbL7U8uP"
# (GLOBALS) TCR implementation with commit-reveal scheme
let VOTERS = 3
let QUORUM = 2
let TIERS = [3*100000000, 10*100000000, 100*100000000, 300*100000000, 1000*100000000]
let VOTEBET = 1*100000000
let BLOCKSINDAY = 1440
let MULTIPLIER = 150
let MAXFREEINVITE = 1000
let INVITEFEE = 900000
let ADDITEMFEE = 1000000
let freeInviteCount = getNumberByKey(getKeyFreeInviteCount())
let freeInviteBlock = getNumberByKey(getKeyFreeInviteBlock())
@Callable(i)
func inviteuser(newaccount: String, data: String) = {
let account = toBase58String(i.caller.bytes)
let newstatus = getValueWhitelistStatus(newaccount)
let currstatus = getValueWhitelistStatus(account)
if (newstatus == WHITELISTED || newstatus == WHALE)
then throw("User has already been registered")
else if(isDefined(i.feeAssetId))
then throw("invalid asset")
else if(i.fee > INVITEFEE)
then throw("fee more max")
else if (currstatus != WHITELISTED && account != GENESIS && currstatus != WHALE)
then throw("Your account should be whitelisted. status: " + currstatus)
else {
ScriptResult(
WriteSet([
DataEntry(getKeyWhitelistRef(newaccount), account),
DataEntry(getKeyWhitelistBio(newaccount), data),
DataEntry(getKeyWhitelistStatus(newaccount), INVITED),
DataEntry(getKeyFreeInviteBlock(), if(height > freeInviteBlock) then height + BLOCKSINDAY else freeInviteBlock),
DataEntry(getKeyFreeInviteCount(), if(height > freeInviteBlock) then MAXFREEINVITE else freeInviteCount - 1)
]),
TransferSet([ScriptTransfer(addressFromStringValue(account),
if(wavesBalance(addressFromStringValue(account)) == 0 && (freeInviteCount > 0 || height > freeInviteBlock)) then i.fee else 0, unit)])
)
}
}
@Callable(i)
func signupbylink(hash: String, data: String, type: String) = {
let account = toBase58String(i.caller.bytes)
let status = getValueWhitelistStatus(hash)
if (status != INVITED)
then throw("Referral invite needed. Current status: " + status + ", key:" + getKeyWhitelistStatus(hash) + ", account:" + hash)
else if(isDefined(i.feeAssetId))
then throw("invalid asset")
else if(i.fee > INVITEFEE)
then throw("fee more max")
else {
ScriptResult(
WriteSet([
DataEntry(getKeyWhitelistBio(account), data),
DataEntry(getKeyWhitelistBlock(account), height),
DataEntry(getKeyWhitelistStatus(account), if (type == WHALE) then WHALE else WHITELISTED),
DataEntry(getKeyWhitelistRef(account), getValueWhitelistRef(hash)),
DataEntry(getKeyFreeInviteBlock(), if(height > freeInviteBlock) then height + BLOCKSINDAY else freeInviteBlock),
DataEntry(getKeyFreeInviteCount(), if(height > freeInviteBlock) then MAXFREEINVITE else freeInviteCount - 1)
]),
TransferSet([ScriptTransfer(addressFromStringValue(account),
if(wavesBalance(addressFromStringValue(account)) == 0 && (freeInviteCount > 0 || height > freeInviteBlock)) then i.fee else 0, unit)])
)
}
}
@Callable(i)
func signup(data: String, type: String) = {
let account = toBase58String(i.caller.bytes)
let status = getValueWhitelistStatus(account)
if (status == NONE)
then throw("Referral invite needed. Current status: " + status + ", key:" + getKeyWhitelistStatus(account) + ", account:" + account)
else {
WriteSet([
DataEntry(getKeyWhitelistBio(account), data),
DataEntry(getKeyWhitelistBlock(account), height),
DataEntry(getKeyWhitelistStatus(account), if (type == WHALE) then WHALE else WHITELISTED)
])
}
}
@Callable(i)
func userupdate(data: String, type: String) = {
let account = toBase58String(i.caller.bytes)
let status = getValueWhitelistStatus(account)
if(status == NONE)
then throw("user not signup")
else if(isDefined(i.feeAssetId))
then throw("invalid asset")
else if(i.fee > INVITEFEE)
then throw("fee more max")
else
ScriptResult(
WriteSet([
DataEntry(getKeyWhitelistBio(account), data),
DataEntry(getKeyWhitelistStatus(account), if (type == WHALE) then WHALE else WHITELISTED),
DataEntry(getKeyFreeInviteBlock(), if(height > freeInviteBlock) then height + BLOCKSINDAY else freeInviteBlock),
DataEntry(getKeyFreeInviteCount(), if(height > freeInviteBlock) then MAXFREEINVITE else freeInviteCount - 1)
]),
TransferSet([ScriptTransfer(addressFromStringValue(account),
if(wavesBalance(addressFromStringValue(account)) == 0 && (freeInviteCount > 0 || height > freeInviteBlock)) then i.fee else 0, unit)])
)
}
@Callable(i)
func projupdate(item: String, data: String) = {
let account = toBase58String(i.caller.bytes)
if (getValueItemAuthor(item) != account)
then throw("You're not author")
else if(i.fee > INVITEFEE)
then throw("fee more max")
else {
ScriptResult(
WriteSet([
DataEntry(getKeyItemData(item), data),
DataEntry(getKeyFreeInviteBlock(), if(height > freeInviteBlock) then height + BLOCKSINDAY else freeInviteBlock),
DataEntry(getKeyFreeInviteCount(), if(height > freeInviteBlock) then MAXFREEINVITE else freeInviteCount - 1)
]),
TransferSet([ScriptTransfer(addressFromStringValue(account),
if(wavesBalance(addressFromStringValue(account)) == 0 && (freeInviteCount > 0 || height > freeInviteBlock)) then i.fee else 0, unit)])
)
}
}
@Callable(i)
func contestAddOrUpdate(item: String, data: String) = {
let account = toBase58String(i.caller.bytes)
if ( account != ADMIN ) then throw("You're not admin")
else {
WriteSet([DataEntry(getKeyContestData(item), data)])
}
}
@Callable(i)
func withdraw(address : String) = {
let amount = getValueBalance(address)
if (amount <= 0) then throw("Not enough balance")
else ScriptResult(
WriteSet([ DataEntry(getKeyBalance(address), 0)]),
TransferSet([ScriptTransfer(addressFromStringValue(address), amount, unit)])
)
}
@Callable(i)
func additem(item: String, expVoting: Int, expCrowd: Int, expWhale: Int, data: String) = {
let account = toBase58String(i.caller.bytes)
if(isDefined(i.feeAssetId))
then throw("invalid asset")
else if(i.fee > INVITEFEE)
then throw("fee more max")
else {
if (!(expVoting > 2 && expCrowd > expVoting && expWhale > expCrowd))
then throw("Incorrect time parameters")
else if (getValueItemAuthor(item) != NONE)
then throw("Item already exist")
else
ScriptResult(
WriteSet([
DataEntry(getKeyItemAuthor(item), account),
DataEntry(getKeyItemBlock(item), height),
DataEntry(getKeyItemVotingExpiration(item), height + expVoting),
DataEntry(getKeyItemStatus(item), FEATURED),
DataEntry(getKeyItemData(item), data),
DataEntry(getKeyItemCrowdExpiration(item), height + expCrowd),
DataEntry(getKeyItemWhaleExpiration(item), height + expWhale),
DataEntry(getKeyFreeInviteBlock(), if(height > freeInviteBlock) then height + BLOCKSINDAY else freeInviteBlock),
DataEntry(getKeyFreeInviteCount(), if(height > freeInviteBlock) then MAXFREEINVITE else freeInviteCount - 1)
]),
TransferSet([ScriptTransfer(addressFromStringValue(account),
if(wavesBalance(addressFromStringValue(account)) == 0 && (freeInviteCount > 0 || height > freeInviteBlock)) then i.fee else 0, unit)])
)
}
}
@Callable(i)
func reportProject(item: String, data: String) = {
let account = toBase58String(i.caller.bytes)
WriteSet([
DataEntry(getKeyItemAccReportData(item, account), data)
])
}
@Callable(i)
func labsdonate(item: String, review: String) = {
let account = toBase58String(i.caller.bytes)
let pmt = extract(i.payment)
if (isDefined(pmt.assetId))
then throw("can use waves only at the moment")
else if (account != LABS)
then throw("labs donation is allowed only for waves labs")
else if (getValueItemStatus(item) != BUYOUT)
then throw("Investement has already done")
else {
let cnt = getValueItemAccReviewsCnt(item, account) + 1
let newpositivefund = getValueItemFundPositive(item) + pmt.amount
WriteSet([
DataEntry(getKeyItemAccReviewsCnt(item, account), cnt),
DataEntry(getKeyItemAccFundPositive(item, account),
getValueItemAccFundPositive(item, account) + pmt.amount ),
DataEntry(getKeyItemFundPositive(item), newpositivefund),
DataEntry(getKeyItemAccReviewText(item, account, toString(cnt)), review),
DataEntry(getKeyItemAccReviewMode(item, account, toString(cnt)), POSITIVE),
DataEntry(getKeyItemAccReviewTier(item, account, toString(cnt)), 5),
DataEntry(getKeyBalance(getValueItemAuthor(item)), getValueBalance(getValueItemAuthor(item)) + pmt.amount),
DataEntry(getKeyItemStatus(item), CASHOUT)
])
}
}
@Callable(i)
func changeStatus(item: String) = {
let account = toBase58String(i.caller.bytes)
if (account != LABS)
then throw("labs change is allowed only for waves labs")
else {
WriteSet([
DataEntry(getKeyItemStatus(item), CASHOUT)
])
}
}
@Callable(i)
func donate( item: String, tier: Int, mode: String, review: String ) = {
let account = toBase58String(i.caller.bytes)
let pmt = extract(i.payment)
if (isDefined(pmt.assetId)) then throw("can use waves only at the moment")
else {
let cnt = getValueItemAccReviewsCnt(item, account) + 1
let newnegativefund = getValueItemFundNegative(item) +
( if ( mode == NEGATIVE ) then 1 else 0) * pmt.amount
let newpositivefund = getValueItemFundPositive(item) +
( if ( mode == POSITIVE ) then 1 else 0) * pmt.amount
if (getValueItemStatus(item) != FEATURED)
then throw("The project hasn't accepted by community")
else if (height >= getValueItemCrowdExpiration(item))
then throw("The time for crowdfunding has expired")
else if (newnegativefund >= newpositivefund)
then throw("Negative fund can't be higher than positive fund")
else if (mode != POSITIVE && mode != NEGATIVE)
then throw("Wrong mode parameter")
else if (getValueItemAuthor(item) == account)
then throw("Can't donate own project")
else if (pmt.amount != TIERS[tier - 1])
then throw("The payment must be equal to tier amount: " + toString(TIERS[tier - 1]))
else WriteSet([
DataEntry(getKeyItemAccReviewsCnt(item, account), cnt),
DataEntry(getKeyItemAccFundPositive(item, account),
getValueItemAccFundPositive(item, account) +
( if ( mode == POSITIVE ) then 1 else 0) * pmt.amount ),
DataEntry(getKeyItemAccFundNegative(item, account),
getValueItemAccFundNegative(item, account) +
( if ( mode == NEGATIVE ) then 1 else 0) * pmt.amount ),
DataEntry(getKeyItemFundPositive(item), newpositivefund),
DataEntry(getKeyItemFundNegative(item), newnegativefund),
DataEntry(getKeyItemAccReviewText(item, account, toString(cnt)), review),
DataEntry(getKeyItemAccReviewMode(item, account, toString(cnt)), mode),
DataEntry(getKeyItemAccReviewTier(item, account, toString(cnt)), tier)
])
}
}
@Callable(i)
func whale( item: String) = {
let account = toBase58String(i.caller.bytes)
let pmt = extract(i.payment)
if (isDefined(pmt.assetId))
then throw("can use waves only at the moment")
else if (account != LABS)
then throw("labs donation is allowed only for waves labs")
else if (getValueItemStatus(item) != FEATURED)
then throw("The project hasn't accepted by community")
else if (height < getValueItemCrowdExpiration(item))
then throw("The time for crowdfunding has not expired yet")
else if (height > getValueItemWhaleExpiration(item))
then throw("The time for grant has expired")
else if (getValueItemStatus(item) == BUYOUT)
then throw("Investement has already done")
else if (pmt.amount != (getValueItemFundPositive(item)*MULTIPLIER)/100)
then throw("Investement must be more than " + toString(MULTIPLIER) + "% of supportes funds")
else {
WriteSet([
DataEntry(getKeyItemStatus(item), BUYOUT),
DataEntry(getKeyBalance(getValueItemAuthor(item)),
getValueBalance(getValueItemAuthor(item)) + getValueItemFundPositive(item)),
DataEntry(getKeyItemBuyoutAmount(item), pmt.amount),
DataEntry(getKeyItemAccFinal(item, getValueItemAuthor(item)), CLAIMED)
])
}
}
@Callable(i)
func claimwinnings( item: String, account: String ) = {
let status = getValueItemStatus(item)
let isbayout = if (status == BUYOUT) then 1 else 0
let iscrowdf = if (status != BUYOUT) then 1 else 0
let positivefund = getValueItemFundPositive(item) - getValueItemAccFundPositive(item, LABS)
let negativefund = getValueItemFundNegative(item)
let share = isbayout*(getValueItemAccFundPositive(item, account)*100)/
(if (positivefund <= 0) then 1 else positivefund) +
iscrowdf*(getValueItemAccFundNegative(item, account)*100)/
(if (negativefund <= 0) then 1 else negativefund)
let tmpnegwin = (negativefund*MULTIPLIER)/100
let betprofit = isbayout*((share*negativefund)/100) +
iscrowdf*((share*(if (positivefund > tmpnegwin) then tmpnegwin else positivefund))/100)
let roiprofit = isbayout*((getValueItemAccFundPositive(item, account)*MULTIPLIER)/100)
let authorprofit = iscrowdf*(if (getValueItemAuthor(item) == account) then 1 else 0)*
(if (positivefund > tmpnegwin) then positivefund-tmpnegwin else 0)
if (toString(i.caller) != LABS)
then throw("caller error")
else if (status == DELISTED)
then throw("The project hasn't accepted by community")
else if(account == LABS)
then throw("account error")
else if (getValueItemAccFinal(item, account) == CLAIMED)
then throw("Status is claimed")
else if (roiprofit == 0 && betprofit == 0 && authorprofit == 0)
then throw("The share equals zero")
else if (status != BUYOUT && height <= getValueItemWhaleExpiration(item))
then throw("The time for grant has not expired yet")
else if (positivefund + negativefund <= 0)
then throw("The campaign wasn't active")
else WriteSet([
DataEntry(getKeyBalance(account), getValueBalance(account) +
betprofit + roiprofit + authorprofit),
DataEntry(getKeyItemAccFinal(item, account), CLAIMED)
])
}
@Callable(i)
func transfer(account: String) = {
let pmt = extract(i.payment)
if (isDefined(pmt.assetId))
then throw("can use waves only at the moment")
else TransferSet([ScriptTransfer(addressFromStringValue(account), pmt.amount, unit)])
}