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