tx · HFeUrGFcGj2bF6X3btp1tGBJ56xMdymwqEjvjQKLn3fe

3N7hBLNCFEhtWwSWkk7Pbd5qoCdYhABdAPg:  -0.01000000 Waves

2021.07.18 09:50 [1618716] smart account 3N7hBLNCFEhtWwSWkk7Pbd5qoCdYhABdAPg > SELF 0.00000000 Waves

{ "type": 13, "id": "HFeUrGFcGj2bF6X3btp1tGBJ56xMdymwqEjvjQKLn3fe", "fee": 1000000, "feeAssetId": null, "timestamp": 1626591019563, "version": 2, "chainId": 84, "sender": "3N7hBLNCFEhtWwSWkk7Pbd5qoCdYhABdAPg", "senderPublicKey": "3dgMH7dCr1W2HyMSf2t3ZvDFstt6YnTvHtvZKUt6Cwgx", "proofs": [ "2DiEyPxuyf5BGhRVFoD8jv8YQ8X28KxUoZkESk9h3SoJ8FzPSmjt1DzuR9tLKjb9x9bvU2bRYKMjf3oytpvk8rC1" ], "script": "base64:AAIDAAAAAAAAAAYIARIAEgAAAAAAAAAAAgAAAAFpAQAAAA5XYXZlc1N3YXBUb2tlbgAAAAAEAAAACmN1cnJlbnRLZXkJAAEsAAAAAgIAAAANdG90YWxEZXBvc2l0XwkAAlgAAAABCAgFAAAAAWkAAAAGY2FsbGVyAAAABWJ5dGVzBAAAAAlzd2FwVG9rZW4BAAAAIOcOzrhZ7nmACRz71uIBzDdZQS4CHzCdrSwGyoWA1CnEBAAAAANwbXQJAQAAAAdleHRyYWN0AAAAAQgFAAAAAWkAAAAHcGF5bWVudAQAAAAGYW1vdW50CAUAAAADcG10AAAABmFtb3VudAQAAAANY3VycmVudEFtb3VudAQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAApjdXJyZW50S2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAEAAAACW5ld0Ftb3VudAkAAGQAAAACBQAAAA1jdXJyZW50QW1vdW50CAUAAAADcG10AAAABmFtb3VudAMJAQAAAA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2FuJ3Qgd2l0aGRyYXcgbmVnYXRpdmUgYW1vdW50AwkAAGYAAAACAAAAAAAAAAAABQAAABZuZXdBbW91bnRUb3RhbFdpdGhkcmF3CQAAAgAAAAECAAAAEk5vdCBlbm91Z2ggYmFsYW5jZQkBAAAADFNjcmlwdFJlc3VsdAAAAAIJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAACmN1cnJlbnRLZXkFAAAAFm5ld0Ftb3VudFRvdGFsV2l0aGRyYXcFAAAAA25pbAkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIFAAAAGXRvdGFsQXV0aG9yaXplZFdpdGhkcmF3YWwFAAAABHVuaXQFAAAAA25pbAAAAAC39WPd", "height": 1618716, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6RfHKzS6MuMML4XmMgHgVQJRFSegKtaZqzkzLDSN7KWq Next: 3fsz6khkbCB7GLHwNcc4XTiNmaGY6JVn3dvCffMT2JkJ Diff:
OldNewDifferences
2727 func TokenSwapWaves () = {
2828 let swapToken = base58'GYxGtmuBa72BShwGRLyf8wNDEzJt7zngMLCRTnuSuhMm'
2929 let currentKey = ("totalWithdrawInWaves_" + toBase58String(i.caller.bytes))
30+ let keyTotalDeposit = ("totalDeposit_" + toBase58String(i.caller.bytes))
31+ let totalTokensEmitidos = 100
3032 let pmt = extract(i.payment)
3133 let amount = pmt.amount
32- let currentAmount = match getInteger(this, currentKey) {
34+ let currentAmountDeposits = match getInteger(this, keyTotalDeposit) {
3335 case a: Int =>
3436 a
3537 case _ =>
3638 0
3739 }
38- let newAmount = (currentAmount + amount)
40+ let percentualParticipacao = ((currentAmountDeposits / totalTokensEmitidos) * 100)
41+ let currentAmountWithdraw = match getInteger(this, currentKey) {
42+ case a: Int =>
43+ a
44+ case _ =>
45+ 0
46+ }
47+ let currentProfit = match getInteger(this, "currentProfit") {
48+ case a: Int =>
49+ a
50+ case _ =>
51+ 0
52+ }
53+ let walletProfit = (currentProfit * percentualParticipacao)
54+ let totalAuthorizedWithdrawal = (walletProfit - currentAmountWithdraw)
55+ let newAmountTotalWithdraw = (currentAmountWithdraw + amount)
3956 if ((pmt.assetId != swapToken))
4057 then throw("can hodl Swap Token only.")
41- else if ((0 > amount))
42- then throw("Can't withdraw negative amount")
43- else if ((0 > newAmount))
44- then throw("Not enough balance")
45- else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, unit)]))
58+ else if ((totalAuthorizedWithdrawal >= amount))
59+ then throw("Você não possui lucro suficiente para esta solicitação, verifique novamente.")
60+ else if ((0 > amount))
61+ then throw("Can't withdraw negative amount")
62+ else if ((0 > newAmountTotalWithdraw))
63+ then throw("Not enough balance")
64+ else ScriptResult(WriteSet([DataEntry(currentKey, newAmountTotalWithdraw)]), TransferSet([ScriptTransfer(i.caller, totalAuthorizedWithdrawal, unit)]))
4665 }
4766
4867
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44
55
66 @Callable(i)
77 func WavesSwapToken () = {
88 let currentKey = ("totalDeposit_" + toBase58String(i.caller.bytes))
99 let swapToken = base58'GYxGtmuBa72BShwGRLyf8wNDEzJt7zngMLCRTnuSuhMm'
1010 let pmt = extract(i.payment)
1111 let amount = pmt.amount
1212 let currentAmount = match getInteger(this, currentKey) {
1313 case a: Int =>
1414 a
1515 case _ =>
1616 0
1717 }
1818 let newAmount = (currentAmount + pmt.amount)
1919 if (isDefined(pmt.assetId))
2020 then throw("can hodl waves only at the moment")
2121 else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, swapToken)]))
2222 }
2323
2424
2525
2626 @Callable(i)
2727 func TokenSwapWaves () = {
2828 let swapToken = base58'GYxGtmuBa72BShwGRLyf8wNDEzJt7zngMLCRTnuSuhMm'
2929 let currentKey = ("totalWithdrawInWaves_" + toBase58String(i.caller.bytes))
30+ let keyTotalDeposit = ("totalDeposit_" + toBase58String(i.caller.bytes))
31+ let totalTokensEmitidos = 100
3032 let pmt = extract(i.payment)
3133 let amount = pmt.amount
32- let currentAmount = match getInteger(this, currentKey) {
34+ let currentAmountDeposits = match getInteger(this, keyTotalDeposit) {
3335 case a: Int =>
3436 a
3537 case _ =>
3638 0
3739 }
38- let newAmount = (currentAmount + amount)
40+ let percentualParticipacao = ((currentAmountDeposits / totalTokensEmitidos) * 100)
41+ let currentAmountWithdraw = match getInteger(this, currentKey) {
42+ case a: Int =>
43+ a
44+ case _ =>
45+ 0
46+ }
47+ let currentProfit = match getInteger(this, "currentProfit") {
48+ case a: Int =>
49+ a
50+ case _ =>
51+ 0
52+ }
53+ let walletProfit = (currentProfit * percentualParticipacao)
54+ let totalAuthorizedWithdrawal = (walletProfit - currentAmountWithdraw)
55+ let newAmountTotalWithdraw = (currentAmountWithdraw + amount)
3956 if ((pmt.assetId != swapToken))
4057 then throw("can hodl Swap Token only.")
41- else if ((0 > amount))
42- then throw("Can't withdraw negative amount")
43- else if ((0 > newAmount))
44- then throw("Not enough balance")
45- else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, unit)]))
58+ else if ((totalAuthorizedWithdrawal >= amount))
59+ then throw("Você não possui lucro suficiente para esta solicitação, verifique novamente.")
60+ else if ((0 > amount))
61+ then throw("Can't withdraw negative amount")
62+ else if ((0 > newAmountTotalWithdraw))
63+ then throw("Not enough balance")
64+ else ScriptResult(WriteSet([DataEntry(currentKey, newAmountTotalWithdraw)]), TransferSet([ScriptTransfer(i.caller, totalAuthorizedWithdrawal, unit)]))
4665 }
4766
4867

github/deemru/w8io/169f3d6 
22.82 ms