tx · EoLSyHsy6moCym4RV4mYKg7iTAZCuhgXRVzQYzRvsJBZ 3N6qtbZbSPVcvJ1pk87e9ahdsZTjHN8e5mL: -0.01000000 Waves 2021.09.12 19:22 [1700066] smart account 3N6qtbZbSPVcvJ1pk87e9ahdsZTjHN8e5mL > SELF 0.00000000 Waves
{ "type": 13, "id": "EoLSyHsy6moCym4RV4mYKg7iTAZCuhgXRVzQYzRvsJBZ", "fee": 1000000, "feeAssetId": null, "timestamp": 1631463779883, "version": 2, "chainId": 84, "sender": "3N6qtbZbSPVcvJ1pk87e9ahdsZTjHN8e5mL", "senderPublicKey": "EYAKsFBespqQveBrfmX29rsehBJrSwQ3B6yN4ADyw8Kx", "proofs": [ "8Rn24ZViXQo6rxTXH4owhNcrrCZ67q3Rh8UHfyZGMxN3wU3RYra1X23c8Ms6cN7MhJ4zWShye344hiQQi3UrbVA" ], "script": "base64:AAIFAAAAAAAAAA0IAhIJCgcYGBERGAIBAAAACQAAAAAHZGlnaXRzOAAAAAAAAAAACAAAAAAGc2NhbGU4AAAAAAAF9eEAAAAAAAdzY2FsZTEyAAAAAOjUpRAAAAAAAAVhbHBoYQAAAAAAAAAAMgAAAAALYWxwaGFEaWdpdHMAAAAAAAAAAAIAAAAABGJldGEAAAAAAAK954ABAAAACHNrZXduZXNzAAAAAgAAAAF4AAAAAXkJAABpAAAAAgkAAGkAAAACCQAAZAAAAAIJAABrAAAAAwUAAAAHc2NhbGUxMgUAAAABeAUAAAABeQkAAGsAAAADBQAAAAdzY2FsZTEyBQAAAAF5BQAAAAF4AAAAAAAAAAACAAAAAAAAACcQAQAAAA1pbnZhcmlhbnRDYWxjAAAAAgAAAAF4AAAAAXkEAAAAAnNrCQEAAAAIc2tld25lc3MAAAACBQAAAAF4BQAAAAF5CQAAZAAAAAIJAABrAAAAAwkAAGQAAAACBQAAAAF4BQAAAAF5BQAAAAZzY2FsZTgJAABsAAAABgUAAAACc2sFAAAAB2RpZ2l0czgFAAAABWFscGhhBQAAAAthb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bmdlQ291bnRlcgUAAAALcm91dGluZ1NpemUJAABnAAAAAgUAAAAPYW1vdW50VG9SZWNpZXZlBQAAABJtaW5BbW91bnRUb1JlY2VpdmUHCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFpAAAABmNhbGxlcgUAAAAPYW1vdW50VG9SZWNpZXZlBQAAAA5yZWNlaXZlQXNzZXRJZAUAAAADbmlsCQAAAgAAAAECAAAAPnJvdXRpbmcgIT0gcm91dGluZ1NpemUgb3IgYW1vdW50VG9SZWNpZXZlIDwgbWluQW1vdW50VG9SZWNlaXZlAAAAAFqaUq8=", "height": 1700066, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: CdZYon4JJbf1r9uhhso9PRSwSiUCNPGZ4aFQtib4u91i Next: 5P6aTYNSWLn5uR8Kfe2bFgf3t8qgtJMmgaixhRfNCX7w Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | func checkPossibilty (pmtAmount,minAmountToReceive,exchangers,exchangersType,routingAssetsKeys) = { | |
4 | + | let digits8 = 8 | |
5 | + | ||
6 | + | let scale8 = 100000000 | |
7 | + | ||
8 | + | let scale12 = 1000000000000 | |
9 | + | ||
10 | + | let alpha = 50 | |
11 | + | ||
12 | + | let alphaDigits = 2 | |
13 | + | ||
14 | + | let beta = 46000000 | |
15 | + | ||
16 | + | func skewness (x,y) = (((fraction(scale12, x, y) + fraction(scale12, y, x)) / 2) / 10000) | |
17 | + | ||
18 | + | ||
19 | + | func invariantCalc (x,y) = { | |
20 | + | let sk = skewness(x, y) | |
21 | + | (fraction((x + y), scale8, pow(sk, digits8, alpha, alphaDigits, digits8, CEILING)) + (2 * fraction(pow(fraction(x, y, scale8), 0, 5, 1, (digits8 / 2), DOWN), pow((sk - beta), digits8, alpha, alphaDigits, digits8, DOWN), scale8))) | |
22 | + | } | |
23 | + | ||
24 | + | ||
25 | + | func checkPossibilty (pmtAmount,minAmountToReceive,exchangers,exchangersType,routingAssetsKeys,args1,args2) = { | |
5 | 26 | let commission = 3000 | |
6 | 27 | let commissionScaleDelimiter = 1000000 | |
7 | 28 | let dApp1TokenPay = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[0]) | |
8 | 29 | let dApp1TokenGet = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[1]) | |
9 | 30 | let dApp2TokenPay = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[2]) | |
10 | 31 | let dApp2TokenGet = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[3]) | |
11 | - | let getFrom1Trade = fraction(dApp1TokenGet, pmtAmount, (pmtAmount + dApp1TokenPay)) | |
12 | - | let getFrom1TradeWithFee = fraction(getFrom1Trade, (commissionScaleDelimiter - commission), commissionScaleDelimiter) | |
13 | - | let getFrom2Trade = fraction(dApp2TokenGet, getFrom1TradeWithFee, (getFrom1TradeWithFee + dApp2TokenPay)) | |
14 | - | let getFrom2TradeWithFee = fraction(getFrom2Trade, (commissionScaleDelimiter - commission), commissionScaleDelimiter) | |
32 | + | let getFrom1TradeWithFee = if ((exchangersType[0] == "cpmm")) | |
33 | + | then { | |
34 | + | let getFrom1Trade = fraction(dApp1TokenGet, pmtAmount, (pmtAmount + dApp1TokenPay)) | |
35 | + | fraction(getFrom1Trade, (commissionScaleDelimiter - commission), commissionScaleDelimiter) | |
36 | + | } | |
37 | + | else if ((exchangersType[0] == "flat")) | |
38 | + | then { | |
39 | + | let invariant = invariantCalc(dApp1TokenPay, dApp1TokenGet) | |
40 | + | let invariantNew = invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - args2[0])) | |
41 | + | args2[0] | |
42 | + | } | |
43 | + | else throw("Incorrect exchange type") | |
44 | + | let getFrom2TradeWithFee = if ((exchangersType[1] == "cpmm")) | |
45 | + | then { | |
46 | + | let getFrom2Trade = fraction(dApp2TokenGet, getFrom1TradeWithFee, (getFrom1TradeWithFee + dApp2TokenPay)) | |
47 | + | fraction(getFrom2Trade, (commissionScaleDelimiter - commission), commissionScaleDelimiter) | |
48 | + | } | |
49 | + | else if ((exchangersType[1] == "flat")) | |
50 | + | then { | |
51 | + | let invariant = invariantCalc(dApp2TokenPay, dApp2TokenGet) | |
52 | + | let invariantNew = invariantCalc((dApp2TokenPay + getFrom1TradeWithFee), (dApp2TokenGet - args2[1])) | |
53 | + | args2[1] | |
54 | + | } | |
55 | + | else throw("Incorrect exchange type") | |
15 | 56 | if ((getFrom2TradeWithFee >= minAmountToReceive)) | |
16 | 57 | then true | |
17 | 58 | else false | |
20 | 61 | ||
21 | 62 | @Callable(i) | |
22 | 63 | 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.") | |
64 | + | let $t034533527 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
65 | + | let pmtAmount = $t034533527._1 | |
66 | + | let pmtAssetId = $t034533527._2 | |
67 | + | if (!(checkPossibilty(pmtAmount, minAmountToReceive, exchangers, exchangersType, routingAssetsKeys, args1, args2))) | |
68 | + | then throw("Check transaction possibilty: declined") | |
69 | + | else { | |
70 | + | let routingSize = size(exchangers) | |
71 | + | func exchangeFold (accumulated,exchanger) = { | |
72 | + | let $t038263889 = accumulated | |
73 | + | let exchangeCounter = $t038263889._1 | |
74 | + | let amountsWithFee = $t038263889._2 | |
75 | + | let assetsIdSend = $t038263889._3 | |
76 | + | if ((exchangeCounter == 0)) | |
77 | + | then { | |
78 | + | let exchangerAddress = addressFromStringValue(exchanger) | |
79 | + | let inv = if ((exchangersType[exchangeCounter] == "cpmm")) | |
80 | + | then invoke(exchangerAddress, "exchange", [args1[exchangeCounter]], [AttachedPayment(pmtAssetId, pmtAmount)]) | |
81 | + | else if ((exchangersType[exchangeCounter] == "flat")) | |
82 | + | then invoke(exchangerAddress, "exchange", [args1[exchangeCounter], args2[exchangeCounter]], [AttachedPayment(pmtAssetId, pmtAmount)]) | |
83 | + | else throw("Incorrect exchange type") | |
84 | + | if ((inv == inv)) | |
85 | + | then match inv { | |
86 | + | case inv: (Int, ByteVector) => | |
87 | + | let $t045854623 = inv | |
88 | + | let amountWithFee = $t045854623._1 | |
89 | + | let assetIdSend = $t045854623._2 | |
90 | + | $Tuple3((exchangeCounter + 1), amountWithFee, assetIdSend) | |
91 | + | case _ => | |
92 | + | throw("Incorrect invoke result: expected amountWithFee and assetsIdSend") | |
93 | + | } | |
94 | + | else throw("Strict value is not equal to itself.") | |
95 | + | } | |
96 | + | else if (if ((exchangeCounter > 0)) | |
97 | + | then (routingSize > exchangeCounter) | |
98 | + | else false) | |
99 | + | then { | |
100 | + | let exchangerAddress = addressFromStringValue(exchanger) | |
101 | + | let $t049695035 = $Tuple2(assetsIdSend, amountsWithFee) | |
102 | + | let pmtAssetIdRout = $t049695035._1 | |
103 | + | let pmtAmountRout = $t049695035._2 | |
104 | + | let inv = if ((exchangersType[exchangeCounter] == "cpmm")) | |
105 | + | then invoke(exchangerAddress, "exchange", [args1[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)]) | |
106 | + | else if ((exchangersType[exchangeCounter] == "flat")) | |
107 | + | then invoke(exchangerAddress, "exchange", [args1[exchangeCounter], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)]) | |
108 | + | else throw("Incorrect exchange type") | |
109 | + | if ((inv == inv)) | |
110 | + | then match inv { | |
111 | + | case inv: (Int, ByteVector) => | |
112 | + | let $t056405678 = inv | |
113 | + | let amountWithFee = $t056405678._1 | |
114 | + | let assetIdSend = $t056405678._2 | |
115 | + | $Tuple3((exchangeCounter + 1), amountWithFee, assetIdSend) | |
116 | + | case _ => | |
117 | + | throw("Incorrect invoke result: expected amountWithFee and assetsIdSend") | |
118 | + | } | |
119 | + | else throw("Strict value is not equal to itself.") | |
120 | + | } | |
121 | + | else accumulated | |
51 | 122 | } | |
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") | |
74 | - | } | |
75 | - | else throw("Strict value is not equal to itself.") | |
76 | - | } | |
77 | - | else accumulated | |
78 | - | } | |
79 | 123 | ||
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 | |
124 | + | let $t059166017 = { | |
125 | + | let $list59686017 = exchangers | |
126 | + | let $size59686017 = size($list59686017) | |
127 | + | let $acc059686017 = $Tuple3(0, 0, base58'') | |
128 | + | if (($size59686017 == 0)) | |
129 | + | then $acc059686017 | |
90 | 130 | else { | |
91 | - | let $ | |
92 | - | if (($ | |
93 | - | then $ | |
131 | + | let $acc159686017 = exchangeFold($acc059686017, $list59686017[0]) | |
132 | + | if (($size59686017 == 1)) | |
133 | + | then $acc159686017 | |
94 | 134 | else { | |
95 | - | let $ | |
96 | - | if (($ | |
97 | - | then $ | |
135 | + | let $acc259686017 = exchangeFold($acc159686017, $list59686017[1]) | |
136 | + | if (($size59686017 == 2)) | |
137 | + | then $acc259686017 | |
98 | 138 | else { | |
99 | - | let $acc445764625 = exchangeFold($acc345764625, $list45764625[3]) | |
100 | - | throw("List size exceed 3") | |
139 | + | let $acc359686017 = exchangeFold($acc259686017, $list59686017[2]) | |
140 | + | if (($size59686017 == 3)) | |
141 | + | then $acc359686017 | |
142 | + | else { | |
143 | + | let $acc459686017 = exchangeFold($acc359686017, $list59686017[3]) | |
144 | + | throw("List size exceed 3") | |
145 | + | } | |
101 | 146 | } | |
102 | 147 | } | |
103 | 148 | } | |
104 | 149 | } | |
105 | - | | |
106 | - | let | |
107 | - | let | |
108 | - | let | |
109 | - | | |
110 | - | | |
111 | - | | |
112 | - | | |
113 | - | | |
114 | - | | |
150 | + | let exchangeCounter = $t059166017._1 | |
151 | + | let amountsWithFee = $t059166017._2 | |
152 | + | let assetsIdSend = $t059166017._3 | |
153 | + | let amountToRecieve = assetBalance(this, receiveAssetId) | |
154 | + | if (if ((exchangeCounter == routingSize)) | |
155 | + | then (amountToRecieve >= minAmountToReceive) | |
156 | + | else false) | |
157 | + | then [ScriptTransfer(i.caller, amountToRecieve, receiveAssetId)] | |
158 | + | else throw("routing != routingSize or amountToRecieve < minAmountToReceive") | |
159 | + | } | |
115 | 160 | } | |
116 | 161 | ||
117 | 162 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | func checkPossibilty (pmtAmount,minAmountToReceive,exchangers,exchangersType,routingAssetsKeys) = { | |
4 | + | let digits8 = 8 | |
5 | + | ||
6 | + | let scale8 = 100000000 | |
7 | + | ||
8 | + | let scale12 = 1000000000000 | |
9 | + | ||
10 | + | let alpha = 50 | |
11 | + | ||
12 | + | let alphaDigits = 2 | |
13 | + | ||
14 | + | let beta = 46000000 | |
15 | + | ||
16 | + | func skewness (x,y) = (((fraction(scale12, x, y) + fraction(scale12, y, x)) / 2) / 10000) | |
17 | + | ||
18 | + | ||
19 | + | func invariantCalc (x,y) = { | |
20 | + | let sk = skewness(x, y) | |
21 | + | (fraction((x + y), scale8, pow(sk, digits8, alpha, alphaDigits, digits8, CEILING)) + (2 * fraction(pow(fraction(x, y, scale8), 0, 5, 1, (digits8 / 2), DOWN), pow((sk - beta), digits8, alpha, alphaDigits, digits8, DOWN), scale8))) | |
22 | + | } | |
23 | + | ||
24 | + | ||
25 | + | func checkPossibilty (pmtAmount,minAmountToReceive,exchangers,exchangersType,routingAssetsKeys,args1,args2) = { | |
5 | 26 | let commission = 3000 | |
6 | 27 | let commissionScaleDelimiter = 1000000 | |
7 | 28 | let dApp1TokenPay = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[0]) | |
8 | 29 | let dApp1TokenGet = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[1]) | |
9 | 30 | let dApp2TokenPay = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[2]) | |
10 | 31 | let dApp2TokenGet = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[3]) | |
11 | - | let getFrom1Trade = fraction(dApp1TokenGet, pmtAmount, (pmtAmount + dApp1TokenPay)) | |
12 | - | let getFrom1TradeWithFee = fraction(getFrom1Trade, (commissionScaleDelimiter - commission), commissionScaleDelimiter) | |
13 | - | let getFrom2Trade = fraction(dApp2TokenGet, getFrom1TradeWithFee, (getFrom1TradeWithFee + dApp2TokenPay)) | |
14 | - | let getFrom2TradeWithFee = fraction(getFrom2Trade, (commissionScaleDelimiter - commission), commissionScaleDelimiter) | |
32 | + | let getFrom1TradeWithFee = if ((exchangersType[0] == "cpmm")) | |
33 | + | then { | |
34 | + | let getFrom1Trade = fraction(dApp1TokenGet, pmtAmount, (pmtAmount + dApp1TokenPay)) | |
35 | + | fraction(getFrom1Trade, (commissionScaleDelimiter - commission), commissionScaleDelimiter) | |
36 | + | } | |
37 | + | else if ((exchangersType[0] == "flat")) | |
38 | + | then { | |
39 | + | let invariant = invariantCalc(dApp1TokenPay, dApp1TokenGet) | |
40 | + | let invariantNew = invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - args2[0])) | |
41 | + | args2[0] | |
42 | + | } | |
43 | + | else throw("Incorrect exchange type") | |
44 | + | let getFrom2TradeWithFee = if ((exchangersType[1] == "cpmm")) | |
45 | + | then { | |
46 | + | let getFrom2Trade = fraction(dApp2TokenGet, getFrom1TradeWithFee, (getFrom1TradeWithFee + dApp2TokenPay)) | |
47 | + | fraction(getFrom2Trade, (commissionScaleDelimiter - commission), commissionScaleDelimiter) | |
48 | + | } | |
49 | + | else if ((exchangersType[1] == "flat")) | |
50 | + | then { | |
51 | + | let invariant = invariantCalc(dApp2TokenPay, dApp2TokenGet) | |
52 | + | let invariantNew = invariantCalc((dApp2TokenPay + getFrom1TradeWithFee), (dApp2TokenGet - args2[1])) | |
53 | + | args2[1] | |
54 | + | } | |
55 | + | else throw("Incorrect exchange type") | |
15 | 56 | if ((getFrom2TradeWithFee >= minAmountToReceive)) | |
16 | 57 | then true | |
17 | 58 | else false | |
18 | 59 | } | |
19 | 60 | ||
20 | 61 | ||
21 | 62 | @Callable(i) | |
22 | 63 | 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.") | |
64 | + | let $t034533527 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
65 | + | let pmtAmount = $t034533527._1 | |
66 | + | let pmtAssetId = $t034533527._2 | |
67 | + | if (!(checkPossibilty(pmtAmount, minAmountToReceive, exchangers, exchangersType, routingAssetsKeys, args1, args2))) | |
68 | + | then throw("Check transaction possibilty: declined") | |
69 | + | else { | |
70 | + | let routingSize = size(exchangers) | |
71 | + | func exchangeFold (accumulated,exchanger) = { | |
72 | + | let $t038263889 = accumulated | |
73 | + | let exchangeCounter = $t038263889._1 | |
74 | + | let amountsWithFee = $t038263889._2 | |
75 | + | let assetsIdSend = $t038263889._3 | |
76 | + | if ((exchangeCounter == 0)) | |
77 | + | then { | |
78 | + | let exchangerAddress = addressFromStringValue(exchanger) | |
79 | + | let inv = if ((exchangersType[exchangeCounter] == "cpmm")) | |
80 | + | then invoke(exchangerAddress, "exchange", [args1[exchangeCounter]], [AttachedPayment(pmtAssetId, pmtAmount)]) | |
81 | + | else if ((exchangersType[exchangeCounter] == "flat")) | |
82 | + | then invoke(exchangerAddress, "exchange", [args1[exchangeCounter], args2[exchangeCounter]], [AttachedPayment(pmtAssetId, pmtAmount)]) | |
83 | + | else throw("Incorrect exchange type") | |
84 | + | if ((inv == inv)) | |
85 | + | then match inv { | |
86 | + | case inv: (Int, ByteVector) => | |
87 | + | let $t045854623 = inv | |
88 | + | let amountWithFee = $t045854623._1 | |
89 | + | let assetIdSend = $t045854623._2 | |
90 | + | $Tuple3((exchangeCounter + 1), amountWithFee, assetIdSend) | |
91 | + | case _ => | |
92 | + | throw("Incorrect invoke result: expected amountWithFee and assetsIdSend") | |
93 | + | } | |
94 | + | else throw("Strict value is not equal to itself.") | |
95 | + | } | |
96 | + | else if (if ((exchangeCounter > 0)) | |
97 | + | then (routingSize > exchangeCounter) | |
98 | + | else false) | |
99 | + | then { | |
100 | + | let exchangerAddress = addressFromStringValue(exchanger) | |
101 | + | let $t049695035 = $Tuple2(assetsIdSend, amountsWithFee) | |
102 | + | let pmtAssetIdRout = $t049695035._1 | |
103 | + | let pmtAmountRout = $t049695035._2 | |
104 | + | let inv = if ((exchangersType[exchangeCounter] == "cpmm")) | |
105 | + | then invoke(exchangerAddress, "exchange", [args1[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)]) | |
106 | + | else if ((exchangersType[exchangeCounter] == "flat")) | |
107 | + | then invoke(exchangerAddress, "exchange", [args1[exchangeCounter], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)]) | |
108 | + | else throw("Incorrect exchange type") | |
109 | + | if ((inv == inv)) | |
110 | + | then match inv { | |
111 | + | case inv: (Int, ByteVector) => | |
112 | + | let $t056405678 = inv | |
113 | + | let amountWithFee = $t056405678._1 | |
114 | + | let assetIdSend = $t056405678._2 | |
115 | + | $Tuple3((exchangeCounter + 1), amountWithFee, assetIdSend) | |
116 | + | case _ => | |
117 | + | throw("Incorrect invoke result: expected amountWithFee and assetsIdSend") | |
118 | + | } | |
119 | + | else throw("Strict value is not equal to itself.") | |
120 | + | } | |
121 | + | else accumulated | |
51 | 122 | } | |
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") | |
74 | - | } | |
75 | - | else throw("Strict value is not equal to itself.") | |
76 | - | } | |
77 | - | else accumulated | |
78 | - | } | |
79 | 123 | ||
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 | |
124 | + | let $t059166017 = { | |
125 | + | let $list59686017 = exchangers | |
126 | + | let $size59686017 = size($list59686017) | |
127 | + | let $acc059686017 = $Tuple3(0, 0, base58'') | |
128 | + | if (($size59686017 == 0)) | |
129 | + | then $acc059686017 | |
90 | 130 | else { | |
91 | - | let $ | |
92 | - | if (($ | |
93 | - | then $ | |
131 | + | let $acc159686017 = exchangeFold($acc059686017, $list59686017[0]) | |
132 | + | if (($size59686017 == 1)) | |
133 | + | then $acc159686017 | |
94 | 134 | else { | |
95 | - | let $ | |
96 | - | if (($ | |
97 | - | then $ | |
135 | + | let $acc259686017 = exchangeFold($acc159686017, $list59686017[1]) | |
136 | + | if (($size59686017 == 2)) | |
137 | + | then $acc259686017 | |
98 | 138 | else { | |
99 | - | let $acc445764625 = exchangeFold($acc345764625, $list45764625[3]) | |
100 | - | throw("List size exceed 3") | |
139 | + | let $acc359686017 = exchangeFold($acc259686017, $list59686017[2]) | |
140 | + | if (($size59686017 == 3)) | |
141 | + | then $acc359686017 | |
142 | + | else { | |
143 | + | let $acc459686017 = exchangeFold($acc359686017, $list59686017[3]) | |
144 | + | throw("List size exceed 3") | |
145 | + | } | |
101 | 146 | } | |
102 | 147 | } | |
103 | 148 | } | |
104 | 149 | } | |
105 | - | | |
106 | - | let | |
107 | - | let | |
108 | - | let | |
109 | - | | |
110 | - | | |
111 | - | | |
112 | - | | |
113 | - | | |
114 | - | | |
150 | + | let exchangeCounter = $t059166017._1 | |
151 | + | let amountsWithFee = $t059166017._2 | |
152 | + | let assetsIdSend = $t059166017._3 | |
153 | + | let amountToRecieve = assetBalance(this, receiveAssetId) | |
154 | + | if (if ((exchangeCounter == routingSize)) | |
155 | + | then (amountToRecieve >= minAmountToReceive) | |
156 | + | else false) | |
157 | + | then [ScriptTransfer(i.caller, amountToRecieve, receiveAssetId)] | |
158 | + | else throw("routing != routingSize or amountToRecieve < minAmountToReceive") | |
159 | + | } | |
115 | 160 | } | |
116 | 161 | ||
117 | 162 |
github/deemru/w8io/026f985 57.27 ms ◑