tx · 9xEw1hJ9MYLessbuxNCJbYFaE9LdXm1SLnB9i6wUVXDS 3N7hBLNCFEhtWwSWkk7Pbd5qoCdYhABdAPg: -0.01000000 Waves 2021.07.19 23:04 [1620956] smart account 3N7hBLNCFEhtWwSWkk7Pbd5qoCdYhABdAPg > SELF 0.00000000 Waves
{ "type": 13, "id": "9xEw1hJ9MYLessbuxNCJbYFaE9LdXm1SLnB9i6wUVXDS", "fee": 1000000, "feeAssetId": null, "timestamp": 1626725094152, "version": 2, "chainId": 84, "sender": "3N7hBLNCFEhtWwSWkk7Pbd5qoCdYhABdAPg", "senderPublicKey": "3dgMH7dCr1W2HyMSf2t3ZvDFstt6YnTvHtvZKUt6Cwgx", "proofs": [ "JD374RmkTQMyw92DShwjmkQ5CFVLAgR4xNzTbHvAdUNMvegVGVnppFRQoGFceFEF94ZkqtfXzVmrpjiNS1aw7VL" ], "script": "base64:AAIDAAAAAAAAAdcIARIAEgAaBwoCYTESAWkaEAoCYTISCmN1cnJlbnRLZXkaDwoCYTMSCXN3YXBUb2tlbhoJCgJhNBIDcG10GgwKAmE1EgZhbW91bnQaEwoCYTYSDWN1cnJlbnRBbW91bnQaDQoCYTcSByRtYXRjaDAaBwoCYTgSAWEaDwoCYTkSCW5ld0Ftb3VudBoVCgJiMRIPa2V5VG90YWxEZXBvc2l0GhkKAmIyEhN0b3RhbFRva2Vuc0VtaXRpZG9zGhsKAmIzEhVjdXJyZW50QW1vdW50RGVwb3NpdHMaGAoCYjQSEmF1eGlsaWFQb3JjZW50YWdlbRocCgJiNRIWcGVyY2VudHVhbFBhcnRpY2lwYWNhbxobCgJiNhIVY3VycmVudEFtb3VudFdpdGhkcmF3GhMKAmI3Eg1jdXJyZW50UHJvZml0GhIKAmI4Egx3YWxsZXRQcm9maXQaHwoCYjkSGXRvdGFsQXV0aG9yaXplZFdpdGhkcmF3YWwaGgoCYzESFHRvdGFsVG9rZW5zRm9yUHJvZml0GhIKAmMyEgxjYWxjV2l0aGRyYXcaHAo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mMyBQAAAAR1bml0BQAAAANuaWwAAAAAam6sjQ==", "height": 1620956, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: EHC3VSYvGRSYeXGNHp2d46FYsRSLozvb4U4SAfQ2dz6i Next: 2XEPx4EHpwBATncq6wmu2yafiSW2cz3evBtTCK73cABd Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | ||
5 | 5 | ||
6 | 6 | @Callable(i) | |
7 | 7 | func WavesSwapToken () = { | |
8 | 8 | let currentKey = ("totalDeposit_" + toBase58String(i.caller.bytes)) | |
9 | 9 | let swapToken = base58'GYxGtmuBa72BShwGRLyf8wNDEzJt7zngMLCRTnuSuhMm' | |
10 | 10 | let pmt = extract(i.payment) | |
11 | 11 | let amount = pmt.amount | |
12 | 12 | let currentAmount = match getInteger(this, currentKey) { | |
13 | 13 | case a: Int => | |
14 | 14 | a | |
15 | 15 | case _ => | |
16 | 16 | 0 | |
17 | 17 | } | |
18 | 18 | let newAmount = (currentAmount + pmt.amount) | |
19 | 19 | if (isDefined(pmt.assetId)) | |
20 | 20 | then throw("can hodl waves only at the moment") | |
21 | 21 | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, swapToken)])) | |
22 | 22 | } | |
23 | 23 | ||
24 | 24 | ||
25 | 25 | ||
26 | 26 | @Callable(i) | |
27 | 27 | func TokenSwapWaves () = { | |
28 | 28 | let swapToken = base58'GYxGtmuBa72BShwGRLyf8wNDEzJt7zngMLCRTnuSuhMm' | |
29 | 29 | let currentKey = ("totalWithdrawInWaves_" + toBase58String(i.caller.bytes)) | |
30 | 30 | let keyTotalDeposit = ("totalDeposit_" + toBase58String(i.caller.bytes)) | |
31 | 31 | let totalTokensEmitidos = 10000000000 | |
32 | 32 | let pmt = extract(i.payment) | |
33 | 33 | let amount = pmt.amount | |
34 | 34 | let currentAmountDeposits = match getInteger(this, keyTotalDeposit) { | |
35 | 35 | case a: Int => | |
36 | 36 | a | |
37 | 37 | case _ => | |
38 | 38 | 0 | |
39 | 39 | } | |
40 | 40 | let auxiliaPorcentagem = 100 | |
41 | 41 | let percentualParticipacao = ((currentAmountDeposits * auxiliaPorcentagem) / (totalTokensEmitidos / auxiliaPorcentagem)) | |
42 | 42 | let currentAmountWithdraw = match getInteger(this, currentKey) { | |
43 | 43 | case a: Int => | |
44 | 44 | a | |
45 | 45 | case _ => | |
46 | 46 | 0 | |
47 | 47 | } | |
48 | 48 | let currentProfit = match getInteger(this, "currentProfit") { | |
49 | 49 | case a: Int => | |
50 | 50 | a | |
51 | 51 | case _ => | |
52 | 52 | 0 | |
53 | 53 | } | |
54 | 54 | let walletProfit = ((currentProfit / percentualParticipacao) * auxiliaPorcentagem) | |
55 | 55 | let totalAuthorizedWithdrawal = (walletProfit - currentAmountWithdraw) | |
56 | 56 | let totalTokensForProfit = ((totalAuthorizedWithdrawal / 200) * 100) | |
57 | 57 | let calcWithdraw = ((amount * 200) / 100) | |
58 | 58 | let newAmountTotalWithdraw = (currentAmountWithdraw + calcWithdraw) | |
59 | 59 | let consoleLog = ((((((((((("currentAmountDeposits:" + toString(currentAmountDeposits)) + "/percentualParticipacao:") + toString(percentualParticipacao)) + "/walletProfit:") + toString(walletProfit)) + "totalAuthorizedWithdrawal:") + toString(totalAuthorizedWithdrawal)) + "newAmountTotalWithdraw:") + toString(newAmountTotalWithdraw)) + "totalTokensForProfit:") + toString(totalTokensForProfit)) | |
60 | 60 | if ((pmt.assetId != swapToken)) | |
61 | 61 | then throw("can hodl Swap Token only.") | |
62 | 62 | else if ((calcWithdraw > totalAuthorizedWithdrawal)) | |
63 | 63 | then throw((((("O valor solicitado ultrapassa o valor da troca autorizada de:" + toString(totalTokensForProfit)) + " tokens por ") + toString(totalAuthorizedWithdrawal)) + " waves")) | |
64 | 64 | else if ((0 > amount)) | |
65 | 65 | then throw("Can't withdraw negative amount") | |
66 | 66 | else if ((0 > newAmountTotalWithdraw)) | |
67 | 67 | then throw("Not enough balance") | |
68 | 68 | else ScriptResult(WriteSet([DataEntry(currentKey, newAmountTotalWithdraw)]), TransferSet([ScriptTransfer(i.caller, calcWithdraw, unit)])) | |
69 | 69 | } | |
70 | 70 | ||
71 | 71 |
github/deemru/w8io/169f3d6 37.02 ms ◑