tx · H4VGBBU9ZmrA8XG9vmczGMcjAAV8SKNLbViTLz48Mfym

3MqDf9VgoL9eqrCPx8F74Au6xBpvdTm9UP8:  -0.01500000 Waves

2022.09.14 14:41 [2228723] smart account 3MqDf9VgoL9eqrCPx8F74Au6xBpvdTm9UP8 > SELF 0.00000000 Waves

{ "type": 13, "id": "H4VGBBU9ZmrA8XG9vmczGMcjAAV8SKNLbViTLz48Mfym", "fee": 1500000, "feeAssetId": null, "timestamp": 1663155683206, "version": 2, "chainId": 84, "sender": "3MqDf9VgoL9eqrCPx8F74Au6xBpvdTm9UP8", "senderPublicKey": "4ja2PX5eqM576zv9KGzu5Qe7M92Z3jbuSmkLPdGjK4ue", "proofs": [ "2tHzUwUA1Bx9KomMZrNV1yghfcHw6qbBnmjA9ttHCX4zDiD77qt6s3XYQQ47wnkHxg2m722UhB2q8TFmBToLrq42", "3TPKwowN1pSR8b4kaWpfq9XEXL4LcJRBqfWvsseweiVL5HtkWfZa6hsdMyzfhUV1zjk9MDo8vB4s9DxjSqn9ZCQb" ], "script": "base64:AAIFAAAAAAAAABAIAhIICgYYGBERGAESABIAAAAAJQAAAAAHa0FjdGl2ZQIAAAAGYWN0aXZlAAAAAAZrQ2F1c2UCAAAADnNodXRkb3duX2NhdXNlAAAAAA1rUG9vbEluT3JhY2xlAgAAAAVwb29sXwAAAAAOa1VzZXJTd29wSW5Hb3YCAAAADF9TV09QX2Ftb3VudAAAAAAKa0Rpc2NvdW50cwIAAAAJZGlzY291bnRzAAAAAA9rRGlzY291bnRWYWx1ZXMCAAAAD2Rpc2NvdW50X3ZhbHVlcwAAAAALa1JvdXRpbmdGZWUCAAAAC3JvdXRpbmdfZmVlAAAAAA1rQWRtaW5QdWJLZXkxAgAAAAthZG1pbl9wdWJfMQAAAAANa0FkbWluUHViS2V5MgIAAAALYWRtaW5fcHViXzIAAAAADWtBZG1pblB1YktleTMCAAAAC2FkbWluX3B1Yl8zAAAAABBrTW9uZXlCb3hBZGRyZXNzAgAAABF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AAAAAAAAAAEAAAAAAAAAAAAJAABnAAAAAgkAAGQAAAACCQAAZAAAAAIFAAAAEmFkbWluUHViS2V5MVNpZ25lZAUAAAASYWRtaW5QdWJLZXkyU2lnbmVkBQAAABJhZG1pblB1YktleTNTaWduZWQAAAAAAAAAAAIEAAAAByRtYXRjaDAFAAAAAnR4BQAAABNtdWx0aVNpZ25lZEJ5QWRtaW5zm9b11w==", "height": 2228723, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 8aZNzeXShrL1Rw5LTm67zxmAZmUidW3Ju65FeooUdt64 Next: 9922meKgC3fkWX2itfeaHUKhNTCJ5GfdoasNvt4pE4S6 Diff:
OldNewDifferences
1-{-# STDLIB_VERSION 6 #-}
1+{-# STDLIB_VERSION 5 #-}
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"
3129
3230 let digits8 = 8
3331
119117
120118
121119 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])
122124 let feeDiscount = calculateFeeDiscount(caller)
123- let getFrom1TradeWithFee = if ((exchangersType[0] == "curveMultyFlat"))
125+ let getFrom1TradeWithFee = if ((exchangersType[0] == "cpmm"))
124126 then {
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)"))
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)
130+ }
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")
130139 }
131- if ((inv == inv))
132- then inv._1
133- else throw("Strict value is not equal to itself.")
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)
134146 }
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)"))
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")
162155 }
163- if ((inv == inv))
164- then inv._1
165- else throw("Strict value is not equal to itself.")
166- }
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- }
156+ else throw("Incorrect exchange type")
187157 (getFrom2TradeWithFee >= minAmountToReceive)
188158 }
189159
190160
191161 @Callable(i)
192162 func routingTrade (exchangers,exchangersType,args1,args2,routingAssetsKeys,minAmountToReceive) = valueOrElse(isActive(), {
193- let $t074417515 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
194- let pmtAmount = $t074417515._1
195- let pmtAssetId = $t074417515._2
163+ let $t067036777 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
164+ let pmtAmount = $t067036777._1
165+ let pmtAssetId = $t067036777._2
196166 if (!(checkPossibility(i.caller, pmtAmount, minAmountToReceive, exchangers, exchangersType, routingAssetsKeys, args1, args2)))
197167 then throw("Check transaction possibilty: declined")
198168 else if (if (!(isDefined(getString(oracle, (kPoolInOracle + exchangers[0])))))
202172 else {
203173 let routingSize = size(exchangers)
204174 func exchangeFold (accumulated,exchanger) = {
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))
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))
210180 then $Tuple2(pmtAssetId, pmtAmount)
211181 else $Tuple2(assetsIdSend, amountsWithFee)
212- let pmtAssetIdRout = $t081078305._1
213- let pmtAmountRout = $t081078305._2
182+ let pmtAssetIdRout = $t073697567._1
183+ let pmtAmountRout = $t073697567._2
214184 if (((if ((exchangeCounter >= 0))
215185 then (routingSize > exchangeCounter)
216186 else false) == true))
217187 then {
218188 let exchangerAddress = addressFromStringValue(exchanger)
219- if ((exchangersType[exchangeCounter] == "cpmm"))
220- then {
221- let inv = {
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 ((inv == inv))
228- then $Tuple3((exchangeCounter + 1), inv._1, inv._2)
229- else throw("Strict value is not equal to itself.")
230- }
189+ let inv = if ((exchangersType[exchangeCounter] == "cpmm"))
190+ then invoke(exchangerAddress, "exchange", [args1[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
231191 else if ((exchangersType[exchangeCounter] == "flat"))
232- then {
233- let inv = {
234- let @ = invoke(exchangerAddress, "exchange", [args1[exchangeCounter], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
235- if ($isInstanceOf(@, "List[Any]"))
236- then @
237- else throw(($getType(invoke(exchangerAddress, "exchange", [args1[exchangeCounter], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])) + " couldn't be cast to List[Any]"))
238- }
239- if ((inv == inv))
240- then $Tuple3((exchangeCounter + 1), inv[0], inv[1])
241- else throw("Strict value is not equal to itself.")
242- }
243- else if ((exchangersType[exchangeCounter] == "curveMultyFlat"))
244- then {
245- let inv = {
246- let @ = invoke(exchangerAddress, "exchange", [routingAssetsKeys[((exchangeCounter * 2) + 1)], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
247- if ($isInstanceOf(@, "List[Any]"))
248- then @
249- else throw(($getType(invoke(exchangerAddress, "exchange", [routingAssetsKeys[((exchangeCounter * 2) + 1)], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])) + " couldn't be cast to List[Any]"))
250- }
251- if ((inv == inv))
252- then $Tuple3((exchangeCounter + 1), inv[0], inv[1])
253- else throw("Strict value is not equal to itself.")
254- }
255- else throw("Incorrect exchange type")
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.")
256205 }
257206 else accumulated
258207 }
259208
260- let $t095539659 = {
209+ let $t087338839 = {
261210 let $l = exchangers
262211 let $s = size($l)
263212 let $acc0 = $Tuple3(0, 0, base58'')
271220
272221 $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3)
273222 }
274- let exchangeCounter = $t095539659._1
275- let amountWithoutFee = $t095539659._2
276- let assetIdSend = $t095539659._3
223+ let exchangeCounter = $t087338839._1
224+ let amountWithoutFee = $t087338839._2
225+ let assetIdSend = $t087338839._3
277226 let amountWithFee = fraction(amountWithoutFee, (feeScale6 - routingFee), feeScale6)
278227 if (if ((exchangeCounter == routingSize))
279228 then (amountWithFee >= minAmountToReceive)
Full:
OldNewDifferences
1-{-# STDLIB_VERSION 6 #-}
1+{-# STDLIB_VERSION 5 #-}
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"
3129
3230 let digits8 = 8
3331
3432 let scale8 = 100000000
3533
3634 let scale16 = 10000000000000000
3735
3836 let alpha = 50
3937
4038 let alphaDigits = 2
4139
4240 let beta = 4600000000000000
4341
4442 let oracle = Address(base58'3NBBWfzZtZtszaXbitTKnrB2xXwv26Bn7H9')
4543
4644 func getBase58FromOracle (key) = match getString(oracle, key) {
4745 case string: String =>
4846 fromBase58String(string)
4947 case nothing =>
5048 throw((key + "is empty"))
5149 }
5250
5351
5452 let adminPubKey1 = getBase58FromOracle(kAdminPubKey1)
5553
5654 let adminPubKey2 = getBase58FromOracle(kAdminPubKey2)
5755
5856 let adminPubKey3 = getBase58FromOracle(kAdminPubKey3)
5957
6058 let moneyBoxAddress = Address(getBase58FromOracle(kMoneyBoxAddress))
6159
6260 let govAddress = Address(getBase58FromOracle(kGovAddress))
6361
6462 let active = valueOrElse(getBoolean(this, kActive), true)
6563
6664 let routingFee = valueOrErrorMessage(getInteger(oracle, kRoutingFee), "routing_fee is empty")
6765
6866 let feeScale6 = 1000000
6967
7068 func isActive () = if (active)
7169 then unit
7270 else throw("DApp is inactive at this moment")
7371
7472
7573 func isAdminCall (i) = if (containsElement([adminPubKey1, adminPubKey2, adminPubKey3], i.callerPublicKey))
7674 then unit
7775 else throw("Only admin can call this function")
7876
7977
8078 func throwIsActive () = throw("DApp is already active")
8179
8280
8381 func suspend (cause) = [BooleanEntry(kActive, false), StringEntry(kCause, cause)]
8482
8583
8684 func skewness (x,y) = ((fraction(scale16, x, y) + fraction(scale16, y, x)) / 2)
8785
8886
8987 func invariantCalc (x,y) = {
9088 let sk = skewness(x, y)
9189 (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)))
9290 }
9391
9492
9593 func calculateFeeDiscount (userAddr) = {
9694 let swopAmount = valueOrElse(getInteger(govAddress, (toString(userAddr) + kUserSwopInGov)), 0)
9795 let discountValues = split(getStringValue(oracle, kDiscountValues), ",")
9896 let discounts = split(getStringValue(oracle, kDiscounts), ",")
9997 if (if ((swopAmount >= parseIntValue(discountValues[0])))
10098 then (parseIntValue(discountValues[1]) > swopAmount)
10199 else false)
102100 then (feeScale6 - parseIntValue(discounts[0]))
103101 else if (if ((swopAmount >= parseIntValue(discountValues[1])))
104102 then (parseIntValue(discountValues[2]) > swopAmount)
105103 else false)
106104 then (feeScale6 - parseIntValue(discounts[1]))
107105 else if (if ((swopAmount >= parseIntValue(discountValues[2])))
108106 then (parseIntValue(discountValues[3]) > swopAmount)
109107 else false)
110108 then (feeScale6 - parseIntValue(discounts[2]))
111109 else if (if ((swopAmount >= parseIntValue(discountValues[3])))
112110 then (parseIntValue(discountValues[4]) > swopAmount)
113111 else false)
114112 then (feeScale6 - parseIntValue(discounts[3]))
115113 else if ((swopAmount >= parseIntValue(discountValues[4])))
116114 then (feeScale6 - parseIntValue(discounts[4]))
117115 else feeScale6
118116 }
119117
120118
121119 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])
122124 let feeDiscount = calculateFeeDiscount(caller)
123- let getFrom1TradeWithFee = if ((exchangersType[0] == "curveMultyFlat"))
125+ let getFrom1TradeWithFee = if ((exchangersType[0] == "cpmm"))
124126 then {
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)"))
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)
130+ }
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")
130139 }
131- if ((inv == inv))
132- then inv._1
133- else throw("Strict value is not equal to itself.")
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)
134146 }
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)"))
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")
162155 }
163- if ((inv == inv))
164- then inv._1
165- else throw("Strict value is not equal to itself.")
166- }
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- }
156+ else throw("Incorrect exchange type")
187157 (getFrom2TradeWithFee >= minAmountToReceive)
188158 }
189159
190160
191161 @Callable(i)
192162 func routingTrade (exchangers,exchangersType,args1,args2,routingAssetsKeys,minAmountToReceive) = valueOrElse(isActive(), {
193- let $t074417515 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
194- let pmtAmount = $t074417515._1
195- let pmtAssetId = $t074417515._2
163+ let $t067036777 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
164+ let pmtAmount = $t067036777._1
165+ let pmtAssetId = $t067036777._2
196166 if (!(checkPossibility(i.caller, pmtAmount, minAmountToReceive, exchangers, exchangersType, routingAssetsKeys, args1, args2)))
197167 then throw("Check transaction possibilty: declined")
198168 else if (if (!(isDefined(getString(oracle, (kPoolInOracle + exchangers[0])))))
199169 then true
200170 else !(isDefined(getString(oracle, (kPoolInOracle + exchangers[1])))))
201171 then throw("Pool is not in oracle")
202172 else {
203173 let routingSize = size(exchangers)
204174 func exchangeFold (accumulated,exchanger) = {
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))
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))
210180 then $Tuple2(pmtAssetId, pmtAmount)
211181 else $Tuple2(assetsIdSend, amountsWithFee)
212- let pmtAssetIdRout = $t081078305._1
213- let pmtAmountRout = $t081078305._2
182+ let pmtAssetIdRout = $t073697567._1
183+ let pmtAmountRout = $t073697567._2
214184 if (((if ((exchangeCounter >= 0))
215185 then (routingSize > exchangeCounter)
216186 else false) == true))
217187 then {
218188 let exchangerAddress = addressFromStringValue(exchanger)
219- if ((exchangersType[exchangeCounter] == "cpmm"))
220- then {
221- let inv = {
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 ((inv == inv))
228- then $Tuple3((exchangeCounter + 1), inv._1, inv._2)
229- else throw("Strict value is not equal to itself.")
230- }
189+ let inv = if ((exchangersType[exchangeCounter] == "cpmm"))
190+ then invoke(exchangerAddress, "exchange", [args1[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
231191 else if ((exchangersType[exchangeCounter] == "flat"))
232- then {
233- let inv = {
234- let @ = invoke(exchangerAddress, "exchange", [args1[exchangeCounter], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
235- if ($isInstanceOf(@, "List[Any]"))
236- then @
237- else throw(($getType(invoke(exchangerAddress, "exchange", [args1[exchangeCounter], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])) + " couldn't be cast to List[Any]"))
238- }
239- if ((inv == inv))
240- then $Tuple3((exchangeCounter + 1), inv[0], inv[1])
241- else throw("Strict value is not equal to itself.")
242- }
243- else if ((exchangersType[exchangeCounter] == "curveMultyFlat"))
244- then {
245- let inv = {
246- let @ = invoke(exchangerAddress, "exchange", [routingAssetsKeys[((exchangeCounter * 2) + 1)], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])
247- if ($isInstanceOf(@, "List[Any]"))
248- then @
249- else throw(($getType(invoke(exchangerAddress, "exchange", [routingAssetsKeys[((exchangeCounter * 2) + 1)], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)])) + " couldn't be cast to List[Any]"))
250- }
251- if ((inv == inv))
252- then $Tuple3((exchangeCounter + 1), inv[0], inv[1])
253- else throw("Strict value is not equal to itself.")
254- }
255- else throw("Incorrect exchange type")
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.")
256205 }
257206 else accumulated
258207 }
259208
260- let $t095539659 = {
209+ let $t087338839 = {
261210 let $l = exchangers
262211 let $s = size($l)
263212 let $acc0 = $Tuple3(0, 0, base58'')
264213 func $f0_1 ($a,$i) = if (($i >= $s))
265214 then $a
266215 else exchangeFold($a, $l[$i])
267216
268217 func $f0_2 ($a,$i) = if (($i >= $s))
269218 then $a
270219 else throw("List size exceeds 3")
271220
272221 $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3)
273222 }
274- let exchangeCounter = $t095539659._1
275- let amountWithoutFee = $t095539659._2
276- let assetIdSend = $t095539659._3
223+ let exchangeCounter = $t087338839._1
224+ let amountWithoutFee = $t087338839._2
225+ let assetIdSend = $t087338839._3
277226 let amountWithFee = fraction(amountWithoutFee, (feeScale6 - routingFee), feeScale6)
278227 if (if ((exchangeCounter == routingSize))
279228 then (amountWithFee >= minAmountToReceive)
280229 else false)
281230 then [ScriptTransfer(i.caller, amountWithFee, assetIdSend), ScriptTransfer(moneyBoxAddress, (amountWithoutFee - amountWithFee), assetIdSend)]
282231 else throw("routing != routingSize or amountToRecieve < minAmountToReceive")
283232 }
284233 })
285234
286235
287236
288237 @Callable(i)
289238 func shutdown () = valueOrElse(isAdminCall(i), if (!(active))
290239 then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, kCause), "the cause wasn't specified")))
291240 else suspend("Paused by admin"))
292241
293242
294243
295244 @Callable(i)
296245 func activate () = valueOrElse(isAdminCall(i), if (active)
297246 then throwIsActive()
298247 else [BooleanEntry(kActive, true), DeleteEntry(kCause)])
299248
300249
301250 @Verifier(tx)
302251 func verify () = {
303252 let multiSignedByAdmins = {
304253 let adminPubKey1Signed = if (sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey1))
305254 then 1
306255 else 0
307256 let adminPubKey2Signed = if (sigVerify(tx.bodyBytes, tx.proofs[1], adminPubKey2))
308257 then 1
309258 else 0
310259 let adminPubKey3Signed = if (sigVerify(tx.bodyBytes, tx.proofs[2], adminPubKey3))
311260 then 1
312261 else 0
313262 (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 2)
314263 }
315264 match tx {
316265 case _ =>
317266 multiSignedByAdmins
318267 }
319268 }
320269

github/deemru/w8io/026f985 
43.52 ms