tx · 6Fs8rzUuoHKgpMcMxR6uxFxNXzdSQ8fr9Y28V6UgPTkc

3N6qtbZbSPVcvJ1pk87e9ahdsZTjHN8e5mL:  -0.01000000 Waves

2021.09.12 20:18 [1700124] smart account 3N6qtbZbSPVcvJ1pk87e9ahdsZTjHN8e5mL > SELF 0.00000000 Waves

{ "type": 13, "id": "6Fs8rzUuoHKgpMcMxR6uxFxNXzdSQ8fr9Y28V6UgPTkc", "fee": 1000000, "feeAssetId": null, "timestamp": 1631467137699, "version": 2, "chainId": 84, "sender": "3N6qtbZbSPVcvJ1pk87e9ahdsZTjHN8e5mL", "senderPublicKey": "EYAKsFBespqQveBrfmX29rsehBJrSwQ3B6yN4ADyw8Kx", "proofs": [ "62m96gY6HZHoETdECaSqdSkvUec3tx22XZD1uwMZZrQtQDZEfibKoTxi4dwLYDrbW1CmtqddTojnfoNccoWfaTUX" ], "script": "base64:AAIFAAAAAAAAAA0IAhIJCgcYGBERGAIBAAAACwAAAAAHZGlnaXRzOAAAAAAAAAAACAAAAAAGc2NhbGU4AAAAAAAF9eEAAAAAAAdzY2FsZTEyAAAAAOjUpRAAAAAAAAVhbHBoYQAAAAAAAAAAMgAAAAALYWxwaGFEaWdpdHMAAAAAAAAAAAIAAAAABGJldGEAAAAAAAK954AAAAAACmNvbW1pc3Npb24AAAAAAAAAC7gAAAAAGGNvbW1pc3Npb25TY2FsZURlbGltaXRlcgAAAAAAAA9CQAEAAAAIc2tld25lc3MAAAACAAAAAXgAAAABeQkAAGkAAAACCQAAaQAAAAIJAABkAAAAAgkAAGsAAAADBQAAAAdzY2FsZTEyBQAAAAF4BQAAAAF5CQAAawAAAAMFAAAAB3NjYWxlMTIFAAAAAXkFAAAAAXgAAAAAAAAAAAIAAAAAAAAAJxABAAAADWludmFyaWFudENhbGMAAAACAAAAAXgAAAABeQQAAAACc2sJAQAAAAhza2V3bmVzcwAAAAIFAAAAAXgFAAAAAXkJAABkAAAAAgkAAGsAAAADCQAAZAAAAAIFAAAAAX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VudFRvUmVjaWV2ZQkAA/AAAAACBQAAAAR0aGlzBQAAAA5yZWNlaXZlQXNzZXRJZAMDCQAAAAAAAAIFAAAAD2V4Y2hhbmdlQ291bnRlcgUAAAALcm91dGluZ1NpemUJAABnAAAAAgUAAAAPYW1vdW50VG9SZWNpZXZlBQAAABJtaW5BbW91bnRUb1JlY2VpdmUHCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFpAAAABmNhbGxlcgUAAAAPYW1vdW50VG9SZWNpZXZlBQAAAA5yZWNlaXZlQXNzZXRJZAUAAAADbmlsCQAAAgAAAAECAAAAPnJvdXRpbmcgIT0gcm91dGluZ1NpemUgb3IgYW1vdW50VG9SZWNpZXZlIDwgbWluQW1vdW50VG9SZWNlaXZlAAAAAK9crnk=", "height": 1700124, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7X3LFxdPQt1bxd5JsemCmswSPgD2rUyJy6aBmT426SSi Next: 79UEBDqghBiBhmkUSbBN98tYqtzwWgC579ysBhdx5vvH Diff:
OldNewDifferences
1313
1414 let beta = 46000000
1515
16+let commission = 3000
17+
18+let commissionScaleDelimiter = 1000000
19+
1620 func skewness (x,y) = (((fraction(scale12, x, y) + fraction(scale12, y, x)) / 2) / 10000)
1721
1822
2327
2428
2529 func checkPossibilty (pmtAmount,minAmountToReceive,exchangers,exchangersType,routingAssetsKeys,args1,args2) = {
26- let commission = 3000
27- let commissionScaleDelimiter = 1000000
2830 let dApp1TokenPay = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[0])
2931 let dApp1TokenGet = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[1])
3032 let dApp2TokenPay = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[2])
3840 then {
3941 let invariant = invariantCalc(dApp1TokenPay, dApp1TokenGet)
4042 let minAmountToReceive1 = args2[0]
41- let invariantNew = invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - args2[0]))
43+ let invariantNew = invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1))
4244 if ((invariantNew >= invariant))
4345 then minAmountToReceive1
4446 else throw("Flat contract: invariantNew < invariant")
6769
6870 @Callable(i)
6971 func routingTrade (exchangers,exchangersType,args1,args2,routingAssetsKeys,receiveAssetId,minAmountToReceive) = {
70- let $t037483822 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
71- let pmtAmount = $t037483822._1
72- let pmtAssetId = $t037483822._2
72+ let $t041774251 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
73+ let pmtAmount = $t041774251._1
74+ let pmtAssetId = $t041774251._2
7375 if (!(checkPossibilty(pmtAmount, minAmountToReceive, exchangers, exchangersType, routingAssetsKeys, args1, args2)))
7476 then throw("Check transaction possibilty: declined")
7577 else {
7678 let routingSize = size(exchangers)
7779 func exchangeFold (accumulated,exchanger) = {
78- let $t041214184 = accumulated
79- let exchangeCounter = $t041214184._1
80- let amountsWithFee = $t041214184._2
81- let assetsIdSend = $t041214184._3
82- if ((exchangeCounter == 0))
80+ let $t045504613 = accumulated
81+ let exchangeCounter = $t045504613._1
82+ let amountsWithFee = $t045504613._2
83+ let assetsIdSend = $t045504613._3
84+ let $t046224745 = if ((exchangeCounter == 0))
85+ then $Tuple2(pmtAssetId, pmtAmount)
86+ else $Tuple2(assetsIdSend, amountsWithFee)
87+ let pmtAssetIdRout = $t046224745._1
88+ let pmtAmountRout = $t046224745._2
89+ if (((if ((exchangeCounter >= 0))
90+ then (routingSize > exchangeCounter)
91+ else false) == true))
8392 then {
8493 let exchangerAddress = addressFromStringValue(exchanger)
8594 let inv = if ((exchangersType[exchangeCounter] == "cpmm"))
86- then invoke(exchangerAddress, "exchange", [args1[exchangeCounter]], [AttachedPayment(pmtAssetId, pmtAmount)])
95+ then invoke(exchangerAddress, "exchange", [args1[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
8796 else if ((exchangersType[exchangeCounter] == "flat"))
88- then invoke(exchangerAddress, "exchange", [args1[exchangeCounter], args2[exchangeCounter]], [AttachedPayment(pmtAssetId, pmtAmount)])
97+ then invoke(exchangerAddress, "exchange", [args1[exchangeCounter], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
8998 else throw("Incorrect exchange type")
9099 if ((inv == inv))
91100 then match inv {
92101 case inv: (Int, ByteVector) =>
93- let $t048804918 = inv
94- let amountWithFee = $t048804918._1
95- let assetIdSend = $t048804918._2
102+ let $t055145552 = inv
103+ let amountWithFee = $t055145552._1
104+ let assetIdSend = $t055145552._2
96105 $Tuple3((exchangeCounter + 1), amountWithFee, assetIdSend)
97106 case _ =>
98107 throw("Incorrect invoke result: expected amountWithFee and assetsIdSend")
99108 }
100109 else throw("Strict value is not equal to itself.")
101110 }
102- else if (if ((exchangeCounter > 0))
103- then (routingSize > exchangeCounter)
104- else false)
105- then {
106- let exchangerAddress = addressFromStringValue(exchanger)
107- let $t052645330 = $Tuple2(assetsIdSend, amountsWithFee)
108- let pmtAssetIdRout = $t052645330._1
109- let pmtAmountRout = $t052645330._2
110- let inv = if ((exchangersType[exchangeCounter] == "cpmm"))
111- then invoke(exchangerAddress, "exchange", [args1[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
112- else if ((exchangersType[exchangeCounter] == "flat"))
113- then invoke(exchangerAddress, "exchange", [args1[exchangeCounter], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
114- else throw("Incorrect exchange type")
115- if ((inv == inv))
116- then match inv {
117- case inv: (Int, ByteVector) =>
118- let $t059355973 = inv
119- let amountWithFee = $t059355973._1
120- let assetIdSend = $t059355973._2
121- $Tuple3((exchangeCounter + 1), amountWithFee, assetIdSend)
122- case _ =>
123- throw("Incorrect invoke result: expected amountWithFee and assetsIdSend")
124- }
125- else throw("Strict value is not equal to itself.")
126- }
127- else accumulated
111+ else accumulated
128112 }
129113
130- let $t062116312 = {
131- let $list62636312 = exchangers
132- let $size62636312 = size($list62636312)
133- let $acc062636312 = $Tuple3(0, 0, base58'')
134- if (($size62636312 == 0))
135- then $acc062636312
114+ let $t058025903 = {
115+ let $list58545903 = exchangers
116+ let $size58545903 = size($list58545903)
117+ let $acc058545903 = $Tuple3(0, 0, base58'')
118+ if (($size58545903 == 0))
119+ then $acc058545903
136120 else {
137- let $acc162636312 = exchangeFold($acc062636312, $list62636312[0])
138- if (($size62636312 == 1))
139- then $acc162636312
121+ let $acc158545903 = exchangeFold($acc058545903, $list58545903[0])
122+ if (($size58545903 == 1))
123+ then $acc158545903
140124 else {
141- let $acc262636312 = exchangeFold($acc162636312, $list62636312[1])
142- if (($size62636312 == 2))
143- then $acc262636312
125+ let $acc258545903 = exchangeFold($acc158545903, $list58545903[1])
126+ if (($size58545903 == 2))
127+ then $acc258545903
144128 else {
145- let $acc362636312 = exchangeFold($acc262636312, $list62636312[2])
146- if (($size62636312 == 3))
147- then $acc362636312
129+ let $acc358545903 = exchangeFold($acc258545903, $list58545903[2])
130+ if (($size58545903 == 3))
131+ then $acc358545903
148132 else {
149- let $acc462636312 = exchangeFold($acc362636312, $list62636312[3])
133+ let $acc458545903 = exchangeFold($acc358545903, $list58545903[3])
150134 throw("List size exceed 3")
151135 }
152136 }
153137 }
154138 }
155139 }
156- let exchangeCounter = $t062116312._1
157- let amountsWithFee = $t062116312._2
158- let assetsIdSend = $t062116312._3
140+ let exchangeCounter = $t058025903._1
141+ let amountsWithFee = $t058025903._2
142+ let assetsIdSend = $t058025903._3
159143 let amountToRecieve = assetBalance(this, receiveAssetId)
160144 if (if ((exchangeCounter == routingSize))
161145 then (amountToRecieve >= minAmountToReceive)
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let digits8 = 8
55
66 let scale8 = 100000000
77
88 let scale12 = 1000000000000
99
1010 let alpha = 50
1111
1212 let alphaDigits = 2
1313
1414 let beta = 46000000
1515
16+let commission = 3000
17+
18+let commissionScaleDelimiter = 1000000
19+
1620 func skewness (x,y) = (((fraction(scale12, x, y) + fraction(scale12, y, x)) / 2) / 10000)
1721
1822
1923 func invariantCalc (x,y) = {
2024 let sk = skewness(x, y)
2125 (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)))
2226 }
2327
2428
2529 func checkPossibilty (pmtAmount,minAmountToReceive,exchangers,exchangersType,routingAssetsKeys,args1,args2) = {
26- let commission = 3000
27- let commissionScaleDelimiter = 1000000
2830 let dApp1TokenPay = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[0])
2931 let dApp1TokenGet = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[1])
3032 let dApp2TokenPay = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[2])
3133 let dApp2TokenGet = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[3])
3234 let getFrom1TradeWithFee = if ((exchangersType[0] == "cpmm"))
3335 then {
3436 let getFrom1Trade = fraction(dApp1TokenGet, pmtAmount, (pmtAmount + dApp1TokenPay))
3537 fraction(getFrom1Trade, (commissionScaleDelimiter - commission), commissionScaleDelimiter)
3638 }
3739 else if ((exchangersType[0] == "flat"))
3840 then {
3941 let invariant = invariantCalc(dApp1TokenPay, dApp1TokenGet)
4042 let minAmountToReceive1 = args2[0]
41- let invariantNew = invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - args2[0]))
43+ let invariantNew = invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1))
4244 if ((invariantNew >= invariant))
4345 then minAmountToReceive1
4446 else throw("Flat contract: invariantNew < invariant")
4547 }
4648 else throw("Incorrect exchange type")
4749 let getFrom2TradeWithFee = if ((exchangersType[1] == "cpmm"))
4850 then {
4951 let getFrom2Trade = fraction(dApp2TokenGet, getFrom1TradeWithFee, (getFrom1TradeWithFee + dApp2TokenPay))
5052 fraction(getFrom2Trade, (commissionScaleDelimiter - commission), commissionScaleDelimiter)
5153 }
5254 else if ((exchangersType[1] == "flat"))
5355 then {
5456 let invariant = invariantCalc(dApp2TokenPay, dApp2TokenGet)
5557 let minAmountToReceive2 = args2[1]
5658 let invariantNew = invariantCalc((dApp2TokenPay + getFrom1TradeWithFee), (dApp2TokenGet - minAmountToReceive2))
5759 if ((invariantNew >= invariant))
5860 then minAmountToReceive2
5961 else throw("Flat contract: invariantNew < invariant")
6062 }
6163 else throw("Incorrect exchange type")
6264 if ((getFrom2TradeWithFee >= minAmountToReceive))
6365 then true
6466 else false
6567 }
6668
6769
6870 @Callable(i)
6971 func routingTrade (exchangers,exchangersType,args1,args2,routingAssetsKeys,receiveAssetId,minAmountToReceive) = {
70- let $t037483822 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
71- let pmtAmount = $t037483822._1
72- let pmtAssetId = $t037483822._2
72+ let $t041774251 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
73+ let pmtAmount = $t041774251._1
74+ let pmtAssetId = $t041774251._2
7375 if (!(checkPossibilty(pmtAmount, minAmountToReceive, exchangers, exchangersType, routingAssetsKeys, args1, args2)))
7476 then throw("Check transaction possibilty: declined")
7577 else {
7678 let routingSize = size(exchangers)
7779 func exchangeFold (accumulated,exchanger) = {
78- let $t041214184 = accumulated
79- let exchangeCounter = $t041214184._1
80- let amountsWithFee = $t041214184._2
81- let assetsIdSend = $t041214184._3
82- if ((exchangeCounter == 0))
80+ let $t045504613 = accumulated
81+ let exchangeCounter = $t045504613._1
82+ let amountsWithFee = $t045504613._2
83+ let assetsIdSend = $t045504613._3
84+ let $t046224745 = if ((exchangeCounter == 0))
85+ then $Tuple2(pmtAssetId, pmtAmount)
86+ else $Tuple2(assetsIdSend, amountsWithFee)
87+ let pmtAssetIdRout = $t046224745._1
88+ let pmtAmountRout = $t046224745._2
89+ if (((if ((exchangeCounter >= 0))
90+ then (routingSize > exchangeCounter)
91+ else false) == true))
8392 then {
8493 let exchangerAddress = addressFromStringValue(exchanger)
8594 let inv = if ((exchangersType[exchangeCounter] == "cpmm"))
86- then invoke(exchangerAddress, "exchange", [args1[exchangeCounter]], [AttachedPayment(pmtAssetId, pmtAmount)])
95+ then invoke(exchangerAddress, "exchange", [args1[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
8796 else if ((exchangersType[exchangeCounter] == "flat"))
88- then invoke(exchangerAddress, "exchange", [args1[exchangeCounter], args2[exchangeCounter]], [AttachedPayment(pmtAssetId, pmtAmount)])
97+ then invoke(exchangerAddress, "exchange", [args1[exchangeCounter], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
8998 else throw("Incorrect exchange type")
9099 if ((inv == inv))
91100 then match inv {
92101 case inv: (Int, ByteVector) =>
93- let $t048804918 = inv
94- let amountWithFee = $t048804918._1
95- let assetIdSend = $t048804918._2
102+ let $t055145552 = inv
103+ let amountWithFee = $t055145552._1
104+ let assetIdSend = $t055145552._2
96105 $Tuple3((exchangeCounter + 1), amountWithFee, assetIdSend)
97106 case _ =>
98107 throw("Incorrect invoke result: expected amountWithFee and assetsIdSend")
99108 }
100109 else throw("Strict value is not equal to itself.")
101110 }
102- else if (if ((exchangeCounter > 0))
103- then (routingSize > exchangeCounter)
104- else false)
105- then {
106- let exchangerAddress = addressFromStringValue(exchanger)
107- let $t052645330 = $Tuple2(assetsIdSend, amountsWithFee)
108- let pmtAssetIdRout = $t052645330._1
109- let pmtAmountRout = $t052645330._2
110- let inv = if ((exchangersType[exchangeCounter] == "cpmm"))
111- then invoke(exchangerAddress, "exchange", [args1[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
112- else if ((exchangersType[exchangeCounter] == "flat"))
113- then invoke(exchangerAddress, "exchange", [args1[exchangeCounter], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
114- else throw("Incorrect exchange type")
115- if ((inv == inv))
116- then match inv {
117- case inv: (Int, ByteVector) =>
118- let $t059355973 = inv
119- let amountWithFee = $t059355973._1
120- let assetIdSend = $t059355973._2
121- $Tuple3((exchangeCounter + 1), amountWithFee, assetIdSend)
122- case _ =>
123- throw("Incorrect invoke result: expected amountWithFee and assetsIdSend")
124- }
125- else throw("Strict value is not equal to itself.")
126- }
127- else accumulated
111+ else accumulated
128112 }
129113
130- let $t062116312 = {
131- let $list62636312 = exchangers
132- let $size62636312 = size($list62636312)
133- let $acc062636312 = $Tuple3(0, 0, base58'')
134- if (($size62636312 == 0))
135- then $acc062636312
114+ let $t058025903 = {
115+ let $list58545903 = exchangers
116+ let $size58545903 = size($list58545903)
117+ let $acc058545903 = $Tuple3(0, 0, base58'')
118+ if (($size58545903 == 0))
119+ then $acc058545903
136120 else {
137- let $acc162636312 = exchangeFold($acc062636312, $list62636312[0])
138- if (($size62636312 == 1))
139- then $acc162636312
121+ let $acc158545903 = exchangeFold($acc058545903, $list58545903[0])
122+ if (($size58545903 == 1))
123+ then $acc158545903
140124 else {
141- let $acc262636312 = exchangeFold($acc162636312, $list62636312[1])
142- if (($size62636312 == 2))
143- then $acc262636312
125+ let $acc258545903 = exchangeFold($acc158545903, $list58545903[1])
126+ if (($size58545903 == 2))
127+ then $acc258545903
144128 else {
145- let $acc362636312 = exchangeFold($acc262636312, $list62636312[2])
146- if (($size62636312 == 3))
147- then $acc362636312
129+ let $acc358545903 = exchangeFold($acc258545903, $list58545903[2])
130+ if (($size58545903 == 3))
131+ then $acc358545903
148132 else {
149- let $acc462636312 = exchangeFold($acc362636312, $list62636312[3])
133+ let $acc458545903 = exchangeFold($acc358545903, $list58545903[3])
150134 throw("List size exceed 3")
151135 }
152136 }
153137 }
154138 }
155139 }
156- let exchangeCounter = $t062116312._1
157- let amountsWithFee = $t062116312._2
158- let assetsIdSend = $t062116312._3
140+ let exchangeCounter = $t058025903._1
141+ let amountsWithFee = $t058025903._2
142+ let assetsIdSend = $t058025903._3
159143 let amountToRecieve = assetBalance(this, receiveAssetId)
160144 if (if ((exchangeCounter == routingSize))
161145 then (amountToRecieve >= minAmountToReceive)
162146 else false)
163147 then [ScriptTransfer(i.caller, amountToRecieve, receiveAssetId)]
164148 else throw("routing != routingSize or amountToRecieve < minAmountToReceive")
165149 }
166150 }
167151
168152

github/deemru/w8io/026f985 
55.17 ms