tx · AKshftvMpydcDpNp4H8nieFEsWTbstjktnroPRfQosF9 3N6qtbZbSPVcvJ1pk87e9ahdsZTjHN8e5mL: -0.01000000 Waves 2021.09.09 23:42 [1696005] smart account 3N6qtbZbSPVcvJ1pk87e9ahdsZTjHN8e5mL > SELF 0.00000000 Waves
{ "type": 13, "id": "AKshftvMpydcDpNp4H8nieFEsWTbstjktnroPRfQosF9", "fee": 1000000, "feeAssetId": null, "timestamp": 1631220162832, "version": 2, "chainId": 84, "sender": "3N6qtbZbSPVcvJ1pk87e9ahdsZTjHN8e5mL", "senderPublicKey": "EYAKsFBespqQveBrfmX29rsehBJrSwQ3B6yN4ADyw8Kx", "proofs": [ "4uK1T53qdaKD92SD877vmMj8q25xAySYQQg532AKdwbazMVHkjnQZFi7q6WkCn57J61DHGjEWEU94sE1dEaF2rWh" ], "script": "base64:AAIFAAAAAAAAA+EIAhIICgYYGBEYAgEaFQoCYTESD2NoZWNrUG9zc2liaWx0eRoPCgJhMhIJcG10QW1vdW50GhgKAmEzEhJtaW5BbW91bnRUb1JlY2VpdmUaEAoCYTQSCmV4Y2hhbmdlcnMaFAoCYTUSDmV4Y2hhbmdlcnNUeXBlGhcKAmE2EhFyb3V0aW5nQXNzZXRzS2V5cxoQCgJhNxIKY29tbWlzc2lvbhoeCgJhOBIYY29tbWlzc2lvblNjYWxlRGVsaW1pdGVyGhMKAmE5Eg1kQXBwMVRva2VuUGF5GhMKAmIxEg1kQXBwMVRva2VuR2V0GhMKAmIyEg1kQXBwMlRva2VuUGF5GhMKAmIzEg1kQXBwMlRva2VuR2V0GhMKAmI0Eg1nZXRGcm9tMVRyYWRlGhoKAmI1EhRnZXRGcm9tMVRyYWRlV2l0aEZlZRoTCgJiNhINZ2V0RnJvbTJUcmFkZRoaCgJiNxIUZ2V0RnJvbTJUcmFkZVdpdGhGZWUaBwoCYjgSAWkaCgoCYjkSBGFyZ3MaFAoCYzESDnJlY2VpdmVBc3NldElkGhEKAmMyEgskdDAyMDE4MjA5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AAACBQAAAAJlNQAAAAAAAAAAAgMJAAAAAAAAAgUAAAACZTYAAAAAAAAAAAMFAAAAAmYxBAAAAAJmMgkBAAAAAmM1AAAAAgUAAAACZjEJAAGRAAAAAgUAAAACZTUAAAAAAAAAAAMJAAACAAAAAQIAAAASTGlzdCBzaXplIGV4Y2VlZCAzBAAAAAJjOQgFAAAAAmU0AAAAAl8xBAAAAAJkMQgFAAAAAmU0AAAAAl8yBAAAAAJkMggFAAAAAmU0AAAAAl8zBAAAAAJmMwkAA/AAAAACBQAAAAR0aGlzBQAAAAJjMQMDCQAAAAAAAAIFAAAAAmM5BQAAAAJjNAkAAGcAAAACBQAAAAJmMwUAAAACYTMHCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAJiOAAAAAZjYWxsZXIFAAAAAmYzBQAAAAJjMQUAAAADbmlsCQAAAgAAAAECAAAAPnJvdXRpbmcgIT0gcm91dGluZ1NpemUgb3IgYW1vdW50VG9SZWNpZXZlIDwgbWluQW1vdW50VG9SZWNlaXZlAAAAACPqkoU=", "height": 1696005, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9nRz3prEFDzBQh5ucKzU9hKDdxb8cFGJsRjtacjsum3 Next: CVKTmB7SMgkegv9a3hmMDyC4AV27Ambe2BEhXZ3sNw8X Diff:
Old | New | Differences | |
---|---|---|---|
13 | 13 | let getFrom2Trade = fraction(dApp2TokenGet, getFrom1TradeWithFee, (getFrom1TradeWithFee + dApp2TokenPay)) | |
14 | 14 | let getFrom2TradeWithFee = fraction(getFrom2Trade, (commissionScaleDelimiter - commission), commissionScaleDelimiter) | |
15 | 15 | if (true) | |
16 | - | then throw(toString( | |
16 | + | then throw(toString(dApp1TokenGet)) | |
17 | 17 | else if ((getFrom2TradeWithFee >= minAmountToReceive)) | |
18 | 18 | then true | |
19 | 19 | else false |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func checkPossibilty (pmtAmount,minAmountToReceive,exchangers,exchangersType,routingAssetsKeys) = { | |
5 | 5 | let commission = 3000 | |
6 | 6 | let commissionScaleDelimiter = 1000000 | |
7 | 7 | let dApp1TokenPay = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[0]) | |
8 | 8 | let dApp1TokenGet = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[1]) | |
9 | 9 | let dApp2TokenPay = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[2]) | |
10 | 10 | let dApp2TokenGet = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[3]) | |
11 | 11 | let getFrom1Trade = fraction(dApp1TokenGet, pmtAmount, (pmtAmount + dApp1TokenPay)) | |
12 | 12 | let getFrom1TradeWithFee = fraction(getFrom1Trade, (commissionScaleDelimiter - commission), commissionScaleDelimiter) | |
13 | 13 | let getFrom2Trade = fraction(dApp2TokenGet, getFrom1TradeWithFee, (getFrom1TradeWithFee + dApp2TokenPay)) | |
14 | 14 | let getFrom2TradeWithFee = fraction(getFrom2Trade, (commissionScaleDelimiter - commission), commissionScaleDelimiter) | |
15 | 15 | if (true) | |
16 | - | then throw(toString( | |
16 | + | then throw(toString(dApp1TokenGet)) | |
17 | 17 | else if ((getFrom2TradeWithFee >= minAmountToReceive)) | |
18 | 18 | then true | |
19 | 19 | else false | |
20 | 20 | } | |
21 | 21 | ||
22 | 22 | ||
23 | 23 | @Callable(i) | |
24 | 24 | func routingTrade (exchangers,exchangersType,args,routingAssetsKeys,receiveAssetId,minAmountToReceive) = { | |
25 | 25 | let $t020182092 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
26 | 26 | let pmtAmount = $t020182092._1 | |
27 | 27 | let pmtAssetId = $t020182092._2 | |
28 | 28 | if (!(checkPossibilty(pmtAmount, minAmountToReceive, exchangers, exchangersType, routingAssetsKeys))) | |
29 | 29 | then throw("Check transaction possibilty: declined") | |
30 | 30 | else { | |
31 | 31 | let routingSize = size(exchangers) | |
32 | 32 | func exchangeFold (accumulated,exchanger) = { | |
33 | 33 | let $t023822445 = accumulated | |
34 | 34 | let exchangeCounter = $t023822445._1 | |
35 | 35 | let amountsWithFee = $t023822445._2 | |
36 | 36 | let assetsIdSend = $t023822445._3 | |
37 | 37 | if ((exchangeCounter == 0)) | |
38 | 38 | then { | |
39 | 39 | let exchangerAddress = addressFromStringValue(exchanger) | |
40 | 40 | let inv = invoke(exchangerAddress, "exchange", [args[exchangeCounter]], [AttachedPayment(pmtAssetId, pmtAmount)]) | |
41 | 41 | if ((inv == inv)) | |
42 | 42 | then match inv { | |
43 | 43 | case inv: (Int, ByteVector) => | |
44 | 44 | let $t027802818 = inv | |
45 | 45 | let amountWithFee = $t027802818._1 | |
46 | 46 | let assetIdSend = $t027802818._2 | |
47 | 47 | $Tuple3((exchangeCounter + 1), amountWithFee, assetIdSend) | |
48 | 48 | case _ => | |
49 | 49 | throw("Incorrect invoke result: expected amountWithFee and assetsIdSend") | |
50 | 50 | } | |
51 | 51 | else throw("Strict value is not equal to itself.") | |
52 | 52 | } | |
53 | 53 | else if (if ((exchangeCounter > 0)) | |
54 | 54 | then (routingSize > exchangeCounter) | |
55 | 55 | else false) | |
56 | 56 | then { | |
57 | 57 | let exchangerAddress = addressFromStringValue(exchanger) | |
58 | 58 | let $t031643230 = $Tuple2(assetsIdSend, amountsWithFee) | |
59 | 59 | let pmtAssetIdRout = $t031643230._1 | |
60 | 60 | let pmtAmountRout = $t031643230._2 | |
61 | 61 | let inv = invoke(exchangerAddress, "exchange", [args[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)]) | |
62 | 62 | if ((inv == inv)) | |
63 | 63 | then match inv { | |
64 | 64 | case inv: (Int, ByteVector) => | |
65 | 65 | let $t034793517 = inv | |
66 | 66 | let amountWithFee = $t034793517._1 | |
67 | 67 | let assetIdSend = $t034793517._2 | |
68 | 68 | $Tuple3((exchangeCounter + 1), amountWithFee, assetIdSend) | |
69 | 69 | case _ => | |
70 | 70 | throw("Incorrect invoke result: expected amountWithFee and assetsIdSend") | |
71 | 71 | } | |
72 | 72 | else throw("Strict value is not equal to itself.") | |
73 | 73 | } | |
74 | 74 | else accumulated | |
75 | 75 | } | |
76 | 76 | ||
77 | 77 | let $t037553856 = { | |
78 | 78 | let $list38073856 = exchangers | |
79 | 79 | let $size38073856 = size($list38073856) | |
80 | 80 | let $acc038073856 = $Tuple3(0, 0, base58'') | |
81 | 81 | if (($size38073856 == 0)) | |
82 | 82 | then $acc038073856 | |
83 | 83 | else { | |
84 | 84 | let $acc138073856 = exchangeFold($acc038073856, $list38073856[0]) | |
85 | 85 | if (($size38073856 == 1)) | |
86 | 86 | then $acc138073856 | |
87 | 87 | else { | |
88 | 88 | let $acc238073856 = exchangeFold($acc138073856, $list38073856[1]) | |
89 | 89 | if (($size38073856 == 2)) | |
90 | 90 | then $acc238073856 | |
91 | 91 | else { | |
92 | 92 | let $acc338073856 = exchangeFold($acc238073856, $list38073856[2]) | |
93 | 93 | if (($size38073856 == 3)) | |
94 | 94 | then $acc338073856 | |
95 | 95 | else { | |
96 | 96 | let $acc438073856 = exchangeFold($acc338073856, $list38073856[3]) | |
97 | 97 | throw("List size exceed 3") | |
98 | 98 | } | |
99 | 99 | } | |
100 | 100 | } | |
101 | 101 | } | |
102 | 102 | } | |
103 | 103 | let exchangeCounter = $t037553856._1 | |
104 | 104 | let amountsWithFee = $t037553856._2 | |
105 | 105 | let assetsIdSend = $t037553856._3 | |
106 | 106 | let amountToRecieve = assetBalance(this, receiveAssetId) | |
107 | 107 | if (if ((exchangeCounter == routingSize)) | |
108 | 108 | then (amountToRecieve >= minAmountToReceive) | |
109 | 109 | else false) | |
110 | 110 | then [ScriptTransfer(i.caller, amountToRecieve, receiveAssetId)] | |
111 | 111 | else throw("routing != routingSize or amountToRecieve < minAmountToReceive") | |
112 | 112 | } | |
113 | 113 | } | |
114 | 114 | ||
115 | 115 |
github/deemru/w8io/026f985 44.95 ms ◑