tx · 2qXJBMu1pz4BUcCMK5hEqWfis2pNySZwg9ftfZ2zLW4p

3Ms8fqbXM4RhmM6CPTr44hUwHe2CCmVCfVA:  -0.01000000 Waves

2023.09.09 23:51 [2748356] smart account 3Ms8fqbXM4RhmM6CPTr44hUwHe2CCmVCfVA > SELF 0.00000000 Waves

{ "type": 13, "id": "2qXJBMu1pz4BUcCMK5hEqWfis2pNySZwg9ftfZ2zLW4p", "fee": 1000000, "feeAssetId": null, "timestamp": 1694292688687, "version": 2, "chainId": 84, "sender": "3Ms8fqbXM4RhmM6CPTr44hUwHe2CCmVCfVA", "senderPublicKey": "HQQ69Dum2Dp6ikGs7dfYRtTema79wqesthHx1wHmHC5Q", "proofs": [ "wbDdxYXRLdXLrCsddvxKvUX4kRP1AQ9r144C9ucLkSFs7Qe4tUmKifZWi5BYdv2Cs9KAEjKinfovFjC9kt9bojN" ], "script": "base64:AAIFAAAAAAAAAA4IAhIECgIIARIECgIBCAAAAAMAAAAABnVzZG5JZAEAAAAgD/IcEqzkxDya7EYaqyWosOy6BytGzG2IcvC14pJJAbQBAAAAFGdldFdhdmVzQ3VycmVudFByaWNlAAAAAAAAAAAAAB6EgAEAAAAQZ2V0V2F2ZXNOZXdQcmljZQAAAAAAAAAAAAAtxsAAAAACAAAAAWkBAAAAC3N3YXBUb1dhdmVzAAAAAgAAAAhjYWxsZXJJZAAAAAp1c2RuQW1vdW50BAAAAAhBbW91bnRJbgUAAAAKdXNkbkFtb3VudAQAAAAJQW1vdW50T3V0CQAAaQAAAAIJAABoAAAAAgUAAAAIQW1vdW50SW4AAAAAAAX14QAAAAAAAAAehIAJAAUUAAAAAgkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIFAAAACUFtb3VudE91dAUAAAAEdW5pdAkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgIAAAANQW1vdW50SW5fVVNETgUAAAAIQW1vdW50SW4JAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAICAAAAD0Ftb3VudE91dF9XQVZFUwUAAAAJQW1vdW50T3V0CQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACCQABLAAAAAIFAAAACGNhbGxlcklkAgAAABVfTGFzdF9BbW91bnRPdXRfV2F2ZXMFAAAACUFtb3VudE91dAUAAAADbmlsBQAAAAlBbW91bnRPdXQAAAABaQEAAAAKc3dhcFRvVVNETgAAAAIAAAALd2F2ZXNBbW91bnQAAAALdXNlckFkZHJlc3MEAAAACUFtb3VudE91dAkAAGgAAAACBQAAAAt3YXZlc0Ftb3VudAkBAAAAEGdldFdhdmVzTmV3UHJpY2UAAAAACQAFFAAAAAIJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwkBAAAAEUBleHRyTmF0aXZlKDEwNjIpAAAAAQUAAAALdXNlckFkZHJlc3MFAAAACUFtb3VudE91dAUAAAAGdXNkbklkCQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACAgAAAA5BbW91bnRJbl9XYXZlcwUAAAALd2F2ZXNBbW91bnQJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAICAAAADkFtb3VudE91dF9VU0ROBQAAAAlBbW91bnRPdXQFAAAAA25pbAUAAAAJQW1vdW50T3V0AAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXmbLDz8", "height": 2748356, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3AWcH11UPGnenDKJXu7DNgGJFR89yFYPNQnchuLQuPa2 Next: DpNUDy27jRRNG6js4MBb7funacgJywDtyJdWSvLF9TF6 Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4+let usdnId = base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT'
5+
46 func getWavesCurrentPrice () = 2000000
57
68
810
911
1012 @Callable(i)
11-func swapToWaves (callerId) = if (if ((size(i.payments) != 1))
12- then true
13- else (i.payments[0].amount == 0))
14- then throw("1 payment has to be attached")
15- else {
16- let AmountIn = i.payments[0].amount
17- let AmountOut = ((AmountIn * 100000000) / 2000000)
18- $Tuple2([IntegerEntry("AmountIn_USDN", AmountIn), IntegerEntry("AmountOut_WAVES", AmountOut), IntegerEntry((callerId + "_Last_AmountOut_Waves"), AmountOut)], AmountOut)
19- }
13+func swapToWaves (callerId,usdnAmount) = {
14+ let AmountIn = usdnAmount
15+ let AmountOut = ((AmountIn * 100000000) / 2000000)
16+ $Tuple2([ScriptTransfer(i.caller, AmountOut, unit), IntegerEntry("AmountIn_USDN", AmountIn), IntegerEntry("AmountOut_WAVES", AmountOut), IntegerEntry((callerId + "_Last_AmountOut_Waves"), AmountOut)], AmountOut)
17+ }
2018
2119
2220
2321 @Callable(i)
24-func swapToUSDN () = if (if ((size(i.payments) != 1))
25- then true
26- else (i.payments[0].amount == 0))
27- then throw("1 payment has to be attached")
28- else {
29- let AmountIn = i.payments[0].amount
30- let AmountOut = ((AmountIn * getWavesNewPrice()) / 100)
31- $Tuple2([IntegerEntry("AmountIn_Waves", AmountIn), IntegerEntry("AmountOut_USDN", AmountOut)], AmountOut)
32- }
22+func swapToUSDN (wavesAmount,userAddress) = {
23+ let AmountOut = (wavesAmount * getWavesNewPrice())
24+ $Tuple2([ScriptTransfer(addressFromStringValue(userAddress), AmountOut, usdnId), IntegerEntry("AmountIn_Waves", wavesAmount), IntegerEntry("AmountOut_USDN", AmountOut)], AmountOut)
25+ }
3326
3427
3528 @Verifier(tx)
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4+let usdnId = base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT'
5+
46 func getWavesCurrentPrice () = 2000000
57
68
79 func getWavesNewPrice () = 3000000
810
911
1012 @Callable(i)
11-func swapToWaves (callerId) = if (if ((size(i.payments) != 1))
12- then true
13- else (i.payments[0].amount == 0))
14- then throw("1 payment has to be attached")
15- else {
16- let AmountIn = i.payments[0].amount
17- let AmountOut = ((AmountIn * 100000000) / 2000000)
18- $Tuple2([IntegerEntry("AmountIn_USDN", AmountIn), IntegerEntry("AmountOut_WAVES", AmountOut), IntegerEntry((callerId + "_Last_AmountOut_Waves"), AmountOut)], AmountOut)
19- }
13+func swapToWaves (callerId,usdnAmount) = {
14+ let AmountIn = usdnAmount
15+ let AmountOut = ((AmountIn * 100000000) / 2000000)
16+ $Tuple2([ScriptTransfer(i.caller, AmountOut, unit), IntegerEntry("AmountIn_USDN", AmountIn), IntegerEntry("AmountOut_WAVES", AmountOut), IntegerEntry((callerId + "_Last_AmountOut_Waves"), AmountOut)], AmountOut)
17+ }
2018
2119
2220
2321 @Callable(i)
24-func swapToUSDN () = if (if ((size(i.payments) != 1))
25- then true
26- else (i.payments[0].amount == 0))
27- then throw("1 payment has to be attached")
28- else {
29- let AmountIn = i.payments[0].amount
30- let AmountOut = ((AmountIn * getWavesNewPrice()) / 100)
31- $Tuple2([IntegerEntry("AmountIn_Waves", AmountIn), IntegerEntry("AmountOut_USDN", AmountOut)], AmountOut)
32- }
22+func swapToUSDN (wavesAmount,userAddress) = {
23+ let AmountOut = (wavesAmount * getWavesNewPrice())
24+ $Tuple2([ScriptTransfer(addressFromStringValue(userAddress), AmountOut, usdnId), IntegerEntry("AmountIn_Waves", wavesAmount), IntegerEntry("AmountOut_USDN", AmountOut)], AmountOut)
25+ }
3326
3427
3528 @Verifier(tx)
3629 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
3730

github/deemru/w8io/169f3d6 
27.24 ms