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