tx · CdZYon4JJbf1r9uhhso9PRSwSiUCNPGZ4aFQtib4u91i

3N6qtbZbSPVcvJ1pk87e9ahdsZTjHN8e5mL:  -0.01000000 Waves

2021.09.12 17:58 [1699982] smart account 3N6qtbZbSPVcvJ1pk87e9ahdsZTjHN8e5mL > SELF 0.00000000 Waves

{ "type": 13, "id": "CdZYon4JJbf1r9uhhso9PRSwSiUCNPGZ4aFQtib4u91i", "fee": 1000000, "feeAssetId": null, "timestamp": 1631458766571, "version": 2, "chainId": 84, "sender": "3N6qtbZbSPVcvJ1pk87e9ahdsZTjHN8e5mL", "senderPublicKey": "EYAKsFBespqQveBrfmX29rsehBJrSwQ3B6yN4ADyw8Kx", "proofs": [ "5w9p4XXj9qiCknGQEWGUdjVRYRnkqtL2c1MLbiPnAdxUDLmGRuvsDgrV9d1rgmoduajpsnU5K8qTpjDbWosXRFjt" ], "script": "base64:AAIFAAAAAAAAAA0IAhIJCgcYGBERGAIBAAAAAQEAAAAPY2hlY2tQb3NzaWJpbHR5AAAABQAAAAlwbXRBbW91bnQAAAASbWluQW1vdW50VG9SZWNlaXZlAAAACmV4Y2hhbmdlcnMAAAAOZXhjaGFuZ2Vyc1R5cGUAAAARcm91dGluZ0Fzc2V0c0tleXMEAAAACmNvbW1pc3Npb24AAAAAAAAAC7gEAAAAGGNvbW1pc3Npb25TY2FsZURlbGltaXRlcgAAAAAAAA9CQAQAAAANZEFwcDFUb2tlblBheQkBAAAAEUBleHRyTmF0aXZlKDEwNTApAAAAAgkBAAAAEUBleHRyTmF0aXZlKDEwNjIpAAAAAQkAAZEAAAACBQAAAApleGNoYW5nZXJzAAAAAAAAAAAACQABkQAAAAIFAAAAEXJvdXRpbmdBc3NldHNLZXlzAAAAAAAAAAAABAAAAA1kQXBwMVRva2VuR2V0CQEAAAARQGV4dHJOYXRpdmUoMTA1MCkAAAACCQEAAAARQGV4dHJOYXRpdmUoMTA2MikAAAABCQABkQAAAAIFAAAACmV4Y2hhbmdlcnMAAAAAAAAAA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WNpZXZlBQAAABJtaW5BbW91bnRUb1JlY2VpdmUHCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFpAAAABmNhbGxlcgUAAAAPYW1vdW50VG9SZWNpZXZlBQAAAA5yZWNlaXZlQXNzZXRJZAUAAAADbmlsCQAAAgAAAAECAAAAPnJvdXRpbmcgIT0gcm91dGluZ1NpemUgb3IgYW1vdW50VG9SZWNpZXZlIDwgbWluQW1vdW50VG9SZWNlaXZlAAAAADgfK+8=", "height": 1699982, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FY5V8rz5rLaMr94r5G68yKVrdwpwiE5sYjHMP9c1Jf6W Next: EoLSyHsy6moCym4RV4mYKg7iTAZCuhgXRVzQYzRvsJBZ Diff:
OldNewDifferences
1919
2020
2121 @Callable(i)
22-func routingTrade (exchangers,exchangersType,args,routingAssetsKeys,receiveAssetId,minAmountToReceive) = {
23- let $t019642038 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
24- let pmtAmount = $t019642038._1
25- let pmtAssetId = $t019642038._2
26- if (!(checkPossibilty(pmtAmount, minAmountToReceive, exchangers, exchangersType, routingAssetsKeys)))
27- then throw("Check transaction possibilty: declined")
28- else {
29- let routingSize = size(exchangers)
30- func exchangeFold (accumulated,exchanger) = {
31- let $t023282391 = accumulated
32- let exchangeCounter = $t023282391._1
33- let amountsWithFee = $t023282391._2
34- let assetsIdSend = $t023282391._3
35- if ((exchangeCounter == 0))
36- then {
37- let exchangerAddress = addressFromStringValue(exchanger)
38- let inv = invoke(exchangerAddress, "exchange", [args[exchangeCounter]], [AttachedPayment(pmtAssetId, pmtAmount)])
39- if ((inv == inv))
40- then match inv {
41- case inv: (Int, ByteVector) =>
42- let $t027262764 = inv
43- let amountWithFee = $t027262764._1
44- let assetIdSend = $t027262764._2
45- $Tuple3((exchangeCounter + 1), amountWithFee, assetIdSend)
46- case _ =>
47- throw("Incorrect invoke result: expected amountWithFee and assetsIdSend")
48- }
49- else throw("Strict value is not equal to itself.")
22+func routingTrade (exchangers,exchangersType,args1,args2,routingAssetsKeys,receiveAssetId,minAmountToReceive) = {
23+ let $t020672300 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
24+ let pmtAmount = $t020672300._1
25+ let pmtAssetId = $t020672300._2
26+ let routingSize = size(exchangers)
27+ func exchangeFold (accumulated,exchanger) = {
28+ let $t024342497 = accumulated
29+ let exchangeCounter = $t024342497._1
30+ let amountsWithFee = $t024342497._2
31+ let assetsIdSend = $t024342497._3
32+ if ((exchangeCounter == 0))
33+ then {
34+ let exchangerAddress = addressFromStringValue(exchanger)
35+ let inv = if ((exchangersType[exchangeCounter] == "cpmm"))
36+ then invoke(exchangerAddress, "exchange", [args1[exchangeCounter]], [AttachedPayment(pmtAssetId, pmtAmount)])
37+ else if ((exchangersType[exchangeCounter] == "flat"))
38+ then invoke(exchangerAddress, "exchange", [args1[exchangeCounter], args2[exchangeCounter]], [AttachedPayment(pmtAssetId, pmtAmount)])
39+ else throw("Incorrect exchange type")
40+ if ((inv == inv))
41+ then match inv {
42+ case inv: (Int, ByteVector) =>
43+ let $t031933231 = inv
44+ let amountWithFee = $t031933231._1
45+ let assetIdSend = $t031933231._2
46+ $Tuple3((exchangeCounter + 1), amountWithFee, assetIdSend)
47+ case _ =>
48+ throw("Incorrect invoke result: expected amountWithFee and assetsIdSend")
49+ }
50+ else throw("Strict value is not equal to itself.")
51+ }
52+ else if (if ((exchangeCounter > 0))
53+ then (routingSize > exchangeCounter)
54+ else false)
55+ then {
56+ let exchangerAddress = addressFromStringValue(exchanger)
57+ let $t035773643 = $Tuple2(assetsIdSend, amountsWithFee)
58+ let pmtAssetIdRout = $t035773643._1
59+ let pmtAmountRout = $t035773643._2
60+ let inv = if ((exchangersType[exchangeCounter] == "cpmm"))
61+ then invoke(exchangerAddress, "exchange", [args1[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
62+ else if ((exchangersType[exchangeCounter] == "flat"))
63+ then invoke(exchangerAddress, "exchange", [args1[exchangeCounter], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
64+ else throw("Incorrect exchange type")
65+ if ((inv == inv))
66+ then match inv {
67+ case inv: (Int, ByteVector) =>
68+ let $t042484286 = inv
69+ let amountWithFee = $t042484286._1
70+ let assetIdSend = $t042484286._2
71+ $Tuple3((exchangeCounter + 1), amountWithFee, assetIdSend)
72+ case _ =>
73+ throw("Incorrect invoke result: expected amountWithFee and assetsIdSend")
5074 }
51- else if (if ((exchangeCounter > 0))
52- then (routingSize > exchangeCounter)
53- else false)
54- then {
55- let exchangerAddress = addressFromStringValue(exchanger)
56- let $t031103176 = $Tuple2(assetsIdSend, amountsWithFee)
57- let pmtAssetIdRout = $t031103176._1
58- let pmtAmountRout = $t031103176._2
59- let inv = invoke(exchangerAddress, "exchange", [args[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
60- if ((inv == inv))
61- then match inv {
62- case inv: (Int, ByteVector) =>
63- let $t034253463 = inv
64- let amountWithFee = $t034253463._1
65- let assetIdSend = $t034253463._2
66- $Tuple3((exchangeCounter + 1), amountWithFee, assetIdSend)
67- case _ =>
68- throw("Incorrect invoke result: expected amountWithFee and assetsIdSend")
69- }
70- else throw("Strict value is not equal to itself.")
71- }
72- else accumulated
73- }
75+ else throw("Strict value is not equal to itself.")
76+ }
77+ else accumulated
78+ }
7479
75- let $t037013802 = {
76- let $list37533802 = exchangers
77- let $size37533802 = size($list37533802)
78- let $acc037533802 = $Tuple3(0, 0, base58'')
79- if (($size37533802 == 0))
80- then $acc037533802
80+ let $t045244625 = {
81+ let $list45764625 = exchangers
82+ let $size45764625 = size($list45764625)
83+ let $acc045764625 = $Tuple3(0, 0, base58'')
84+ if (($size45764625 == 0))
85+ then $acc045764625
86+ else {
87+ let $acc145764625 = exchangeFold($acc045764625, $list45764625[0])
88+ if (($size45764625 == 1))
89+ then $acc145764625
8190 else {
82- let $acc137533802 = exchangeFold($acc037533802, $list37533802[0])
83- if (($size37533802 == 1))
84- then $acc137533802
91+ let $acc245764625 = exchangeFold($acc145764625, $list45764625[1])
92+ if (($size45764625 == 2))
93+ then $acc245764625
8594 else {
86- let $acc237533802 = exchangeFold($acc137533802, $list37533802[1])
87- if (($size37533802 == 2))
88- then $acc237533802
95+ let $acc345764625 = exchangeFold($acc245764625, $list45764625[2])
96+ if (($size45764625 == 3))
97+ then $acc345764625
8998 else {
90- let $acc337533802 = exchangeFold($acc237533802, $list37533802[2])
91- if (($size37533802 == 3))
92- then $acc337533802
93- else {
94- let $acc437533802 = exchangeFold($acc337533802, $list37533802[3])
95- throw("List size exceed 3")
96- }
99+ let $acc445764625 = exchangeFold($acc345764625, $list45764625[3])
100+ throw("List size exceed 3")
97101 }
98102 }
99103 }
100104 }
101- let exchangeCounter = $t037013802._1
102- let amountsWithFee = $t037013802._2
103- let assetsIdSend = $t037013802._3
104- let amountToRecieve = assetBalance(this, receiveAssetId)
105- if (if ((exchangeCounter == routingSize))
106- then (amountToRecieve >= minAmountToReceive)
107- else false)
108- then [ScriptTransfer(i.caller, amountToRecieve, receiveAssetId)]
109- else throw("routing != routingSize or amountToRecieve < minAmountToReceive")
110- }
105+ }
106+ let exchangeCounter = $t045244625._1
107+ let amountsWithFee = $t045244625._2
108+ let assetsIdSend = $t045244625._3
109+ let amountToRecieve = assetBalance(this, receiveAssetId)
110+ if (if ((exchangeCounter == routingSize))
111+ then (amountToRecieve >= minAmountToReceive)
112+ else false)
113+ then [ScriptTransfer(i.caller, amountToRecieve, receiveAssetId)]
114+ else throw("routing != routingSize or amountToRecieve < minAmountToReceive")
111115 }
112116
113117
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 func checkPossibilty (pmtAmount,minAmountToReceive,exchangers,exchangersType,routingAssetsKeys) = {
55 let commission = 3000
66 let commissionScaleDelimiter = 1000000
77 let dApp1TokenPay = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[0])
88 let dApp1TokenGet = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[1])
99 let dApp2TokenPay = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[2])
1010 let dApp2TokenGet = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[3])
1111 let getFrom1Trade = fraction(dApp1TokenGet, pmtAmount, (pmtAmount + dApp1TokenPay))
1212 let getFrom1TradeWithFee = fraction(getFrom1Trade, (commissionScaleDelimiter - commission), commissionScaleDelimiter)
1313 let getFrom2Trade = fraction(dApp2TokenGet, getFrom1TradeWithFee, (getFrom1TradeWithFee + dApp2TokenPay))
1414 let getFrom2TradeWithFee = fraction(getFrom2Trade, (commissionScaleDelimiter - commission), commissionScaleDelimiter)
1515 if ((getFrom2TradeWithFee >= minAmountToReceive))
1616 then true
1717 else false
1818 }
1919
2020
2121 @Callable(i)
22-func routingTrade (exchangers,exchangersType,args,routingAssetsKeys,receiveAssetId,minAmountToReceive) = {
23- let $t019642038 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
24- let pmtAmount = $t019642038._1
25- let pmtAssetId = $t019642038._2
26- if (!(checkPossibilty(pmtAmount, minAmountToReceive, exchangers, exchangersType, routingAssetsKeys)))
27- then throw("Check transaction possibilty: declined")
28- else {
29- let routingSize = size(exchangers)
30- func exchangeFold (accumulated,exchanger) = {
31- let $t023282391 = accumulated
32- let exchangeCounter = $t023282391._1
33- let amountsWithFee = $t023282391._2
34- let assetsIdSend = $t023282391._3
35- if ((exchangeCounter == 0))
36- then {
37- let exchangerAddress = addressFromStringValue(exchanger)
38- let inv = invoke(exchangerAddress, "exchange", [args[exchangeCounter]], [AttachedPayment(pmtAssetId, pmtAmount)])
39- if ((inv == inv))
40- then match inv {
41- case inv: (Int, ByteVector) =>
42- let $t027262764 = inv
43- let amountWithFee = $t027262764._1
44- let assetIdSend = $t027262764._2
45- $Tuple3((exchangeCounter + 1), amountWithFee, assetIdSend)
46- case _ =>
47- throw("Incorrect invoke result: expected amountWithFee and assetsIdSend")
48- }
49- else throw("Strict value is not equal to itself.")
22+func routingTrade (exchangers,exchangersType,args1,args2,routingAssetsKeys,receiveAssetId,minAmountToReceive) = {
23+ let $t020672300 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
24+ let pmtAmount = $t020672300._1
25+ let pmtAssetId = $t020672300._2
26+ let routingSize = size(exchangers)
27+ func exchangeFold (accumulated,exchanger) = {
28+ let $t024342497 = accumulated
29+ let exchangeCounter = $t024342497._1
30+ let amountsWithFee = $t024342497._2
31+ let assetsIdSend = $t024342497._3
32+ if ((exchangeCounter == 0))
33+ then {
34+ let exchangerAddress = addressFromStringValue(exchanger)
35+ let inv = if ((exchangersType[exchangeCounter] == "cpmm"))
36+ then invoke(exchangerAddress, "exchange", [args1[exchangeCounter]], [AttachedPayment(pmtAssetId, pmtAmount)])
37+ else if ((exchangersType[exchangeCounter] == "flat"))
38+ then invoke(exchangerAddress, "exchange", [args1[exchangeCounter], args2[exchangeCounter]], [AttachedPayment(pmtAssetId, pmtAmount)])
39+ else throw("Incorrect exchange type")
40+ if ((inv == inv))
41+ then match inv {
42+ case inv: (Int, ByteVector) =>
43+ let $t031933231 = inv
44+ let amountWithFee = $t031933231._1
45+ let assetIdSend = $t031933231._2
46+ $Tuple3((exchangeCounter + 1), amountWithFee, assetIdSend)
47+ case _ =>
48+ throw("Incorrect invoke result: expected amountWithFee and assetsIdSend")
49+ }
50+ else throw("Strict value is not equal to itself.")
51+ }
52+ else if (if ((exchangeCounter > 0))
53+ then (routingSize > exchangeCounter)
54+ else false)
55+ then {
56+ let exchangerAddress = addressFromStringValue(exchanger)
57+ let $t035773643 = $Tuple2(assetsIdSend, amountsWithFee)
58+ let pmtAssetIdRout = $t035773643._1
59+ let pmtAmountRout = $t035773643._2
60+ let inv = if ((exchangersType[exchangeCounter] == "cpmm"))
61+ then invoke(exchangerAddress, "exchange", [args1[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
62+ else if ((exchangersType[exchangeCounter] == "flat"))
63+ then invoke(exchangerAddress, "exchange", [args1[exchangeCounter], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
64+ else throw("Incorrect exchange type")
65+ if ((inv == inv))
66+ then match inv {
67+ case inv: (Int, ByteVector) =>
68+ let $t042484286 = inv
69+ let amountWithFee = $t042484286._1
70+ let assetIdSend = $t042484286._2
71+ $Tuple3((exchangeCounter + 1), amountWithFee, assetIdSend)
72+ case _ =>
73+ throw("Incorrect invoke result: expected amountWithFee and assetsIdSend")
5074 }
51- else if (if ((exchangeCounter > 0))
52- then (routingSize > exchangeCounter)
53- else false)
54- then {
55- let exchangerAddress = addressFromStringValue(exchanger)
56- let $t031103176 = $Tuple2(assetsIdSend, amountsWithFee)
57- let pmtAssetIdRout = $t031103176._1
58- let pmtAmountRout = $t031103176._2
59- let inv = invoke(exchangerAddress, "exchange", [args[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
60- if ((inv == inv))
61- then match inv {
62- case inv: (Int, ByteVector) =>
63- let $t034253463 = inv
64- let amountWithFee = $t034253463._1
65- let assetIdSend = $t034253463._2
66- $Tuple3((exchangeCounter + 1), amountWithFee, assetIdSend)
67- case _ =>
68- throw("Incorrect invoke result: expected amountWithFee and assetsIdSend")
69- }
70- else throw("Strict value is not equal to itself.")
71- }
72- else accumulated
73- }
75+ else throw("Strict value is not equal to itself.")
76+ }
77+ else accumulated
78+ }
7479
75- let $t037013802 = {
76- let $list37533802 = exchangers
77- let $size37533802 = size($list37533802)
78- let $acc037533802 = $Tuple3(0, 0, base58'')
79- if (($size37533802 == 0))
80- then $acc037533802
80+ let $t045244625 = {
81+ let $list45764625 = exchangers
82+ let $size45764625 = size($list45764625)
83+ let $acc045764625 = $Tuple3(0, 0, base58'')
84+ if (($size45764625 == 0))
85+ then $acc045764625
86+ else {
87+ let $acc145764625 = exchangeFold($acc045764625, $list45764625[0])
88+ if (($size45764625 == 1))
89+ then $acc145764625
8190 else {
82- let $acc137533802 = exchangeFold($acc037533802, $list37533802[0])
83- if (($size37533802 == 1))
84- then $acc137533802
91+ let $acc245764625 = exchangeFold($acc145764625, $list45764625[1])
92+ if (($size45764625 == 2))
93+ then $acc245764625
8594 else {
86- let $acc237533802 = exchangeFold($acc137533802, $list37533802[1])
87- if (($size37533802 == 2))
88- then $acc237533802
95+ let $acc345764625 = exchangeFold($acc245764625, $list45764625[2])
96+ if (($size45764625 == 3))
97+ then $acc345764625
8998 else {
90- let $acc337533802 = exchangeFold($acc237533802, $list37533802[2])
91- if (($size37533802 == 3))
92- then $acc337533802
93- else {
94- let $acc437533802 = exchangeFold($acc337533802, $list37533802[3])
95- throw("List size exceed 3")
96- }
99+ let $acc445764625 = exchangeFold($acc345764625, $list45764625[3])
100+ throw("List size exceed 3")
97101 }
98102 }
99103 }
100104 }
101- let exchangeCounter = $t037013802._1
102- let amountsWithFee = $t037013802._2
103- let assetsIdSend = $t037013802._3
104- let amountToRecieve = assetBalance(this, receiveAssetId)
105- if (if ((exchangeCounter == routingSize))
106- then (amountToRecieve >= minAmountToReceive)
107- else false)
108- then [ScriptTransfer(i.caller, amountToRecieve, receiveAssetId)]
109- else throw("routing != routingSize or amountToRecieve < minAmountToReceive")
110- }
105+ }
106+ let exchangeCounter = $t045244625._1
107+ let amountsWithFee = $t045244625._2
108+ let assetsIdSend = $t045244625._3
109+ let amountToRecieve = assetBalance(this, receiveAssetId)
110+ if (if ((exchangeCounter == routingSize))
111+ then (amountToRecieve >= minAmountToReceive)
112+ else false)
113+ then [ScriptTransfer(i.caller, amountToRecieve, receiveAssetId)]
114+ else throw("routing != routingSize or amountToRecieve < minAmountToReceive")
111115 }
112116
113117

github/deemru/w8io/026f985 
37.61 ms