tx · DkPRq3NNQvmBma34QbfS3iAZPTU9v8oCsam3qT2syCHo

3N7hBLNCFEhtWwSWkk7Pbd5qoCdYhABdAPg:  -0.01000000 Waves

2021.07.20 20:23 [1622231] smart account 3N7hBLNCFEhtWwSWkk7Pbd5qoCdYhABdAPg > SELF 0.00000000 Waves

{ "type": 13, "id": "DkPRq3NNQvmBma34QbfS3iAZPTU9v8oCsam3qT2syCHo", "fee": 1000000, "feeAssetId": null, "timestamp": 1626801890076, "version": 2, "chainId": 84, "sender": "3N7hBLNCFEhtWwSWkk7Pbd5qoCdYhABdAPg", "senderPublicKey": "3dgMH7dCr1W2HyMSf2t3ZvDFstt6YnTvHtvZKUt6Cwgx", "proofs": [ "4UpZ3mnT9bcRmxNsFT9QgvSHvJSGcdctE7jc4vQHUc7qJbDRgaWNDZAtKcSEpeuRHM8GrWULKypzGhL7oUKYrzTD" ], "script": "base64:AAIDAAAAAAAAAZ0IARIAGgcKAmExEgFpGg8KAmEyEglzd2FwVG9rZW4aEAoCYTMSCmN1cnJlbnRLZXkaFQoCYTQSD2tleVRvdGFsRGVwb3NpdBoZCgJhNRITdG90YWxUb2tlbnNFbWl0aWRvcxoJCgJhNhIDcG10GgwKAmE3EgZhbW91bnQaGwoCYTgSFWN1cnJlbnRBbW91bnREZXBvc2l0cxoNCgJhORIHJG1hdGNoMBoHCgJiMRIBYRoYCgJiMhISYXV4aWxpYVBvcmNlbnRhZ2VtGhwKAmIzEhZwZXJjZW50dWFsUGFydGljaXBhY2FvGhsKAmI0EhVjdXJyZW50QW1vdW50V2l0aGRyYXcaEwoCYjUSDWN1cnJlbnRQcm9maXQaEgoCYjYSDHdhbGxldFByb2ZpdBofCgJiNxIZdG90YWxBdXRob3JpemVkV2l0aGRyYXdhbBoaCgJiOBIUdG90YWxUb2tlbnNGb3JQcm9maXQaEgoCYjkSDGNhbGNXaXRoZHJhdxocCgJjMRIWbmV3QW1vdW50VG90YWxXaXRoZHJhdwAAAAAAAAABAAAAAmExAQAAAA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AAAAAADIAAAAAAAAAABkBAAAAAJjMQkAAGQAAAACBQAAAAJiNAUAAAACYjkDCQEAAAACIT0AAAACCAUAAAACYTYAAAAHYXNzZXRJZAUAAAACYTIJAAACAAAAAQIAAAAZY2FuIGhvZGwgU3dhcCBUb2tlbiBvbmx5LgMJAABmAAAAAgAAAAAAAAAAAAUAAAACYTcJAAACAAAAAQIAAAAeQ2FuJ3Qgd2l0aGRyYXcgbmVnYXRpdmUgYW1vdW50AwkAAGYAAAACBQAAAAJiOQUAAAACYjcJAAACAAAAAQkAASwAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAD1PIHZhbG9yIHNvbGljaXRhZG8gdWx0cmFwYXNzYSBvIHZhbG9yIGRhIHRyb2NhIGF1dG9yaXphZGEgZGU6CQABpAAAAAEFAAAAAmI4AgAAAAwgdG9rZW5zIHBvciAJAAGkAAAAAQUAAAACYjcCAAAABiB3YXZlcwMJAABmAAAAAgAAAAAAAAAAAAUAAAACYzEJAAACAAAAAQIAAAASTm90IGVub3VnaCBiYWxhbmNlCQEAAAAMU2NyaXB0UmVzdWx0AAAAAgkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAACYTMFAAAAAmMxBQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAmExAAAABmNhbGxlcgUAAAACYjkFAAAABHVuaXQFAAAAA25pbAAAAAAMthWx", "height": 1622231, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 2XEPx4EHpwBATncq6wmu2yafiSW2cz3evBtTCK73cABd Next: none Diff:
OldNewDifferences
44
55
66 @Callable(i)
7-func WavesSwapToken () = {
8- let currentKey = ("totalDeposit_" + toBase58String(i.caller.bytes))
7+func TokenSwapWaves () = {
98 let swapToken = base58'GYxGtmuBa72BShwGRLyf8wNDEzJt7zngMLCRTnuSuhMm'
9+ let currentKey = ("totalWithdrawInWaves_" + toBase58String(i.caller.bytes))
10+ let keyTotalDeposit = ("totalDeposit_" + toBase58String(i.caller.bytes))
11+ let totalTokensEmitidos = 10000000000
1012 let pmt = extract(i.payment)
1113 let amount = pmt.amount
12- let currentAmount = match getInteger(this, currentKey) {
14+ let currentAmountDeposits = match getInteger(this, keyTotalDeposit) {
1315 case a: Int =>
1416 a
1517 case _ =>
1618 0
1719 }
18- let newAmount = (currentAmount + pmt.amount)
19- if (isDefined(pmt.assetId))
20- then throw("can hodl waves only at the moment")
21- else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, swapToken)]))
20+ let auxiliaPorcentagem = 100
21+ let percentualParticipacao = ((currentAmountDeposits * auxiliaPorcentagem) / (totalTokensEmitidos / auxiliaPorcentagem))
22+ let currentAmountWithdraw = match getInteger(this, currentKey) {
23+ case a: Int =>
24+ a
25+ case _ =>
26+ 0
27+ }
28+ let currentProfit = match getInteger(this, "currentProfit") {
29+ case a: Int =>
30+ a
31+ case _ =>
32+ 0
33+ }
34+ let walletProfit = ((currentProfit / percentualParticipacao) * auxiliaPorcentagem)
35+ let totalAuthorizedWithdrawal = (walletProfit - currentAmountWithdraw)
36+ let totalTokensForProfit = ((totalAuthorizedWithdrawal / 200) * 100)
37+ let calcWithdraw = ((amount * 200) / 100)
38+ let newAmountTotalWithdraw = (currentAmountWithdraw + calcWithdraw)
39+ if ((pmt.assetId != swapToken))
40+ then throw("can hodl Swap Token only.")
41+ else if ((0 > amount))
42+ then throw("Can't withdraw negative amount")
43+ else if ((calcWithdraw > totalAuthorizedWithdrawal))
44+ then throw((((("O valor solicitado ultrapassa o valor da troca autorizada de:" + toString(totalTokensForProfit)) + " tokens por ") + toString(totalAuthorizedWithdrawal)) + " waves"))
45+ else if ((0 > newAmountTotalWithdraw))
46+ then throw("Not enough balance")
47+ else ScriptResult(WriteSet([DataEntry(currentKey, newAmountTotalWithdraw)]), TransferSet([ScriptTransfer(i.caller, calcWithdraw, unit)]))
2248 }
2349
2450
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44
55
66 @Callable(i)
7-func WavesSwapToken () = {
8- let currentKey = ("totalDeposit_" + toBase58String(i.caller.bytes))
7+func TokenSwapWaves () = {
98 let swapToken = base58'GYxGtmuBa72BShwGRLyf8wNDEzJt7zngMLCRTnuSuhMm'
9+ let currentKey = ("totalWithdrawInWaves_" + toBase58String(i.caller.bytes))
10+ let keyTotalDeposit = ("totalDeposit_" + toBase58String(i.caller.bytes))
11+ let totalTokensEmitidos = 10000000000
1012 let pmt = extract(i.payment)
1113 let amount = pmt.amount
12- let currentAmount = match getInteger(this, currentKey) {
14+ let currentAmountDeposits = match getInteger(this, keyTotalDeposit) {
1315 case a: Int =>
1416 a
1517 case _ =>
1618 0
1719 }
18- let newAmount = (currentAmount + pmt.amount)
19- if (isDefined(pmt.assetId))
20- then throw("can hodl waves only at the moment")
21- else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, swapToken)]))
20+ let auxiliaPorcentagem = 100
21+ let percentualParticipacao = ((currentAmountDeposits * auxiliaPorcentagem) / (totalTokensEmitidos / auxiliaPorcentagem))
22+ let currentAmountWithdraw = match getInteger(this, currentKey) {
23+ case a: Int =>
24+ a
25+ case _ =>
26+ 0
27+ }
28+ let currentProfit = match getInteger(this, "currentProfit") {
29+ case a: Int =>
30+ a
31+ case _ =>
32+ 0
33+ }
34+ let walletProfit = ((currentProfit / percentualParticipacao) * auxiliaPorcentagem)
35+ let totalAuthorizedWithdrawal = (walletProfit - currentAmountWithdraw)
36+ let totalTokensForProfit = ((totalAuthorizedWithdrawal / 200) * 100)
37+ let calcWithdraw = ((amount * 200) / 100)
38+ let newAmountTotalWithdraw = (currentAmountWithdraw + calcWithdraw)
39+ if ((pmt.assetId != swapToken))
40+ then throw("can hodl Swap Token only.")
41+ else if ((0 > amount))
42+ then throw("Can't withdraw negative amount")
43+ else if ((calcWithdraw > totalAuthorizedWithdrawal))
44+ then throw((((("O valor solicitado ultrapassa o valor da troca autorizada de:" + toString(totalTokensForProfit)) + " tokens por ") + toString(totalAuthorizedWithdrawal)) + " waves"))
45+ else if ((0 > newAmountTotalWithdraw))
46+ then throw("Not enough balance")
47+ else ScriptResult(WriteSet([DataEntry(currentKey, newAmountTotalWithdraw)]), TransferSet([ScriptTransfer(i.caller, calcWithdraw, unit)]))
2248 }
2349
2450

github/deemru/w8io/169f3d6 
23.39 ms