tx · EVBxS7L8RfNez299Dp1j4BfYj9aKuskHa1Kn3F5S6mE1 3N7hJu27qmD5Xtvi6DPkwYzQyvtYEH2WhuE: -0.01400000 Waves 2021.10.01 14:47 [1727083] smart account 3N7hJu27qmD5Xtvi6DPkwYzQyvtYEH2WhuE > SELF 0.00000000 Waves
{ "type": 13, "id": "EVBxS7L8RfNez299Dp1j4BfYj9aKuskHa1Kn3F5S6mE1", "fee": 1400000, "feeAssetId": null, "timestamp": 1633088852427, "version": 1, "sender": "3N7hJu27qmD5Xtvi6DPkwYzQyvtYEH2WhuE", "senderPublicKey": "HoK9nfY6HDBaSSrV6qGhf3m38Ym2fMP1YmwaTNM5uGAu", "proofs": [ "3nwJDekN9Nuz9uG4uZDQFJUxSobPiVkvyM4g9yVWe2nnLgVcD8xLamMi1qht5wHP3S28sexoaEVh3Jnx8VMGSDcQ" ], "script": "base64:AAIFAAAAAAAAAAYIAhIAEgAAAAAGAAAAAAtmcm9lQXNzZXRJZAEAAAAgSsv1ZJ09Ny43QbbnBS7IGxI8mddY9Mw8h+wjzyuSMzUAAAAABm9uZURheQAAAAAAAAAFoAAAAAAPZGF5c1ZvdGVJc1ZhbGlkCQAAaAAAAAIFAAAABm9uZURheQAAAAAAAAAABwAAAAAXZGF5c1ZvdGVJc1ZhbGlkSW5CbG9ja3MJAABkAAAAAgUAAAAPZGF5c1ZvdGVJc1ZhbGlkBQAAAAZoZWlnaHQAAAAACmdyYW5kVG90YWwJAAPwAAAAAgUAAAAEdGhpcwUAAAALZnJvZUFzc2V0SWQBAAAAD2NhbGN1bGF0ZVJld2FyZAAAAAEAAAAKcGVyY2VudGFnZQQAAAAQcGVyY2VudGFnZVJld2FyZAkAAGkAAAACCQAAaAAAAAIFAAAACmdyYW5kVG90YWwFAAAACnBlcmNlbnRhZ2UAAAAAAAAPQkAEAAAABnJld2FyZAkAAGkAAAACCQAAaAAAAAIFAAAAEHBlcmNlbnRhZ2VSZXdhcmQAAAAAAAAAJxAFAAAACmdyYW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0eAAAAA9zZW5kZXJQdWJsaWNLZXlZ0+Y0", "chainId": 84, "height": 1727083, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: H5NMVU6hujox4tGbnynhdEGUCmiSbqNLjNgSReoZx6Kt Next: HuY6jZKZD3ghtRdaRkNeVyrub94wWxZi3ADheAEDtY3K Diff:
Old | New | Differences | |
---|---|---|---|
12 | 12 | let grandTotal = assetBalance(this, froeAssetId) | |
13 | 13 | ||
14 | 14 | func calculateReward (percentage) = { | |
15 | - | let percentageReward = | |
16 | - | let reward = | |
15 | + | let percentageReward = ((grandTotal * percentage) / 1000000) | |
16 | + | let reward = ((percentageReward * 10000) / grandTotal) | |
17 | 17 | reward | |
18 | 18 | } | |
19 | 19 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let froeAssetId = base58'62yYzfZL17bnZ2aPCuDoT1mfwick4PMHNooyAewfq8Sp' | |
5 | 5 | ||
6 | 6 | let oneDay = 1440 | |
7 | 7 | ||
8 | 8 | let daysVoteIsValid = (oneDay * 7) | |
9 | 9 | ||
10 | 10 | let daysVoteIsValidInBlocks = (daysVoteIsValid + height) | |
11 | 11 | ||
12 | 12 | let grandTotal = assetBalance(this, froeAssetId) | |
13 | 13 | ||
14 | 14 | func calculateReward (percentage) = { | |
15 | - | let percentageReward = | |
16 | - | let reward = | |
15 | + | let percentageReward = ((grandTotal * percentage) / 1000000) | |
16 | + | let reward = ((percentageReward * 10000) / grandTotal) | |
17 | 17 | reward | |
18 | 18 | } | |
19 | 19 | ||
20 | 20 | ||
21 | 21 | @Callable(i) | |
22 | 22 | func Vote () = { | |
23 | 23 | let pmt = if ((size(i.payments) == 1)) | |
24 | 24 | then i.payments[0] | |
25 | 25 | else throw("You need exactly one froe to make a vote") | |
26 | 26 | let AddressOfVoter = toBase58String(i.caller.bytes) | |
27 | 27 | let currentvalue = match getInteger(this, "Total_vote_amount") { | |
28 | 28 | case t: Int => | |
29 | 29 | t | |
30 | 30 | case _ => | |
31 | 31 | 0 | |
32 | 32 | } | |
33 | 33 | let checkVoter = match getInteger(this, ("Vote_Amount_For_" + AddressOfVoter)) { | |
34 | 34 | case c: Int => | |
35 | 35 | c | |
36 | 36 | case _ => | |
37 | 37 | unit | |
38 | 38 | } | |
39 | 39 | let votersIndex = match getInteger(this, "Voter_Index") { | |
40 | 40 | case a: Int => | |
41 | 41 | a | |
42 | 42 | case _ => | |
43 | 43 | 0 | |
44 | 44 | } | |
45 | 45 | let voteState = match getString(this, "Vote_State") { | |
46 | 46 | case v: String => | |
47 | 47 | v | |
48 | 48 | case _ => | |
49 | 49 | unit | |
50 | 50 | } | |
51 | 51 | let rewardValue = calculateReward(81) | |
52 | 52 | if ((pmt.assetId != froeAssetId)) | |
53 | 53 | then throw((("Incorrect asset attached, please attach " + toBase58String(froeAssetId)) + " only.")) | |
54 | 54 | else if (if ((voteState != unit)) | |
55 | 55 | then (voteState == "DISABLED") | |
56 | 56 | else false) | |
57 | 57 | then throw("Voting is currently disable") | |
58 | 58 | else if ((checkVoter != unit)) | |
59 | 59 | then throw("You already Voted") | |
60 | 60 | else if ((10000 != pmt.amount)) | |
61 | 61 | then throw("Exactly 1 Froe is need to make a vote") | |
62 | 62 | else [StringEntry("Voter", AddressOfVoter), IntegerEntry(("Vote_Amount_For_" + AddressOfVoter), pmt.amount), IntegerEntry("Voter_Index", (votersIndex + 1))] | |
63 | 63 | } | |
64 | 64 | ||
65 | 65 | ||
66 | 66 | ||
67 | 67 | @Callable(i) | |
68 | 68 | func Withdraw () = { | |
69 | 69 | let checkWithDrawState = getStringValue("Withdraw_State") | |
70 | 70 | let AddressOfVoter = toBase58String(i.caller.bytes) | |
71 | 71 | let reward = calculateReward(81) | |
72 | 72 | let checkValidVote = match getInteger(this, ("Vote_Amount_For_" + AddressOfVoter)) { | |
73 | 73 | case val: Int => | |
74 | 74 | val | |
75 | 75 | case _ => | |
76 | 76 | 0 | |
77 | 77 | } | |
78 | 78 | if ((checkWithDrawState == "DISABLED")) | |
79 | 79 | then throw("Withdrawal Is currently disabled. A minimum of 30 Days is needed for eligible withdrawals") | |
80 | 80 | else if ((checkValidVote == 0)) | |
81 | 81 | then throw("No Valid Vote Found") | |
82 | 82 | else [ScriptTransfer(i.caller, (getIntegerValue(this, ("Vote_Amount_For_" + AddressOfVoter)) + (reward * 10000)), froeAssetId), IntegerEntry("Reward due Voter", reward)] | |
83 | 83 | } | |
84 | 84 | ||
85 | 85 | ||
86 | 86 | @Verifier(tx) | |
87 | 87 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
88 | 88 |
github/deemru/w8io/03bedc9 42.31 ms ◑![]()