tx · DPcV5qUwjnx4A49SHUqReMjkfuQYmAd5CHi854dLfeZU

3N7hBLNCFEhtWwSWkk7Pbd5qoCdYhABdAPg:  -0.01000000 Waves

2021.07.18 10:36 [1618767] smart account 3N7hBLNCFEhtWwSWkk7Pbd5qoCdYhABdAPg > SELF 0.00000000 Waves

{ "type": 13, "id": "DPcV5qUwjnx4A49SHUqReMjkfuQYmAd5CHi854dLfeZU", "fee": 1000000, "feeAssetId": null, "timestamp": 1626593852501, "version": 2, "chainId": 84, "sender": "3N7hBLNCFEhtWwSWkk7Pbd5qoCdYhABdAPg", "senderPublicKey": "3dgMH7dCr1W2HyMSf2t3ZvDFstt6YnTvHtvZKUt6Cwgx", "proofs": [ "4X7DmQvcz28jag68TMrRZWCqRUiExukD6GNqRwa89vAokQbDJT5joBzac9mNSfmQ3aCmHKYcviFynhnQNBaP3i7L" ], "script": "base64:AAIDAAAAAAAAAAYIARIAEgAAAAAAAAAAAgAAAAFpAQAAAA5XYXZlc1N3YXBUb2tlbgAAAAAEAAAACmN1cnJlbnRLZXkJAAEsAAAAAgIAAAANdG90YWxEZXBvc2l0XwkAAlgAAAABCAgFAAAAAWkAAAAGY2FsbGVyAAAABWJ5dGVzBAAAAAlzd2FwVG9rZW4BAAAAIOcOzrhZ7nmACRz71uIBzDdZQS4CHzCdrSwGyoWA1CnEBAAAAANwbXQJAQAAAAdleHRyYWN0AAAAAQgFAAAAAWkAAAAHcGF5bWVudAQAAAAGYW1vdW50CAUAAAADcG10AAAABmFtb3VudAQAAAANY3VycmVudEFtb3VudAQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAApjdXJyZW50S2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAEAAAACW5ld0Ftb3VudAkAAGQAAAACBQAAAA1jdXJyZW50QW1vdW50CAUAAAADcG10AAAABmFtb3VudAMJAQAAAAlpc0RlZmluZWQA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2F0aXZlIGFtb3VudAMJAABmAAAAAgAAAAAAAAAAAAUAAAAWbmV3QW1vdW50VG90YWxXaXRoZHJhdwkAAAIAAAABAgAAABJOb3QgZW5vdWdoIGJhbGFuY2UJAQAAAAxTY3JpcHRSZXN1bHQAAAACCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAApjdXJyZW50S2V5BQAAABZuZXdBbW91bnRUb3RhbFdpdGhkcmF3BQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAABl0b3RhbEF1dGhvcml6ZWRXaXRoZHJhd2FsBQAAAAR1bml0BQAAAANuaWwAAAAAD9w2rw==", "height": 1618767, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: CBpb4uzBwkytcS9HU9MS7UL2XpyQsnryKcTKTvGKSUje Next: AuUDiswGx2Ud5MVi2uhgMDcxgoy7aQyhTUo6pgS7vWDt Diff:
OldNewDifferences
3737 case _ =>
3838 0
3939 }
40- let percentualParticipacao = (currentAmountDeposits / totalTokensEmitidos)
40+ let percentualParticipacao = (totalTokensEmitidos / currentAmountDeposits)
4141 let currentAmountWithdraw = match getInteger(this, currentKey) {
4242 case a: Int =>
4343 a
5656 if ((pmt.assetId != swapToken))
5757 then throw("can hodl Swap Token only.")
5858 else if ((amount > totalAuthorizedWithdrawal))
59- then throw(("O valor solicitado ultrapassa o valor autorizado de:" + toString((currentAmountDeposits / totalTokensEmitidos))))
59+ then throw(("O valor solicitado ultrapassa o valor autorizado de:" + toString(percentualParticipacao)))
6060 else if ((0 > amount))
6161 then throw("Can't withdraw negative amount")
6262 else if ((0 > newAmountTotalWithdraw))
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))
3030 let keyTotalDeposit = ("totalDeposit_" + toBase58String(i.caller.bytes))
3131 let totalTokensEmitidos = 10000000000
3232 let pmt = extract(i.payment)
3333 let amount = pmt.amount
3434 let currentAmountDeposits = match getInteger(this, keyTotalDeposit) {
3535 case a: Int =>
3636 a
3737 case _ =>
3838 0
3939 }
40- let percentualParticipacao = (currentAmountDeposits / totalTokensEmitidos)
40+ let percentualParticipacao = (totalTokensEmitidos / currentAmountDeposits)
4141 let currentAmountWithdraw = match getInteger(this, currentKey) {
4242 case a: Int =>
4343 a
4444 case _ =>
4545 0
4646 }
4747 let currentProfit = match getInteger(this, "currentProfit") {
4848 case a: Int =>
4949 a
5050 case _ =>
5151 0
5252 }
5353 let walletProfit = (currentProfit * percentualParticipacao)
5454 let totalAuthorizedWithdrawal = (walletProfit - currentAmountWithdraw)
5555 let newAmountTotalWithdraw = (currentAmountWithdraw + amount)
5656 if ((pmt.assetId != swapToken))
5757 then throw("can hodl Swap Token only.")
5858 else if ((amount > totalAuthorizedWithdrawal))
59- then throw(("O valor solicitado ultrapassa o valor autorizado de:" + toString((currentAmountDeposits / totalTokensEmitidos))))
59+ then throw(("O valor solicitado ultrapassa o valor autorizado de:" + toString(percentualParticipacao)))
6060 else if ((0 > amount))
6161 then throw("Can't withdraw negative amount")
6262 else if ((0 > newAmountTotalWithdraw))
6363 then throw("Not enough balance")
6464 else ScriptResult(WriteSet([DataEntry(currentKey, newAmountTotalWithdraw)]), TransferSet([ScriptTransfer(i.caller, totalAuthorizedWithdrawal, unit)]))
6565 }
6666
6767

github/deemru/w8io/169f3d6 
32.38 ms