tx · AGf5gH31wVmghTYnEYRiYE8sxUGvwXCudkWSEQALvWqj 3MqDf9VgoL9eqrCPx8F74Au6xBpvdTm9UP8: -0.14000000 Waves 2022.06.02 14:17 [2078639] smart account 3MqDf9VgoL9eqrCPx8F74Au6xBpvdTm9UP8 > SELF 0.00000000 Waves
{ "type": 13, "id": "AGf5gH31wVmghTYnEYRiYE8sxUGvwXCudkWSEQALvWqj", "fee": 14000000, "feeAssetId": null, "timestamp": 1654168626410, "version": 2, "chainId": 84, "sender": "3MqDf9VgoL9eqrCPx8F74Au6xBpvdTm9UP8", "senderPublicKey": "4ja2PX5eqM576zv9KGzu5Qe7M92Z3jbuSmkLPdGjK4ue", "proofs": [ "3osEDSHDcgmXiDq5t997vRYKsgS1ZSTw5e8iRBozkoyt7BR2oTYHNyPH6DBok93BF5jXCUwT5o2u674eXwpMhE6o", "3CiHhTi8YU3AmcTRcthEASrZ6SUn4hk1jm314WmXxJ8C52sHfGp8jphcYW6CKynQU3q196cVCy8AV1UAeenk3yhw" ], "script": "base64:AAIFAAAAAAAAABAIAhIICgYYGBERGAESABIAAAAAJQAAAAAHa0FjdGl2ZQIAAAAGYWN0aXZlAAAAAAZrQ2F1c2UCAAAADnNodXRkb3duX2NhdXNlAAAAAA1rUG9vbEluT3JhY2xlAgAAAAVwb29sXwAAAAAOa1VzZXJTd29wSW5Hb3YCAAAADF9TV09QX2Ftb3VudAAAAAAKa0Rpc2NvdW50cwIAAAAJZGlzY291bnRzAAAAAA9rRGlzY291bnRWYWx1ZXMCAAAAD2Rpc2NvdW50X3ZhbHVlcwAAAAALa1JvdXRpbmdGZWUCAAAAC3JvdXRpbmdfZmVlAAAAAA1rQWRtaW5QdWJLZXkxAgAAAAthZG1pbl9wdWJfMQAAAAANa0FkbWluUHViS2V5MgIAAAALYWRtaW5fcHViXzIAAAAADWtBZG1pblB1YktleTMCAAAAC2FkbWluX3B1Yl8zAAAAABBrTW9uZXlCb3hBZGRyZXNzAgAAABFtb25leV9ib3hfY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AAAAAAAAAAAJAABnAAAAAgkAAGQAAAACCQAAZAAAAAIFAAAAEmFkbWluUHViS2V5MVNpZ25lZAUAAAASYWRtaW5QdWJLZXkyU2lnbmVkBQAAABJhZG1pblB1YktleTNTaWduZWQAAAAAAAAAAAIEAAAAByRtYXRjaDAFAAAAAnR4BQAAABNtdWx0aVNpZ25lZEJ5QWRtaW5zm9b11w==", "height": 2078639, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BNksmBfsvFo3wKhqhpG7cR2v3R84wAddhAmrLbQo9QCR Next: 3RmRwRySRNKjzx8kLkRPiDrmVe3woY2LPiJPRsnkcGFH Diff:
Old | New | Differences | |
---|---|---|---|
4 | 4 | let kActive = "active" | |
5 | 5 | ||
6 | 6 | let kCause = "shutdown_cause" | |
7 | + | ||
8 | + | let kPoolInOracle = "pool_" | |
9 | + | ||
10 | + | let kUserSwopInGov = "_SWOP_amount" | |
11 | + | ||
12 | + | let kDiscounts = "discounts" | |
13 | + | ||
14 | + | let kDiscountValues = "discount_values" | |
7 | 15 | ||
8 | 16 | let kRoutingFee = "routing_fee" | |
9 | 17 | ||
15 | 23 | ||
16 | 24 | let kMoneyBoxAddress = "money_box_address" | |
17 | 25 | ||
18 | - | let kPoolInOracle = "pool_" | |
26 | + | let kGovAddress = "governance_address" | |
27 | + | ||
28 | + | let kFee = "commission" | |
19 | 29 | ||
20 | 30 | let digits8 = 8 | |
21 | 31 | ||
28 | 38 | let alphaDigits = 2 | |
29 | 39 | ||
30 | 40 | let beta = 4600000000000000 | |
31 | - | ||
32 | - | let commission = 3000 | |
33 | - | ||
34 | - | let commissionScaleDelimiter = 1000000 | |
35 | 41 | ||
36 | 42 | let oracle = Address(base58'3NBBWfzZtZtszaXbitTKnrB2xXwv26Bn7H9') | |
37 | 43 | ||
50 | 56 | let adminPubKey3 = getBase58FromOracle(kAdminPubKey3) | |
51 | 57 | ||
52 | 58 | let moneyBoxAddress = Address(getBase58FromOracle(kMoneyBoxAddress)) | |
59 | + | ||
60 | + | let govAddress = Address(getBase58FromOracle(kGovAddress)) | |
53 | 61 | ||
54 | 62 | let active = valueOrElse(getBoolean(this, kActive), true) | |
55 | 63 | ||
82 | 90 | } | |
83 | 91 | ||
84 | 92 | ||
85 | - | func checkPossibility (pmtAmount,minAmountToReceive,exchangers,exchangersType,routingAssetsKeys,args1,args2) = { | |
93 | + | func calculateFeeDiscount (userAddr) = { | |
94 | + | let swopAmount = valueOrElse(getInteger(govAddress, (toString(userAddr) + kUserSwopInGov)), 0) | |
95 | + | let discountValues = split(getStringValue(oracle, kDiscountValues), ",") | |
96 | + | let discounts = split(getStringValue(oracle, kDiscounts), ",") | |
97 | + | if (if ((swopAmount >= parseIntValue(discountValues[0]))) | |
98 | + | then (parseIntValue(discountValues[1]) > swopAmount) | |
99 | + | else false) | |
100 | + | then (feeScale6 - parseIntValue(discounts[0])) | |
101 | + | else if (if ((swopAmount >= parseIntValue(discountValues[1]))) | |
102 | + | then (parseIntValue(discountValues[2]) > swopAmount) | |
103 | + | else false) | |
104 | + | then (feeScale6 - parseIntValue(discounts[1])) | |
105 | + | else if (if ((swopAmount >= parseIntValue(discountValues[2]))) | |
106 | + | then (parseIntValue(discountValues[3]) > swopAmount) | |
107 | + | else false) | |
108 | + | then (feeScale6 - parseIntValue(discounts[2])) | |
109 | + | else if (if ((swopAmount >= parseIntValue(discountValues[3]))) | |
110 | + | then (parseIntValue(discountValues[4]) > swopAmount) | |
111 | + | else false) | |
112 | + | then (feeScale6 - parseIntValue(discounts[3])) | |
113 | + | else if ((swopAmount >= parseIntValue(discountValues[4]))) | |
114 | + | then (feeScale6 - parseIntValue(discounts[4])) | |
115 | + | else feeScale6 | |
116 | + | } | |
117 | + | ||
118 | + | ||
119 | + | func checkPossibility (caller,pmtAmount,minAmountToReceive,exchangers,exchangersType,routingAssetsKeys,args1,args2) = { | |
86 | 120 | let dApp1TokenPay = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[0]) | |
87 | 121 | let dApp1TokenGet = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[1]) | |
88 | 122 | let dApp2TokenPay = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[2]) | |
89 | 123 | let dApp2TokenGet = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[3]) | |
124 | + | let feeDiscount = calculateFeeDiscount(caller) | |
90 | 125 | let getFrom1TradeWithFee = if ((exchangersType[0] == "cpmm")) | |
91 | 126 | then { | |
127 | + | let fee = getIntegerValue(addressFromStringValue(exchangers[0]), kFee) | |
92 | 128 | let getFrom1TradeWithoutFee = fraction(dApp1TokenGet, pmtAmount, (pmtAmount + dApp1TokenPay)) | |
93 | - | fraction(getFrom1TradeWithoutFee, ( | |
129 | + | fraction(getFrom1TradeWithoutFee, (feeScale6 - fraction(fee, feeDiscount, feeScale6)), feeScale6) | |
94 | 130 | } | |
95 | 131 | else if ((exchangersType[0] == "flat")) | |
96 | 132 | then { | |
105 | 141 | let getFrom2TradeWithFee = if ((exchangersType[1] == "cpmm")) | |
106 | 142 | then { | |
107 | 143 | let getFrom2TradeWithoutFee = fraction(dApp2TokenGet, getFrom1TradeWithFee, (getFrom1TradeWithFee + dApp2TokenPay)) | |
108 | - | fraction(getFrom2TradeWithoutFee, (commissionScaleDelimiter - commission), commissionScaleDelimiter) | |
144 | + | let fee = getIntegerValue(addressFromStringValue(exchangers[0]), kFee) | |
145 | + | fraction(getFrom2TradeWithoutFee, (feeScale6 - fraction(fee, feeDiscount, feeScale6)), feeScale6) | |
109 | 146 | } | |
110 | 147 | else if ((exchangersType[1] == "flat")) | |
111 | 148 | then { | |
123 | 160 | ||
124 | 161 | @Callable(i) | |
125 | 162 | func routingTrade (exchangers,exchangersType,args1,args2,routingAssetsKeys,minAmountToReceive) = valueOrElse(isActive(), { | |
126 | - | let $ | |
127 | - | let pmtAmount = $ | |
128 | - | let pmtAssetId = $ | |
129 | - | if (!(checkPossibility(pmtAmount, minAmountToReceive, exchangers, exchangersType, routingAssetsKeys, args1, args2))) | |
163 | + | let $t067036777 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
164 | + | let pmtAmount = $t067036777._1 | |
165 | + | let pmtAssetId = $t067036777._2 | |
166 | + | if (!(checkPossibility(i.caller, pmtAmount, minAmountToReceive, exchangers, exchangersType, routingAssetsKeys, args1, args2))) | |
130 | 167 | then throw("Check transaction possibilty: declined") | |
131 | 168 | else if (if (!(isDefined(getString(oracle, (kPoolInOracle + exchangers[0]))))) | |
132 | 169 | then true | |
135 | 172 | else { | |
136 | 173 | let routingSize = size(exchangers) | |
137 | 174 | func exchangeFold (accumulated,exchanger) = { | |
138 | - | let $ | |
139 | - | let exchangeCounter = $ | |
140 | - | let amountsWithFee = $ | |
141 | - | let assetsIdSend = $ | |
142 | - | 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)) | |
143 | 180 | then $Tuple2(pmtAssetId, pmtAmount) | |
144 | 181 | else $Tuple2(assetsIdSend, amountsWithFee) | |
145 | - | let pmtAssetIdRout = $ | |
146 | - | let pmtAmountRout = $ | |
182 | + | let pmtAssetIdRout = $t073697567._1 | |
183 | + | let pmtAmountRout = $t073697567._2 | |
147 | 184 | if (((if ((exchangeCounter >= 0)) | |
148 | 185 | then (routingSize > exchangeCounter) | |
149 | 186 | else false) == true)) | |
156 | 193 | else throw("Incorrect exchange type") | |
157 | 194 | if ((inv == inv)) | |
158 | 195 | then match inv { | |
159 | - | case inv: (Int, ByteVector) => | |
160 | - | let $ | |
161 | - | let amountWithFee = $ | |
162 | - | let assetIdSend = $ | |
196 | + | case inv: (Int, Unit)|(Int, ByteVector) => | |
197 | + | let $t084158453 = inv | |
198 | + | let amountWithFee = $t084158453._1 | |
199 | + | let assetIdSend = $t084158453._2 | |
163 | 200 | $Tuple3((exchangeCounter + 1), amountWithFee, assetIdSend) | |
164 | 201 | case _ => | |
165 | 202 | throw("Incorrect invoke result: expected amountWithFee and assetsIdSend") | |
169 | 206 | else accumulated | |
170 | 207 | } | |
171 | 208 | ||
172 | - | let $ | |
209 | + | let $t087338839 = { | |
173 | 210 | let $l = exchangers | |
174 | 211 | let $s = size($l) | |
175 | 212 | let $acc0 = $Tuple3(0, 0, base58'') | |
183 | 220 | ||
184 | 221 | $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3) | |
185 | 222 | } | |
186 | - | let exchangeCounter = $ | |
187 | - | let amountWithoutFee = $ | |
188 | - | let assetIdSend = $ | |
223 | + | let exchangeCounter = $t087338839._1 | |
224 | + | let amountWithoutFee = $t087338839._2 | |
225 | + | let assetIdSend = $t087338839._3 | |
189 | 226 | let amountWithFee = fraction(amountWithoutFee, (feeScale6 - routingFee), feeScale6) | |
190 | 227 | if (if ((exchangeCounter == routingSize)) | |
191 | 228 | then (amountWithFee >= minAmountToReceive) |
Old | New | Differences | |
---|---|---|---|
1 | 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 | + | ||
8 | + | let kPoolInOracle = "pool_" | |
9 | + | ||
10 | + | let kUserSwopInGov = "_SWOP_amount" | |
11 | + | ||
12 | + | let kDiscounts = "discounts" | |
13 | + | ||
14 | + | let kDiscountValues = "discount_values" | |
7 | 15 | ||
8 | 16 | let kRoutingFee = "routing_fee" | |
9 | 17 | ||
10 | 18 | let kAdminPubKey1 = "admin_pub_1" | |
11 | 19 | ||
12 | 20 | let kAdminPubKey2 = "admin_pub_2" | |
13 | 21 | ||
14 | 22 | let kAdminPubKey3 = "admin_pub_3" | |
15 | 23 | ||
16 | 24 | let kMoneyBoxAddress = "money_box_address" | |
17 | 25 | ||
18 | - | let kPoolInOracle = "pool_" | |
26 | + | let kGovAddress = "governance_address" | |
27 | + | ||
28 | + | let kFee = "commission" | |
19 | 29 | ||
20 | 30 | let digits8 = 8 | |
21 | 31 | ||
22 | 32 | let scale8 = 100000000 | |
23 | 33 | ||
24 | 34 | let scale16 = 10000000000000000 | |
25 | 35 | ||
26 | 36 | let alpha = 50 | |
27 | 37 | ||
28 | 38 | let alphaDigits = 2 | |
29 | 39 | ||
30 | 40 | let beta = 4600000000000000 | |
31 | - | ||
32 | - | let commission = 3000 | |
33 | - | ||
34 | - | let commissionScaleDelimiter = 1000000 | |
35 | 41 | ||
36 | 42 | let oracle = Address(base58'3NBBWfzZtZtszaXbitTKnrB2xXwv26Bn7H9') | |
37 | 43 | ||
38 | 44 | func getBase58FromOracle (key) = match getString(oracle, key) { | |
39 | 45 | case string: String => | |
40 | 46 | fromBase58String(string) | |
41 | 47 | case nothing => | |
42 | 48 | throw((key + "is empty")) | |
43 | 49 | } | |
44 | 50 | ||
45 | 51 | ||
46 | 52 | let adminPubKey1 = getBase58FromOracle(kAdminPubKey1) | |
47 | 53 | ||
48 | 54 | let adminPubKey2 = getBase58FromOracle(kAdminPubKey2) | |
49 | 55 | ||
50 | 56 | let adminPubKey3 = getBase58FromOracle(kAdminPubKey3) | |
51 | 57 | ||
52 | 58 | let moneyBoxAddress = Address(getBase58FromOracle(kMoneyBoxAddress)) | |
59 | + | ||
60 | + | let govAddress = Address(getBase58FromOracle(kGovAddress)) | |
53 | 61 | ||
54 | 62 | let active = valueOrElse(getBoolean(this, kActive), true) | |
55 | 63 | ||
56 | 64 | let routingFee = valueOrErrorMessage(getInteger(oracle, kRoutingFee), "routing_fee is empty") | |
57 | 65 | ||
58 | 66 | let feeScale6 = 1000000 | |
59 | 67 | ||
60 | 68 | func isActive () = if (active) | |
61 | 69 | then unit | |
62 | 70 | else throw("DApp is inactive at this moment") | |
63 | 71 | ||
64 | 72 | ||
65 | 73 | func isAdminCall (i) = if (containsElement([adminPubKey1, adminPubKey2, adminPubKey3], i.callerPublicKey)) | |
66 | 74 | then unit | |
67 | 75 | else throw("Only admin can call this function") | |
68 | 76 | ||
69 | 77 | ||
70 | 78 | func throwIsActive () = throw("DApp is already active") | |
71 | 79 | ||
72 | 80 | ||
73 | 81 | func suspend (cause) = [BooleanEntry(kActive, false), StringEntry(kCause, cause)] | |
74 | 82 | ||
75 | 83 | ||
76 | 84 | func skewness (x,y) = ((fraction(scale16, x, y) + fraction(scale16, y, x)) / 2) | |
77 | 85 | ||
78 | 86 | ||
79 | 87 | func invariantCalc (x,y) = { | |
80 | 88 | let sk = skewness(x, y) | |
81 | 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))) | |
82 | 90 | } | |
83 | 91 | ||
84 | 92 | ||
85 | - | func checkPossibility (pmtAmount,minAmountToReceive,exchangers,exchangersType,routingAssetsKeys,args1,args2) = { | |
93 | + | func calculateFeeDiscount (userAddr) = { | |
94 | + | let swopAmount = valueOrElse(getInteger(govAddress, (toString(userAddr) + kUserSwopInGov)), 0) | |
95 | + | let discountValues = split(getStringValue(oracle, kDiscountValues), ",") | |
96 | + | let discounts = split(getStringValue(oracle, kDiscounts), ",") | |
97 | + | if (if ((swopAmount >= parseIntValue(discountValues[0]))) | |
98 | + | then (parseIntValue(discountValues[1]) > swopAmount) | |
99 | + | else false) | |
100 | + | then (feeScale6 - parseIntValue(discounts[0])) | |
101 | + | else if (if ((swopAmount >= parseIntValue(discountValues[1]))) | |
102 | + | then (parseIntValue(discountValues[2]) > swopAmount) | |
103 | + | else false) | |
104 | + | then (feeScale6 - parseIntValue(discounts[1])) | |
105 | + | else if (if ((swopAmount >= parseIntValue(discountValues[2]))) | |
106 | + | then (parseIntValue(discountValues[3]) > swopAmount) | |
107 | + | else false) | |
108 | + | then (feeScale6 - parseIntValue(discounts[2])) | |
109 | + | else if (if ((swopAmount >= parseIntValue(discountValues[3]))) | |
110 | + | then (parseIntValue(discountValues[4]) > swopAmount) | |
111 | + | else false) | |
112 | + | then (feeScale6 - parseIntValue(discounts[3])) | |
113 | + | else if ((swopAmount >= parseIntValue(discountValues[4]))) | |
114 | + | then (feeScale6 - parseIntValue(discounts[4])) | |
115 | + | else feeScale6 | |
116 | + | } | |
117 | + | ||
118 | + | ||
119 | + | func checkPossibility (caller,pmtAmount,minAmountToReceive,exchangers,exchangersType,routingAssetsKeys,args1,args2) = { | |
86 | 120 | let dApp1TokenPay = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[0]) | |
87 | 121 | let dApp1TokenGet = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[1]) | |
88 | 122 | let dApp2TokenPay = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[2]) | |
89 | 123 | let dApp2TokenGet = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[3]) | |
124 | + | let feeDiscount = calculateFeeDiscount(caller) | |
90 | 125 | let getFrom1TradeWithFee = if ((exchangersType[0] == "cpmm")) | |
91 | 126 | then { | |
127 | + | let fee = getIntegerValue(addressFromStringValue(exchangers[0]), kFee) | |
92 | 128 | let getFrom1TradeWithoutFee = fraction(dApp1TokenGet, pmtAmount, (pmtAmount + dApp1TokenPay)) | |
93 | - | fraction(getFrom1TradeWithoutFee, ( | |
129 | + | fraction(getFrom1TradeWithoutFee, (feeScale6 - fraction(fee, feeDiscount, feeScale6)), feeScale6) | |
94 | 130 | } | |
95 | 131 | else if ((exchangersType[0] == "flat")) | |
96 | 132 | then { | |
97 | 133 | let invariant = invariantCalc(dApp1TokenPay, dApp1TokenGet) | |
98 | 134 | let minAmountToReceive1 = args2[0] | |
99 | 135 | let invariantNew = invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1)) | |
100 | 136 | if ((invariantNew >= invariant)) | |
101 | 137 | then minAmountToReceive1 | |
102 | 138 | else throw("Flat contract: invariantNew < invariant") | |
103 | 139 | } | |
104 | 140 | else throw("Incorrect exchange type") | |
105 | 141 | let getFrom2TradeWithFee = if ((exchangersType[1] == "cpmm")) | |
106 | 142 | then { | |
107 | 143 | let getFrom2TradeWithoutFee = fraction(dApp2TokenGet, getFrom1TradeWithFee, (getFrom1TradeWithFee + dApp2TokenPay)) | |
108 | - | fraction(getFrom2TradeWithoutFee, (commissionScaleDelimiter - commission), commissionScaleDelimiter) | |
144 | + | let fee = getIntegerValue(addressFromStringValue(exchangers[0]), kFee) | |
145 | + | fraction(getFrom2TradeWithoutFee, (feeScale6 - fraction(fee, feeDiscount, feeScale6)), feeScale6) | |
109 | 146 | } | |
110 | 147 | else if ((exchangersType[1] == "flat")) | |
111 | 148 | then { | |
112 | 149 | let invariant = invariantCalc(dApp2TokenPay, dApp2TokenGet) | |
113 | 150 | let minAmountToReceive2 = args2[1] | |
114 | 151 | let invariantNew = invariantCalc((dApp2TokenPay + getFrom1TradeWithFee), (dApp2TokenGet - minAmountToReceive2)) | |
115 | 152 | if ((invariantNew >= invariant)) | |
116 | 153 | then minAmountToReceive2 | |
117 | 154 | else throw("Flat contract: invariantNew < invariant") | |
118 | 155 | } | |
119 | 156 | else throw("Incorrect exchange type") | |
120 | 157 | (getFrom2TradeWithFee >= minAmountToReceive) | |
121 | 158 | } | |
122 | 159 | ||
123 | 160 | ||
124 | 161 | @Callable(i) | |
125 | 162 | func routingTrade (exchangers,exchangersType,args1,args2,routingAssetsKeys,minAmountToReceive) = valueOrElse(isActive(), { | |
126 | - | let $ | |
127 | - | let pmtAmount = $ | |
128 | - | let pmtAssetId = $ | |
129 | - | if (!(checkPossibility(pmtAmount, minAmountToReceive, exchangers, exchangersType, routingAssetsKeys, args1, args2))) | |
163 | + | let $t067036777 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
164 | + | let pmtAmount = $t067036777._1 | |
165 | + | let pmtAssetId = $t067036777._2 | |
166 | + | if (!(checkPossibility(i.caller, pmtAmount, minAmountToReceive, exchangers, exchangersType, routingAssetsKeys, args1, args2))) | |
130 | 167 | then throw("Check transaction possibilty: declined") | |
131 | 168 | else if (if (!(isDefined(getString(oracle, (kPoolInOracle + exchangers[0]))))) | |
132 | 169 | then true | |
133 | 170 | else !(isDefined(getString(oracle, (kPoolInOracle + exchangers[1]))))) | |
134 | 171 | then throw("Pool is not in oracle") | |
135 | 172 | else { | |
136 | 173 | let routingSize = size(exchangers) | |
137 | 174 | func exchangeFold (accumulated,exchanger) = { | |
138 | - | let $ | |
139 | - | let exchangeCounter = $ | |
140 | - | let amountsWithFee = $ | |
141 | - | let assetsIdSend = $ | |
142 | - | 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)) | |
143 | 180 | then $Tuple2(pmtAssetId, pmtAmount) | |
144 | 181 | else $Tuple2(assetsIdSend, amountsWithFee) | |
145 | - | let pmtAssetIdRout = $ | |
146 | - | let pmtAmountRout = $ | |
182 | + | let pmtAssetIdRout = $t073697567._1 | |
183 | + | let pmtAmountRout = $t073697567._2 | |
147 | 184 | if (((if ((exchangeCounter >= 0)) | |
148 | 185 | then (routingSize > exchangeCounter) | |
149 | 186 | else false) == true)) | |
150 | 187 | then { | |
151 | 188 | let exchangerAddress = addressFromStringValue(exchanger) | |
152 | 189 | let inv = if ((exchangersType[exchangeCounter] == "cpmm")) | |
153 | 190 | then invoke(exchangerAddress, "exchange", [args1[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)]) | |
154 | 191 | else if ((exchangersType[exchangeCounter] == "flat")) | |
155 | 192 | then invoke(exchangerAddress, "exchange", [args1[exchangeCounter], args2[exchangeCounter]], [AttachedPayment(pmtAssetIdRout, pmtAmountRout)]) | |
156 | 193 | else throw("Incorrect exchange type") | |
157 | 194 | if ((inv == inv)) | |
158 | 195 | then match inv { | |
159 | - | case inv: (Int, ByteVector) => | |
160 | - | let $ | |
161 | - | let amountWithFee = $ | |
162 | - | let assetIdSend = $ | |
196 | + | case inv: (Int, Unit)|(Int, ByteVector) => | |
197 | + | let $t084158453 = inv | |
198 | + | let amountWithFee = $t084158453._1 | |
199 | + | let assetIdSend = $t084158453._2 | |
163 | 200 | $Tuple3((exchangeCounter + 1), amountWithFee, assetIdSend) | |
164 | 201 | case _ => | |
165 | 202 | throw("Incorrect invoke result: expected amountWithFee and assetsIdSend") | |
166 | 203 | } | |
167 | 204 | else throw("Strict value is not equal to itself.") | |
168 | 205 | } | |
169 | 206 | else accumulated | |
170 | 207 | } | |
171 | 208 | ||
172 | - | let $ | |
209 | + | let $t087338839 = { | |
173 | 210 | let $l = exchangers | |
174 | 211 | let $s = size($l) | |
175 | 212 | let $acc0 = $Tuple3(0, 0, base58'') | |
176 | 213 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
177 | 214 | then $a | |
178 | 215 | else exchangeFold($a, $l[$i]) | |
179 | 216 | ||
180 | 217 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
181 | 218 | then $a | |
182 | 219 | else throw("List size exceeds 3") | |
183 | 220 | ||
184 | 221 | $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3) | |
185 | 222 | } | |
186 | - | let exchangeCounter = $ | |
187 | - | let amountWithoutFee = $ | |
188 | - | let assetIdSend = $ | |
223 | + | let exchangeCounter = $t087338839._1 | |
224 | + | let amountWithoutFee = $t087338839._2 | |
225 | + | let assetIdSend = $t087338839._3 | |
189 | 226 | let amountWithFee = fraction(amountWithoutFee, (feeScale6 - routingFee), feeScale6) | |
190 | 227 | if (if ((exchangeCounter == routingSize)) | |
191 | 228 | then (amountWithFee >= minAmountToReceive) | |
192 | 229 | else false) | |
193 | 230 | then [ScriptTransfer(i.caller, amountWithFee, assetIdSend), ScriptTransfer(moneyBoxAddress, (amountWithoutFee - amountWithFee), assetIdSend)] | |
194 | 231 | else throw("routing != routingSize or amountToRecieve < minAmountToReceive") | |
195 | 232 | } | |
196 | 233 | }) | |
197 | 234 | ||
198 | 235 | ||
199 | 236 | ||
200 | 237 | @Callable(i) | |
201 | 238 | func shutdown () = valueOrElse(isAdminCall(i), if (!(active)) | |
202 | 239 | then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, kCause), "the cause wasn't specified"))) | |
203 | 240 | else suspend("Paused by admin")) | |
204 | 241 | ||
205 | 242 | ||
206 | 243 | ||
207 | 244 | @Callable(i) | |
208 | 245 | func activate () = valueOrElse(isAdminCall(i), if (active) | |
209 | 246 | then throwIsActive() | |
210 | 247 | else [BooleanEntry(kActive, true), DeleteEntry(kCause)]) | |
211 | 248 | ||
212 | 249 | ||
213 | 250 | @Verifier(tx) | |
214 | 251 | func verify () = { | |
215 | 252 | let multiSignedByAdmins = { | |
216 | 253 | let adminPubKey1Signed = if (sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey1)) | |
217 | 254 | then 1 | |
218 | 255 | else 0 | |
219 | 256 | let adminPubKey2Signed = if (sigVerify(tx.bodyBytes, tx.proofs[1], adminPubKey2)) | |
220 | 257 | then 1 | |
221 | 258 | else 0 | |
222 | 259 | let adminPubKey3Signed = if (sigVerify(tx.bodyBytes, tx.proofs[2], adminPubKey3)) | |
223 | 260 | then 1 | |
224 | 261 | else 0 | |
225 | 262 | (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 2) | |
226 | 263 | } | |
227 | 264 | match tx { | |
228 | 265 | case _ => | |
229 | 266 | multiSignedByAdmins | |
230 | 267 | } | |
231 | 268 | } | |
232 | 269 |
github/deemru/w8io/169f3d6 74.44 ms ◑