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:AAIFAAAAAAAAAiMIAhIAEgMKAQgSAwoBBBIAEgAaFAoBQRIPYWxyZWFkeVJlc2VydmVkGhQKAUISD3JlbWFpbmluZ1Rva2VucxoPCgFDEgpyZXNlcnZhYmxlGhUKAUQSEHJlbWFpbmluZ1Rva2VuczIaDQoBRRIIdG9SZWRlZW0aDgoBRhIJcmVtYWluaW5nGg8KAWESCnNoaW55d2dnaWQaEQoBYhIMYWRtaW5BZGRyZXNzGhcKAWMSEnByZXNhbGV0b2tlbmFtb3VudBoYCgFkEhNtYXhUb2tlbnNwZXJBZGRyZXNzGgkKAWUSBHVzZE4aEgoBZhINdHJ5R2V0SW50ZWdlchoICgFnEgNrZXkaDAoBaBIHJG1hdGNoMBoGCgFpEgFiGhIKAWoSDXRyeUdldEJvb2xlYW4aEgoBaxINaXNHYW1lU3RhcnRlZBoSCgFsEg1pc1doaXRlTGlzdGVkGg8KAW0SCmFkZHJlc3NTdHIaFgoBbhIRY2FsY1Rva2VudG9SZWRlZW0aCQoBbxIEYW1udBoQCgFwEgtzdGFydEhlaWdodBoNCgFxEghyZWRlZW1lZBo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AAAAFxBQAAAAFhBQAAAANuaWwJAAACAAAAAQkAASwAAAACCQABLAAAAAICAAAAE3lvdSBjYW4gcmVkZWVtIG1heCAJAAGkAAAAAQUAAAABRgIAAAAGIFNIRUdHAAAAAPGgLhM=", "height": 1873046, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: EaRcG4nb1WzmggqDbJSKxF55veTm9rfk7m1ZquczE8Fw Next: DzCd7V7HAQVDTTyduKdnwjAS2zSTaiji9XSasPhbtJbV Diff:
OldNewDifferences
3333 func isWhiteListed (addressStr) = tryGetBoolean((addressStr + "_whiteListed"))
3434
3535
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")
4041 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+ }
4449 }
4550 }
4651
6065 @Callable(i)
6166 func setStartGame (start) = if ((i.caller != this))
6267 then throw("you are not authorized to perform this operation")
63- else [BooleanEntry("Game_Started", start), IntegerEntry("End_Height", (lastBlock.height + (1440 * 180)))]
68+ else [BooleanEntry("Game_Started", start), IntegerEntry("Start_Height", lastBlock.height)]
6469
6570
6671
127132 if ((reservedAmount == 0))
128133 then throw("Nothing to redeem")
129134 else {
130- let toRedeem = calcTokentoRedeem(reservedAmount)
135+ let toRedeem = calcTokentoRedeem(reservedAmount, addressStr)
131136 let remaining = (reservedAmount - redeemed)
132137 if ((toRedeem >= remaining))
133138 then [IntegerEntry((addressStr + "_Redeemed"), (redeemed + toRedeem)), ScriptTransfer(i.caller, redeemed, shinywggid)]
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let shinywggid = base58'AFQS5E4ELtxex3iANtWtUU2V2oWJZSo8VVnK8z3VFmqf'
55
66 let adminAddress = addressFromStringValue("3N2fmsxjTetfnJBXEUpnALKcAQeNR4EizQQ")
77
88 let presaletokenamount = 50000000000000
99
1010 let maxTokensperAddress = 10000
1111
1212 let usdN = unit
1313
1414 func tryGetInteger (key) = match getInteger(this, key) {
1515 case b: Int =>
1616 b
1717 case _ =>
1818 0
1919 }
2020
2121
2222 func tryGetBoolean (key) = match getBoolean(this, key) {
2323 case b: Boolean =>
2424 b
2525 case _ =>
2626 false
2727 }
2828
2929
3030 func isGameStarted () = tryGetBoolean("Game_Started")
3131
3232
3333 func isWhiteListed (addressStr) = tryGetBoolean((addressStr + "_whiteListed"))
3434
3535
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")
4041 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+ }
4449 }
4550 }
4651
4752
4853 @Callable(i)
4954 func init () = [IntegerEntry("Remaining_Tokens", presaletokenamount)]
5055
5156
5257
5358 @Callable(i)
5459 func addToWhiteList (addressStr) = if ((i.caller != this))
5560 then throw("you are not authorized to perform this operation")
5661 else [BooleanEntry((addressStr + "_whiteListed"), true)]
5762
5863
5964
6065 @Callable(i)
6166 func setStartGame (start) = if ((i.caller != this))
6267 then throw("you are not authorized to perform this operation")
63- else [BooleanEntry("Game_Started", start), IntegerEntry("End_Height", (lastBlock.height + (1440 * 180)))]
68+ else [BooleanEntry("Game_Started", start), IntegerEntry("Start_Height", lastBlock.height)]
6469
6570
6671
6772 @Callable(i)
6873 func reserveTokens () = {
6974 let addressStr = toString(i.caller)
7075 let wl = isWhiteListed(addressStr)
7176 if (!(wl))
7277 then throw("you are not whitelisted!")
7378 else {
7479 let pmt = i.payments[0]
7580 if ((pmt == pmt))
7681 then {
7782 let amountIn = value(i.payments[0].amount)
7883 if ((amountIn == amountIn))
7984 then {
8085 let assetIn = pmt.assetId
8186 if ((assetIn == assetIn))
8287 then {
8388 let reservedAmount = amountIn
8489 if ((reservedAmount == reservedAmount))
8590 then {
8691 let alreadyReserved = tryGetInteger((addressStr + "_Reserved"))
8792 if ((alreadyReserved == alreadyReserved))
8893 then {
8994 let remainingTokens = tryGetInteger("Remaining_Tokens")
9095 if ((assetIn != usdN))
9196 then throw("ONLY USDN ALLOWED")
9297 else if ((0 >= remainingTokens))
9398 then throw("Presale is out of stock!")
9499 else if ((reservedAmount > remainingTokens))
95100 then throw((("You can reserve only" + toString(remainingTokens)) + " SHEGG"))
96101 else {
97102 let reservable = (maxTokensperAddress - alreadyReserved)
98103 if ((alreadyReserved > reservable))
99104 then throw((("You can reserve max " + toString(reservable)) + " SHEGG"))
100105 else {
101106 let remainingTokens2 = (remainingTokens - reservedAmount)
102107 [IntegerEntry((addressStr + "_Reserved"), (reservedAmount + alreadyReserved)), IntegerEntry("Remaining_Tokens", remainingTokens2), ScriptTransfer(adminAddress, amountIn, usdN)]
103108 }
104109 }
105110 }
106111 else throw("Strict value is not equal to itself.")
107112 }
108113 else throw("Strict value is not equal to itself.")
109114 }
110115 else throw("Strict value is not equal to itself.")
111116 }
112117 else throw("Strict value is not equal to itself.")
113118 }
114119 else throw("Strict value is not equal to itself.")
115120 }
116121 }
117122
118123
119124
120125 @Callable(i)
121126 func redeem () = if (!(isGameStarted()))
122127 then throw("Cannot redeem anything before the game starts!")
123128 else {
124129 let addressStr = toString(i.caller)
125130 let reservedAmount = tryGetInteger((addressStr + "_Reserved"))
126131 let redeemed = tryGetInteger((addressStr + "_Redeemed"))
127132 if ((reservedAmount == 0))
128133 then throw("Nothing to redeem")
129134 else {
130- let toRedeem = calcTokentoRedeem(reservedAmount)
135+ let toRedeem = calcTokentoRedeem(reservedAmount, addressStr)
131136 let remaining = (reservedAmount - redeemed)
132137 if ((toRedeem >= remaining))
133138 then [IntegerEntry((addressStr + "_Redeemed"), (redeemed + toRedeem)), ScriptTransfer(i.caller, redeemed, shinywggid)]
134139 else throw((("you can redeem max " + toString(remaining)) + " SHEGG"))
135140 }
136141 }
137142
138143

github/deemru/w8io/026f985 
26.39 ms