tx · EaRcG4nb1WzmggqDbJSKxF55veTm9rfk7m1ZquczE8Fw 3MpNtiPSRSq6NnaQYk38BfWSzZcgAYTyrQ9: -0.01400000 Waves 2022.01.10 18:24 [1873000] smart account 3MpNtiPSRSq6NnaQYk38BfWSzZcgAYTyrQ9 > SELF 0.00000000 Waves
{ "type": 13, "id": "EaRcG4nb1WzmggqDbJSKxF55veTm9rfk7m1ZquczE8Fw", "fee": 1400000, "feeAssetId": null, "timestamp": 1641828339850, "version": 2, "chainId": 84, "sender": "3MpNtiPSRSq6NnaQYk38BfWSzZcgAYTyrQ9", "senderPublicKey": "HwnFy5MZJ9eyVKF9GSXN8nuA5uT2rcvnVqHw9vCv3DNn", "proofs": [ "33cJih4zuETrhRyfpqyrAB6uKZtV82ckz9BTaqD4zW7GfjCEkgLBQPZgC6MbCo1UWqXo4QLwv8morsfDxYNYmsNL" ], "script": "base64:AAIFAAAAAAAAAh0IAhIAEgMKAQgSAwoBBBIAEgAaFAoBQRIPcmVtYWluaW5nVG9rZW5zGg8KAUISCnJlc2VydmFibGUaFQoBQxIQcmVtYWluaW5nVG9rZW5zMhoNCgFEEghyZWRlZW1lZBoNCgFFEgh0b1JlZGVlbRoOCgFGEglyZW1haW5pbmcaDwoBYRIKc2hpbnl3Z2dpZBoRCgFiEgxhZG1pbkFkZHJlc3MaFwoBYxIScHJlc2FsZXRva2VuYW1vdW50GhgKAWQSE21heFRva2Vuc3BlckFkZHJlc3MaCQoBZRIEdXNkThoSCgFmEg10cnlHZXRJbnRlZ2VyGggKAWcSA2tleRoMCgFoEgckbWF0Y2gwGgYKAWkSAWIaEgoBahINdHJ5R2V0Qm9vbGVhbhoSCgFrEg1pc0dhbWVTdGFydGVkGhIKAWwSDWlzV2hpdGVMaXN0ZWQaDwoBbRIKYWRkcmVzc1N0choWCgFuEhFjYWxjVG9rZW50b1JlZGVlbRoJCgFvEgRhbW50Gg4KAXASCWVuZGhlaWdodBoLCgFxEgZwYXNzZWQaCwoBchIGcGVyZG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AAAkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQAAAgAAAAECAAAAJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAAIAAAABAgAAACRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4JAAACAAAAAQIAAAAkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAAAAAXMBAAAABnJlZGVlbQAAAAADCQEAAAABIQAAAAEJAQAAAAFrAAAAAAkAAAIAAAABAgAAAC5DYW5ub3QgcmVkZWVtIGFueXRoaW5nIGJlZm9yZSB0aGUgZ2FtZSBzdGFydHMhBAAAAAFtCQAEJQAAAAEIBQAAAAFzAAAABmNhbGxlcgQAAAABeQkBAAAAAWYAAAABCQABLAAAAAIFAAAAAW0CAAAACV9SZXNlcnZlZAQAAAABRAkBAAAAAWYAAAABCQABLAAAAAIFAAAAAW0CAAAACV9SZWRlZW1lZAMJAAAAAAAAAgUAAAABeQAAAAAAAAAAAAkAAAIAAAABAgAAABFOb3RoaW5nIHRvIHJlZGVlbQQAAAABRQkBAAAAAW4AAAABBQAAAAF5BAAAAAFGCQAAZQAAAAIFAAAAAXkFAAAAAUQDCQAAZwAAAAIFAAAAAUUFAAAAAUYJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAAEsAAAAAgUAAAABbQIAAAAJX1JlZGVlbWVkCQAAZAAAAAIFAAAAAUQFAAAAAUUJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAXMAAAAGY2FsbGVyBQAAAAFEBQAAAAFhBQAAAANuaWwJAAACAAAAAQkAASwAAAACCQABLAAAAAICAAAAE3lvdSBjYW4gcmVkZWVtIG1heCAJAAGkAAAAAQUAAAABRgIAAAAGIFNIRUdHAAAAAKObB8A=", "height": 1873000, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 24T724h9MUjHFmPvtz9cBbWGrvuzFVmSyf6P9V9oTX5J Next: 3tRD2kAddgKNrytVnVoi34vvRXNYXURj4i7rW77UksbD Diff:
Old | New | Differences | |
---|---|---|---|
33 | 33 | func isWhiteListed (addressStr) = tryGetBoolean((addressStr + "_whiteListed")) | |
34 | 34 | ||
35 | 35 | ||
36 | + | func calcTokentoRedeem (amnt) = { | |
37 | + | let endheight = tryGetInteger("End_Height") | |
38 | + | if ((endheight == 0)) | |
39 | + | then 0 | |
40 | + | else { | |
41 | + | let passed = fraction((endheight - lastBlock.height), 1, 1440) | |
42 | + | let perday = fraction(amnt, 1, 180) | |
43 | + | (passed * perday) | |
44 | + | } | |
45 | + | } | |
46 | + | ||
47 | + | ||
36 | 48 | @Callable(i) | |
37 | 49 | func init () = [IntegerEntry("Remaining_Tokens", presaletokenamount)] | |
38 | 50 | ||
48 | 60 | @Callable(i) | |
49 | 61 | func setStartGame (start) = if ((i.caller != this)) | |
50 | 62 | then throw("you are not authorized to perform this operation") | |
51 | - | else [BooleanEntry("Game_Started", start)] | |
63 | + | else [BooleanEntry("Game_Started", start), IntegerEntry("End_Height", (lastBlock.height + (1440 * 180)))] | |
52 | 64 | ||
53 | 65 | ||
54 | 66 | ||
111 | 123 | else { | |
112 | 124 | let addressStr = toString(i.caller) | |
113 | 125 | let reservedAmount = tryGetInteger((addressStr + "_Reserved")) | |
126 | + | let redeemed = tryGetInteger((addressStr + "_Redeemed")) | |
114 | 127 | if ((reservedAmount == 0)) | |
115 | 128 | then throw("Nothing to redeem") | |
116 | 129 | else { | |
117 | - | let redeemed = reservedAmount | |
118 | - | [IntegerEntry((addressStr + "_Reserved"), (reservedAmount - redeemed)), ScriptTransfer(i.caller, redeemed, shinywggid)] | |
130 | + | let toRedeem = calcTokentoRedeem(reservedAmount) | |
131 | + | let remaining = (reservedAmount - redeemed) | |
132 | + | if ((toRedeem >= remaining)) | |
133 | + | then [IntegerEntry((addressStr + "_Redeemed"), (redeemed + toRedeem)), ScriptTransfer(i.caller, redeemed, shinywggid)] | |
134 | + | else throw((("you can redeem max " + toString(remaining)) + " SHEGG")) | |
119 | 135 | } | |
120 | 136 | } | |
121 | 137 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let shinywggid = base58'AFQS5E4ELtxex3iANtWtUU2V2oWJZSo8VVnK8z3VFmqf' | |
5 | 5 | ||
6 | 6 | let adminAddress = addressFromStringValue("3N2fmsxjTetfnJBXEUpnALKcAQeNR4EizQQ") | |
7 | 7 | ||
8 | 8 | let presaletokenamount = 50000000000000 | |
9 | 9 | ||
10 | 10 | let maxTokensperAddress = 10000 | |
11 | 11 | ||
12 | 12 | let usdN = unit | |
13 | 13 | ||
14 | 14 | func tryGetInteger (key) = match getInteger(this, key) { | |
15 | 15 | case b: Int => | |
16 | 16 | b | |
17 | 17 | case _ => | |
18 | 18 | 0 | |
19 | 19 | } | |
20 | 20 | ||
21 | 21 | ||
22 | 22 | func tryGetBoolean (key) = match getBoolean(this, key) { | |
23 | 23 | case b: Boolean => | |
24 | 24 | b | |
25 | 25 | case _ => | |
26 | 26 | false | |
27 | 27 | } | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | func isGameStarted () = tryGetBoolean("Game_Started") | |
31 | 31 | ||
32 | 32 | ||
33 | 33 | func isWhiteListed (addressStr) = tryGetBoolean((addressStr + "_whiteListed")) | |
34 | 34 | ||
35 | 35 | ||
36 | + | func calcTokentoRedeem (amnt) = { | |
37 | + | let endheight = tryGetInteger("End_Height") | |
38 | + | if ((endheight == 0)) | |
39 | + | then 0 | |
40 | + | else { | |
41 | + | let passed = fraction((endheight - lastBlock.height), 1, 1440) | |
42 | + | let perday = fraction(amnt, 1, 180) | |
43 | + | (passed * perday) | |
44 | + | } | |
45 | + | } | |
46 | + | ||
47 | + | ||
36 | 48 | @Callable(i) | |
37 | 49 | func init () = [IntegerEntry("Remaining_Tokens", presaletokenamount)] | |
38 | 50 | ||
39 | 51 | ||
40 | 52 | ||
41 | 53 | @Callable(i) | |
42 | 54 | func addToWhiteList (addressStr) = if ((i.caller != this)) | |
43 | 55 | then throw("you are not authorized to perform this operation") | |
44 | 56 | else [BooleanEntry((addressStr + "_whiteListed"), true)] | |
45 | 57 | ||
46 | 58 | ||
47 | 59 | ||
48 | 60 | @Callable(i) | |
49 | 61 | func setStartGame (start) = if ((i.caller != this)) | |
50 | 62 | then throw("you are not authorized to perform this operation") | |
51 | - | else [BooleanEntry("Game_Started", start)] | |
63 | + | else [BooleanEntry("Game_Started", start), IntegerEntry("End_Height", (lastBlock.height + (1440 * 180)))] | |
52 | 64 | ||
53 | 65 | ||
54 | 66 | ||
55 | 67 | @Callable(i) | |
56 | 68 | func reserveTokens () = { | |
57 | 69 | let addressStr = toString(i.caller) | |
58 | 70 | let wl = isWhiteListed(addressStr) | |
59 | 71 | if (!(wl)) | |
60 | 72 | then throw("you are not whitelisted!") | |
61 | 73 | else { | |
62 | 74 | let pmt = i.payments[0] | |
63 | 75 | if ((pmt == pmt)) | |
64 | 76 | then { | |
65 | 77 | let amountIn = value(i.payments[0].amount) | |
66 | 78 | if ((amountIn == amountIn)) | |
67 | 79 | then { | |
68 | 80 | let assetIn = pmt.assetId | |
69 | 81 | if ((assetIn == assetIn)) | |
70 | 82 | then { | |
71 | 83 | let reservedAmount = amountIn | |
72 | 84 | if ((reservedAmount == reservedAmount)) | |
73 | 85 | then { | |
74 | 86 | let alreadyReserved = tryGetInteger((addressStr + "_Reserved")) | |
75 | 87 | if ((alreadyReserved == alreadyReserved)) | |
76 | 88 | then { | |
77 | 89 | let remainingTokens = tryGetInteger("Remaining_Tokens") | |
78 | 90 | if ((assetIn != usdN)) | |
79 | 91 | then throw("ONLY USDN ALLOWED") | |
80 | 92 | else if ((0 >= remainingTokens)) | |
81 | 93 | then throw("Presale is out of stock!") | |
82 | 94 | else if ((reservedAmount > remainingTokens)) | |
83 | 95 | then throw((("You can reserve only" + toString(remainingTokens)) + " SHEGG")) | |
84 | 96 | else { | |
85 | 97 | let reservable = (maxTokensperAddress - alreadyReserved) | |
86 | 98 | if ((alreadyReserved > reservable)) | |
87 | 99 | then throw((("You can reserve max " + toString(reservable)) + " SHEGG")) | |
88 | 100 | else { | |
89 | 101 | let remainingTokens2 = (remainingTokens - reservedAmount) | |
90 | 102 | [IntegerEntry((addressStr + "_Reserved"), (reservedAmount + alreadyReserved)), IntegerEntry("Remaining_Tokens", remainingTokens2), ScriptTransfer(adminAddress, amountIn, usdN)] | |
91 | 103 | } | |
92 | 104 | } | |
93 | 105 | } | |
94 | 106 | else throw("Strict value is not equal to itself.") | |
95 | 107 | } | |
96 | 108 | else throw("Strict value is not equal to itself.") | |
97 | 109 | } | |
98 | 110 | else throw("Strict value is not equal to itself.") | |
99 | 111 | } | |
100 | 112 | else throw("Strict value is not equal to itself.") | |
101 | 113 | } | |
102 | 114 | else throw("Strict value is not equal to itself.") | |
103 | 115 | } | |
104 | 116 | } | |
105 | 117 | ||
106 | 118 | ||
107 | 119 | ||
108 | 120 | @Callable(i) | |
109 | 121 | func redeem () = if (!(isGameStarted())) | |
110 | 122 | then throw("Cannot redeem anything before the game starts!") | |
111 | 123 | else { | |
112 | 124 | let addressStr = toString(i.caller) | |
113 | 125 | let reservedAmount = tryGetInteger((addressStr + "_Reserved")) | |
126 | + | let redeemed = tryGetInteger((addressStr + "_Redeemed")) | |
114 | 127 | if ((reservedAmount == 0)) | |
115 | 128 | then throw("Nothing to redeem") | |
116 | 129 | else { | |
117 | - | let redeemed = reservedAmount | |
118 | - | [IntegerEntry((addressStr + "_Reserved"), (reservedAmount - redeemed)), ScriptTransfer(i.caller, redeemed, shinywggid)] | |
130 | + | let toRedeem = calcTokentoRedeem(reservedAmount) | |
131 | + | let remaining = (reservedAmount - redeemed) | |
132 | + | if ((toRedeem >= remaining)) | |
133 | + | then [IntegerEntry((addressStr + "_Redeemed"), (redeemed + toRedeem)), ScriptTransfer(i.caller, redeemed, shinywggid)] | |
134 | + | else throw((("you can redeem max " + toString(remaining)) + " SHEGG")) | |
119 | 135 | } | |
120 | 136 | } | |
121 | 137 | ||
122 | 138 |
github/deemru/w8io/026f985 24.96 ms ◑