tx · GNhFL44CgAcuVgymGrDxheB5adkPs1nZBTF845nS8dUx 3MpVunRPnNPuBCtAb95NPY1Q1aNf43a6Gyh: -0.01400000 Waves 2019.12.24 14:44 [823043] smart account 3MpVunRPnNPuBCtAb95NPY1Q1aNf43a6Gyh > SELF 0.00000000 Waves
{ "type": 13, "id": "GNhFL44CgAcuVgymGrDxheB5adkPs1nZBTF845nS8dUx", "fee": 1400000, "feeAssetId": null, "timestamp": 1577187897555, "version": 1, "sender": "3MpVunRPnNPuBCtAb95NPY1Q1aNf43a6Gyh", "senderPublicKey": "HMJMUXBatArd2SDvjv3YbtdrY2BAsxDEfWhqv8kYH4Kj", "proofs": [ "5o4dbJhm9EtRPTaR3XWuT5kknwFQB4iH1SLKoX6QReRwtPjGuzKnydPjDa4eGaBBzqrZiwqgk7tcoRkHyeXs2oda" ], "script": "base64:AAIDAAAAAAAAABIIARIHCgUIAQEBARIAEgMKAQgAAAAbAAAAAAd3YXZlbGV0AAAAAAAF9eEAAAAAAA93YXZlc0RlcG9zaXRBbXQJAABoAAAAAgAAAAAAAAAKKAUAAAAHd2F2ZWxldAAAAAANYnRjRGVwb3NpdEFtdAkAAGkAAAACCQAAaAAAAAIAAAAAAAAACigFAAAAB3dhdmVsZXQAAAAAAAAAJxAAAAAADWV0aERlcG9zaXRBbXQJAABoAAAAAgAAAAAAAAAADQUAAAAHd2F2ZWxldAAAAAANbHRjRGVwb3NpdEFtdAkAAGgAAAACAAAAAAAAAAAnBQAAAAd3YXZlbGV0AAAAAA53ZXN0RGVwb3NpdEFtdAkAAGgAAAACAAAAAAAAAGWQBQAAAAd3YXZlbGV0AAAAAA13Y3REZXBvc2l0QW10CQAAaAAAAAIAAAAAAAAAZZAFAAAAB3dhdmVsZXQAAAAAEGRpdmlkZW5kc1BlcmNlbnQAAAAAAAAAAB4AAAAAEmRlcG9zaXRTdGFydEhlaWdodAAAAAAAAAAAAQAAAAASRHJhZ29uRnJ1aXRBZGRyZXNzAgAAACMzTXFwNDUz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AAAAckbWF0Y2gwAgAAABNUcmFuc2ZlclRyYW5zYWN0aW9uBAAAAAN0dHgFAAAAByRtYXRjaDAEAAAACWFzc2V0TmFtZQkBAAAAEWFzc2V0QmFzZTU4VG9OYW1lAAAAAQgFAAAAA3R0eAAAAAdhc3NldElkBAAAABJkaXZpZGVuZHNXaXRoZHJhd24JAQAAABtnZXREaXZpZGVuZHNXaXRoZHJhd25BbW91bnQAAAABBQAAAAlhc3NldE5hbWUEAAAACWRpdmlkZW5kcwkBAAAAEmdldERpdmlkZW5kQmFsYW5jZQAAAAIIBQAAAAN0dHgAAAAHYXNzZXRJZAUAAAASZGl2aWRlbmRzV2l0aGRyYXduBAAAAA5hY2NvdW50QmFsYW5jZQkAA+sAAAACBQAAAAR0aGlzCAUAAAADdHR4AAAAB2Fzc2V0SWQJAABnAAAAAgkAAGUAAAACBQAAAA5hY2NvdW50QmFsYW5jZQgFAAAAA3R0eAAAAAZhbW91bnQFAAAACWRpdmlkZW5kcwcHknBIhg==", "chainId": 84, "height": 823043, "spentComplexity": 0 } View: original | compacted Prev: HBkjtxwToBwT8ZimyXdAdBBEg3cdpJuivQoge9jh2NG8 Next: ENCiWiwWHwCuz3ZP59Ety2FowdweZZp8xLyQkqDQWBTn Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let WavesPub = fromBase58String("47yVx7y7Q9CP9VbAYgns76YMDmxeeGz2REzmVZsBC83g") | |
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 dividendsPercent = 30 | |
19 | + | ||
20 | + | let depositStartHeight = 1 | |
5 | 21 | ||
6 | 22 | let DragonFruitAddress = "3Mqp45361wCutaKEqM2kCbFZmrkodQGvpUE" | |
7 | 23 | ||
8 | - | let | |
24 | + | let divProgramPub = fromBase58String("HMJMUXBatArd2SDvjv3YbtdrY2BAsxDEfWhqv8kYH4Kj") | |
9 | 25 | ||
10 | - | let | |
26 | + | let adminPub = fromBase58String("1") | |
11 | 27 | ||
12 | - | let | |
28 | + | let depositTimeFrame = ((1440 * 30) * 6) | |
13 | 29 | ||
14 | 30 | let wavesAssetId = unit | |
15 | 31 | ||
23 | 39 | ||
24 | 40 | let wctAssetId = base58'1' | |
25 | 41 | ||
26 | - | func callerPubIsPredefined (callerPublicKey) = if ((callerPublicKey == WavesPub)) | |
27 | - | then toBase58String(callerPublicKey) | |
28 | - | else throw("Only predefined public keys can make deposits") | |
42 | + | func callerIsAdmin (callerPublicKey) = if ((callerPublicKey == adminPub)) | |
43 | + | then callerPublicKey | |
44 | + | else throw("You cannot create deposits") | |
45 | + | ||
46 | + | ||
47 | + | func callerIsDepositOwner (assetName,callerPublicKey) = { | |
48 | + | let depositOwner = getString(this, (assetName + "_DepositOwner")) | |
49 | + | if ((callerPublicKey == depositOwner)) | |
50 | + | then callerPublicKey | |
51 | + | else throw("Only deposit owner can withdrawal dividends") | |
52 | + | } | |
53 | + | ||
54 | + | ||
55 | + | func depositCreatedCheck (assetName) = { | |
56 | + | let key = (assetName + "_DepositOwner") | |
57 | + | let val = getString(this, key) | |
58 | + | match val { | |
59 | + | case a: String => | |
60 | + | true | |
61 | + | case _ => | |
62 | + | false | |
63 | + | } | |
64 | + | } | |
65 | + | ||
66 | + | ||
67 | + | func amountCheck (assetName,pmtAmount) = { | |
68 | + | let key = (assetName + "_DepositAmount") | |
69 | + | let val = getInteger(this, key) | |
70 | + | let depositAmount = match val { | |
71 | + | case a: Int => | |
72 | + | a | |
73 | + | case _ => | |
74 | + | throw("Couldn't find deposit amount") | |
75 | + | } | |
76 | + | if ((pmtAmount == depositAmount)) | |
77 | + | then pmtAmount | |
78 | + | else throw("Amount is incorrect") | |
79 | + | } | |
29 | 80 | ||
30 | 81 | ||
31 | 82 | func assetBase58ToName (assetId) = if (!(isDefined(assetId))) | |
58 | 109 | else throw("Asset name is incorrect") | |
59 | 110 | ||
60 | 111 | ||
61 | - | func setNewDepositAmount (callerPub,pmtAssetId,amount) = { | |
62 | - | let a = match getInteger(this, (((callerPub + "_") + pmtAssetId) + "_DepositAmount")) { | |
63 | - | case a: Int => | |
64 | - | a | |
65 | - | case _ => | |
66 | - | 0 | |
67 | - | } | |
68 | - | (a + amount) | |
69 | - | } | |
70 | - | ||
71 | - | ||
72 | - | func getDividendsBalance (assetId,callerPub,assetName) = { | |
73 | - | let totalBalance = assetBalance(this, assetId) | |
74 | - | let depositedBalance = { | |
75 | - | let key = (((callerPub + "_") + assetName) + "_DepositAmount") | |
76 | - | let val = getInteger(this, key) | |
77 | - | match val { | |
78 | - | case a: Int => | |
79 | - | a | |
80 | - | case _ => | |
81 | - | 0 | |
82 | - | } | |
83 | - | } | |
84 | - | ((totalBalance - depositedBalance) / 5) | |
85 | - | } | |
86 | - | ||
87 | - | ||
88 | - | func callerPubCheck (callerPublicKey,pmtAssetId) = { | |
89 | - | let key = (((callerPublicKey + "_") + pmtAssetId) + "_DepositAmount") | |
90 | - | let val = getInteger(this, key) | |
91 | - | match val { | |
92 | - | case a: Int => | |
93 | - | callerPublicKey | |
94 | - | case _ => | |
95 | - | throw("Couldn't find deposit amount for this user") | |
96 | - | } | |
97 | - | } | |
98 | - | ||
99 | - | ||
100 | - | func getDepositHeight (callerPub) = { | |
101 | - | let key = (callerPub + "_DepositHeight") | |
102 | - | let val = getInteger(this, key) | |
103 | - | match val { | |
104 | - | case a: Int => | |
105 | - | a | |
106 | - | case _ => | |
107 | - | throw("Couldn't find deposit height") | |
108 | - | } | |
109 | - | } | |
110 | - | ||
111 | - | ||
112 | - | func getDepositBalance (callerPub,pmtAssetId) = { | |
113 | - | let key = (((callerPub + "_") + pmtAssetId) + "_DepositAmount") | |
114 | - | let val = getInteger(this, key) | |
115 | - | match val { | |
116 | - | case a: Int => | |
117 | - | a | |
118 | - | case _ => | |
119 | - | throw("Couldn't find deposit balance") | |
120 | - | } | |
121 | - | } | |
122 | - | ||
123 | - | ||
124 | - | func getInvestorDividendBalance () = { | |
125 | - | let key = (toBase58String(WavesPub) + "_DividendBalance") | |
126 | - | let val = getInteger(this, key) | |
112 | + | func getDividendsWithdrawnAmount (assetName) = { | |
113 | + | let val = getInteger(this, (assetName + "_DividendsWithdrawn")) | |
127 | 114 | match val { | |
128 | 115 | case a: Int => | |
129 | 116 | a | |
133 | 120 | } | |
134 | 121 | ||
135 | 122 | ||
123 | + | func getDividendBalance (assetId,dividendsWithdrawn) = { | |
124 | + | let dividendsTotalBalance = (assetBalance(this, assetId) + dividendsWithdrawn) | |
125 | + | let userStake = ((dividendsTotalBalance * dividendsPercent) / 100) | |
126 | + | (userStake - dividendsWithdrawn) | |
127 | + | } | |
128 | + | ||
129 | + | ||
130 | + | @Callable(i) | |
131 | + | func createDeposit (assetName,amount,deividendPercent,heightStart,duration) = { | |
132 | + | let callerPub = callerIsAdmin(i.callerPublicKey) | |
133 | + | let depositAlreadyCreated = depositCreatedCheck(assetName) | |
134 | + | if (depositAlreadyCreated) | |
135 | + | then throw("Deposit is already created") | |
136 | + | else WriteSet([DataEntry((assetName + "_DepositState"), "Created"), DataEntry((assetName + "_DepositAmount"), amount), DataEntry((assetName + "_DividendPercent"), deividendPercent), DataEntry((assetName + "_DepositStart"), heightStart), DataEntry((assetName + "_DepositDuration"), duration)]) | |
137 | + | } | |
138 | + | ||
139 | + | ||
140 | + | ||
136 | 141 | @Callable(i) | |
137 | 142 | func deposit () = { | |
138 | - | let callerPub = | |
143 | + | let callerPub = toBase58String(i.callerPublicKey) | |
139 | 144 | let pmt = extract(i.payment) | |
140 | - | let amount = pmt.amount | |
141 | - | let pmtAssetId = assetBase58ToName(pmt.assetId) | |
142 | - | let callerNewDepositAmount = setNewDepositAmount(callerPub, pmtAssetId, amount) | |
143 | - | WriteSet([DataEntry((((callerPub + "_") + pmtAssetId) + "_DepositAmount"), callerNewDepositAmount), DataEntry((callerPub + "_DepositHeight"), height)]) | |
145 | + | let assetName = assetBase58ToName(pmt.assetId) | |
146 | + | let amount = amountCheck(assetName, pmt.amount) | |
147 | + | let depositState = getString(this, (assetName + "_DepositState")) | |
148 | + | if ((depositState == "Created")) | |
149 | + | then ScriptResult(WriteSet([DataEntry((assetName + "_DepositOwner"), callerPub), DataEntry((assetName + "_DepositState"), "Active")]), TransferSet([ScriptTransfer(addressFromStringValue(DragonFruitAddress), amount, pmt.assetId)])) | |
150 | + | else throw("Deposit is unavailable") | |
144 | 151 | } | |
145 | 152 | ||
146 | 153 | ||
148 | 155 | @Callable(i) | |
149 | 156 | func withdrawDividends (assetName) = { | |
150 | 157 | let assetId = assetNameToBase58(assetName) | |
151 | - | let callerPub = callerPubCheck(toBase58String(i.callerPublicKey), assetName) | |
152 | - | let dividends = getDividendsBalance(assetId, callerPub, assetName) | |
153 | - | ScriptResult(WriteSet([DataEntry((callerPub + "_DividendBalance"), 0)]), TransferSet([ScriptTransfer(addressFromPublicKey(fromBase58String(callerPub)), dividends, assetId)])) | |
154 | - | } | |
155 | - | ||
156 | - | ||
157 | - | ||
158 | - | @Callable(i) | |
159 | - | func withdrawDeposit (assetName) = { | |
160 | - | let pmtAssetId = assetNameToBase58(assetName) | |
161 | - | let callerPub = callerPubCheck(toBase58String(i.callerPublicKey), assetName) | |
162 | - | let dAppBalance = assetBalance(this, pmtAssetId) | |
163 | - | let depositHeight = getDepositHeight(callerPub) | |
164 | - | let heightDifference = (height - depositHeight) | |
165 | - | let depositBalance = getDepositBalance(callerPub, assetName) | |
166 | - | let avaliableBalance = if (((dAppBalance - depositBalance) >= 0)) | |
167 | - | then depositBalance | |
168 | - | else dAppBalance | |
169 | - | if ((heightDifference > freezingTime)) | |
170 | - | then ScriptResult(WriteSet([DataEntry((((callerPub + "_") + assetName) + "_DepositAmount"), (depositBalance - avaliableBalance))]), TransferSet([ScriptTransfer(addressFromPublicKey(fromBase58String(callerPub)), avaliableBalance, pmtAssetId)])) | |
171 | - | else throw((("Freezing time is not over. " + toString(heightDifference)) + " blocks left")) | |
172 | - | } | |
173 | - | ||
174 | - | ||
175 | - | ||
176 | - | @Callable(i) | |
177 | - | func sendToGameBalance (recipient,amount,assetName) = { | |
178 | - | let callerPub = if ((i.callerPublicKey == adminPub)) | |
179 | - | then i.callerPublicKey | |
180 | - | else throw("You cannot send funds to game accounts") | |
181 | - | let recipientCheck = if ((recipient == DragonFruitAddress)) | |
182 | - | then recipient | |
183 | - | else throw("Funds can be sent on to defined game addresses") | |
184 | - | let assetId = assetNameToBase58(assetName) | |
185 | - | ScriptResult(WriteSet(nil), TransferSet([ScriptTransfer(addressFromStringValue(recipientCheck), amount, assetId)])) | |
158 | + | let depositOwner = callerIsDepositOwner(assetName, toBase58String(i.callerPublicKey)) | |
159 | + | let dividendsWithdrawn = getDividendsWithdrawnAmount(assetName) | |
160 | + | let dividendsAvaliable = getDividendBalance(assetId, dividendsWithdrawn) | |
161 | + | ScriptResult(WriteSet([DataEntry((depositOwner + "_DividendsWithdrawn"), (dividendsWithdrawn + dividendsAvaliable))]), TransferSet([ScriptTransfer(addressFromPublicKey(fromBase58String(depositOwner)), dividendsAvaliable, assetId)])) | |
186 | 162 | } | |
187 | 163 | ||
188 | 164 | ||
189 | 165 | @Verifier(tx) | |
190 | - | func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], | |
166 | + | func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], divProgramPub)) | |
191 | 167 | then match tx { | |
192 | 168 | case sstx: SetScriptTransaction => | |
193 | 169 | true | |
194 | 170 | case ttx: TransferTransaction => | |
171 | + | let assetName = assetBase58ToName(ttx.assetId) | |
172 | + | let dividendsWithdrawn = getDividendsWithdrawnAmount(assetName) | |
173 | + | let dividends = getDividendBalance(ttx.assetId, dividendsWithdrawn) | |
195 | 174 | let accountBalance = assetBalance(this, ttx.assetId) | |
196 | - | let investorDividendBalance = getInvestorDividendBalance() | |
197 | - | ((accountBalance - ttx.amount) >= investorDividendBalance) | |
175 | + | ((accountBalance - ttx.amount) >= dividends) | |
198 | 176 | case _ => | |
199 | 177 | false | |
200 | 178 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let WavesPub = fromBase58String("47yVx7y7Q9CP9VbAYgns76YMDmxeeGz2REzmVZsBC83g") | |
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 dividendsPercent = 30 | |
19 | + | ||
20 | + | let depositStartHeight = 1 | |
5 | 21 | ||
6 | 22 | let DragonFruitAddress = "3Mqp45361wCutaKEqM2kCbFZmrkodQGvpUE" | |
7 | 23 | ||
8 | - | let | |
24 | + | let divProgramPub = fromBase58String("HMJMUXBatArd2SDvjv3YbtdrY2BAsxDEfWhqv8kYH4Kj") | |
9 | 25 | ||
10 | - | let | |
26 | + | let adminPub = fromBase58String("1") | |
11 | 27 | ||
12 | - | let | |
28 | + | let depositTimeFrame = ((1440 * 30) * 6) | |
13 | 29 | ||
14 | 30 | let wavesAssetId = unit | |
15 | 31 | ||
16 | 32 | let btcAssetId = base58'1' | |
17 | 33 | ||
18 | 34 | let ethAssetId = base58'1' | |
19 | 35 | ||
20 | 36 | let ltcAssetId = base58'1' | |
21 | 37 | ||
22 | 38 | let westAssetId = base58'1' | |
23 | 39 | ||
24 | 40 | let wctAssetId = base58'1' | |
25 | 41 | ||
26 | - | func callerPubIsPredefined (callerPublicKey) = if ((callerPublicKey == WavesPub)) | |
27 | - | then toBase58String(callerPublicKey) | |
28 | - | else throw("Only predefined public keys can make deposits") | |
42 | + | func callerIsAdmin (callerPublicKey) = if ((callerPublicKey == adminPub)) | |
43 | + | then callerPublicKey | |
44 | + | else throw("You cannot create deposits") | |
45 | + | ||
46 | + | ||
47 | + | func callerIsDepositOwner (assetName,callerPublicKey) = { | |
48 | + | let depositOwner = getString(this, (assetName + "_DepositOwner")) | |
49 | + | if ((callerPublicKey == depositOwner)) | |
50 | + | then callerPublicKey | |
51 | + | else throw("Only deposit owner can withdrawal dividends") | |
52 | + | } | |
53 | + | ||
54 | + | ||
55 | + | func depositCreatedCheck (assetName) = { | |
56 | + | let key = (assetName + "_DepositOwner") | |
57 | + | let val = getString(this, key) | |
58 | + | match val { | |
59 | + | case a: String => | |
60 | + | true | |
61 | + | case _ => | |
62 | + | false | |
63 | + | } | |
64 | + | } | |
65 | + | ||
66 | + | ||
67 | + | func amountCheck (assetName,pmtAmount) = { | |
68 | + | let key = (assetName + "_DepositAmount") | |
69 | + | let val = getInteger(this, key) | |
70 | + | let depositAmount = match val { | |
71 | + | case a: Int => | |
72 | + | a | |
73 | + | case _ => | |
74 | + | throw("Couldn't find deposit amount") | |
75 | + | } | |
76 | + | if ((pmtAmount == depositAmount)) | |
77 | + | then pmtAmount | |
78 | + | else throw("Amount is incorrect") | |
79 | + | } | |
29 | 80 | ||
30 | 81 | ||
31 | 82 | func assetBase58ToName (assetId) = if (!(isDefined(assetId))) | |
32 | 83 | then "WAVES" | |
33 | 84 | else if ((assetId == btcAssetId)) | |
34 | 85 | then "BTC" | |
35 | 86 | else if ((assetId == ethAssetId)) | |
36 | 87 | then "ETH" | |
37 | 88 | else if ((assetId == ltcAssetId)) | |
38 | 89 | then "LTC" | |
39 | 90 | else if ((assetId == westAssetId)) | |
40 | 91 | then "VST" | |
41 | 92 | else if ((assetId == wctAssetId)) | |
42 | 93 | then "WCT" | |
43 | 94 | else throw("AssetId is incorrect") | |
44 | 95 | ||
45 | 96 | ||
46 | 97 | func assetNameToBase58 (assetName) = if ((assetName == "WAVES")) | |
47 | 98 | then wavesAssetId | |
48 | 99 | else if ((assetName == "BTC")) | |
49 | 100 | then btcAssetId | |
50 | 101 | else if ((assetName == "ETH")) | |
51 | 102 | then ethAssetId | |
52 | 103 | else if ((assetName == "LTC")) | |
53 | 104 | then ltcAssetId | |
54 | 105 | else if ((assetName == "VST")) | |
55 | 106 | then westAssetId | |
56 | 107 | else if ((assetName == "WCT")) | |
57 | 108 | then wctAssetId | |
58 | 109 | else throw("Asset name is incorrect") | |
59 | 110 | ||
60 | 111 | ||
61 | - | func setNewDepositAmount (callerPub,pmtAssetId,amount) = { | |
62 | - | let a = match getInteger(this, (((callerPub + "_") + pmtAssetId) + "_DepositAmount")) { | |
63 | - | case a: Int => | |
64 | - | a | |
65 | - | case _ => | |
66 | - | 0 | |
67 | - | } | |
68 | - | (a + amount) | |
69 | - | } | |
70 | - | ||
71 | - | ||
72 | - | func getDividendsBalance (assetId,callerPub,assetName) = { | |
73 | - | let totalBalance = assetBalance(this, assetId) | |
74 | - | let depositedBalance = { | |
75 | - | let key = (((callerPub + "_") + assetName) + "_DepositAmount") | |
76 | - | let val = getInteger(this, key) | |
77 | - | match val { | |
78 | - | case a: Int => | |
79 | - | a | |
80 | - | case _ => | |
81 | - | 0 | |
82 | - | } | |
83 | - | } | |
84 | - | ((totalBalance - depositedBalance) / 5) | |
85 | - | } | |
86 | - | ||
87 | - | ||
88 | - | func callerPubCheck (callerPublicKey,pmtAssetId) = { | |
89 | - | let key = (((callerPublicKey + "_") + pmtAssetId) + "_DepositAmount") | |
90 | - | let val = getInteger(this, key) | |
91 | - | match val { | |
92 | - | case a: Int => | |
93 | - | callerPublicKey | |
94 | - | case _ => | |
95 | - | throw("Couldn't find deposit amount for this user") | |
96 | - | } | |
97 | - | } | |
98 | - | ||
99 | - | ||
100 | - | func getDepositHeight (callerPub) = { | |
101 | - | let key = (callerPub + "_DepositHeight") | |
102 | - | let val = getInteger(this, key) | |
103 | - | match val { | |
104 | - | case a: Int => | |
105 | - | a | |
106 | - | case _ => | |
107 | - | throw("Couldn't find deposit height") | |
108 | - | } | |
109 | - | } | |
110 | - | ||
111 | - | ||
112 | - | func getDepositBalance (callerPub,pmtAssetId) = { | |
113 | - | let key = (((callerPub + "_") + pmtAssetId) + "_DepositAmount") | |
114 | - | let val = getInteger(this, key) | |
115 | - | match val { | |
116 | - | case a: Int => | |
117 | - | a | |
118 | - | case _ => | |
119 | - | throw("Couldn't find deposit balance") | |
120 | - | } | |
121 | - | } | |
122 | - | ||
123 | - | ||
124 | - | func getInvestorDividendBalance () = { | |
125 | - | let key = (toBase58String(WavesPub) + "_DividendBalance") | |
126 | - | let val = getInteger(this, key) | |
112 | + | func getDividendsWithdrawnAmount (assetName) = { | |
113 | + | let val = getInteger(this, (assetName + "_DividendsWithdrawn")) | |
127 | 114 | match val { | |
128 | 115 | case a: Int => | |
129 | 116 | a | |
130 | 117 | case _ => | |
131 | 118 | 0 | |
132 | 119 | } | |
133 | 120 | } | |
134 | 121 | ||
135 | 122 | ||
123 | + | func getDividendBalance (assetId,dividendsWithdrawn) = { | |
124 | + | let dividendsTotalBalance = (assetBalance(this, assetId) + dividendsWithdrawn) | |
125 | + | let userStake = ((dividendsTotalBalance * dividendsPercent) / 100) | |
126 | + | (userStake - dividendsWithdrawn) | |
127 | + | } | |
128 | + | ||
129 | + | ||
130 | + | @Callable(i) | |
131 | + | func createDeposit (assetName,amount,deividendPercent,heightStart,duration) = { | |
132 | + | let callerPub = callerIsAdmin(i.callerPublicKey) | |
133 | + | let depositAlreadyCreated = depositCreatedCheck(assetName) | |
134 | + | if (depositAlreadyCreated) | |
135 | + | then throw("Deposit is already created") | |
136 | + | else WriteSet([DataEntry((assetName + "_DepositState"), "Created"), DataEntry((assetName + "_DepositAmount"), amount), DataEntry((assetName + "_DividendPercent"), deividendPercent), DataEntry((assetName + "_DepositStart"), heightStart), DataEntry((assetName + "_DepositDuration"), duration)]) | |
137 | + | } | |
138 | + | ||
139 | + | ||
140 | + | ||
136 | 141 | @Callable(i) | |
137 | 142 | func deposit () = { | |
138 | - | let callerPub = | |
143 | + | let callerPub = toBase58String(i.callerPublicKey) | |
139 | 144 | let pmt = extract(i.payment) | |
140 | - | let amount = pmt.amount | |
141 | - | let pmtAssetId = assetBase58ToName(pmt.assetId) | |
142 | - | let callerNewDepositAmount = setNewDepositAmount(callerPub, pmtAssetId, amount) | |
143 | - | WriteSet([DataEntry((((callerPub + "_") + pmtAssetId) + "_DepositAmount"), callerNewDepositAmount), DataEntry((callerPub + "_DepositHeight"), height)]) | |
145 | + | let assetName = assetBase58ToName(pmt.assetId) | |
146 | + | let amount = amountCheck(assetName, pmt.amount) | |
147 | + | let depositState = getString(this, (assetName + "_DepositState")) | |
148 | + | if ((depositState == "Created")) | |
149 | + | then ScriptResult(WriteSet([DataEntry((assetName + "_DepositOwner"), callerPub), DataEntry((assetName + "_DepositState"), "Active")]), TransferSet([ScriptTransfer(addressFromStringValue(DragonFruitAddress), amount, pmt.assetId)])) | |
150 | + | else throw("Deposit is unavailable") | |
144 | 151 | } | |
145 | 152 | ||
146 | 153 | ||
147 | 154 | ||
148 | 155 | @Callable(i) | |
149 | 156 | func withdrawDividends (assetName) = { | |
150 | 157 | let assetId = assetNameToBase58(assetName) | |
151 | - | let callerPub = callerPubCheck(toBase58String(i.callerPublicKey), assetName) | |
152 | - | let dividends = getDividendsBalance(assetId, callerPub, assetName) | |
153 | - | ScriptResult(WriteSet([DataEntry((callerPub + "_DividendBalance"), 0)]), TransferSet([ScriptTransfer(addressFromPublicKey(fromBase58String(callerPub)), dividends, assetId)])) | |
154 | - | } | |
155 | - | ||
156 | - | ||
157 | - | ||
158 | - | @Callable(i) | |
159 | - | func withdrawDeposit (assetName) = { | |
160 | - | let pmtAssetId = assetNameToBase58(assetName) | |
161 | - | let callerPub = callerPubCheck(toBase58String(i.callerPublicKey), assetName) | |
162 | - | let dAppBalance = assetBalance(this, pmtAssetId) | |
163 | - | let depositHeight = getDepositHeight(callerPub) | |
164 | - | let heightDifference = (height - depositHeight) | |
165 | - | let depositBalance = getDepositBalance(callerPub, assetName) | |
166 | - | let avaliableBalance = if (((dAppBalance - depositBalance) >= 0)) | |
167 | - | then depositBalance | |
168 | - | else dAppBalance | |
169 | - | if ((heightDifference > freezingTime)) | |
170 | - | then ScriptResult(WriteSet([DataEntry((((callerPub + "_") + assetName) + "_DepositAmount"), (depositBalance - avaliableBalance))]), TransferSet([ScriptTransfer(addressFromPublicKey(fromBase58String(callerPub)), avaliableBalance, pmtAssetId)])) | |
171 | - | else throw((("Freezing time is not over. " + toString(heightDifference)) + " blocks left")) | |
172 | - | } | |
173 | - | ||
174 | - | ||
175 | - | ||
176 | - | @Callable(i) | |
177 | - | func sendToGameBalance (recipient,amount,assetName) = { | |
178 | - | let callerPub = if ((i.callerPublicKey == adminPub)) | |
179 | - | then i.callerPublicKey | |
180 | - | else throw("You cannot send funds to game accounts") | |
181 | - | let recipientCheck = if ((recipient == DragonFruitAddress)) | |
182 | - | then recipient | |
183 | - | else throw("Funds can be sent on to defined game addresses") | |
184 | - | let assetId = assetNameToBase58(assetName) | |
185 | - | ScriptResult(WriteSet(nil), TransferSet([ScriptTransfer(addressFromStringValue(recipientCheck), amount, assetId)])) | |
158 | + | let depositOwner = callerIsDepositOwner(assetName, toBase58String(i.callerPublicKey)) | |
159 | + | let dividendsWithdrawn = getDividendsWithdrawnAmount(assetName) | |
160 | + | let dividendsAvaliable = getDividendBalance(assetId, dividendsWithdrawn) | |
161 | + | ScriptResult(WriteSet([DataEntry((depositOwner + "_DividendsWithdrawn"), (dividendsWithdrawn + dividendsAvaliable))]), TransferSet([ScriptTransfer(addressFromPublicKey(fromBase58String(depositOwner)), dividendsAvaliable, assetId)])) | |
186 | 162 | } | |
187 | 163 | ||
188 | 164 | ||
189 | 165 | @Verifier(tx) | |
190 | - | func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], | |
166 | + | func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], divProgramPub)) | |
191 | 167 | then match tx { | |
192 | 168 | case sstx: SetScriptTransaction => | |
193 | 169 | true | |
194 | 170 | case ttx: TransferTransaction => | |
171 | + | let assetName = assetBase58ToName(ttx.assetId) | |
172 | + | let dividendsWithdrawn = getDividendsWithdrawnAmount(assetName) | |
173 | + | let dividends = getDividendBalance(ttx.assetId, dividendsWithdrawn) | |
195 | 174 | let accountBalance = assetBalance(this, ttx.assetId) | |
196 | - | let investorDividendBalance = getInvestorDividendBalance() | |
197 | - | ((accountBalance - ttx.amount) >= investorDividendBalance) | |
175 | + | ((accountBalance - ttx.amount) >= dividends) | |
198 | 176 | case _ => | |
199 | 177 | false | |
200 | 178 | } | |
201 | 179 | else false | |
202 | 180 |
github/deemru/w8io/169f3d6 47.53 ms ◑