tx · 9922meKgC3fkWX2itfeaHUKhNTCJ5GfdoasNvt4pE4S6

3MqDf9VgoL9eqrCPx8F74Au6xBpvdTm9UP8:  -0.01400000 Waves

2022.09.14 15:20 [2228759] smart account 3MqDf9VgoL9eqrCPx8F74Au6xBpvdTm9UP8 > SELF 0.00000000 Waves

{ "type": 13, "id": "9922meKgC3fkWX2itfeaHUKhNTCJ5GfdoasNvt4pE4S6", "fee": 1400000, "feeAssetId": null, "timestamp": 1663158058314, "version": 2, "chainId": 84, "sender": "3MqDf9VgoL9eqrCPx8F74Au6xBpvdTm9UP8", "senderPublicKey": "4ja2PX5eqM576zv9KGzu5Qe7M92Z3jbuSmkLPdGjK4ue", "proofs": [ "3xB47gTJRaPveqRQgDoPsp7YsPug3pQCYLLw6xTSZd8Ejw4m8BCSWfp1PH151KrMWg79CeJc3fro1fuRFqikZsd3", "3cTj4XZknxCuXJfRjX7DQk1qQkUMYe9PKCm7FiJQshmwFy4BbUWijg8bfDTTNbL25g6oCBL6nnXQs88H3WN2vaf9" ], "script": "base64:BgIQCAISCAoGGBgRERgBEgASACYAB2tBY3RpdmUCBmFjdGl2ZQAGa0NhdXNlAg5zaHV0ZG93bl9jYXVzZQANa1Bvb2xJbk9yYWNsZQIFcG9vbF8ADmtVc2VyU3dvcEluR292AgxfU1dPUF9hbW91bnQACmtEaXNjb3VudHMCCWRpc2NvdW50cwAPa0Rpc2NvdW50VmFsdWVzAg9kaXNjb3VudF92YWx1ZXMAC2tSb3V0aW5nRmVlAgtyb3V0aW5nX2ZlZQANa0FkbWluUHViS2V5MQILYWRtaW5fcHViXzEADWtBZG1pblB1YktleTICC2FkbWluX3B1Yl8yAA1rQWRtaW5QdWJLZXkzAgthZG1pbl9wdWJfMwAQa01vbmV5Qm94QWRkcmVzcwIRbW9uZXlfYm94X2FkZHJlc3MAC2tHb3ZBZGRyZXNzAhJnb3Zlcm5hbmNlX2FkZHJlc3MABGtGZWUCCmNvbW1pc3Npb24AEmtNdWx0eUFzc2V0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nl0ZXMJAJEDAggFAnR4BnByb29mcwACBQxhZG1pblB1YktleTMAAQAACQBnAgkAZAIJAGQCBRJhZG1pblB1YktleTFTaWduZWQFEmFkbWluUHViS2V5MlNpZ25lZAUSYWRtaW5QdWJLZXkzU2lnbmVkAAIEByRtYXRjaDAFAnR4BRNtdWx0aVNpZ25lZEJ5QWRtaW5zgk6e/A==", "height": 2228759, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: H4VGBBU9ZmrA8XG9vmczGMcjAAV8SKNLbViTLz48Mfym Next: 71JE7V6wKjCbGbgtWhk4gSeV2duKEy4aX6qT6RKthMpk Diff:
OldNewDifferences
1-{-# STDLIB_VERSION 5 #-}
1+{-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let kActive = "active"
2626 let kGovAddress = "governance_address"
2727
2828 let kFee = "commission"
29+
30+let kMultyAssetBalance = "_balance"
2931
3032 let digits8 = 8
3133
117119
118120
119121 func checkPossibility (caller,pmtAmount,minAmountToReceive,exchangers,exchangersType,routingAssetsKeys,args1,args2) = {
120- let dApp1TokenPay = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[0])
121- let dApp1TokenGet = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[1])
122- let dApp2TokenPay = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[2])
123- let dApp2TokenGet = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[3])
124122 let feeDiscount = calculateFeeDiscount(caller)
125- let getFrom1TradeWithFee = if ((exchangersType[0] == "cpmm"))
123+ let getFrom1TradeWithFee = if ((exchangersType[0] == "curveMultyFlat"))
126124 then {
127- let fee = getIntegerValue(addressFromStringValue(exchangers[0]), kFee)
128- let getFrom1TradeWithoutFee = fraction(dApp1TokenGet, pmtAmount, (pmtAmount + dApp1TokenPay))
129- fraction(getFrom1TradeWithoutFee, (feeScale6 - fraction(fee, feeDiscount, feeScale6)), feeScale6)
125+ let inv = {
126+ let @ = invoke(addressFromStringValue(exchangers[0]), "getDy", [routingAssetsKeys[0], routingAssetsKeys[1], pmtAmount, toString(caller)], nil)
127+ if ($isInstanceOf(@, "(Int, Int)"))
128+ then @
129+ else throw(($getType(invoke(addressFromStringValue(exchangers[0]), "getDy", [routingAssetsKeys[0], routingAssetsKeys[1], pmtAmount, toString(caller)], nil)) + " couldn't be cast to (Int, Int)"))
130+ }
131+ if ((inv == inv))
132+ then inv._1
133+ else throw("Strict value is not equal to itself.")
130134 }
131- else if ((exchangersType[0] == "flat"))
132- then {
133- let invariant = invariantCalc(dApp1TokenPay, dApp1TokenGet)
134- let minAmountToReceive1 = args2[0]
135- let invariantNew = invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1))
136- if ((invariantNew >= invariant))
137- then minAmountToReceive1
138- else throw("Flat contract: invariantNew < invariant")
135+ else {
136+ let dApp1TokenPay = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[0])
137+ let dApp1TokenGet = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[1])
138+ if ((exchangersType[0] == "cpmm"))
139+ then {
140+ let fee = getIntegerValue(addressFromStringValue(exchangers[0]), kFee)
141+ let getFrom1TradeWithoutFee = fraction(dApp1TokenGet, pmtAmount, (pmtAmount + dApp1TokenPay))
142+ fraction(getFrom1TradeWithoutFee, (feeScale6 - fraction(fee, feeDiscount, feeScale6)), feeScale6)
143+ }
144+ else if ((exchangersType[0] == "flat"))
145+ then {
146+ let invariant = invariantCalc(dApp1TokenPay, dApp1TokenGet)
147+ let minAmountToReceive1 = args2[0]
148+ let invariantNew = invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1))
149+ if ((invariantNew >= invariant))
150+ then minAmountToReceive1
151+ else throw("Flat contract: invariantNew < invariant")
152+ }
153+ else throw("Incorrect exchange type")
154+ }
155+ let getFrom2TradeWithFee = if ((exchangersType[1] == "curveMultyFlat"))
156+ then {
157+ let inv = {
158+ let @ = invoke(addressFromStringValue(exchangers[1]), "getDy", [routingAssetsKeys[2], routingAssetsKeys[3], getFrom1TradeWithFee, toString(caller)], nil)
159+ if ($isInstanceOf(@, "(Int, Int)"))
160+ then @
161+ else throw(($getType(invoke(addressFromStringValue(exchangers[1]), "getDy", [routingAssetsKeys[2], routingAssetsKeys[3], getFrom1TradeWithFee, toString(caller)], nil)) + " couldn't be cast to (Int, Int)"))
139162 }
140- else throw("Incorrect exchange type")
141- let getFrom2TradeWithFee = if ((exchangersType[1] == "cpmm"))
142- then {
143- let getFrom2TradeWithoutFee = fraction(dApp2TokenGet, getFrom1TradeWithFee, (getFrom1TradeWithFee + dApp2TokenPay))
144- let fee = getIntegerValue(addressFromStringValue(exchangers[0]), kFee)
145- fraction(getFrom2TradeWithoutFee, (feeScale6 - fraction(fee, feeDiscount, feeScale6)), feeScale6)
163+ if ((inv == inv))
164+ then inv._1
165+ else throw("Strict value is not equal to itself.")
146166 }
147- else if ((exchangersType[1] == "flat"))
148- then {
149- let invariant = invariantCalc(dApp2TokenPay, dApp2TokenGet)
150- let minAmountToReceive2 = args2[1]
151- let invariantNew = invariantCalc((dApp2TokenPay + getFrom1TradeWithFee), (dApp2TokenGet - minAmountToReceive2))
152- if ((invariantNew >= invariant))
153- then minAmountToReceive2
154- else throw("Flat contract: invariantNew < invariant")
155- }
156- else throw("Incorrect exchange type")
167+ else {
168+ let dApp2TokenPay = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[2])
169+ let dApp2TokenGet = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[3])
170+ if ((exchangersType[1] == "cpmm"))
171+ then {
172+ let getFrom2TradeWithoutFee = fraction(dApp2TokenGet, getFrom1TradeWithFee, (getFrom1TradeWithFee + dApp2TokenPay))
173+ let fee = getIntegerValue(addressFromStringValue(exchangers[1]), kFee)
174+ fraction(getFrom2TradeWithoutFee, (feeScale6 - fraction(fee, feeDiscount, feeScale6)), feeScale6)
175+ }
176+ else if ((exchangersType[1] == "flat"))
177+ then {
178+ let invariant = invariantCalc(dApp2TokenPay, dApp2TokenGet)
179+ let minAmountToReceive2 = args2[1]
180+ let invariantNew = invariantCalc((dApp2TokenPay + getFrom1TradeWithFee), (dApp2TokenGet - minAmountToReceive2))
181+ if ((invariantNew >= invariant))
182+ then minAmountToReceive2
183+ else throw("Flat contract: invariantNew < invariant")
184+ }
185+ else throw("Incorrect exchange type")
186+ }
157187 (getFrom2TradeWithFee >= minAmountToReceive)
158188 }
159189
160190
161191 @Callable(i)
162192 func routingTrade (exchangers,exchangersType,args1,args2,routingAssetsKeys,minAmountToReceive) = valueOrElse(isActive(), {
163- let $t067036777 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
164- let pmtAmount = $t067036777._1
165- let pmtAssetId = $t067036777._2
193+ let $t074417515 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
194+ let pmtAmount = $t074417515._1
195+ let pmtAssetId = $t074417515._2
166196 if (!(checkPossibility(i.caller, pmtAmount, minAmountToReceive, exchangers, exchangersType, routingAssetsKeys, args1, args2)))
167197 then throw("Check transaction possibilty: declined")
168198 else if (if (!(isDefined(getString(oracle, (kPoolInOracle + exchangers[0])))))
172202 else {
173203 let routingSize = size(exchangers)
174204 func exchangeFold (accumulated,exchanger) = {
175- let $t072917356 = accumulated
176- let exchangeCounter = $t072917356._1
177- let amountsWithFee = $t072917356._2
178- let assetsIdSend = $t072917356._3
179- let $t073697567 = if ((exchangeCounter == 0))
205+ let $t080298094 = accumulated
206+ let exchangeCounter = $t080298094._1
207+ let amountsWithFee = $t080298094._2
208+ let assetsIdSend = $t080298094._3
209+ let $t081078305 = if ((exchangeCounter == 0))
180210 then $Tuple2(pmtAssetId, pmtAmount)
181211 else $Tuple2(assetsIdSend, amountsWithFee)
182- let pmtAssetIdRout = $t073697567._1
183- let pmtAmountRout = $t073697567._2
212+ let pmtAssetIdRout = $t081078305._1
213+ let pmtAmountRout = $t081078305._2
184214 if (((if ((exchangeCounter >= 0))
185215 then (routingSize > exchangeCounter)
186216 else false) == true))
187217 then {
188218 let exchangerAddress = addressFromStringValue(exchanger)
189- let inv = if ((exchangersType[exchangeCounter] == "cpmm"))
190- then invoke(exchangerAddress, "exchange", [args1[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
219+ if ((exchangersType[exchangeCounter] == "cpmm"))
220+ then {
221+ let $t085528711 = {
222+ let @ = invoke(exchangerAddress, "exchange", [args1[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
223+ if ($isInstanceOf(@, "(Int, Int)"))
224+ then @
225+ else throw(($getType(invoke(exchangerAddress, "exchange", [args1[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])) + " couldn't be cast to (Int, Int)"))
226+ }
227+ if (($t085528711 == $t085528711))
228+ then {
229+ let assetId = $t085528711._2
230+ let amount = $t085528711._1
231+ $Tuple3((exchangeCounter + 1), amount, assetId)
232+ }
233+ else throw("Strict value is not equal to itself.")
234+ }
191235 else if ((exchangersType[exchangeCounter] == "flat"))
192- then invoke(exchangerAddress, "exchange", [args1[exchangeCounter], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
193- else throw("Incorrect exchange type")
194- if ((inv == inv))
195- then match inv {
196- case inv: (Int, Unit)|(Int, ByteVector) =>
197- let $t084158453 = inv
198- let amountWithFee = $t084158453._1
199- let assetIdSend = $t084158453._2
200- $Tuple3((exchangeCounter + 1), amountWithFee, assetIdSend)
201- case _ =>
202- throw("Incorrect invoke result: expected amountWithFee and assetsIdSend")
203- }
204- else throw("Strict value is not equal to itself.")
236+ then {
237+ let inv = {
238+ let @ = invoke(exchangerAddress, "exchange", [args1[exchangeCounter], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
239+ if ($isInstanceOf(@, "List[Any]"))
240+ then @
241+ else throw(($getType(invoke(exchangerAddress, "exchange", [args1[exchangeCounter], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])) + " couldn't be cast to List[Any]"))
242+ }
243+ if ((inv == inv))
244+ then $Tuple3((exchangeCounter + 1), inv[0], inv[1])
245+ else throw("Strict value is not equal to itself.")
246+ }
247+ else if ((exchangersType[exchangeCounter] == "curveMultyFlat"))
248+ then {
249+ let inv = {
250+ let @ = invoke(exchangerAddress, "exchange", [routingAssetsKeys[((exchangeCounter * 2) + 1)], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
251+ if ($isInstanceOf(@, "List[Any]"))
252+ then @
253+ else throw(($getType(invoke(exchangerAddress, "exchange", [routingAssetsKeys[((exchangeCounter * 2) + 1)], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])) + " couldn't be cast to List[Any]"))
254+ }
255+ if ((inv == inv))
256+ then $Tuple3((exchangeCounter + 1), inv[0], inv[1])
257+ else throw("Strict value is not equal to itself.")
258+ }
259+ else throw("Incorrect exchange type")
205260 }
206261 else accumulated
207262 }
208263
209- let $t087338839 = {
264+ let $t095689674 = {
210265 let $l = exchangers
211266 let $s = size($l)
212267 let $acc0 = $Tuple3(0, 0, base58'')
220275
221276 $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3)
222277 }
223- let exchangeCounter = $t087338839._1
224- let amountWithoutFee = $t087338839._2
225- let assetIdSend = $t087338839._3
278+ let exchangeCounter = $t095689674._1
279+ let amountWithoutFee = $t095689674._2
280+ let assetIdSend = $t095689674._3
226281 let amountWithFee = fraction(amountWithoutFee, (feeScale6 - routingFee), feeScale6)
227282 if (if ((exchangeCounter == routingSize))
228283 then (amountWithFee >= minAmountToReceive)
Full:
OldNewDifferences
1-{-# STDLIB_VERSION 5 #-}
1+{-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let kActive = "active"
55
66 let kCause = "shutdown_cause"
77
88 let kPoolInOracle = "pool_"
99
1010 let kUserSwopInGov = "_SWOP_amount"
1111
1212 let kDiscounts = "discounts"
1313
1414 let kDiscountValues = "discount_values"
1515
1616 let kRoutingFee = "routing_fee"
1717
1818 let kAdminPubKey1 = "admin_pub_1"
1919
2020 let kAdminPubKey2 = "admin_pub_2"
2121
2222 let kAdminPubKey3 = "admin_pub_3"
2323
2424 let kMoneyBoxAddress = "money_box_address"
2525
2626 let kGovAddress = "governance_address"
2727
2828 let kFee = "commission"
29+
30+let kMultyAssetBalance = "_balance"
2931
3032 let digits8 = 8
3133
3234 let scale8 = 100000000
3335
3436 let scale16 = 10000000000000000
3537
3638 let alpha = 50
3739
3840 let alphaDigits = 2
3941
4042 let beta = 4600000000000000
4143
4244 let oracle = Address(base58'3NBBWfzZtZtszaXbitTKnrB2xXwv26Bn7H9')
4345
4446 func getBase58FromOracle (key) = match getString(oracle, key) {
4547 case string: String =>
4648 fromBase58String(string)
4749 case nothing =>
4850 throw((key + "is empty"))
4951 }
5052
5153
5254 let adminPubKey1 = getBase58FromOracle(kAdminPubKey1)
5355
5456 let adminPubKey2 = getBase58FromOracle(kAdminPubKey2)
5557
5658 let adminPubKey3 = getBase58FromOracle(kAdminPubKey3)
5759
5860 let moneyBoxAddress = Address(getBase58FromOracle(kMoneyBoxAddress))
5961
6062 let govAddress = Address(getBase58FromOracle(kGovAddress))
6163
6264 let active = valueOrElse(getBoolean(this, kActive), true)
6365
6466 let routingFee = valueOrErrorMessage(getInteger(oracle, kRoutingFee), "routing_fee is empty")
6567
6668 let feeScale6 = 1000000
6769
6870 func isActive () = if (active)
6971 then unit
7072 else throw("DApp is inactive at this moment")
7173
7274
7375 func isAdminCall (i) = if (containsElement([adminPubKey1, adminPubKey2, adminPubKey3], i.callerPublicKey))
7476 then unit
7577 else throw("Only admin can call this function")
7678
7779
7880 func throwIsActive () = throw("DApp is already active")
7981
8082
8183 func suspend (cause) = [BooleanEntry(kActive, false), StringEntry(kCause, cause)]
8284
8385
8486 func skewness (x,y) = ((fraction(scale16, x, y) + fraction(scale16, y, x)) / 2)
8587
8688
8789 func invariantCalc (x,y) = {
8890 let sk = skewness(x, y)
8991 (fraction((x + y), scale16, pow(sk, digits8, alpha, alphaDigits, digits8, CEILING)) + (2 * fraction(toInt(pow(fraction(toBigInt(x), toBigInt(y), toBigInt(scale8)), 0, toBigInt(5), 1, (digits8 / 2), DOWN)), pow((sk - beta), digits8, alpha, alphaDigits, digits8, DOWN), scale8)))
9092 }
9193
9294
9395 func calculateFeeDiscount (userAddr) = {
9496 let swopAmount = valueOrElse(getInteger(govAddress, (toString(userAddr) + kUserSwopInGov)), 0)
9597 let discountValues = split(getStringValue(oracle, kDiscountValues), ",")
9698 let discounts = split(getStringValue(oracle, kDiscounts), ",")
9799 if (if ((swopAmount >= parseIntValue(discountValues[0])))
98100 then (parseIntValue(discountValues[1]) > swopAmount)
99101 else false)
100102 then (feeScale6 - parseIntValue(discounts[0]))
101103 else if (if ((swopAmount >= parseIntValue(discountValues[1])))
102104 then (parseIntValue(discountValues[2]) > swopAmount)
103105 else false)
104106 then (feeScale6 - parseIntValue(discounts[1]))
105107 else if (if ((swopAmount >= parseIntValue(discountValues[2])))
106108 then (parseIntValue(discountValues[3]) > swopAmount)
107109 else false)
108110 then (feeScale6 - parseIntValue(discounts[2]))
109111 else if (if ((swopAmount >= parseIntValue(discountValues[3])))
110112 then (parseIntValue(discountValues[4]) > swopAmount)
111113 else false)
112114 then (feeScale6 - parseIntValue(discounts[3]))
113115 else if ((swopAmount >= parseIntValue(discountValues[4])))
114116 then (feeScale6 - parseIntValue(discounts[4]))
115117 else feeScale6
116118 }
117119
118120
119121 func checkPossibility (caller,pmtAmount,minAmountToReceive,exchangers,exchangersType,routingAssetsKeys,args1,args2) = {
120- let dApp1TokenPay = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[0])
121- let dApp1TokenGet = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[1])
122- let dApp2TokenPay = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[2])
123- let dApp2TokenGet = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[3])
124122 let feeDiscount = calculateFeeDiscount(caller)
125- let getFrom1TradeWithFee = if ((exchangersType[0] == "cpmm"))
123+ let getFrom1TradeWithFee = if ((exchangersType[0] == "curveMultyFlat"))
126124 then {
127- let fee = getIntegerValue(addressFromStringValue(exchangers[0]), kFee)
128- let getFrom1TradeWithoutFee = fraction(dApp1TokenGet, pmtAmount, (pmtAmount + dApp1TokenPay))
129- fraction(getFrom1TradeWithoutFee, (feeScale6 - fraction(fee, feeDiscount, feeScale6)), feeScale6)
125+ let inv = {
126+ let @ = invoke(addressFromStringValue(exchangers[0]), "getDy", [routingAssetsKeys[0], routingAssetsKeys[1], pmtAmount, toString(caller)], nil)
127+ if ($isInstanceOf(@, "(Int, Int)"))
128+ then @
129+ else throw(($getType(invoke(addressFromStringValue(exchangers[0]), "getDy", [routingAssetsKeys[0], routingAssetsKeys[1], pmtAmount, toString(caller)], nil)) + " couldn't be cast to (Int, Int)"))
130+ }
131+ if ((inv == inv))
132+ then inv._1
133+ else throw("Strict value is not equal to itself.")
130134 }
131- else if ((exchangersType[0] == "flat"))
132- then {
133- let invariant = invariantCalc(dApp1TokenPay, dApp1TokenGet)
134- let minAmountToReceive1 = args2[0]
135- let invariantNew = invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1))
136- if ((invariantNew >= invariant))
137- then minAmountToReceive1
138- else throw("Flat contract: invariantNew < invariant")
135+ else {
136+ let dApp1TokenPay = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[0])
137+ let dApp1TokenGet = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[1])
138+ if ((exchangersType[0] == "cpmm"))
139+ then {
140+ let fee = getIntegerValue(addressFromStringValue(exchangers[0]), kFee)
141+ let getFrom1TradeWithoutFee = fraction(dApp1TokenGet, pmtAmount, (pmtAmount + dApp1TokenPay))
142+ fraction(getFrom1TradeWithoutFee, (feeScale6 - fraction(fee, feeDiscount, feeScale6)), feeScale6)
143+ }
144+ else if ((exchangersType[0] == "flat"))
145+ then {
146+ let invariant = invariantCalc(dApp1TokenPay, dApp1TokenGet)
147+ let minAmountToReceive1 = args2[0]
148+ let invariantNew = invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1))
149+ if ((invariantNew >= invariant))
150+ then minAmountToReceive1
151+ else throw("Flat contract: invariantNew < invariant")
152+ }
153+ else throw("Incorrect exchange type")
154+ }
155+ let getFrom2TradeWithFee = if ((exchangersType[1] == "curveMultyFlat"))
156+ then {
157+ let inv = {
158+ let @ = invoke(addressFromStringValue(exchangers[1]), "getDy", [routingAssetsKeys[2], routingAssetsKeys[3], getFrom1TradeWithFee, toString(caller)], nil)
159+ if ($isInstanceOf(@, "(Int, Int)"))
160+ then @
161+ else throw(($getType(invoke(addressFromStringValue(exchangers[1]), "getDy", [routingAssetsKeys[2], routingAssetsKeys[3], getFrom1TradeWithFee, toString(caller)], nil)) + " couldn't be cast to (Int, Int)"))
139162 }
140- else throw("Incorrect exchange type")
141- let getFrom2TradeWithFee = if ((exchangersType[1] == "cpmm"))
142- then {
143- let getFrom2TradeWithoutFee = fraction(dApp2TokenGet, getFrom1TradeWithFee, (getFrom1TradeWithFee + dApp2TokenPay))
144- let fee = getIntegerValue(addressFromStringValue(exchangers[0]), kFee)
145- fraction(getFrom2TradeWithoutFee, (feeScale6 - fraction(fee, feeDiscount, feeScale6)), feeScale6)
163+ if ((inv == inv))
164+ then inv._1
165+ else throw("Strict value is not equal to itself.")
146166 }
147- else if ((exchangersType[1] == "flat"))
148- then {
149- let invariant = invariantCalc(dApp2TokenPay, dApp2TokenGet)
150- let minAmountToReceive2 = args2[1]
151- let invariantNew = invariantCalc((dApp2TokenPay + getFrom1TradeWithFee), (dApp2TokenGet - minAmountToReceive2))
152- if ((invariantNew >= invariant))
153- then minAmountToReceive2
154- else throw("Flat contract: invariantNew < invariant")
155- }
156- else throw("Incorrect exchange type")
167+ else {
168+ let dApp2TokenPay = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[2])
169+ let dApp2TokenGet = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[3])
170+ if ((exchangersType[1] == "cpmm"))
171+ then {
172+ let getFrom2TradeWithoutFee = fraction(dApp2TokenGet, getFrom1TradeWithFee, (getFrom1TradeWithFee + dApp2TokenPay))
173+ let fee = getIntegerValue(addressFromStringValue(exchangers[1]), kFee)
174+ fraction(getFrom2TradeWithoutFee, (feeScale6 - fraction(fee, feeDiscount, feeScale6)), feeScale6)
175+ }
176+ else if ((exchangersType[1] == "flat"))
177+ then {
178+ let invariant = invariantCalc(dApp2TokenPay, dApp2TokenGet)
179+ let minAmountToReceive2 = args2[1]
180+ let invariantNew = invariantCalc((dApp2TokenPay + getFrom1TradeWithFee), (dApp2TokenGet - minAmountToReceive2))
181+ if ((invariantNew >= invariant))
182+ then minAmountToReceive2
183+ else throw("Flat contract: invariantNew < invariant")
184+ }
185+ else throw("Incorrect exchange type")
186+ }
157187 (getFrom2TradeWithFee >= minAmountToReceive)
158188 }
159189
160190
161191 @Callable(i)
162192 func routingTrade (exchangers,exchangersType,args1,args2,routingAssetsKeys,minAmountToReceive) = valueOrElse(isActive(), {
163- let $t067036777 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
164- let pmtAmount = $t067036777._1
165- let pmtAssetId = $t067036777._2
193+ let $t074417515 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
194+ let pmtAmount = $t074417515._1
195+ let pmtAssetId = $t074417515._2
166196 if (!(checkPossibility(i.caller, pmtAmount, minAmountToReceive, exchangers, exchangersType, routingAssetsKeys, args1, args2)))
167197 then throw("Check transaction possibilty: declined")
168198 else if (if (!(isDefined(getString(oracle, (kPoolInOracle + exchangers[0])))))
169199 then true
170200 else !(isDefined(getString(oracle, (kPoolInOracle + exchangers[1])))))
171201 then throw("Pool is not in oracle")
172202 else {
173203 let routingSize = size(exchangers)
174204 func exchangeFold (accumulated,exchanger) = {
175- let $t072917356 = accumulated
176- let exchangeCounter = $t072917356._1
177- let amountsWithFee = $t072917356._2
178- let assetsIdSend = $t072917356._3
179- let $t073697567 = if ((exchangeCounter == 0))
205+ let $t080298094 = accumulated
206+ let exchangeCounter = $t080298094._1
207+ let amountsWithFee = $t080298094._2
208+ let assetsIdSend = $t080298094._3
209+ let $t081078305 = if ((exchangeCounter == 0))
180210 then $Tuple2(pmtAssetId, pmtAmount)
181211 else $Tuple2(assetsIdSend, amountsWithFee)
182- let pmtAssetIdRout = $t073697567._1
183- let pmtAmountRout = $t073697567._2
212+ let pmtAssetIdRout = $t081078305._1
213+ let pmtAmountRout = $t081078305._2
184214 if (((if ((exchangeCounter >= 0))
185215 then (routingSize > exchangeCounter)
186216 else false) == true))
187217 then {
188218 let exchangerAddress = addressFromStringValue(exchanger)
189- let inv = if ((exchangersType[exchangeCounter] == "cpmm"))
190- then invoke(exchangerAddress, "exchange", [args1[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
219+ if ((exchangersType[exchangeCounter] == "cpmm"))
220+ then {
221+ let $t085528711 = {
222+ let @ = invoke(exchangerAddress, "exchange", [args1[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
223+ if ($isInstanceOf(@, "(Int, Int)"))
224+ then @
225+ else throw(($getType(invoke(exchangerAddress, "exchange", [args1[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])) + " couldn't be cast to (Int, Int)"))
226+ }
227+ if (($t085528711 == $t085528711))
228+ then {
229+ let assetId = $t085528711._2
230+ let amount = $t085528711._1
231+ $Tuple3((exchangeCounter + 1), amount, assetId)
232+ }
233+ else throw("Strict value is not equal to itself.")
234+ }
191235 else if ((exchangersType[exchangeCounter] == "flat"))
192- then invoke(exchangerAddress, "exchange", [args1[exchangeCounter], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
193- else throw("Incorrect exchange type")
194- if ((inv == inv))
195- then match inv {
196- case inv: (Int, Unit)|(Int, ByteVector) =>
197- let $t084158453 = inv
198- let amountWithFee = $t084158453._1
199- let assetIdSend = $t084158453._2
200- $Tuple3((exchangeCounter + 1), amountWithFee, assetIdSend)
201- case _ =>
202- throw("Incorrect invoke result: expected amountWithFee and assetsIdSend")
203- }
204- else throw("Strict value is not equal to itself.")
236+ then {
237+ let inv = {
238+ let @ = invoke(exchangerAddress, "exchange", [args1[exchangeCounter], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
239+ if ($isInstanceOf(@, "List[Any]"))
240+ then @
241+ else throw(($getType(invoke(exchangerAddress, "exchange", [args1[exchangeCounter], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])) + " couldn't be cast to List[Any]"))
242+ }
243+ if ((inv == inv))
244+ then $Tuple3((exchangeCounter + 1), inv[0], inv[1])
245+ else throw("Strict value is not equal to itself.")
246+ }
247+ else if ((exchangersType[exchangeCounter] == "curveMultyFlat"))
248+ then {
249+ let inv = {
250+ let @ = invoke(exchangerAddress, "exchange", [routingAssetsKeys[((exchangeCounter * 2) + 1)], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
251+ if ($isInstanceOf(@, "List[Any]"))
252+ then @
253+ else throw(($getType(invoke(exchangerAddress, "exchange", [routingAssetsKeys[((exchangeCounter * 2) + 1)], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])) + " couldn't be cast to List[Any]"))
254+ }
255+ if ((inv == inv))
256+ then $Tuple3((exchangeCounter + 1), inv[0], inv[1])
257+ else throw("Strict value is not equal to itself.")
258+ }
259+ else throw("Incorrect exchange type")
205260 }
206261 else accumulated
207262 }
208263
209- let $t087338839 = {
264+ let $t095689674 = {
210265 let $l = exchangers
211266 let $s = size($l)
212267 let $acc0 = $Tuple3(0, 0, base58'')
213268 func $f0_1 ($a,$i) = if (($i >= $s))
214269 then $a
215270 else exchangeFold($a, $l[$i])
216271
217272 func $f0_2 ($a,$i) = if (($i >= $s))
218273 then $a
219274 else throw("List size exceeds 3")
220275
221276 $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3)
222277 }
223- let exchangeCounter = $t087338839._1
224- let amountWithoutFee = $t087338839._2
225- let assetIdSend = $t087338839._3
278+ let exchangeCounter = $t095689674._1
279+ let amountWithoutFee = $t095689674._2
280+ let assetIdSend = $t095689674._3
226281 let amountWithFee = fraction(amountWithoutFee, (feeScale6 - routingFee), feeScale6)
227282 if (if ((exchangeCounter == routingSize))
228283 then (amountWithFee >= minAmountToReceive)
229284 else false)
230285 then [ScriptTransfer(i.caller, amountWithFee, assetIdSend), ScriptTransfer(moneyBoxAddress, (amountWithoutFee - amountWithFee), assetIdSend)]
231286 else throw("routing != routingSize or amountToRecieve < minAmountToReceive")
232287 }
233288 })
234289
235290
236291
237292 @Callable(i)
238293 func shutdown () = valueOrElse(isAdminCall(i), if (!(active))
239294 then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, kCause), "the cause wasn't specified")))
240295 else suspend("Paused by admin"))
241296
242297
243298
244299 @Callable(i)
245300 func activate () = valueOrElse(isAdminCall(i), if (active)
246301 then throwIsActive()
247302 else [BooleanEntry(kActive, true), DeleteEntry(kCause)])
248303
249304
250305 @Verifier(tx)
251306 func verify () = {
252307 let multiSignedByAdmins = {
253308 let adminPubKey1Signed = if (sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey1))
254309 then 1
255310 else 0
256311 let adminPubKey2Signed = if (sigVerify(tx.bodyBytes, tx.proofs[1], adminPubKey2))
257312 then 1
258313 else 0
259314 let adminPubKey3Signed = if (sigVerify(tx.bodyBytes, tx.proofs[2], adminPubKey3))
260315 then 1
261316 else 0
262317 (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 2)
263318 }
264319 match tx {
265320 case _ =>
266321 multiSignedByAdmins
267322 }
268323 }
269324

github/deemru/w8io/026f985 
58.78 ms