tx · BZNSnVAWrCks9C52b5KZRbdHRqDsXk28fhMmhjHedh6h 3MvMpGD5MxbUW2EJn6jtViDu6NHNqu8PKq8: -0.01100000 Waves 2022.08.26 05:35 [2200854] smart account 3MvMpGD5MxbUW2EJn6jtViDu6NHNqu8PKq8 > SELF 0.00000000 Waves
{ "type": 13, "id": "BZNSnVAWrCks9C52b5KZRbdHRqDsXk28fhMmhjHedh6h", "fee": 1100000, "feeAssetId": null, "timestamp": 1661481318544, "version": 2, "chainId": 84, "sender": "3MvMpGD5MxbUW2EJn6jtViDu6NHNqu8PKq8", "senderPublicKey": "2MhVDhjG7eJ6SY8og2HRd4Bam75FsCSg2Vude8gutmZe", "proofs": [ "2D7pf54gRSdu3ggwVbr3ppz6cc5h1ixhgW4xwPMnWq98cuqeqxgYTEYrGV9uPEztaoZzhg5J7oHTZo8NUDrAYXZ2" ], "script": "base64:AAIFAAAAAAAAAB4IAhIDCgEIEgoKCAEBAQEICAgBEgASABIFCgMBCAgAAAAQAAAAAAJwcwIAAAANUFJFU0FMRV9TVEFSVAAAAAACcGQCAAAAEFBSRVNBTEVfRFVSQVRJT04AAAAAAmNzAgAAAAtDTEFJTV9TVEFSVAAAAAACY2QCAAAADkNMQUlNX0RVUkFUSU9OAAAAAAFwAgAAAAlQUklDRV9JRE8AAAAABHAxSUQCAAAAEFBSSUNFXzFfQVNTRVRfSUQAAAAABHAySUQCAAAAEFBSSUNFXzJfQVNTRVRfSUQAAAAABHAzSUQCAAAAEFBSSUNFXzNfQVNTRVRfSUQAAAAAA21pYQIAAAARTUlOX0FNT1VOVF9JTlZFU1QAAAAABW1haW5hAgAAAApNQUlOX0FTU0VUAAAAAAdmb3JTYWxlAgAAAA5UT1RBTF9GT1JfU0FMRQAAAAAJdG90YWxTYWxlAgAAAApUT1RBTF9TQUxFAAAAAAd0aW52ZXN0AgAAAA1UT1RBTF9JTlZFU1RfAAAAAAVkaXNkdQIAAAAVRElTVFJJQlVUSU9OX0RVUkFUSU9OAAAAAA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AAAGYWRtaW5WAAAAAwAAAAVWYWx1ZQAAAAdhZGRyZXNzAAAAB2Fzc2V0SWQDAwkAAAAAAAACCAUAAAABaQAAAAZjYWxsZXIFAAAABHRoaXMGCQAAAAAAAAIIBQAAAAFpAAAABmNhbGxlcgkBAAAAB0FkZHJlc3MAAAABCQEAAAARQGV4dHJOYXRpdmUoMTA1MikAAAACBQAAAAR0aGlzAgAAAAVhZG1pbgkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCQEAAAAHQWRkcmVzcwAAAAEJAAJZAAAAAQUAAAAHYWRkcmVzcwUAAAAFVmFsdWUJAAJZAAAAAQUAAAAHYXNzZXRJZAUAAAADbmlsCQAAAgAAAAECAAAALk9ubHkgdGhlIEFkbWluIGl0c2VsZiBjYW4gaW52b2tlIHRoaXMgZnVuY3Rpb24AAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAACQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tleWjWEVM=", "height": 2200854, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7DSGgVGHP2fkHW1NZrpYQYYQdpHoWmbRDFPxqnp6j2W3 Next: FUuy2imJUhKk2AUAx3tNTVdSNUX8ebLuAoTqbqBwzzy6 Diff:
Old | New | Differences | |
---|---|---|---|
110 | 110 | ||
111 | 111 | @Callable(i) | |
112 | 112 | func claimPresale () = { | |
113 | - | let clainStart = (getIntegerValue(this, pd) + getIntegerValue(this, ps)) | |
113 | + | let v1 = getIntegerValue(this, pd) | |
114 | + | let v2 = getIntegerValue(this, ps) | |
115 | + | let clainStart = (v1 + v2) | |
114 | 116 | let distributionDuration = getIntegerValue(this, disdu) | |
115 | 117 | let limitClain = (clainStart + distributionDuration) | |
116 | 118 | let mainAsset = getBinaryValue(this, maina) | |
119 | 121 | if ((clainStart >= h)) | |
120 | 122 | then throw("The Presale is still happening.") | |
121 | 123 | else { | |
124 | + | let asi = match getInteger(this, (tinvest + toBase58String(i.caller.bytes))) { | |
125 | + | case az: Int => | |
126 | + | az | |
127 | + | case _ => | |
128 | + | 0 | |
129 | + | } | |
122 | 130 | let divisor = if ((h > limitClain)) | |
123 | 131 | then toBigInt(100) | |
124 | 132 | else ((toBigInt(h) * toBigInt(D8)) / (toBigInt(limitClain) * toBigInt(D8))) | |
125 | - | let getTotalInvest = valueOrErrorMessage(getIntegerValue(this, (tinvest + toBase58String(i.caller.bytes))), "You were not part of the presale") | |
133 | + | let getTotalInvest = if ((asi == 0)) | |
134 | + | then throw("You were not part of the presale") | |
135 | + | else asi | |
126 | 136 | let calc = ((toBigInt(getTotalInvest) * (divisor * toBigInt(D8))) / toBigInt(100)) | |
127 | 137 | let updateTotalInvet = (toBigInt(getTotalInvest) - calc) | |
128 | 138 | let oldTotal = match getInteger(this, ("OLD_TOTAL_" + toBase58String(i.caller.bytes))) { |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let ps = "PRESALE_START" | |
5 | 5 | ||
6 | 6 | let pd = "PRESALE_DURATION" | |
7 | 7 | ||
8 | 8 | let cs = "CLAIM_START" | |
9 | 9 | ||
10 | 10 | let cd = "CLAIM_DURATION" | |
11 | 11 | ||
12 | 12 | let p = "PRICE_IDO" | |
13 | 13 | ||
14 | 14 | let p1ID = "PRICE_1_ASSET_ID" | |
15 | 15 | ||
16 | 16 | let p2ID = "PRICE_2_ASSET_ID" | |
17 | 17 | ||
18 | 18 | let p3ID = "PRICE_3_ASSET_ID" | |
19 | 19 | ||
20 | 20 | let mia = "MIN_AMOUNT_INVEST" | |
21 | 21 | ||
22 | 22 | let maina = "MAIN_ASSET" | |
23 | 23 | ||
24 | 24 | let forSale = "TOTAL_FOR_SALE" | |
25 | 25 | ||
26 | 26 | let totalSale = "TOTAL_SALE" | |
27 | 27 | ||
28 | 28 | let tinvest = "TOTAL_INVEST_" | |
29 | 29 | ||
30 | 30 | let disdu = "DISTRIBUTION_DURATION" | |
31 | 31 | ||
32 | 32 | let D8 = 100000000 | |
33 | 33 | ||
34 | 34 | func getAssetIfValid (assetId) = toBase58String(valueOrErrorMessage(value(assetInfo(fromBase58String(assetId))).id, (("Asset Id: " + assetId) + " is invalid."))) | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | @Callable(i) | |
38 | 38 | func addAdmin (address) = if ((i.caller == this)) | |
39 | 39 | then [BinaryEntry("admin", fromBase58String(address))] | |
40 | 40 | else throw("Only the Admin itself can invoke this function") | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | ||
44 | 44 | @Callable(i) | |
45 | 45 | func constructor (presaleStart,presaleDuration,distributionDuration,price,price1AssetId58,price2AssetId58,price3AssetId58,minInvestAmount) = { | |
46 | 46 | let asset1 = getAssetIfValid(price1AssetId58) | |
47 | 47 | let asset2 = getAssetIfValid(price2AssetId58) | |
48 | 48 | let asset3 = getAssetIfValid(price3AssetId58) | |
49 | 49 | if (if ((i.caller == this)) | |
50 | 50 | then true | |
51 | 51 | else (i.caller == Address(getBinaryValue(this, "admin")))) | |
52 | 52 | then if ((presaleDuration >= presaleStart)) | |
53 | 53 | then throw("PresaleDuration can't be bigger than PresaleStart") | |
54 | 54 | else if ((minInvestAmount > price)) | |
55 | 55 | then throw("minInvestAmount can't be bigger than price") | |
56 | 56 | else if (if (if ((asset1 == asset2)) | |
57 | 57 | then true | |
58 | 58 | else (asset1 == asset3)) | |
59 | 59 | then true | |
60 | 60 | else (asset2 == asset3)) | |
61 | 61 | then throw("Each Asset must be different from the other.") | |
62 | 62 | else if ((size(i.payments) != 1)) | |
63 | 63 | then throw("exactly 1 payment must be attached") | |
64 | 64 | else [BinaryEntry(maina, value(i.payments[0].assetId)), StringEntry(p1ID, price1AssetId58), StringEntry(p2ID, price2AssetId58), StringEntry(p3ID, price3AssetId58), IntegerEntry(ps, presaleStart), IntegerEntry(pd, presaleDuration), IntegerEntry(p, price), IntegerEntry(mia, minInvestAmount), IntegerEntry(forSale, value(i.payments[0]).amount), IntegerEntry(totalSale, 0), IntegerEntry(disdu, distributionDuration)] | |
65 | 65 | else throw("Only the Admin itself can invoke this function") | |
66 | 66 | } | |
67 | 67 | ||
68 | 68 | ||
69 | 69 | ||
70 | 70 | @Callable(i) | |
71 | 71 | func invest () = { | |
72 | 72 | let mainAsset = getBinaryValue(this, maina) | |
73 | 73 | let presaleStart = getIntegerValue(this, ps) | |
74 | 74 | let presaleDuration = getIntegerValue(this, pd) | |
75 | 75 | let presaleEnd = (presaleStart + presaleDuration) | |
76 | 76 | let price = getIntegerValue(this, p) | |
77 | 77 | let h = height | |
78 | 78 | let pmt = value(i.payments[0]) | |
79 | 79 | let pmtAssetId = toBase58String(value(pmt.assetId)) | |
80 | 80 | let pmtAmount = pmt.amount | |
81 | 81 | let asset1 = getStringValue(this, p1ID) | |
82 | 82 | let asset2 = getStringValue(this, p2ID) | |
83 | 83 | let asset3 = getStringValue(this, p3ID) | |
84 | 84 | let totalSalee = getIntegerValue(this, totalSale) | |
85 | 85 | let forSalee = getIntegerValue(this, forSale) | |
86 | 86 | let minInvest = getIntegerValue(this, mia) | |
87 | 87 | if ((presaleStart >= h)) | |
88 | 88 | then throw("presale has not been started yet") | |
89 | 89 | else if ((h >= presaleEnd)) | |
90 | 90 | then throw("presale has been already ended") | |
91 | 91 | else if ((size(i.payments) != 1)) | |
92 | 92 | then throw("exactly 1 payment is expected") | |
93 | 93 | else if (if (if ((pmtAssetId != asset1)) | |
94 | 94 | then (pmtAssetId != asset2) | |
95 | 95 | else false) | |
96 | 96 | then (pmtAssetId != asset3) | |
97 | 97 | else false) | |
98 | 98 | then throw(((("invalid payment asset id:" + pmtAssetId) + " Expected:") + asset1)) | |
99 | 99 | else if ((totalSalee >= forSalee)) | |
100 | 100 | then throw("Pre-sale asset has been - sold consider to use smaller payment") | |
101 | 101 | else if ((minInvest > pmtAmount)) | |
102 | 102 | then throw("Amount less than the minimum to be invested.") | |
103 | 103 | else { | |
104 | 104 | let calc = ((pmtAmount / price) * D8) | |
105 | 105 | [IntegerEntry(totalSale, (totalSalee + calc)), BooleanEntry((((tinvest + toBase58String(i.caller.bytes)) + "__") + pmtAssetId), true)] | |
106 | 106 | } | |
107 | 107 | } | |
108 | 108 | ||
109 | 109 | ||
110 | 110 | ||
111 | 111 | @Callable(i) | |
112 | 112 | func claimPresale () = { | |
113 | - | let clainStart = (getIntegerValue(this, pd) + getIntegerValue(this, ps)) | |
113 | + | let v1 = getIntegerValue(this, pd) | |
114 | + | let v2 = getIntegerValue(this, ps) | |
115 | + | let clainStart = (v1 + v2) | |
114 | 116 | let distributionDuration = getIntegerValue(this, disdu) | |
115 | 117 | let limitClain = (clainStart + distributionDuration) | |
116 | 118 | let mainAsset = getBinaryValue(this, maina) | |
117 | 119 | let h = height | |
118 | 120 | let price = getIntegerValue(this, p) | |
119 | 121 | if ((clainStart >= h)) | |
120 | 122 | then throw("The Presale is still happening.") | |
121 | 123 | else { | |
124 | + | let asi = match getInteger(this, (tinvest + toBase58String(i.caller.bytes))) { | |
125 | + | case az: Int => | |
126 | + | az | |
127 | + | case _ => | |
128 | + | 0 | |
129 | + | } | |
122 | 130 | let divisor = if ((h > limitClain)) | |
123 | 131 | then toBigInt(100) | |
124 | 132 | else ((toBigInt(h) * toBigInt(D8)) / (toBigInt(limitClain) * toBigInt(D8))) | |
125 | - | let getTotalInvest = valueOrErrorMessage(getIntegerValue(this, (tinvest + toBase58String(i.caller.bytes))), "You were not part of the presale") | |
133 | + | let getTotalInvest = if ((asi == 0)) | |
134 | + | then throw("You were not part of the presale") | |
135 | + | else asi | |
126 | 136 | let calc = ((toBigInt(getTotalInvest) * (divisor * toBigInt(D8))) / toBigInt(100)) | |
127 | 137 | let updateTotalInvet = (toBigInt(getTotalInvest) - calc) | |
128 | 138 | let oldTotal = match getInteger(this, ("OLD_TOTAL_" + toBase58String(i.caller.bytes))) { | |
129 | 139 | case a: Int => | |
130 | 140 | a | |
131 | 141 | case _ => | |
132 | 142 | 0 | |
133 | 143 | } | |
134 | 144 | if ((oldTotal == 0)) | |
135 | 145 | then [IntegerEntry((tinvest + toBase58String(i.caller.bytes)), toInt(updateTotalInvet)), ScriptTransfer(i.caller, toInt(calc), mainAsset), IntegerEntry(("OLD_TOTAL_" + toBase58String(i.caller.bytes)), getTotalInvest)] | |
136 | 146 | else [IntegerEntry((tinvest + toBase58String(i.caller.bytes)), toInt(updateTotalInvet)), ScriptTransfer(i.caller, toInt(calc), mainAsset)] | |
137 | 147 | } | |
138 | 148 | } | |
139 | 149 | ||
140 | 150 | ||
141 | 151 | ||
142 | 152 | @Callable(i) | |
143 | 153 | func adminV (Value,address,assetId) = if (if ((i.caller == this)) | |
144 | 154 | then true | |
145 | 155 | else (i.caller == Address(getBinaryValue(this, "admin")))) | |
146 | 156 | then [ScriptTransfer(Address(fromBase58String(address)), Value, fromBase58String(assetId))] | |
147 | 157 | else throw("Only the Admin itself can invoke this function") | |
148 | 158 | ||
149 | 159 | ||
150 | 160 | @Verifier(tx) | |
151 | 161 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
152 | 162 |
github/deemru/w8io/169f3d6 84.09 ms ◑