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