tx · 92FsFgCi6vH5Z4FYgsCMFsvx9oV53K6etmeWdYjhZN7U

3MvMpGD5MxbUW2EJn6jtViDu6NHNqu8PKq8:  -0.01100000 Waves

2022.08.26 04:40 [2200796] smart account 3MvMpGD5MxbUW2EJn6jtViDu6NHNqu8PKq8 > SELF 0.00000000 Waves

{ "type": 13, "id": "92FsFgCi6vH5Z4FYgsCMFsvx9oV53K6etmeWdYjhZN7U", "fee": 1100000, "feeAssetId": null, "timestamp": 1661478037629, "version": 2, "chainId": 84, "sender": "3MvMpGD5MxbUW2EJn6jtViDu6NHNqu8PKq8", "senderPublicKey": "2MhVDhjG7eJ6SY8og2HRd4Bam75FsCSg2Vude8gutmZe", "proofs": [ "4PvCxSJJ49bTNuekiWmBD3L7Gxg8zryeRpeVeugn1n9FQxQvW6myMxi6eUQQrYd5uagjqy9uHgojEizrNhhXsWST" ], "script": "base64:AAIFAAAAAAAAAB4IAhIDCgEIEgoKCAEBAQEICAgBEgASABIFCgMBCAgAAAAQAAAAAAJwcwIAAAANUFJFU0FMRV9TVEFSVAAAAAACcGQCAAAAEFBSRVNBTEVfRFVSQVRJT04AAAAAAmNzAgAAAAtDTEFJTV9TVEFSVAAAAAACY2QCAAAADkNMQUlNX0RVUkFUSU9OAAAAAAFwAgAAAAlQUklDRV9JRE8AAAAABHAxSUQCAAAAEFBSSUNFXzFfQVNTRVRfSUQAAAAABHAySUQCAAAAEFBSSUNFXzJfQVNTRVRfSUQAAAAABHAzSUQCAAAAEFBSSUNFXzNfQVNTRVRfSUQAAAAAA21pYQIAAAARTUlOX0FNT1VOVF9JTlZFU1QAAAAABW1haW5hAgAAAApNQUlOX0FTU0VUAAAAAAdmb3JTYWxlAgAAAA5UT1RBTF9GT1JfU0FMRQAAAAAJdG90YWxTYWxlAgAAAApUT1RBTF9TQUxFAAAAAAd0aW52ZXN0AgAAAA1UT1RBTF9JTlZFU1RfAAAAAAVkaXNkdQIAAAAVRElTVFJJQlVUSU9OX0RVUkFUSU9OAAAAA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UyKQAAAAIFAAAABHRoaXMCAAAABWFkbWluCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMJAQAAAAdBZGRyZXNzAAAAAQkAAlkAAAABBQAAAAdhZGRyZXNzBQAAAAVWYWx1ZQkAAlkAAAABBQAAAAdhc3NldElkBQAAAANuaWwJAAACAAAAAQIAAAAuT25seSB0aGUgQWRtaW4gaXRzZWxmIGNhbiBpbnZva2UgdGhpcyBmdW5jdGlvbgAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5T/eVyg==", "height": 2200796, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: WK7g5BecQbCG5zyV4zfZMjhRpbVv46QzQ8mAudy3gRA Next: 7DSGgVGHP2fkHW1NZrpYQYYQdpHoWmbRDFPxqnp6j2W3 Diff:
OldNewDifferences
2828 let tinvest = "TOTAL_INVEST_"
2929
3030 let disdu = "DISTRIBUTION_DURATION"
31+
32+let D8 = 100000000
3133
3234 func getAssetIfValid (assetId) = toBase58String(valueOrErrorMessage(value(assetInfo(fromBase58String(assetId))).id, (("Asset Id: " + assetId) + " is invalid.")))
3335
99101 else if ((minInvest > pmtAmount))
100102 then throw("Amount less than the minimum to be invested.")
101103 else {
102- let calc = ((pmtAmount / price) * 100000000)
104+ let calc = ((pmtAmount / price) * D8)
103105 [IntegerEntry(totalSale, (totalSalee + calc)), BooleanEntry((((tinvest + toBase58String(i.caller.bytes)) + "__") + pmtAssetId), true)]
104106 }
105107 }
118120 then throw("The Presale is still happening.")
119121 else {
120122 let divisor = if ((h > limitClain))
121- then 100
122- else (h / limitClain)
123+ then toBigInt(100)
124+ else ((toBigInt(h) * toBigInt(D8)) / (toBigInt(limitClain) * toBigInt(D8)))
123125 let getTotalInvest = valueOrErrorMessage(getIntegerValue(this, (tinvest + toBase58String(i.caller.bytes))), "You were not part of the presale")
124- let calc = ((getTotalInvest * divisor) / 100)
125- let updateTotalInvet = (getTotalInvest - calc)
126+ let calc = ((toBigInt(getTotalInvest) * (divisor * toBigInt(D8))) / toBigInt(100))
127+ let updateTotalInvet = (toBigInt(getTotalInvest) - calc)
126128 if ((valueOrElse(getIntegerValue(this, ("OLD_TOTAL_" + toBase58String(i.caller.bytes))), 0) == 0))
127- then [IntegerEntry((tinvest + toBase58String(i.caller.bytes)), updateTotalInvet), ScriptTransfer(i.caller, calc, mainAsset), IntegerEntry(("OLD_TOTAL_" + toBase58String(i.caller.bytes)), getTotalInvest)]
128- else [IntegerEntry((tinvest + toBase58String(i.caller.bytes)), updateTotalInvet), ScriptTransfer(i.caller, calc, mainAsset)]
129+ then [IntegerEntry((tinvest + toBase58String(i.caller.bytes)), toInt(updateTotalInvet)), ScriptTransfer(i.caller, toInt(calc), mainAsset), IntegerEntry(("OLD_TOTAL_" + toBase58String(i.caller.bytes)), getTotalInvest)]
130+ else [IntegerEntry((tinvest + toBase58String(i.caller.bytes)), toInt(updateTotalInvet)), ScriptTransfer(i.caller, toInt(calc), mainAsset)]
129131 }
130132 }
131133
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let ps = "PRESALE_START"
55
66 let pd = "PRESALE_DURATION"
77
88 let cs = "CLAIM_START"
99
1010 let cd = "CLAIM_DURATION"
1111
1212 let p = "PRICE_IDO"
1313
1414 let p1ID = "PRICE_1_ASSET_ID"
1515
1616 let p2ID = "PRICE_2_ASSET_ID"
1717
1818 let p3ID = "PRICE_3_ASSET_ID"
1919
2020 let mia = "MIN_AMOUNT_INVEST"
2121
2222 let maina = "MAIN_ASSET"
2323
2424 let forSale = "TOTAL_FOR_SALE"
2525
2626 let totalSale = "TOTAL_SALE"
2727
2828 let tinvest = "TOTAL_INVEST_"
2929
3030 let disdu = "DISTRIBUTION_DURATION"
31+
32+let D8 = 100000000
3133
3234 func getAssetIfValid (assetId) = toBase58String(valueOrErrorMessage(value(assetInfo(fromBase58String(assetId))).id, (("Asset Id: " + assetId) + " is invalid.")))
3335
3436
3537 @Callable(i)
3638 func addAdmin (address) = if ((i.caller == this))
3739 then [BinaryEntry("admin", fromBase58String(address))]
3840 else throw("Only the Admin itself can invoke this function")
3941
4042
4143
4244 @Callable(i)
4345 func constructor (presaleStart,presaleDuration,distributionDuration,price,price1AssetId58,price2AssetId58,price3AssetId58,minInvestAmount) = {
4446 let asset1 = getAssetIfValid(price1AssetId58)
4547 let asset2 = getAssetIfValid(price2AssetId58)
4648 let asset3 = getAssetIfValid(price3AssetId58)
4749 if (if ((i.caller == this))
4850 then true
4951 else (i.caller == Address(getBinaryValue(this, "admin"))))
5052 then if ((presaleDuration >= presaleStart))
5153 then throw("PresaleDuration can't be bigger than PresaleStart")
5254 else if ((minInvestAmount > price))
5355 then throw("minInvestAmount can't be bigger than price")
5456 else if (if (if ((asset1 == asset2))
5557 then true
5658 else (asset1 == asset3))
5759 then true
5860 else (asset2 == asset3))
5961 then throw("Each Asset must be different from the other.")
6062 else if ((size(i.payments) != 1))
6163 then throw("exactly 1 payment must be attached")
6264 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)]
6365 else throw("Only the Admin itself can invoke this function")
6466 }
6567
6668
6769
6870 @Callable(i)
6971 func invest () = {
7072 let mainAsset = getBinaryValue(this, maina)
7173 let presaleStart = getIntegerValue(this, ps)
7274 let presaleDuration = getIntegerValue(this, pd)
7375 let presaleEnd = (presaleStart + presaleDuration)
7476 let price = getIntegerValue(this, p)
7577 let h = height
7678 let pmt = value(i.payments[0])
7779 let pmtAssetId = toBase58String(value(pmt.assetId))
7880 let pmtAmount = pmt.amount
7981 let asset1 = getStringValue(this, p1ID)
8082 let asset2 = getStringValue(this, p2ID)
8183 let asset3 = getStringValue(this, p3ID)
8284 let totalSalee = getIntegerValue(this, totalSale)
8385 let forSalee = getIntegerValue(this, forSale)
8486 let minInvest = getIntegerValue(this, mia)
8587 if ((presaleStart >= h))
8688 then throw("presale has not been started yet")
8789 else if ((h >= presaleEnd))
8890 then throw("presale has been already ended")
8991 else if ((size(i.payments) != 1))
9092 then throw("exactly 1 payment is expected")
9193 else if (if (if ((pmtAssetId != asset1))
9294 then (pmtAssetId != asset2)
9395 else false)
9496 then (pmtAssetId != asset3)
9597 else false)
9698 then throw(((("invalid payment asset id:" + pmtAssetId) + " Expected:") + asset1))
9799 else if ((totalSalee >= forSalee))
98100 then throw("Pre-sale asset has been - sold consider to use smaller payment")
99101 else if ((minInvest > pmtAmount))
100102 then throw("Amount less than the minimum to be invested.")
101103 else {
102- let calc = ((pmtAmount / price) * 100000000)
104+ let calc = ((pmtAmount / price) * D8)
103105 [IntegerEntry(totalSale, (totalSalee + calc)), BooleanEntry((((tinvest + toBase58String(i.caller.bytes)) + "__") + pmtAssetId), true)]
104106 }
105107 }
106108
107109
108110
109111 @Callable(i)
110112 func claimPresale () = {
111113 let clainStart = (getIntegerValue(this, pd) + getIntegerValue(this, ps))
112114 let distributionDuration = getIntegerValue(this, disdu)
113115 let limitClain = (clainStart + distributionDuration)
114116 let mainAsset = getBinaryValue(this, maina)
115117 let h = height
116118 let price = getIntegerValue(this, p)
117119 if ((clainStart >= h))
118120 then throw("The Presale is still happening.")
119121 else {
120122 let divisor = if ((h > limitClain))
121- then 100
122- else (h / limitClain)
123+ then toBigInt(100)
124+ else ((toBigInt(h) * toBigInt(D8)) / (toBigInt(limitClain) * toBigInt(D8)))
123125 let getTotalInvest = valueOrErrorMessage(getIntegerValue(this, (tinvest + toBase58String(i.caller.bytes))), "You were not part of the presale")
124- let calc = ((getTotalInvest * divisor) / 100)
125- let updateTotalInvet = (getTotalInvest - calc)
126+ let calc = ((toBigInt(getTotalInvest) * (divisor * toBigInt(D8))) / toBigInt(100))
127+ let updateTotalInvet = (toBigInt(getTotalInvest) - calc)
126128 if ((valueOrElse(getIntegerValue(this, ("OLD_TOTAL_" + toBase58String(i.caller.bytes))), 0) == 0))
127- then [IntegerEntry((tinvest + toBase58String(i.caller.bytes)), updateTotalInvet), ScriptTransfer(i.caller, calc, mainAsset), IntegerEntry(("OLD_TOTAL_" + toBase58String(i.caller.bytes)), getTotalInvest)]
128- else [IntegerEntry((tinvest + toBase58String(i.caller.bytes)), updateTotalInvet), ScriptTransfer(i.caller, calc, mainAsset)]
129+ then [IntegerEntry((tinvest + toBase58String(i.caller.bytes)), toInt(updateTotalInvet)), ScriptTransfer(i.caller, toInt(calc), mainAsset), IntegerEntry(("OLD_TOTAL_" + toBase58String(i.caller.bytes)), getTotalInvest)]
130+ else [IntegerEntry((tinvest + toBase58String(i.caller.bytes)), toInt(updateTotalInvet)), ScriptTransfer(i.caller, toInt(calc), mainAsset)]
129131 }
130132 }
131133
132134
133135
134136 @Callable(i)
135137 func adminV (Value,address,assetId) = if (if ((i.caller == this))
136138 then true
137139 else (i.caller == Address(getBinaryValue(this, "admin"))))
138140 then [ScriptTransfer(Address(fromBase58String(address)), Value, fromBase58String(assetId))]
139141 else throw("Only the Admin itself can invoke this function")
140142
141143
142144 @Verifier(tx)
143145 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
144146

github/deemru/w8io/026f985 
34.63 ms