tx · 3tRD2kAddgKNrytVnVoi34vvRXNYXURj4i7rW77UksbD 3MpNtiPSRSq6NnaQYk38BfWSzZcgAYTyrQ9: -0.01400000 Waves 2022.01.10 19:08 [1873046] smart account 3MpNtiPSRSq6NnaQYk38BfWSzZcgAYTyrQ9 > SELF 0.00000000 Waves
{ "type": 13, "id": "3tRD2kAddgKNrytVnVoi34vvRXNYXURj4i7rW77UksbD", "fee": 1400000, "feeAssetId": null, "timestamp": 1641830906755, "version": 2, "chainId": 84, "sender": "3MpNtiPSRSq6NnaQYk38BfWSzZcgAYTyrQ9", "senderPublicKey": "HwnFy5MZJ9eyVKF9GSXN8nuA5uT2rcvnVqHw9vCv3DNn", "proofs": [ "4gKGeCN9b3msvhrNWFJG1mqJeGRxu2TjmrBby7eH74uwtj7sVP37cx3JmpoP9cRH3crKjAZufgsxgJ7FEXat7xaR" ], "script": "base64:AAIFAAAAAAAAAiMIAhIAEgMKAQgSAwoBBBIAEgAaFAoBQRIPYWxyZWFkeVJlc2VydmVkGhQKAUISD3JlbWFpbmluZ1Rva2VucxoPCgFDEgpyZXNlcnZhYmxlGhUKAUQSEHJlbWFpbmluZ1Rva2VuczIaDQoBRRIIdG9SZWRlZW0aDgoBRhIJcmVtYWluaW5nGg8KAWESCnNoaW55d2dnaWQaEQoBYhIMYWRtaW5BZGRyZXNzGhcKAWMSEnByZXNhbGV0b2tlbmFtb3VudBoYCgFkEhNtYXhUb2tlbnNwZXJBZGRyZXNzGgkKAWUSBHVzZE4aEgoBZhINdHJ5R2V0SW50ZWdlchoICgFnEgNrZXkaDAoBaBIHJG1hdGNoMBoGCgFpEgFiGhIKAWoSDXRyeUdldEJvb2xlYW4aEgoBaxINaXNHYW1lU3RhcnRlZBoSCgFsEg1pc1doaXRlTGlzdGVkGg8KAW0SCmFkZHJlc3NTdHIaFgoBbhIRY2FsY1Rva2VudG9SZWRlZW0aCQoBbxIEYW1udBoQCgFwEgtzdGFydEhlaWdodBoNCgFxEghyZWRlZW1lZBoN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AAAFxBQAAAAFhBQAAAANuaWwJAAACAAAAAQkAASwAAAACCQABLAAAAAICAAAAE3lvdSBjYW4gcmVkZWVtIG1heCAJAAGkAAAAAQUAAAABRgIAAAAGIFNIRUdHAAAAAPGgLhM=", "height": 1873046, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: EaRcG4nb1WzmggqDbJSKxF55veTm9rfk7m1ZquczE8Fw Next: DzCd7V7HAQVDTTyduKdnwjAS2zSTaiji9XSasPhbtJbV 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 | |
36 | + | func calcTokentoRedeem (amnt,addressStr) = { | |
37 | + | let startHeight = tryGetInteger("Start_Height") | |
38 | + | let redeemed = tryGetInteger((addressStr + "_Redeemed")) | |
39 | + | if ((startHeight == 0)) | |
40 | + | then throw("Redeem time not started") | |
40 | 41 | else { | |
41 | - | let passed = fraction((endheight - lastBlock.height), 1, 1440) | |
42 | - | let perday = fraction(amnt, 1, 180) | |
43 | - | (passed * perday) | |
42 | + | let blocknum = (1440 * 180) | |
43 | + | if ((lastBlock.height > (startHeight + blocknum))) | |
44 | + | then (amnt - redeemed) | |
45 | + | else { | |
46 | + | let perblock = fraction(amnt, 1, blocknum) | |
47 | + | (((lastBlock.height - startHeight) * perblock) - redeemed) | |
48 | + | } | |
44 | 49 | } | |
45 | 50 | } | |
46 | 51 | ||
60 | 65 | @Callable(i) | |
61 | 66 | func setStartGame (start) = if ((i.caller != this)) | |
62 | 67 | then throw("you are not authorized to perform this operation") | |
63 | - | else [BooleanEntry("Game_Started", start), IntegerEntry(" | |
68 | + | else [BooleanEntry("Game_Started", start), IntegerEntry("Start_Height", lastBlock.height)] | |
64 | 69 | ||
65 | 70 | ||
66 | 71 | ||
127 | 132 | if ((reservedAmount == 0)) | |
128 | 133 | then throw("Nothing to redeem") | |
129 | 134 | else { | |
130 | - | let toRedeem = calcTokentoRedeem(reservedAmount) | |
135 | + | let toRedeem = calcTokentoRedeem(reservedAmount, addressStr) | |
131 | 136 | let remaining = (reservedAmount - redeemed) | |
132 | 137 | if ((toRedeem >= remaining)) | |
133 | 138 | then [IntegerEntry((addressStr + "_Redeemed"), (redeemed + toRedeem)), ScriptTransfer(i.caller, redeemed, shinywggid)] |
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 | |
36 | + | func calcTokentoRedeem (amnt,addressStr) = { | |
37 | + | let startHeight = tryGetInteger("Start_Height") | |
38 | + | let redeemed = tryGetInteger((addressStr + "_Redeemed")) | |
39 | + | if ((startHeight == 0)) | |
40 | + | then throw("Redeem time not started") | |
40 | 41 | else { | |
41 | - | let passed = fraction((endheight - lastBlock.height), 1, 1440) | |
42 | - | let perday = fraction(amnt, 1, 180) | |
43 | - | (passed * perday) | |
42 | + | let blocknum = (1440 * 180) | |
43 | + | if ((lastBlock.height > (startHeight + blocknum))) | |
44 | + | then (amnt - redeemed) | |
45 | + | else { | |
46 | + | let perblock = fraction(amnt, 1, blocknum) | |
47 | + | (((lastBlock.height - startHeight) * perblock) - redeemed) | |
48 | + | } | |
44 | 49 | } | |
45 | 50 | } | |
46 | 51 | ||
47 | 52 | ||
48 | 53 | @Callable(i) | |
49 | 54 | func init () = [IntegerEntry("Remaining_Tokens", presaletokenamount)] | |
50 | 55 | ||
51 | 56 | ||
52 | 57 | ||
53 | 58 | @Callable(i) | |
54 | 59 | func addToWhiteList (addressStr) = if ((i.caller != this)) | |
55 | 60 | then throw("you are not authorized to perform this operation") | |
56 | 61 | else [BooleanEntry((addressStr + "_whiteListed"), true)] | |
57 | 62 | ||
58 | 63 | ||
59 | 64 | ||
60 | 65 | @Callable(i) | |
61 | 66 | func setStartGame (start) = if ((i.caller != this)) | |
62 | 67 | then throw("you are not authorized to perform this operation") | |
63 | - | else [BooleanEntry("Game_Started", start), IntegerEntry(" | |
68 | + | else [BooleanEntry("Game_Started", start), IntegerEntry("Start_Height", lastBlock.height)] | |
64 | 69 | ||
65 | 70 | ||
66 | 71 | ||
67 | 72 | @Callable(i) | |
68 | 73 | func reserveTokens () = { | |
69 | 74 | let addressStr = toString(i.caller) | |
70 | 75 | let wl = isWhiteListed(addressStr) | |
71 | 76 | if (!(wl)) | |
72 | 77 | then throw("you are not whitelisted!") | |
73 | 78 | else { | |
74 | 79 | let pmt = i.payments[0] | |
75 | 80 | if ((pmt == pmt)) | |
76 | 81 | then { | |
77 | 82 | let amountIn = value(i.payments[0].amount) | |
78 | 83 | if ((amountIn == amountIn)) | |
79 | 84 | then { | |
80 | 85 | let assetIn = pmt.assetId | |
81 | 86 | if ((assetIn == assetIn)) | |
82 | 87 | then { | |
83 | 88 | let reservedAmount = amountIn | |
84 | 89 | if ((reservedAmount == reservedAmount)) | |
85 | 90 | then { | |
86 | 91 | let alreadyReserved = tryGetInteger((addressStr + "_Reserved")) | |
87 | 92 | if ((alreadyReserved == alreadyReserved)) | |
88 | 93 | then { | |
89 | 94 | let remainingTokens = tryGetInteger("Remaining_Tokens") | |
90 | 95 | if ((assetIn != usdN)) | |
91 | 96 | then throw("ONLY USDN ALLOWED") | |
92 | 97 | else if ((0 >= remainingTokens)) | |
93 | 98 | then throw("Presale is out of stock!") | |
94 | 99 | else if ((reservedAmount > remainingTokens)) | |
95 | 100 | then throw((("You can reserve only" + toString(remainingTokens)) + " SHEGG")) | |
96 | 101 | else { | |
97 | 102 | let reservable = (maxTokensperAddress - alreadyReserved) | |
98 | 103 | if ((alreadyReserved > reservable)) | |
99 | 104 | then throw((("You can reserve max " + toString(reservable)) + " SHEGG")) | |
100 | 105 | else { | |
101 | 106 | let remainingTokens2 = (remainingTokens - reservedAmount) | |
102 | 107 | [IntegerEntry((addressStr + "_Reserved"), (reservedAmount + alreadyReserved)), IntegerEntry("Remaining_Tokens", remainingTokens2), ScriptTransfer(adminAddress, amountIn, usdN)] | |
103 | 108 | } | |
104 | 109 | } | |
105 | 110 | } | |
106 | 111 | else throw("Strict value is not equal to itself.") | |
107 | 112 | } | |
108 | 113 | else throw("Strict value is not equal to itself.") | |
109 | 114 | } | |
110 | 115 | else throw("Strict value is not equal to itself.") | |
111 | 116 | } | |
112 | 117 | else throw("Strict value is not equal to itself.") | |
113 | 118 | } | |
114 | 119 | else throw("Strict value is not equal to itself.") | |
115 | 120 | } | |
116 | 121 | } | |
117 | 122 | ||
118 | 123 | ||
119 | 124 | ||
120 | 125 | @Callable(i) | |
121 | 126 | func redeem () = if (!(isGameStarted())) | |
122 | 127 | then throw("Cannot redeem anything before the game starts!") | |
123 | 128 | else { | |
124 | 129 | let addressStr = toString(i.caller) | |
125 | 130 | let reservedAmount = tryGetInteger((addressStr + "_Reserved")) | |
126 | 131 | let redeemed = tryGetInteger((addressStr + "_Redeemed")) | |
127 | 132 | if ((reservedAmount == 0)) | |
128 | 133 | then throw("Nothing to redeem") | |
129 | 134 | else { | |
130 | - | let toRedeem = calcTokentoRedeem(reservedAmount) | |
135 | + | let toRedeem = calcTokentoRedeem(reservedAmount, addressStr) | |
131 | 136 | let remaining = (reservedAmount - redeemed) | |
132 | 137 | if ((toRedeem >= remaining)) | |
133 | 138 | then [IntegerEntry((addressStr + "_Redeemed"), (redeemed + toRedeem)), ScriptTransfer(i.caller, redeemed, shinywggid)] | |
134 | 139 | else throw((("you can redeem max " + toString(remaining)) + " SHEGG")) | |
135 | 140 | } | |
136 | 141 | } | |
137 | 142 | ||
138 | 143 |
github/deemru/w8io/026f985 26.39 ms ◑