tx · 5Z7b73dHSect8WW3QovZtWv6sAWrzRuNFKodQuHFq5wn

3MuADE2ryaHKiVHXg5uFLyB4NYnvQJLZBUv:  -0.01400000 Waves

2019.12.25 11:37 [824293] smart account 3MuADE2ryaHKiVHXg5uFLyB4NYnvQJLZBUv > SELF 0.00000000 Waves

{ "type": 13, "id": "5Z7b73dHSect8WW3QovZtWv6sAWrzRuNFKodQuHFq5wn", "fee": 1400000, "feeAssetId": null, "timestamp": 1577263088241, "version": 1, "sender": "3MuADE2ryaHKiVHXg5uFLyB4NYnvQJLZBUv", "senderPublicKey": "A4bJfnBhBTVh7GRNr1hHz6iqJta6eBbaExPDG7UapoaD", "proofs": [ "3JSEpNUhdzeD1kATiX9WTNatxJtWWwvmeznxrweR1gqG6fBQRPHAJxraE61iwJfhu7CBrdBb7GW21xpxQ2htbXMC" ], "script": "base64:AAIDAAAAAAAAABMIARIICgYIAQEBAQESABIDCgEIAAAAEgAAAAASRHJhZ29uRnJ1aXRBZGRyZXNzAgAAACMzTXpERzlydDEzRXU1dXc0bVpxa0c1YXhEaWlqdlZTRGJqYwAAAAANZGl2UHJvZ3JhbVB1YgkAAlkAAAABAgAAACxBNGJKZm5CaEJUVmg3R1JOcjFoSHo2aXFKdGE2ZUJiYUV4UERHN1VhcG9hRAAAAAAIYWRtaW5QdWIJAAJZAAAAAQIAAAAsNXlqY2Z2SDZpdXdya0ZnaFh1V2FKZU1wcGFRODkzRlNzOEhDQWdWUXp1TlkAAAAADHdhdmVzQXNzZXRJZAUAAAAEdW5pdAAAAAAKYnRjQXNzZXRJZAEAAAABAAAAAAAKZXRoQXNzZXRJZAEAAAABAAAAAAAKbHRjQXNzZXRJZAEAAAABAAAAAAALd2VzdEFzc2V0SWQBAAAAAQAAAAAACndjdEFzc2V0SWQBAAAAAQABAAAADWNhbGxlcklzQWRtaW4AAAABAAAAD2NhbGxlclB1YmxpY0tleQMJAAAAAAAAAgUAAAAPY2FsbGVyUHVibGljS2V5BQAAAAhhZG1pblB1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eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAADWRpdlByb2dyYW1QdWIEAAAAByRtYXRjaDAFAAAAAnR4AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABRTZXRTY3JpcHRUcmFuc2FjdGlvbgQAAAAEc3N0eAUAAAAHJG1hdGNoMAYDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAE1RyYW5zZmVyVHJhbnNhY3Rpb24EAAAAA3R0eAUAAAAHJG1hdGNoMAQAAAAJYXNzZXROYW1lCQEAAAARYXNzZXRCYXNlNThUb05hbWUAAAABCAUAAAADdHR4AAAAB2Fzc2V0SWQEAAAAEGRpdmlkZW5kc1BlcmNlbnQJAQAAABNnZXREaXZpZGVuZHNQZXJjZW50AAAAAQUAAAAJYXNzZXROYW1lBAAAABJkaXZpZGVuZHNXaXRoZHJhd24JAQAAABtnZXREaXZpZGVuZHNXaXRoZHJhd25BbW91bnQAAAABBQAAAAlhc3NldE5hbWUEAAAACWRpdmlkZW5kcwkBAAAAEmdldERpdmlkZW5kQmFsYW5jZQAAAAMIBQAAAAN0dHgAAAAHYXNzZXRJZAUAAAASZGl2aWRlbmRzV2l0aGRyYXduBQAAABBkaXZpZGVuZHNQZXJjZW50BAAAAA5hY2NvdW50QmFsYW5jZQkAA+sAAAACBQAAAAR0aGlzCAUAAAADdHR4AAAAB2Fzc2V0SWQJAABnAAAAAgkAAGUAAAACBQAAAA5hY2NvdW50QmFsYW5jZQgFAAAAA3R0eAAAAAZhbW91bnQFAAAACWRpdmlkZW5kcwMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAXSW52b2tlU2NyaXB0VHJhbnNhY3Rpb24EAAAAA2l0eAUAAAAHJG1hdGNoMAYHB7I1RH8=", "chainId": 84, "height": 824293, "spentComplexity": 0 } View: original | compacted Prev: 8XHNJTKASStmvkQArYXPS5XVDiGnivrH8hauWfjnosda Next: FzQ34yq96nygio6MHySAFucwUapDhTN8T77cgSGvxFV8 Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# 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-
184 let DragonFruitAddress = "3MzDG9rt13Eu5uw4mZqkG5axDiijvVSDbjc"
195
206 let divProgramPub = fromBase58String("A4bJfnBhBTVh7GRNr1hHz6iqJta6eBbaExPDG7UapoaD")
152138 let amount = amountCheck(assetName, pmt.amount)
153139 let depositState = getString(this, (assetName + "_DepositState"))
154140 if ((depositState == "Created"))
155- then ScriptResult(WriteSet([DataEntry((assetName + "_DepositOwner"), callerPub), DataEntry((assetName + "_DepositState"), "Active")]), TransferSet([ScriptTransfer(addressFromStringValue(DragonFruitAddress), amount, pmt.assetId)]))
141+ then ScriptResult(WriteSet([DataEntry((assetName + "_DepositOwner"), callerPub), DataEntry((assetName + "_DepositState"), "Active"), DataEntry((callerPub + "_DividendsWithdrawn"), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(DragonFruitAddress), amount, pmt.assetId)]))
156142 else throw("Deposit is unavailable")
157143 }
158144
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# 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-
184 let DragonFruitAddress = "3MzDG9rt13Eu5uw4mZqkG5axDiijvVSDbjc"
195
206 let divProgramPub = fromBase58String("A4bJfnBhBTVh7GRNr1hHz6iqJta6eBbaExPDG7UapoaD")
217
228 let adminPub = fromBase58String("5yjcfvH6iuwrkFghXuWaJeMppaQ893FSs8HCAgVQzuNY")
239
2410 let wavesAssetId = unit
2511
2612 let btcAssetId = base58'1'
2713
2814 let ethAssetId = base58'1'
2915
3016 let ltcAssetId = base58'1'
3117
3218 let westAssetId = base58'1'
3319
3420 let wctAssetId = base58'1'
3521
3622 func callerIsAdmin (callerPublicKey) = if ((callerPublicKey == adminPub))
3723 then callerPublicKey
3824 else throw("You cannot create deposits")
3925
4026
4127 func callerIsDepositOwner (assetName,callerPublicKey) = {
4228 let depositOwner = getString(this, (assetName + "_DepositOwner"))
4329 if ((callerPublicKey == depositOwner))
4430 then callerPublicKey
4531 else throw("Only deposit owner can withdrawal dividends")
4632 }
4733
4834
4935 func depositCreatedCheck (assetName) = {
5036 let key = (assetName + "_DepositOwner")
5137 let val = getString(this, key)
5238 match val {
5339 case a: String =>
5440 true
5541 case _ =>
5642 false
5743 }
5844 }
5945
6046
6147 func amountCheck (assetName,pmtAmount) = {
6248 let key = (assetName + "_DepositAmount")
6349 let val = getInteger(this, key)
6450 let depositAmount = match val {
6551 case a: Int =>
6652 a
6753 case _ =>
6854 throw("Couldn't find deposit amount")
6955 }
7056 if ((pmtAmount == depositAmount))
7157 then pmtAmount
7258 else throw("Amount is incorrect")
7359 }
7460
7561
7662 func assetBase58ToName (assetId) = if (!(isDefined(assetId)))
7763 then "WAVES"
7864 else if ((assetId == btcAssetId))
7965 then "BTC"
8066 else if ((assetId == ethAssetId))
8167 then "ETH"
8268 else if ((assetId == ltcAssetId))
8369 then "LTC"
8470 else if ((assetId == westAssetId))
8571 then "VST"
8672 else if ((assetId == wctAssetId))
8773 then "WCT"
8874 else throw("AssetId is incorrect")
8975
9076
9177 func assetNameToBase58 (assetName) = if ((assetName == "WAVES"))
9278 then wavesAssetId
9379 else if ((assetName == "BTC"))
9480 then btcAssetId
9581 else if ((assetName == "ETH"))
9682 then ethAssetId
9783 else if ((assetName == "LTC"))
9884 then ltcAssetId
9985 else if ((assetName == "VST"))
10086 then westAssetId
10187 else if ((assetName == "WCT"))
10288 then wctAssetId
10389 else throw("Asset name is incorrect")
10490
10591
10692 func getDividendsPercent (assetName) = {
10793 let key = (assetName + "_DividendPercent")
10894 let val = getInteger(this, key)
10995 match val {
11096 case a: Int =>
11197 a
11298 case _ =>
11399 throw("Couldn't Find dividend percent")
114100 }
115101 }
116102
117103
118104 func getDividendsWithdrawnAmount (assetName) = {
119105 let val = getInteger(this, (assetName + "_DividendsWithdrawn"))
120106 match val {
121107 case a: Int =>
122108 a
123109 case _ =>
124110 0
125111 }
126112 }
127113
128114
129115 func getDividendBalance (assetId,dividendsWithdrawn,dividendsPercent) = {
130116 let dividendsTotalBalance = (assetBalance(this, assetId) + dividendsWithdrawn)
131117 let userStake = ((dividendsTotalBalance * dividendsPercent) / 100)
132118 (userStake - dividendsWithdrawn)
133119 }
134120
135121
136122 @Callable(i)
137123 func createDeposit (assetName,amount,deividendPercent,startHeight,durationBlocks,startTimestamp) = {
138124 let callerPub = callerIsAdmin(i.callerPublicKey)
139125 let depositAlreadyCreated = depositCreatedCheck(assetName)
140126 if (depositAlreadyCreated)
141127 then throw("Deposit is already created")
142128 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)])
143129 }
144130
145131
146132
147133 @Callable(i)
148134 func deposit () = {
149135 let callerPub = toBase58String(i.callerPublicKey)
150136 let pmt = extract(i.payment)
151137 let assetName = assetBase58ToName(pmt.assetId)
152138 let amount = amountCheck(assetName, pmt.amount)
153139 let depositState = getString(this, (assetName + "_DepositState"))
154140 if ((depositState == "Created"))
155- then ScriptResult(WriteSet([DataEntry((assetName + "_DepositOwner"), callerPub), DataEntry((assetName + "_DepositState"), "Active")]), TransferSet([ScriptTransfer(addressFromStringValue(DragonFruitAddress), amount, pmt.assetId)]))
141+ then ScriptResult(WriteSet([DataEntry((assetName + "_DepositOwner"), callerPub), DataEntry((assetName + "_DepositState"), "Active"), DataEntry((callerPub + "_DividendsWithdrawn"), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(DragonFruitAddress), amount, pmt.assetId)]))
156142 else throw("Deposit is unavailable")
157143 }
158144
159145
160146
161147 @Callable(i)
162148 func withdrawDividends (assetName) = {
163149 let assetId = assetNameToBase58(assetName)
164150 let depositOwner = callerIsDepositOwner(assetName, toBase58String(i.callerPublicKey))
165151 let dividendsPercent = getDividendsPercent(assetName)
166152 let dividendsWithdrawn = getDividendsWithdrawnAmount(assetName)
167153 let dividendsAvaliable = getDividendBalance(assetId, dividendsWithdrawn, dividendsPercent)
168154 ScriptResult(WriteSet([DataEntry((depositOwner + "_DividendsWithdrawn"), (dividendsWithdrawn + dividendsAvaliable))]), TransferSet([ScriptTransfer(addressFromPublicKey(fromBase58String(depositOwner)), dividendsAvaliable, assetId)]))
169155 }
170156
171157
172158 @Verifier(tx)
173159 func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], divProgramPub))
174160 then match tx {
175161 case sstx: SetScriptTransaction =>
176162 true
177163 case ttx: TransferTransaction =>
178164 let assetName = assetBase58ToName(ttx.assetId)
179165 let dividendsPercent = getDividendsPercent(assetName)
180166 let dividendsWithdrawn = getDividendsWithdrawnAmount(assetName)
181167 let dividends = getDividendBalance(ttx.assetId, dividendsWithdrawn, dividendsPercent)
182168 let accountBalance = assetBalance(this, ttx.assetId)
183169 ((accountBalance - ttx.amount) >= dividends)
184170 case itx: InvokeScriptTransaction =>
185171 true
186172 case _ =>
187173 false
188174 }
189175 else false
190176

github/deemru/w8io/026f985 
31.20 ms