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:AAIFAAAAAAAAABAIAhIICgYYGBERGAESABIAAAAAJQAAAAAHa0FjdGl2ZQIAAAAGYWN0aXZlAAAAAAZrQ2F1c2UCAAAADnNodXRkb3duX2NhdXNlAAAAAA1rUG9vbEluT3JhY2xlAgAAAAVwb29sXwAAAAAOa1VzZXJTd29wSW5Hb3YCAAAADF9TV09QX2Ftb3VudAAAAAAKa0Rpc2NvdW50cwIAAAAJZGlzY291bnRzAAAAAA9rRGlzY291bnRWYWx1ZXMCAAAAD2Rpc2NvdW50X3ZhbHVlcwAAAAALa1JvdXRpbmdGZWUCAAAAC3JvdXRpbmdfZmVlAAAAAA1rQWRtaW5QdWJLZXkxAgAAAAthZG1pbl9wdWJfMQAAAAANa0FkbWluUHViS2V5MgIAAAALYWRtaW5fcHViXzIAAAAADWtBZG1pblB1YktleTMCAAAAC2FkbWluX3B1Yl8zAAAAABBrTW9uZXlCb3hBZGRyZXNzAgAAABFt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AAAAAAAAAEAAAAAAAAAAAAJAABnAAAAAgkAAGQAAAACCQAAZAAAAAIFAAAAEmFkbWluUHViS2V5MVNpZ25lZAUAAAASYWRtaW5QdWJLZXkyU2lnbmVkBQAAABJhZG1pblB1YktleTNTaWduZWQAAAAAAAAAAAIEAAAAByRtYXRjaDAFAAAAAnR4BQAAABNtdWx0aVNpZ25lZEJ5QWRtaW5zm9b11w==", "height": 2228723, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 8aZNzeXShrL1Rw5LTm67zxmAZmUidW3Ju65FeooUdt64 Next: 9922meKgC3fkWX2itfeaHUKhNTCJ5GfdoasNvt4pE4S6 Diff:
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let kActive = "active" | |
26 | 26 | let kGovAddress = "governance_address" | |
27 | 27 | ||
28 | 28 | let kFee = "commission" | |
29 | - | ||
30 | - | let kMultyAssetBalance = "_balance" | |
31 | 29 | ||
32 | 30 | let digits8 = 8 | |
33 | 31 | ||
119 | 117 | ||
120 | 118 | ||
121 | 119 | 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]) | |
122 | 124 | let feeDiscount = calculateFeeDiscount(caller) | |
123 | - | let getFrom1TradeWithFee = if ((exchangersType[0] == " | |
125 | + | let getFrom1TradeWithFee = if ((exchangersType[0] == "cpmm")) | |
124 | 126 | 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") | |
130 | 139 | } | |
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) | |
134 | 146 | } | |
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") | |
162 | 155 | } | |
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") | |
187 | 157 | (getFrom2TradeWithFee >= minAmountToReceive) | |
188 | 158 | } | |
189 | 159 | ||
190 | 160 | ||
191 | 161 | @Callable(i) | |
192 | 162 | func routingTrade (exchangers,exchangersType,args1,args2,routingAssetsKeys,minAmountToReceive) = valueOrElse(isActive(), { | |
193 | - | let $ | |
194 | - | let pmtAmount = $ | |
195 | - | let pmtAssetId = $ | |
163 | + | let $t067036777 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
164 | + | let pmtAmount = $t067036777._1 | |
165 | + | let pmtAssetId = $t067036777._2 | |
196 | 166 | if (!(checkPossibility(i.caller, pmtAmount, minAmountToReceive, exchangers, exchangersType, routingAssetsKeys, args1, args2))) | |
197 | 167 | then throw("Check transaction possibilty: declined") | |
198 | 168 | else if (if (!(isDefined(getString(oracle, (kPoolInOracle + exchangers[0]))))) | |
202 | 172 | else { | |
203 | 173 | let routingSize = size(exchangers) | |
204 | 174 | func exchangeFold (accumulated,exchanger) = { | |
205 | - | let $ | |
206 | - | let exchangeCounter = $ | |
207 | - | let amountsWithFee = $ | |
208 | - | let assetsIdSend = $ | |
209 | - | let $ | |
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)) | |
210 | 180 | then $Tuple2(pmtAssetId, pmtAmount) | |
211 | 181 | else $Tuple2(assetsIdSend, amountsWithFee) | |
212 | - | let pmtAssetIdRout = $ | |
213 | - | let pmtAmountRout = $ | |
182 | + | let pmtAssetIdRout = $t073697567._1 | |
183 | + | let pmtAmountRout = $t073697567._2 | |
214 | 184 | if (((if ((exchangeCounter >= 0)) | |
215 | 185 | then (routingSize > exchangeCounter) | |
216 | 186 | else false) == true)) | |
217 | 187 | then { | |
218 | 188 | 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)]) | |
231 | 191 | 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.") | |
256 | 205 | } | |
257 | 206 | else accumulated | |
258 | 207 | } | |
259 | 208 | ||
260 | - | let $ | |
209 | + | let $t087338839 = { | |
261 | 210 | let $l = exchangers | |
262 | 211 | let $s = size($l) | |
263 | 212 | let $acc0 = $Tuple3(0, 0, base58'') | |
271 | 220 | ||
272 | 221 | $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3) | |
273 | 222 | } | |
274 | - | let exchangeCounter = $ | |
275 | - | let amountWithoutFee = $ | |
276 | - | let assetIdSend = $ | |
223 | + | let exchangeCounter = $t087338839._1 | |
224 | + | let amountWithoutFee = $t087338839._2 | |
225 | + | let assetIdSend = $t087338839._3 | |
277 | 226 | let amountWithFee = fraction(amountWithoutFee, (feeScale6 - routingFee), feeScale6) | |
278 | 227 | if (if ((exchangeCounter == routingSize)) | |
279 | 228 | then (amountWithFee >= minAmountToReceive) |
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let kActive = "active" | |
5 | 5 | ||
6 | 6 | let kCause = "shutdown_cause" | |
7 | 7 | ||
8 | 8 | let kPoolInOracle = "pool_" | |
9 | 9 | ||
10 | 10 | let kUserSwopInGov = "_SWOP_amount" | |
11 | 11 | ||
12 | 12 | let kDiscounts = "discounts" | |
13 | 13 | ||
14 | 14 | let kDiscountValues = "discount_values" | |
15 | 15 | ||
16 | 16 | let kRoutingFee = "routing_fee" | |
17 | 17 | ||
18 | 18 | let kAdminPubKey1 = "admin_pub_1" | |
19 | 19 | ||
20 | 20 | let kAdminPubKey2 = "admin_pub_2" | |
21 | 21 | ||
22 | 22 | let kAdminPubKey3 = "admin_pub_3" | |
23 | 23 | ||
24 | 24 | let kMoneyBoxAddress = "money_box_address" | |
25 | 25 | ||
26 | 26 | let kGovAddress = "governance_address" | |
27 | 27 | ||
28 | 28 | let kFee = "commission" | |
29 | - | ||
30 | - | let kMultyAssetBalance = "_balance" | |
31 | 29 | ||
32 | 30 | let digits8 = 8 | |
33 | 31 | ||
34 | 32 | let scale8 = 100000000 | |
35 | 33 | ||
36 | 34 | let scale16 = 10000000000000000 | |
37 | 35 | ||
38 | 36 | let alpha = 50 | |
39 | 37 | ||
40 | 38 | let alphaDigits = 2 | |
41 | 39 | ||
42 | 40 | let beta = 4600000000000000 | |
43 | 41 | ||
44 | 42 | let oracle = Address(base58'3NBBWfzZtZtszaXbitTKnrB2xXwv26Bn7H9') | |
45 | 43 | ||
46 | 44 | func getBase58FromOracle (key) = match getString(oracle, key) { | |
47 | 45 | case string: String => | |
48 | 46 | fromBase58String(string) | |
49 | 47 | case nothing => | |
50 | 48 | throw((key + "is empty")) | |
51 | 49 | } | |
52 | 50 | ||
53 | 51 | ||
54 | 52 | let adminPubKey1 = getBase58FromOracle(kAdminPubKey1) | |
55 | 53 | ||
56 | 54 | let adminPubKey2 = getBase58FromOracle(kAdminPubKey2) | |
57 | 55 | ||
58 | 56 | let adminPubKey3 = getBase58FromOracle(kAdminPubKey3) | |
59 | 57 | ||
60 | 58 | let moneyBoxAddress = Address(getBase58FromOracle(kMoneyBoxAddress)) | |
61 | 59 | ||
62 | 60 | let govAddress = Address(getBase58FromOracle(kGovAddress)) | |
63 | 61 | ||
64 | 62 | let active = valueOrElse(getBoolean(this, kActive), true) | |
65 | 63 | ||
66 | 64 | let routingFee = valueOrErrorMessage(getInteger(oracle, kRoutingFee), "routing_fee is empty") | |
67 | 65 | ||
68 | 66 | let feeScale6 = 1000000 | |
69 | 67 | ||
70 | 68 | func isActive () = if (active) | |
71 | 69 | then unit | |
72 | 70 | else throw("DApp is inactive at this moment") | |
73 | 71 | ||
74 | 72 | ||
75 | 73 | func isAdminCall (i) = if (containsElement([adminPubKey1, adminPubKey2, adminPubKey3], i.callerPublicKey)) | |
76 | 74 | then unit | |
77 | 75 | else throw("Only admin can call this function") | |
78 | 76 | ||
79 | 77 | ||
80 | 78 | func throwIsActive () = throw("DApp is already active") | |
81 | 79 | ||
82 | 80 | ||
83 | 81 | func suspend (cause) = [BooleanEntry(kActive, false), StringEntry(kCause, cause)] | |
84 | 82 | ||
85 | 83 | ||
86 | 84 | func skewness (x,y) = ((fraction(scale16, x, y) + fraction(scale16, y, x)) / 2) | |
87 | 85 | ||
88 | 86 | ||
89 | 87 | func invariantCalc (x,y) = { | |
90 | 88 | let sk = skewness(x, y) | |
91 | 89 | (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))) | |
92 | 90 | } | |
93 | 91 | ||
94 | 92 | ||
95 | 93 | func calculateFeeDiscount (userAddr) = { | |
96 | 94 | let swopAmount = valueOrElse(getInteger(govAddress, (toString(userAddr) + kUserSwopInGov)), 0) | |
97 | 95 | let discountValues = split(getStringValue(oracle, kDiscountValues), ",") | |
98 | 96 | let discounts = split(getStringValue(oracle, kDiscounts), ",") | |
99 | 97 | if (if ((swopAmount >= parseIntValue(discountValues[0]))) | |
100 | 98 | then (parseIntValue(discountValues[1]) > swopAmount) | |
101 | 99 | else false) | |
102 | 100 | then (feeScale6 - parseIntValue(discounts[0])) | |
103 | 101 | else if (if ((swopAmount >= parseIntValue(discountValues[1]))) | |
104 | 102 | then (parseIntValue(discountValues[2]) > swopAmount) | |
105 | 103 | else false) | |
106 | 104 | then (feeScale6 - parseIntValue(discounts[1])) | |
107 | 105 | else if (if ((swopAmount >= parseIntValue(discountValues[2]))) | |
108 | 106 | then (parseIntValue(discountValues[3]) > swopAmount) | |
109 | 107 | else false) | |
110 | 108 | then (feeScale6 - parseIntValue(discounts[2])) | |
111 | 109 | else if (if ((swopAmount >= parseIntValue(discountValues[3]))) | |
112 | 110 | then (parseIntValue(discountValues[4]) > swopAmount) | |
113 | 111 | else false) | |
114 | 112 | then (feeScale6 - parseIntValue(discounts[3])) | |
115 | 113 | else if ((swopAmount >= parseIntValue(discountValues[4]))) | |
116 | 114 | then (feeScale6 - parseIntValue(discounts[4])) | |
117 | 115 | else feeScale6 | |
118 | 116 | } | |
119 | 117 | ||
120 | 118 | ||
121 | 119 | 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]) | |
122 | 124 | let feeDiscount = calculateFeeDiscount(caller) | |
123 | - | let getFrom1TradeWithFee = if ((exchangersType[0] == " | |
125 | + | let getFrom1TradeWithFee = if ((exchangersType[0] == "cpmm")) | |
124 | 126 | 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") | |
130 | 139 | } | |
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) | |
134 | 146 | } | |
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") | |
162 | 155 | } | |
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") | |
187 | 157 | (getFrom2TradeWithFee >= minAmountToReceive) | |
188 | 158 | } | |
189 | 159 | ||
190 | 160 | ||
191 | 161 | @Callable(i) | |
192 | 162 | func routingTrade (exchangers,exchangersType,args1,args2,routingAssetsKeys,minAmountToReceive) = valueOrElse(isActive(), { | |
193 | - | let $ | |
194 | - | let pmtAmount = $ | |
195 | - | let pmtAssetId = $ | |
163 | + | let $t067036777 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
164 | + | let pmtAmount = $t067036777._1 | |
165 | + | let pmtAssetId = $t067036777._2 | |
196 | 166 | if (!(checkPossibility(i.caller, pmtAmount, minAmountToReceive, exchangers, exchangersType, routingAssetsKeys, args1, args2))) | |
197 | 167 | then throw("Check transaction possibilty: declined") | |
198 | 168 | else if (if (!(isDefined(getString(oracle, (kPoolInOracle + exchangers[0]))))) | |
199 | 169 | then true | |
200 | 170 | else !(isDefined(getString(oracle, (kPoolInOracle + exchangers[1]))))) | |
201 | 171 | then throw("Pool is not in oracle") | |
202 | 172 | else { | |
203 | 173 | let routingSize = size(exchangers) | |
204 | 174 | func exchangeFold (accumulated,exchanger) = { | |
205 | - | let $ | |
206 | - | let exchangeCounter = $ | |
207 | - | let amountsWithFee = $ | |
208 | - | let assetsIdSend = $ | |
209 | - | let $ | |
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)) | |
210 | 180 | then $Tuple2(pmtAssetId, pmtAmount) | |
211 | 181 | else $Tuple2(assetsIdSend, amountsWithFee) | |
212 | - | let pmtAssetIdRout = $ | |
213 | - | let pmtAmountRout = $ | |
182 | + | let pmtAssetIdRout = $t073697567._1 | |
183 | + | let pmtAmountRout = $t073697567._2 | |
214 | 184 | if (((if ((exchangeCounter >= 0)) | |
215 | 185 | then (routingSize > exchangeCounter) | |
216 | 186 | else false) == true)) | |
217 | 187 | then { | |
218 | 188 | 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)]) | |
231 | 191 | 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.") | |
256 | 205 | } | |
257 | 206 | else accumulated | |
258 | 207 | } | |
259 | 208 | ||
260 | - | let $ | |
209 | + | let $t087338839 = { | |
261 | 210 | let $l = exchangers | |
262 | 211 | let $s = size($l) | |
263 | 212 | let $acc0 = $Tuple3(0, 0, base58'') | |
264 | 213 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
265 | 214 | then $a | |
266 | 215 | else exchangeFold($a, $l[$i]) | |
267 | 216 | ||
268 | 217 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
269 | 218 | then $a | |
270 | 219 | else throw("List size exceeds 3") | |
271 | 220 | ||
272 | 221 | $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3) | |
273 | 222 | } | |
274 | - | let exchangeCounter = $ | |
275 | - | let amountWithoutFee = $ | |
276 | - | let assetIdSend = $ | |
223 | + | let exchangeCounter = $t087338839._1 | |
224 | + | let amountWithoutFee = $t087338839._2 | |
225 | + | let assetIdSend = $t087338839._3 | |
277 | 226 | let amountWithFee = fraction(amountWithoutFee, (feeScale6 - routingFee), feeScale6) | |
278 | 227 | if (if ((exchangeCounter == routingSize)) | |
279 | 228 | then (amountWithFee >= minAmountToReceive) | |
280 | 229 | else false) | |
281 | 230 | then [ScriptTransfer(i.caller, amountWithFee, assetIdSend), ScriptTransfer(moneyBoxAddress, (amountWithoutFee - amountWithFee), assetIdSend)] | |
282 | 231 | else throw("routing != routingSize or amountToRecieve < minAmountToReceive") | |
283 | 232 | } | |
284 | 233 | }) | |
285 | 234 | ||
286 | 235 | ||
287 | 236 | ||
288 | 237 | @Callable(i) | |
289 | 238 | func shutdown () = valueOrElse(isAdminCall(i), if (!(active)) | |
290 | 239 | then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, kCause), "the cause wasn't specified"))) | |
291 | 240 | else suspend("Paused by admin")) | |
292 | 241 | ||
293 | 242 | ||
294 | 243 | ||
295 | 244 | @Callable(i) | |
296 | 245 | func activate () = valueOrElse(isAdminCall(i), if (active) | |
297 | 246 | then throwIsActive() | |
298 | 247 | else [BooleanEntry(kActive, true), DeleteEntry(kCause)]) | |
299 | 248 | ||
300 | 249 | ||
301 | 250 | @Verifier(tx) | |
302 | 251 | func verify () = { | |
303 | 252 | let multiSignedByAdmins = { | |
304 | 253 | let adminPubKey1Signed = if (sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey1)) | |
305 | 254 | then 1 | |
306 | 255 | else 0 | |
307 | 256 | let adminPubKey2Signed = if (sigVerify(tx.bodyBytes, tx.proofs[1], adminPubKey2)) | |
308 | 257 | then 1 | |
309 | 258 | else 0 | |
310 | 259 | let adminPubKey3Signed = if (sigVerify(tx.bodyBytes, tx.proofs[2], adminPubKey3)) | |
311 | 260 | then 1 | |
312 | 261 | else 0 | |
313 | 262 | (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 2) | |
314 | 263 | } | |
315 | 264 | match tx { | |
316 | 265 | case _ => | |
317 | 266 | multiSignedByAdmins | |
318 | 267 | } | |
319 | 268 | } | |
320 | 269 |
github/deemru/w8io/026f985 43.86 ms ◑