tx · 2xmHXGqXj3Gjwu8aYgDJDWVua3bAetd3yvw97jNAJZfn 3N6qtbZbSPVcvJ1pk87e9ahdsZTjHN8e5mL: -0.01000000 Waves 2021.09.16 13:59 [1705515] smart account 3N6qtbZbSPVcvJ1pk87e9ahdsZTjHN8e5mL > SELF 0.00000000 Waves
{ "type": 13, "id": "2xmHXGqXj3Gjwu8aYgDJDWVua3bAetd3yvw97jNAJZfn", "fee": 1000000, "feeAssetId": null, "timestamp": 1631790067107, "version": 2, "chainId": 84, "sender": "3N6qtbZbSPVcvJ1pk87e9ahdsZTjHN8e5mL", "senderPublicKey": "EYAKsFBespqQveBrfmX29rsehBJrSwQ3B6yN4ADyw8Kx", "proofs": [ "3Rg72BBDkzTLKg1HGZ8yV9FCyLvdB3fYWAj7jfgYpWEcjiVJ7sLQSyw5avSpyvcXsndaYwYYWVGphUq4qZPqNgPE" ], "script": "base64:AAIFAAAAAAAAAA0IAhIJCgcYGBERGAIBAAAACwAAAAAHZGlnaXRzOAAAAAAAAAAACAAAAAAGc2NhbGU4AAAAAAAF9eEAAAAAAAdzY2FsZTEyAAAAAOjUpRAAAAAAAAVhbHBoYQAAAAAAAAAAMgAAAAALYWxwaGFEaWdpdHMAAAAAAAAAAAIAAAAABGJldGEAAAAAAAK954AAAAAACmNvbW1pc3Npb24AAAAAAAAAC7gAAAAAGGNvbW1pc3Npb25TY2FsZURlbGltaXRlcgAAAAAAAA9CQAEAAAAIc2tld25lc3MAAAACAAAAAXgAAAABeQkAAGkAAAACCQAAaQAAAAIJAABkAAAAAgkAAGsAAAADBQAAAAdzY2FsZTEyBQAAAAF4BQAAAAF5CQAAawAAAAMFAAAAB3NjYWxlMTIFAAAAAXkFAAAAAXgAAAAAAAAAAAIAAAAAAAAAJxABAAAADWludmFyaWFudENhbGMAAAACAAAAAXgAAAABeQQAAAACc2sJAQAAAAhza2V3bmVzcwAAAAIFAAAAAXgFAAAAAXkJAABkAAAAAgkAAGsAAAADCQAAZAAAAAIFAAAAAX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NzQJAAGRAAAAAgUAAAANJGxpc3Q2NzI1Njc3NAAAAAAAAAAAAwkAAAIAAAABAgAAABJMaXN0IHNpemUgZXhjZWVkIDMEAAAAD2V4Y2hhbmdlQ291bnRlcggFAAAACyR0MDY2NzM2Nzc0AAAAAl8xBAAAAA5hbW91bnRzV2l0aEZlZQgFAAAACyR0MDY2NzM2Nzc0AAAAAl8yBAAAAAxhc3NldHNJZFNlbmQIBQAAAAskdDA2NjczNjc3NAAAAAJfMwQAAAAPYW1vdW50VG9SZWNpZXZlCQAD8AAAAAIFAAAABHRoaXMFAAAADnJlY2VpdmVBc3NldElkAwMJAAAAAAAAAgUAAAAPZXhjaGFuZ2VDb3VudGVyBQAAAAtyb3V0aW5nU2l6ZQkAAGcAAAACBQAAAA9hbW91bnRUb1JlY2lldmUFAAAAEm1pbkFtb3VudFRvUmVjZWl2ZQcJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAA9hbW91bnRUb1JlY2lldmUFAAAADnJlY2VpdmVBc3NldElkBQAAAANuaWwJAAACAAAAAQIAAAA+cm91dGluZyAhPSByb3V0aW5nU2l6ZSBvciBhbW91bnRUb1JlY2lldmUgPCBtaW5BbW91bnRUb1JlY2VpdmUAAAAA4GNbZw==", "height": 1705515, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 79UEBDqghBiBhmkUSbBN98tYqtzwWgC579ysBhdx5vvH Next: none Diff:
Old | New | Differences | |
---|---|---|---|
35 | 35 | then { | |
36 | 36 | let invariant = invariantCalc(dApp1TokenPay, dApp1TokenGet) | |
37 | 37 | let minAmountToReceive1 = args2[0] | |
38 | - | let invariantNew = (((invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1)) + invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1))) + invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1))) + invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1))) | |
38 | + | let invariantNew = (((((((invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1)) + invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1))) + invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1))) + invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1))) + invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1))) + invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1))) + invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1))) + invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1))) | |
39 | 39 | if ((invariantNew >= invariant)) | |
40 | 40 | then minAmountToReceive1 | |
41 | 41 | else throw("Flat contract: invariantNew < invariant") | |
53 | 53 | ||
54 | 54 | @Callable(i) | |
55 | 55 | func routingTrade (exchangers,exchangersType,args1,args2,routingAssetsKeys,receiveAssetId,minAmountToReceive) = { | |
56 | - | let $ | |
57 | - | let pmtAmount = $ | |
58 | - | let pmtAssetId = $ | |
56 | + | let $t050485122 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
57 | + | let pmtAmount = $t050485122._1 | |
58 | + | let pmtAssetId = $t050485122._2 | |
59 | 59 | if (!(checkPossibilty(pmtAmount, minAmountToReceive, exchangers, exchangersType, routingAssetsKeys, args1, args2))) | |
60 | 60 | then throw("Check transaction possibilty: declined") | |
61 | 61 | else { | |
62 | 62 | let routingSize = size(exchangers) | |
63 | 63 | func exchangeFold (accumulated,exchanger) = { | |
64 | - | let $ | |
65 | - | let exchangeCounter = $ | |
66 | - | let amountsWithFee = $ | |
67 | - | let assetsIdSend = $ | |
68 | - | let $ | |
64 | + | let $t054215484 = accumulated | |
65 | + | let exchangeCounter = $t054215484._1 | |
66 | + | let amountsWithFee = $t054215484._2 | |
67 | + | let assetsIdSend = $t054215484._3 | |
68 | + | let $t054935616 = if ((exchangeCounter == 0)) | |
69 | 69 | then $Tuple2(pmtAssetId, pmtAmount) | |
70 | 70 | else $Tuple2(assetsIdSend, amountsWithFee) | |
71 | - | let pmtAssetIdRout = $ | |
72 | - | let pmtAmountRout = $ | |
71 | + | let pmtAssetIdRout = $t054935616._1 | |
72 | + | let pmtAmountRout = $t054935616._2 | |
73 | 73 | if (((if ((exchangeCounter >= 0)) | |
74 | 74 | then (routingSize > exchangeCounter) | |
75 | 75 | else false) == true)) | |
83 | 83 | if ((inv == inv)) | |
84 | 84 | then match inv { | |
85 | 85 | case inv: (Int, ByteVector) => | |
86 | - | let $ | |
87 | - | let amountWithFee = $ | |
88 | - | let assetIdSend = $ | |
86 | + | let $t063856423 = inv | |
87 | + | let amountWithFee = $t063856423._1 | |
88 | + | let assetIdSend = $t063856423._2 | |
89 | 89 | $Tuple3((exchangeCounter + 1), amountWithFee, assetIdSend) | |
90 | 90 | case _ => | |
91 | 91 | throw("Incorrect invoke result: expected amountWithFee and assetsIdSend") | |
95 | 95 | else accumulated | |
96 | 96 | } | |
97 | 97 | ||
98 | - | let $ | |
99 | - | let $ | |
100 | - | let $ | |
101 | - | let $ | |
102 | - | if (($ | |
103 | - | then $ | |
98 | + | let $t066736774 = { | |
99 | + | let $list67256774 = exchangers | |
100 | + | let $size67256774 = size($list67256774) | |
101 | + | let $acc067256774 = $Tuple3(0, 0, base58'') | |
102 | + | if (($size67256774 == 0)) | |
103 | + | then $acc067256774 | |
104 | 104 | else { | |
105 | - | let $ | |
106 | - | if (($ | |
107 | - | then $ | |
105 | + | let $acc167256774 = exchangeFold($acc067256774, $list67256774[0]) | |
106 | + | if (($size67256774 == 1)) | |
107 | + | then $acc167256774 | |
108 | 108 | else { | |
109 | - | let $ | |
110 | - | if (($ | |
111 | - | then $ | |
109 | + | let $acc267256774 = exchangeFold($acc167256774, $list67256774[1]) | |
110 | + | if (($size67256774 == 2)) | |
111 | + | then $acc267256774 | |
112 | 112 | else { | |
113 | - | let $ | |
114 | - | if (($ | |
115 | - | then $ | |
113 | + | let $acc367256774 = exchangeFold($acc267256774, $list67256774[2]) | |
114 | + | if (($size67256774 == 3)) | |
115 | + | then $acc367256774 | |
116 | 116 | else { | |
117 | - | let $ | |
117 | + | let $acc467256774 = exchangeFold($acc367256774, $list67256774[3]) | |
118 | 118 | throw("List size exceed 3") | |
119 | 119 | } | |
120 | 120 | } | |
121 | 121 | } | |
122 | 122 | } | |
123 | 123 | } | |
124 | - | let exchangeCounter = $ | |
125 | - | let amountsWithFee = $ | |
126 | - | let assetsIdSend = $ | |
124 | + | let exchangeCounter = $t066736774._1 | |
125 | + | let amountsWithFee = $t066736774._2 | |
126 | + | let assetsIdSend = $t066736774._3 | |
127 | 127 | let amountToRecieve = assetBalance(this, receiveAssetId) | |
128 | 128 | if (if ((exchangeCounter == routingSize)) | |
129 | 129 | then (amountToRecieve >= minAmountToReceive) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let digits8 = 8 | |
5 | 5 | ||
6 | 6 | let scale8 = 100000000 | |
7 | 7 | ||
8 | 8 | let scale12 = 1000000000000 | |
9 | 9 | ||
10 | 10 | let alpha = 50 | |
11 | 11 | ||
12 | 12 | let alphaDigits = 2 | |
13 | 13 | ||
14 | 14 | let beta = 46000000 | |
15 | 15 | ||
16 | 16 | let commission = 3000 | |
17 | 17 | ||
18 | 18 | let commissionScaleDelimiter = 1000000 | |
19 | 19 | ||
20 | 20 | func skewness (x,y) = (((fraction(scale12, x, y) + fraction(scale12, y, x)) / 2) / 10000) | |
21 | 21 | ||
22 | 22 | ||
23 | 23 | func invariantCalc (x,y) = { | |
24 | 24 | let sk = skewness(x, y) | |
25 | 25 | (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))) | |
26 | 26 | } | |
27 | 27 | ||
28 | 28 | ||
29 | 29 | func checkPossibilty (pmtAmount,minAmountToReceive,exchangers,exchangersType,routingAssetsKeys,args1,args2) = { | |
30 | 30 | let dApp1TokenPay = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[0]) | |
31 | 31 | let dApp1TokenGet = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[1]) | |
32 | 32 | let dApp2TokenPay = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[2]) | |
33 | 33 | let dApp2TokenGet = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[3]) | |
34 | 34 | let getFrom1TradeWithFee = if ((exchangersType[0] == "flat")) | |
35 | 35 | then { | |
36 | 36 | let invariant = invariantCalc(dApp1TokenPay, dApp1TokenGet) | |
37 | 37 | let minAmountToReceive1 = args2[0] | |
38 | - | let invariantNew = (((invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1)) + invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1))) + invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1))) + invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1))) | |
38 | + | let invariantNew = (((((((invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1)) + invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1))) + invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1))) + invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1))) + invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1))) + invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1))) + invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1))) + invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1))) | |
39 | 39 | if ((invariantNew >= invariant)) | |
40 | 40 | then minAmountToReceive1 | |
41 | 41 | else throw("Flat contract: invariantNew < invariant") | |
42 | 42 | } | |
43 | 43 | else throw("Incorrect exchange type") | |
44 | 44 | let getFrom2TradeWithFee = if ((exchangersType[1] == "cpmm")) | |
45 | 45 | then { | |
46 | 46 | let getFrom2TradeWithoutFee = fraction(dApp2TokenGet, getFrom1TradeWithFee, (getFrom1TradeWithFee + dApp2TokenPay)) | |
47 | 47 | fraction(getFrom2TradeWithoutFee, (commissionScaleDelimiter - commission), commissionScaleDelimiter) | |
48 | 48 | } | |
49 | 49 | else throw("Incorrect exchange type") | |
50 | 50 | (getFrom2TradeWithFee >= minAmountToReceive) | |
51 | 51 | } | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | @Callable(i) | |
55 | 55 | func routingTrade (exchangers,exchangersType,args1,args2,routingAssetsKeys,receiveAssetId,minAmountToReceive) = { | |
56 | - | let $ | |
57 | - | let pmtAmount = $ | |
58 | - | let pmtAssetId = $ | |
56 | + | let $t050485122 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
57 | + | let pmtAmount = $t050485122._1 | |
58 | + | let pmtAssetId = $t050485122._2 | |
59 | 59 | if (!(checkPossibilty(pmtAmount, minAmountToReceive, exchangers, exchangersType, routingAssetsKeys, args1, args2))) | |
60 | 60 | then throw("Check transaction possibilty: declined") | |
61 | 61 | else { | |
62 | 62 | let routingSize = size(exchangers) | |
63 | 63 | func exchangeFold (accumulated,exchanger) = { | |
64 | - | let $ | |
65 | - | let exchangeCounter = $ | |
66 | - | let amountsWithFee = $ | |
67 | - | let assetsIdSend = $ | |
68 | - | let $ | |
64 | + | let $t054215484 = accumulated | |
65 | + | let exchangeCounter = $t054215484._1 | |
66 | + | let amountsWithFee = $t054215484._2 | |
67 | + | let assetsIdSend = $t054215484._3 | |
68 | + | let $t054935616 = if ((exchangeCounter == 0)) | |
69 | 69 | then $Tuple2(pmtAssetId, pmtAmount) | |
70 | 70 | else $Tuple2(assetsIdSend, amountsWithFee) | |
71 | - | let pmtAssetIdRout = $ | |
72 | - | let pmtAmountRout = $ | |
71 | + | let pmtAssetIdRout = $t054935616._1 | |
72 | + | let pmtAmountRout = $t054935616._2 | |
73 | 73 | if (((if ((exchangeCounter >= 0)) | |
74 | 74 | then (routingSize > exchangeCounter) | |
75 | 75 | else false) == true)) | |
76 | 76 | then { | |
77 | 77 | let exchangerAddress = addressFromStringValue(exchanger) | |
78 | 78 | let inv = if ((exchangersType[exchangeCounter] == "cpmm")) | |
79 | 79 | then invoke(exchangerAddress, "exchange", [args1[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)]) | |
80 | 80 | else if ((exchangersType[exchangeCounter] == "flat")) | |
81 | 81 | then invoke(exchangerAddress, "exchange", [args1[exchangeCounter], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)]) | |
82 | 82 | else throw("Incorrect exchange type") | |
83 | 83 | if ((inv == inv)) | |
84 | 84 | then match inv { | |
85 | 85 | case inv: (Int, ByteVector) => | |
86 | - | let $ | |
87 | - | let amountWithFee = $ | |
88 | - | let assetIdSend = $ | |
86 | + | let $t063856423 = inv | |
87 | + | let amountWithFee = $t063856423._1 | |
88 | + | let assetIdSend = $t063856423._2 | |
89 | 89 | $Tuple3((exchangeCounter + 1), amountWithFee, assetIdSend) | |
90 | 90 | case _ => | |
91 | 91 | throw("Incorrect invoke result: expected amountWithFee and assetsIdSend") | |
92 | 92 | } | |
93 | 93 | else throw("Strict value is not equal to itself.") | |
94 | 94 | } | |
95 | 95 | else accumulated | |
96 | 96 | } | |
97 | 97 | ||
98 | - | let $ | |
99 | - | let $ | |
100 | - | let $ | |
101 | - | let $ | |
102 | - | if (($ | |
103 | - | then $ | |
98 | + | let $t066736774 = { | |
99 | + | let $list67256774 = exchangers | |
100 | + | let $size67256774 = size($list67256774) | |
101 | + | let $acc067256774 = $Tuple3(0, 0, base58'') | |
102 | + | if (($size67256774 == 0)) | |
103 | + | then $acc067256774 | |
104 | 104 | else { | |
105 | - | let $ | |
106 | - | if (($ | |
107 | - | then $ | |
105 | + | let $acc167256774 = exchangeFold($acc067256774, $list67256774[0]) | |
106 | + | if (($size67256774 == 1)) | |
107 | + | then $acc167256774 | |
108 | 108 | else { | |
109 | - | let $ | |
110 | - | if (($ | |
111 | - | then $ | |
109 | + | let $acc267256774 = exchangeFold($acc167256774, $list67256774[1]) | |
110 | + | if (($size67256774 == 2)) | |
111 | + | then $acc267256774 | |
112 | 112 | else { | |
113 | - | let $ | |
114 | - | if (($ | |
115 | - | then $ | |
113 | + | let $acc367256774 = exchangeFold($acc267256774, $list67256774[2]) | |
114 | + | if (($size67256774 == 3)) | |
115 | + | then $acc367256774 | |
116 | 116 | else { | |
117 | - | let $ | |
117 | + | let $acc467256774 = exchangeFold($acc367256774, $list67256774[3]) | |
118 | 118 | throw("List size exceed 3") | |
119 | 119 | } | |
120 | 120 | } | |
121 | 121 | } | |
122 | 122 | } | |
123 | 123 | } | |
124 | - | let exchangeCounter = $ | |
125 | - | let amountsWithFee = $ | |
126 | - | let assetsIdSend = $ | |
124 | + | let exchangeCounter = $t066736774._1 | |
125 | + | let amountsWithFee = $t066736774._2 | |
126 | + | let assetsIdSend = $t066736774._3 | |
127 | 127 | let amountToRecieve = assetBalance(this, receiveAssetId) | |
128 | 128 | if (if ((exchangeCounter == routingSize)) | |
129 | 129 | then (amountToRecieve >= minAmountToReceive) | |
130 | 130 | else false) | |
131 | 131 | then [ScriptTransfer(i.caller, amountToRecieve, receiveAssetId)] | |
132 | 132 | else throw("routing != routingSize or amountToRecieve < minAmountToReceive") | |
133 | 133 | } | |
134 | 134 | } | |
135 | 135 | ||
136 | 136 |
github/deemru/w8io/026f985 47.07 ms ◑