tx · 5Z7b73dHSect8WW3QovZtWv6sAWrzRuNFKodQuHFq5wn 3MuADE2ryaHKiVHXg5uFLyB4NYnvQJLZBUv: -0.01400000 Waves 2019.12.25 11:37 [824293] smart account 3MuADE2ryaHKiVHXg5uFLyB4NYnvQJLZBUv > SELF 0.00000000 Waves
{ "type": 13, "id": "5Z7b73dHSect8WW3QovZtWv6sAWrzRuNFKodQuHFq5wn", "fee": 1400000, "feeAssetId": null, "timestamp": 1577263088241, "version": 1, "sender": "3MuADE2ryaHKiVHXg5uFLyB4NYnvQJLZBUv", "senderPublicKey": "A4bJfnBhBTVh7GRNr1hHz6iqJta6eBbaExPDG7UapoaD", "proofs": [ "3JSEpNUhdzeD1kATiX9WTNatxJtWWwvmeznxrweR1gqG6fBQRPHAJxraE61iwJfhu7CBrdBb7GW21xpxQ2htbXMC" ], "script": "base64:AAIDAAAAAAAAABMIARIICgYIAQEBAQESABIDCgEIAAAAEgAAAAASRHJhZ29uRnJ1aXRBZGRyZXNzAgAAACMzTXpERzlydDEzRXU1dXc0bVpxa0c1YXhEaWlqdlZTRGJqYwAAAAANZGl2UHJvZ3JhbVB1YgkAAlkAAAABAgAAACxBNGJKZm5CaEJUVmg3R1JOcjFoSHo2aXFKdGE2ZUJiYUV4UERHN1VhcG9hRAAAAAAIYWRtaW5QdWIJAAJZAAAAAQIAAAAsNXlqY2Z2SDZpdXdya0ZnaFh1V2FKZU1wcGFRODkzRlNzOEhDQWdWUXp1TlkAAAAADHdhdmVzQXNzZXRJZAUAAAAEdW5pdAAAAAAKYnRjQXNzZXRJZAEAAAABAAAAAAAKZXRoQXNzZXRJZAEAAAABAAAAAAAKbHRjQXNzZXRJZAEAAAABAAAAAAALd2VzdEFzc2V0SWQBAAAAAQAAAAAACndjdEFzc2V0SWQBAAAAAQABAAAADWNhbGxlcklzQWRtaW4AAAABAAAAD2NhbGxlclB1YmxpY0tleQMJAAAAAAAAAgUAAAAPY2FsbGVyUHVibGljS2V5BQAAAAhhZG1pblB1Y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AAAAAZwcm9vZnMAAAAAAAAAAAAFAAAADWRpdlByb2dyYW1QdWIEAAAAByRtYXRjaDAFAAAAAnR4AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABRTZXRTY3JpcHRUcmFuc2FjdGlvbgQAAAAEc3N0eAUAAAAHJG1hdGNoMAYDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAE1RyYW5zZmVyVHJhbnNhY3Rpb24EAAAAA3R0eAUAAAAHJG1hdGNoMAQAAAAJYXNzZXROYW1lCQEAAAARYXNzZXRCYXNlNThUb05hbWUAAAABCAUAAAADdHR4AAAAB2Fzc2V0SWQEAAAAEGRpdmlkZW5kc1BlcmNlbnQJAQAAABNnZXREaXZpZGVuZHNQZXJjZW50AAAAAQUAAAAJYXNzZXROYW1lBAAAABJkaXZpZGVuZHNXaXRoZHJhd24JAQAAABtnZXREaXZpZGVuZHNXaXRoZHJhd25BbW91bnQAAAABBQAAAAlhc3NldE5hbWUEAAAACWRpdmlkZW5kcwkBAAAAEmdldERpdmlkZW5kQmFsYW5jZQAAAAMIBQAAAAN0dHgAAAAHYXNzZXRJZAUAAAASZGl2aWRlbmRzV2l0aGRyYXduBQAAABBkaXZpZGVuZHNQZXJjZW50BAAAAA5hY2NvdW50QmFsYW5jZQkAA+sAAAACBQAAAAR0aGlzCAUAAAADdHR4AAAAB2Fzc2V0SWQJAABnAAAAAgkAAGUAAAACBQAAAA5hY2NvdW50QmFsYW5jZQgFAAAAA3R0eAAAAAZhbW91bnQFAAAACWRpdmlkZW5kcwMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAXSW52b2tlU2NyaXB0VHJhbnNhY3Rpb24EAAAAA2l0eAUAAAAHJG1hdGNoMAYHB7I1RH8=", "chainId": 84, "height": 824293, "spentComplexity": 0 } View: original | compacted Prev: 8XHNJTKASStmvkQArYXPS5XVDiGnivrH8hauWfjnosda Next: FzQ34yq96nygio6MHySAFucwUapDhTN8T77cgSGvxFV8 Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let wavelet = 100000000 | |
5 | - | ||
6 | - | let wavesDepositAmt = (2600 * wavelet) | |
7 | - | ||
8 | - | let btcDepositAmt = ((2600 * wavelet) / 10000) | |
9 | - | ||
10 | - | let ethDepositAmt = (13 * wavelet) | |
11 | - | ||
12 | - | let ltcDepositAmt = (39 * wavelet) | |
13 | - | ||
14 | - | let westDepositAmt = (26000 * wavelet) | |
15 | - | ||
16 | - | let wctDepositAmt = (26000 * wavelet) | |
17 | - | ||
18 | 4 | let DragonFruitAddress = "3MzDG9rt13Eu5uw4mZqkG5axDiijvVSDbjc" | |
19 | 5 | ||
20 | 6 | let divProgramPub = fromBase58String("A4bJfnBhBTVh7GRNr1hHz6iqJta6eBbaExPDG7UapoaD") | |
152 | 138 | let amount = amountCheck(assetName, pmt.amount) | |
153 | 139 | let depositState = getString(this, (assetName + "_DepositState")) | |
154 | 140 | if ((depositState == "Created")) | |
155 | - | then ScriptResult(WriteSet([DataEntry((assetName + "_DepositOwner"), callerPub), DataEntry((assetName + "_DepositState"), "Active")]), TransferSet([ScriptTransfer(addressFromStringValue(DragonFruitAddress), amount, pmt.assetId)])) | |
141 | + | then ScriptResult(WriteSet([DataEntry((assetName + "_DepositOwner"), callerPub), DataEntry((assetName + "_DepositState"), "Active"), DataEntry((callerPub + "_DividendsWithdrawn"), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(DragonFruitAddress), amount, pmt.assetId)])) | |
156 | 142 | else throw("Deposit is unavailable") | |
157 | 143 | } | |
158 | 144 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let wavelet = 100000000 | |
5 | - | ||
6 | - | let wavesDepositAmt = (2600 * wavelet) | |
7 | - | ||
8 | - | let btcDepositAmt = ((2600 * wavelet) / 10000) | |
9 | - | ||
10 | - | let ethDepositAmt = (13 * wavelet) | |
11 | - | ||
12 | - | let ltcDepositAmt = (39 * wavelet) | |
13 | - | ||
14 | - | let westDepositAmt = (26000 * wavelet) | |
15 | - | ||
16 | - | let wctDepositAmt = (26000 * wavelet) | |
17 | - | ||
18 | 4 | let DragonFruitAddress = "3MzDG9rt13Eu5uw4mZqkG5axDiijvVSDbjc" | |
19 | 5 | ||
20 | 6 | let divProgramPub = fromBase58String("A4bJfnBhBTVh7GRNr1hHz6iqJta6eBbaExPDG7UapoaD") | |
21 | 7 | ||
22 | 8 | let adminPub = fromBase58String("5yjcfvH6iuwrkFghXuWaJeMppaQ893FSs8HCAgVQzuNY") | |
23 | 9 | ||
24 | 10 | let wavesAssetId = unit | |
25 | 11 | ||
26 | 12 | let btcAssetId = base58'1' | |
27 | 13 | ||
28 | 14 | let ethAssetId = base58'1' | |
29 | 15 | ||
30 | 16 | let ltcAssetId = base58'1' | |
31 | 17 | ||
32 | 18 | let westAssetId = base58'1' | |
33 | 19 | ||
34 | 20 | let wctAssetId = base58'1' | |
35 | 21 | ||
36 | 22 | func callerIsAdmin (callerPublicKey) = if ((callerPublicKey == adminPub)) | |
37 | 23 | then callerPublicKey | |
38 | 24 | else throw("You cannot create deposits") | |
39 | 25 | ||
40 | 26 | ||
41 | 27 | func callerIsDepositOwner (assetName,callerPublicKey) = { | |
42 | 28 | let depositOwner = getString(this, (assetName + "_DepositOwner")) | |
43 | 29 | if ((callerPublicKey == depositOwner)) | |
44 | 30 | then callerPublicKey | |
45 | 31 | else throw("Only deposit owner can withdrawal dividends") | |
46 | 32 | } | |
47 | 33 | ||
48 | 34 | ||
49 | 35 | func depositCreatedCheck (assetName) = { | |
50 | 36 | let key = (assetName + "_DepositOwner") | |
51 | 37 | let val = getString(this, key) | |
52 | 38 | match val { | |
53 | 39 | case a: String => | |
54 | 40 | true | |
55 | 41 | case _ => | |
56 | 42 | false | |
57 | 43 | } | |
58 | 44 | } | |
59 | 45 | ||
60 | 46 | ||
61 | 47 | func amountCheck (assetName,pmtAmount) = { | |
62 | 48 | let key = (assetName + "_DepositAmount") | |
63 | 49 | let val = getInteger(this, key) | |
64 | 50 | let depositAmount = match val { | |
65 | 51 | case a: Int => | |
66 | 52 | a | |
67 | 53 | case _ => | |
68 | 54 | throw("Couldn't find deposit amount") | |
69 | 55 | } | |
70 | 56 | if ((pmtAmount == depositAmount)) | |
71 | 57 | then pmtAmount | |
72 | 58 | else throw("Amount is incorrect") | |
73 | 59 | } | |
74 | 60 | ||
75 | 61 | ||
76 | 62 | func assetBase58ToName (assetId) = if (!(isDefined(assetId))) | |
77 | 63 | then "WAVES" | |
78 | 64 | else if ((assetId == btcAssetId)) | |
79 | 65 | then "BTC" | |
80 | 66 | else if ((assetId == ethAssetId)) | |
81 | 67 | then "ETH" | |
82 | 68 | else if ((assetId == ltcAssetId)) | |
83 | 69 | then "LTC" | |
84 | 70 | else if ((assetId == westAssetId)) | |
85 | 71 | then "VST" | |
86 | 72 | else if ((assetId == wctAssetId)) | |
87 | 73 | then "WCT" | |
88 | 74 | else throw("AssetId is incorrect") | |
89 | 75 | ||
90 | 76 | ||
91 | 77 | func assetNameToBase58 (assetName) = if ((assetName == "WAVES")) | |
92 | 78 | then wavesAssetId | |
93 | 79 | else if ((assetName == "BTC")) | |
94 | 80 | then btcAssetId | |
95 | 81 | else if ((assetName == "ETH")) | |
96 | 82 | then ethAssetId | |
97 | 83 | else if ((assetName == "LTC")) | |
98 | 84 | then ltcAssetId | |
99 | 85 | else if ((assetName == "VST")) | |
100 | 86 | then westAssetId | |
101 | 87 | else if ((assetName == "WCT")) | |
102 | 88 | then wctAssetId | |
103 | 89 | else throw("Asset name is incorrect") | |
104 | 90 | ||
105 | 91 | ||
106 | 92 | func getDividendsPercent (assetName) = { | |
107 | 93 | let key = (assetName + "_DividendPercent") | |
108 | 94 | let val = getInteger(this, key) | |
109 | 95 | match val { | |
110 | 96 | case a: Int => | |
111 | 97 | a | |
112 | 98 | case _ => | |
113 | 99 | throw("Couldn't Find dividend percent") | |
114 | 100 | } | |
115 | 101 | } | |
116 | 102 | ||
117 | 103 | ||
118 | 104 | func getDividendsWithdrawnAmount (assetName) = { | |
119 | 105 | let val = getInteger(this, (assetName + "_DividendsWithdrawn")) | |
120 | 106 | match val { | |
121 | 107 | case a: Int => | |
122 | 108 | a | |
123 | 109 | case _ => | |
124 | 110 | 0 | |
125 | 111 | } | |
126 | 112 | } | |
127 | 113 | ||
128 | 114 | ||
129 | 115 | func getDividendBalance (assetId,dividendsWithdrawn,dividendsPercent) = { | |
130 | 116 | let dividendsTotalBalance = (assetBalance(this, assetId) + dividendsWithdrawn) | |
131 | 117 | let userStake = ((dividendsTotalBalance * dividendsPercent) / 100) | |
132 | 118 | (userStake - dividendsWithdrawn) | |
133 | 119 | } | |
134 | 120 | ||
135 | 121 | ||
136 | 122 | @Callable(i) | |
137 | 123 | func createDeposit (assetName,amount,deividendPercent,startHeight,durationBlocks,startTimestamp) = { | |
138 | 124 | let callerPub = callerIsAdmin(i.callerPublicKey) | |
139 | 125 | let depositAlreadyCreated = depositCreatedCheck(assetName) | |
140 | 126 | if (depositAlreadyCreated) | |
141 | 127 | then throw("Deposit is already created") | |
142 | 128 | else WriteSet([DataEntry((assetName + "_DepositState"), "Created"), DataEntry((assetName + "_DepositAmount"), amount), DataEntry((assetName + "_DividendPercent"), deividendPercent), DataEntry((assetName + "_DepositStartBlock"), startHeight), DataEntry((assetName + "_DepositStartTimestamp"), startTimestamp), DataEntry((assetName + "_DepositDurationBlock"), durationBlocks)]) | |
143 | 129 | } | |
144 | 130 | ||
145 | 131 | ||
146 | 132 | ||
147 | 133 | @Callable(i) | |
148 | 134 | func deposit () = { | |
149 | 135 | let callerPub = toBase58String(i.callerPublicKey) | |
150 | 136 | let pmt = extract(i.payment) | |
151 | 137 | let assetName = assetBase58ToName(pmt.assetId) | |
152 | 138 | let amount = amountCheck(assetName, pmt.amount) | |
153 | 139 | let depositState = getString(this, (assetName + "_DepositState")) | |
154 | 140 | if ((depositState == "Created")) | |
155 | - | then ScriptResult(WriteSet([DataEntry((assetName + "_DepositOwner"), callerPub), DataEntry((assetName + "_DepositState"), "Active")]), TransferSet([ScriptTransfer(addressFromStringValue(DragonFruitAddress), amount, pmt.assetId)])) | |
141 | + | then ScriptResult(WriteSet([DataEntry((assetName + "_DepositOwner"), callerPub), DataEntry((assetName + "_DepositState"), "Active"), DataEntry((callerPub + "_DividendsWithdrawn"), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(DragonFruitAddress), amount, pmt.assetId)])) | |
156 | 142 | else throw("Deposit is unavailable") | |
157 | 143 | } | |
158 | 144 | ||
159 | 145 | ||
160 | 146 | ||
161 | 147 | @Callable(i) | |
162 | 148 | func withdrawDividends (assetName) = { | |
163 | 149 | let assetId = assetNameToBase58(assetName) | |
164 | 150 | let depositOwner = callerIsDepositOwner(assetName, toBase58String(i.callerPublicKey)) | |
165 | 151 | let dividendsPercent = getDividendsPercent(assetName) | |
166 | 152 | let dividendsWithdrawn = getDividendsWithdrawnAmount(assetName) | |
167 | 153 | let dividendsAvaliable = getDividendBalance(assetId, dividendsWithdrawn, dividendsPercent) | |
168 | 154 | ScriptResult(WriteSet([DataEntry((depositOwner + "_DividendsWithdrawn"), (dividendsWithdrawn + dividendsAvaliable))]), TransferSet([ScriptTransfer(addressFromPublicKey(fromBase58String(depositOwner)), dividendsAvaliable, assetId)])) | |
169 | 155 | } | |
170 | 156 | ||
171 | 157 | ||
172 | 158 | @Verifier(tx) | |
173 | 159 | func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], divProgramPub)) | |
174 | 160 | then match tx { | |
175 | 161 | case sstx: SetScriptTransaction => | |
176 | 162 | true | |
177 | 163 | case ttx: TransferTransaction => | |
178 | 164 | let assetName = assetBase58ToName(ttx.assetId) | |
179 | 165 | let dividendsPercent = getDividendsPercent(assetName) | |
180 | 166 | let dividendsWithdrawn = getDividendsWithdrawnAmount(assetName) | |
181 | 167 | let dividends = getDividendBalance(ttx.assetId, dividendsWithdrawn, dividendsPercent) | |
182 | 168 | let accountBalance = assetBalance(this, ttx.assetId) | |
183 | 169 | ((accountBalance - ttx.amount) >= dividends) | |
184 | 170 | case itx: InvokeScriptTransaction => | |
185 | 171 | true | |
186 | 172 | case _ => | |
187 | 173 | false | |
188 | 174 | } | |
189 | 175 | else false | |
190 | 176 |
github/deemru/w8io/026f985 31.20 ms ◑