tx · DRcowy2N1fHFAcv72zf7nAZoFUqzVtX6SsPBRpcHhFFr 3Mw7mAf2p8drjeSSDEbq6yyFhjqTgDcwGFB: -0.04000000 Waves 2022.05.05 19:37 [2038646] smart account 3Mw7mAf2p8drjeSSDEbq6yyFhjqTgDcwGFB > SELF 0.00000000 Waves
{ "type": 13, "id": "DRcowy2N1fHFAcv72zf7nAZoFUqzVtX6SsPBRpcHhFFr", "fee": 4000000, "feeAssetId": null, "timestamp": 1651768673553, "version": 2, "chainId": 84, "sender": "3Mw7mAf2p8drjeSSDEbq6yyFhjqTgDcwGFB", "senderPublicKey": "Ti5K4A5REvfgdfj3SWhhb2wJXRKenVb3WPQ6tE1TaKe", "proofs": [ "5QS78FNPj5zEuLnyVZ6YC9D34hx4AUWWfjsC4g2o8jiaVGR9abYTxEqEADFmeWxdTJdbUmCaCfQoCDunpeNpRpBV" ], "script": "base64:AAIFAAAAAAAAABYIAhIDCgEIEgsKCQEBAQEBCAgIARIAAAAADgAAAAACcHMCAAAADVBSRVNBTEVfU1RBUlQAAAAAAnBkAgAAABBQUkVTQUxFX0RVUkFUSU9OAAAAAAJjcwIAAAALQ0xBSU1fU1RBUlQAAAAAAmNkAgAAAA5DTEFJTV9EVVJBVElPTgAAAAABcAIAAAAJUFJJQ0VfSURPAAAAAARwMUlEAgAAABBQUklDRV8xX0FTU0VUX0lEAAAAAARwMklEAgAAABBQUklDRV8yX0FTU0VUX0lEAAAAAARwM0lEAgAAABBQUklDRV8zX0FTU0VUX0lEAAAAAANtaWECAAAAEU1JTl9BTU9VTlRfSU5WRVNUAAAAAAVtYWluYQIAAAAKTUFJTl9BU1NFVAAAAAAHZm9yU2FsZQIAAAAOVE9UQUxfRk9SX1NBTEUAAAAACXRvdGFsU2FsZQIAAAAKVE9UQUxfU0FMRQAAAAAHdGludmVzdAIAAAANVE9UQUxfSU5WRVNUXwEAAAAPZ2V0QXNzZXRJZlZhbGlkAAAAAQAAAAdhc3NldElkCQACWAAAAAEJAQAAABN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AFpAAAABmNhbGxlcgAAAAVieXRlcwIAAAACX18FAAAACnBtdEFzc2V0SWQGBQAAAANuaWwAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAACQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tleRxRw8c=", "height": 2038646, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: C5h8Grb2u1EhzvHBwWWChXAXPxMCGWd1XQip5tJNx73p Next: ESNZw5qmPfG9yBDMoqgDnWaijrV936Fsban8UCngnuTQ Diff:
Old | New | Differences | |
---|---|---|---|
101 | 101 | else if ((minInvest > pmtAmount)) | |
102 | 102 | then throw("Amount less than the minimum to be invested.") | |
103 | 103 | else { | |
104 | - | let getTInvest = valueOrElse(getIntegerValue(this, (tinvest + toBase58String(i.caller.bytes))), 0) | |
105 | 104 | let calc = (pmtAmount / price) | |
106 | - | let totalAmount = (pmtAmount + getTInvest) | |
107 | - | [IntegerEntry((tinvest + toBase58String(i.caller.bytes)), totalAmount), IntegerEntry(totalSale, (totalSalee + calc)), ScriptTransfer(i.caller, calc, mainAsset), BooleanEntry((((tinvest + toBase58String(i.caller.bytes)) + "__") + pmtAssetId), true)] | |
105 | + | [IntegerEntry(totalSale, (totalSalee + calc)), ScriptTransfer(i.caller, calc, mainAsset), BooleanEntry((((tinvest + toBase58String(i.caller.bytes)) + "__") + pmtAssetId), true)] | |
108 | 106 | } | |
109 | 107 | } | |
110 | 108 |
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 | func getAssetIfValid (assetId) = toBase58String(valueOrErrorMessage(value(assetInfo(fromBase58String(assetId))).id, (("Asset Id: " + assetId) + " is invalid."))) | |
31 | 31 | ||
32 | 32 | ||
33 | 33 | @Callable(i) | |
34 | 34 | func addAdmin (address) = if ((i.caller == this)) | |
35 | 35 | then [BinaryEntry("admin", fromBase58String(address))] | |
36 | 36 | else throw("Only the Admin itself can invoke this function") | |
37 | 37 | ||
38 | 38 | ||
39 | 39 | ||
40 | 40 | @Callable(i) | |
41 | 41 | func constructor (presaleStart,presaleDuration,claimStart,claimDuration,price,price1AssetId58,price2AssetId58,price3AssetId58,minInvestAmount) = { | |
42 | 42 | let asset1 = getAssetIfValid(price1AssetId58) | |
43 | 43 | let asset2 = getAssetIfValid(price2AssetId58) | |
44 | 44 | let asset3 = getAssetIfValid(price3AssetId58) | |
45 | 45 | if (if ((i.caller == this)) | |
46 | 46 | then true | |
47 | 47 | else (i.caller == Address(getBinaryValue(this, "admin")))) | |
48 | 48 | then if ((presaleDuration >= presaleStart)) | |
49 | 49 | then throw("PresaleDuration can't be bigger than PresaleStart") | |
50 | 50 | else if ((presaleDuration >= claimStart)) | |
51 | 51 | then throw("presaleDuration can't be bigger than claimStart") | |
52 | 52 | else if ((claimDuration >= claimStart)) | |
53 | 53 | then throw("claimDuration can't be bigger than claimStart") | |
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(cs, claimStart), IntegerEntry(cd, claimDuration), IntegerEntry(p, price), IntegerEntry(mia, minInvestAmount), IntegerEntry(forSale, value(i.payments[0]).amount), IntegerEntry(totalSale, 0)] | |
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 = getBinary(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 | - | let getTInvest = valueOrElse(getIntegerValue(this, (tinvest + toBase58String(i.caller.bytes))), 0) | |
105 | 104 | let calc = (pmtAmount / price) | |
106 | - | let totalAmount = (pmtAmount + getTInvest) | |
107 | - | [IntegerEntry((tinvest + toBase58String(i.caller.bytes)), totalAmount), IntegerEntry(totalSale, (totalSalee + calc)), ScriptTransfer(i.caller, calc, mainAsset), BooleanEntry((((tinvest + toBase58String(i.caller.bytes)) + "__") + pmtAssetId), true)] | |
105 | + | [IntegerEntry(totalSale, (totalSalee + calc)), ScriptTransfer(i.caller, calc, mainAsset), BooleanEntry((((tinvest + toBase58String(i.caller.bytes)) + "__") + pmtAssetId), true)] | |
108 | 106 | } | |
109 | 107 | } | |
110 | 108 | ||
111 | 109 | ||
112 | 110 | @Verifier(tx) | |
113 | 111 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
114 | 112 |
github/deemru/w8io/169f3d6 28.95 ms ◑