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