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