tx · 2qFuQqzD9B5T9YcgyS87Yz4rdLamFfQSFhNef1pTb2oc

3NBBWfzZtZtszaXbitTKnrB2xXwv26Bn7H9:  -0.14000000 Waves

2022.09.09 15:08 [2221542] smart account 3NBBWfzZtZtszaXbitTKnrB2xXwv26Bn7H9 > SELF 0.00000000 Waves

{ "type": 13, "id": "2qFuQqzD9B5T9YcgyS87Yz4rdLamFfQSFhNef1pTb2oc", "fee": 14000000, "feeAssetId": null, "timestamp": 1662725265065, "version": 2, "chainId": 84, "sender": "3NBBWfzZtZtszaXbitTKnrB2xXwv26Bn7H9", "senderPublicKey": "D1X9WatF6ARMCmm3jC4Ex5Wd5VQ3LY8i1xbHNqeHqeAa", "proofs": [ "4g25rdyTYtNgbqYv1s9991AXbNk9zqAZsQQtHhvS5S9t2oJBM8BmpEMKqGmu65RiR2hYNGwmPWor3EFiRmh4PfaS", "43hfrLQLKA4seFwf1vyFsDKDS7MowWaCgsCgthidQHWQdTy2ya2H3pgHvEjeNvnUacJGfordSmSTT6zkjMgNKs35" ], "script": "base64:BgIQCAISCAoGGBgRERgBEgASACYAB2tBY3RpdmUCBmFjdGl2ZQAGa0NhdXNlAg5zaHV0ZG93bl9jYXVzZQANa1Bvb2xJbk9yYWNsZQIFcG9vbF8ADmtVc2VyU3dvcEluR292AgxfU1dPUF9hbW91bnQACmtEaXNjb3VudHMCCWRpc2NvdW50cwAPa0Rpc2NvdW50VmFsdWVzAg9kaXNjb3VudF92YWx1ZXMAC2tSb3V0aW5nRmVlAgtyb3V0aW5nX2ZlZQANa0FkbWluUHViS2V5MQILYWRtaW5fcHViXzEADWtBZG1pblB1YktleTICC2FkbWluX3B1Yl8yAA1rQWRtaW5QdWJLZXkzAgthZG1pbl9wdWJfMwAQa01vbmV5Qm94QWRkcmVzcwIRbW9uZXlfYm94X2FkZHJlc3MAC2tHb3ZBZGRyZXNzAhJnb3Zlcm5hbmNlX2FkZHJlc3MABGtGZWUCCmNvbW1pc3Npb24AEmtNdWx0eUFzc2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BRJhZG1pblB1YktleTNTaWduZWQAAgQHJG1hdGNoMAUCdHgFE211bHRpU2lnbmVkQnlBZG1pbnN/X8i/", "height": 2221542, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3UVsrMNfPVpEWMPfpTjD4vUcaeNo5EP1YgCKYSyBzG3Z Next: Fmm7rCSdDzrRFWPreEevEYf2k7ZnXjdnGvBteysP2i1J Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let kPrefixPoolName = "pool_"
4+let kActive = "active"
55
6-let kPair = "pair_"
6+let kCause = "shutdown_cause"
77
8-let kAssetIdA = "A_asset_id"
8+let kPoolInOracle = "pool_"
99
10-let kAssetIdB = "B_asset_id"
10+let kUserSwopInGov = "_SWOP_amount"
1111
12-let kLaunchpadDataTransactionStatus = "launchpad_data_transaction_status"
12+let kDiscounts = "discounts"
13+
14+let kDiscountValues = "discount_values"
15+
16+let kRoutingFee = "routing_fee"
1317
1418 let kAdminPubKey1 = "admin_pub_1"
1519
1721
1822 let kAdminPubKey3 = "admin_pub_3"
1923
20-let kAdminInvokePubKey = "admin_invoke_pub"
24+let kMoneyBoxAddress = "money_box_address"
2125
22-let kAchievementsWriters = "achievements_writers"
26+let kGovAddress = "governance_address"
2327
24-let adminPubKey1 = base58'GFmKZ2naZFRoCvNbwKAQVGmLb1uBeWGDgFabdGBuZiuy'
28+let kFee = "commission"
2529
26-let adminPubKey2 = base58'GmJXRyhRA79g8yUGgKBAVdnFfQFDMjQG98b1MmLDh5kk'
30+let kMultyAssetBalance = "_balance"
2731
28-let adminPubKey3 = base58'CFhbV6h41hVjbGHudGtS3fYUv7QAKRxFQzKNtx4B5PqP'
32+let digits8 = 8
2933
30-let adminPubKeyInvoke = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK'
34+let scale8 = 100000000
3135
32-func isSelfCall (i) = if ((i.caller == this))
33- then unit
34- else throw("Only the Oracle itself can invoke this function")
36+let scale16 = 10000000000000000
37+
38+let alpha = 50
39+
40+let alphaDigits = 2
41+
42+let beta = 4600000000000000
43+
44+let oracle = Address(base58'3NBBWfzZtZtszaXbitTKnrB2xXwv26Bn7H9')
45+
46+func getBase58FromOracle (key) = match getString(oracle, key) {
47+ case string: String =>
48+ fromBase58String(string)
49+ case nothing =>
50+ throw((key + "is empty"))
51+}
3552
3653
37-func getPoolType (poolAddress) = {
38- let version = valueOrErrorMessage(getString(poolAddress, "version"), "Pool is not initialized")
39- if ((version == "1.0.0"))
40- then "cpmm"
41- else if ((version == "2.0.0"))
42- then "flat"
43- else if ((version == "3.0.0"))
44- then "multycurve"
45- else throw("Unknown version of pool")
54+let adminPubKey1 = getBase58FromOracle(kAdminPubKey1)
55+
56+let adminPubKey2 = getBase58FromOracle(kAdminPubKey2)
57+
58+let adminPubKey3 = getBase58FromOracle(kAdminPubKey3)
59+
60+let moneyBoxAddress = Address(getBase58FromOracle(kMoneyBoxAddress))
61+
62+let govAddress = Address(getBase58FromOracle(kGovAddress))
63+
64+let active = valueOrElse(getBoolean(this, kActive), true)
65+
66+let routingFee = valueOrErrorMessage(getInteger(oracle, kRoutingFee), "routing_fee is empty")
67+
68+let feeScale6 = 1000000
69+
70+func isActive () = if (active)
71+ then unit
72+ else throw("DApp is inactive at this moment")
73+
74+
75+func isAdminCall (i) = if (containsElement([adminPubKey1, adminPubKey2, adminPubKey3], i.callerPublicKey))
76+ then unit
77+ else throw("Only admin can call this function")
78+
79+
80+func throwIsActive () = throw("DApp is already active")
81+
82+
83+func suspend (cause) = [BooleanEntry(kActive, false), StringEntry(kCause, cause)]
84+
85+
86+func skewness (x,y) = ((fraction(scale16, x, y) + fraction(scale16, y, x)) / 2)
87+
88+
89+func invariantCalc (x,y) = {
90+ let sk = skewness(x, y)
91+ (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)))
4692 }
4793
4894
49-func getAddressIfValid (address) = toString(valueOrErrorMessage(addressFromString(address), (("Can't parse \"" + address) + "\" as address")))
95+func calculateFeeDiscount (userAddr) = {
96+ let swopAmount = valueOrElse(getInteger(govAddress, (toString(userAddr) + kUserSwopInGov)), 0)
97+ let discountValues = split(getStringValue(oracle, kDiscountValues), ",")
98+ let discounts = split(getStringValue(oracle, kDiscounts), ",")
99+ if (if ((swopAmount >= parseIntValue(discountValues[0])))
100+ then (parseIntValue(discountValues[1]) > swopAmount)
101+ else false)
102+ then (feeScale6 - parseIntValue(discounts[0]))
103+ else if (if ((swopAmount >= parseIntValue(discountValues[1])))
104+ then (parseIntValue(discountValues[2]) > swopAmount)
105+ else false)
106+ then (feeScale6 - parseIntValue(discounts[1]))
107+ else if (if ((swopAmount >= parseIntValue(discountValues[2])))
108+ then (parseIntValue(discountValues[3]) > swopAmount)
109+ else false)
110+ then (feeScale6 - parseIntValue(discounts[2]))
111+ else if (if ((swopAmount >= parseIntValue(discountValues[3])))
112+ then (parseIntValue(discountValues[4]) > swopAmount)
113+ else false)
114+ then (feeScale6 - parseIntValue(discounts[3]))
115+ else if ((swopAmount >= parseIntValue(discountValues[4])))
116+ then (feeScale6 - parseIntValue(discounts[4]))
117+ else feeScale6
118+ }
119+
120+
121+func checkPossibility (caller,pmtAmount,minAmountToReceive,exchangers,exchangersType,routingAssetsKeys,args1,args2) = {
122+ let feeDiscount = calculateFeeDiscount(caller)
123+ let getFrom1TradeWithFee = if ((exchangersType[0] == "curveMultyFlat"))
124+ 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)"))
130+ }
131+ if ((inv == inv))
132+ then inv._1
133+ else throw("Strict value is not equal to itself.")
134+ }
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)"))
162+ }
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+ }
187+ (getFrom2TradeWithFee >= minAmountToReceive)
188+ }
50189
51190
52191 @Callable(i)
53-func setAdmin () = valueOrElse(isSelfCall(i), [StringEntry(kAdminPubKey1, toBase58String(adminPubKey1)), StringEntry(kAdminPubKey2, toBase58String(adminPubKey2)), StringEntry(kAdminPubKey3, toBase58String(adminPubKey3)), StringEntry(kAdminInvokePubKey, toBase58String(adminPubKeyInvoke))])
192+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
196+ if (!(checkPossibility(i.caller, pmtAmount, minAmountToReceive, exchangers, exchangersType, routingAssetsKeys, args1, args2)))
197+ then throw("Check transaction possibilty: declined")
198+ else if (if (!(isDefined(getString(oracle, (kPoolInOracle + exchangers[0])))))
199+ then true
200+ else !(isDefined(getString(oracle, (kPoolInOracle + exchangers[1])))))
201+ then throw("Pool is not in oracle")
202+ else {
203+ let routingSize = size(exchangers)
204+ 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))
210+ then $Tuple2(pmtAssetId, pmtAmount)
211+ else $Tuple2(assetsIdSend, amountsWithFee)
212+ let pmtAssetIdRout = $t081078305._1
213+ let pmtAmountRout = $t081078305._2
214+ if (((if ((exchangeCounter >= 0))
215+ then (routingSize > exchangeCounter)
216+ else false) == true))
217+ then {
218+ 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 $Tuple2(inv._1, inv._2)
229+ else throw("Strict value is not equal to itself.")
230+ }
231+ 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")
256+ }
257+ else accumulated
258+ }
54259
260+ let $t095349640 = {
261+ let $l = exchangers
262+ let $s = size($l)
263+ let $acc0 = $Tuple3(0, 0, base58'')
264+ func $f0_1 ($a,$i) = if (($i >= $s))
265+ then $a
266+ else exchangeFold($a, $l[$i])
55267
268+ func $f0_2 ($a,$i) = if (($i >= $s))
269+ then $a
270+ else throw("List size exceeds 3")
56271
57-@Callable(i)
58-func addPool (poolAddress,poolName) = valueOrElse(isSelfCall(i), {
59- let validatedAddress = getAddressIfValid(poolAddress)
60- let keyName = (kPrefixPoolName + validatedAddress)
61- let possiblyAlreadyAddedPool = getString(this, keyName)
62- if (isDefined(possiblyAlreadyAddedPool))
63- then throw((((("Pool with address \"" + validatedAddress) + "\" is already defined with name \"") + value(possiblyAlreadyAddedPool)) + "\""))
64- else ([StringEntry(keyName, poolName)] ++ (if ((getPoolType(value(addressFromString(poolAddress))) == "multycurve"))
65- then nil
66- else {
67- let assetIdA = valueOrErrorMessage(getString(value(addressFromString(poolAddress)), kAssetIdA), "Asset id A is incorrect")
68- let assetIdB = valueOrErrorMessage(getString(value(addressFromString(poolAddress)), kAssetIdB), "Asset id B is incorrect")
69-[StringEntry((((kPair + assetIdA) + "_") + assetIdB), poolAddress)]
70- }))
272+ $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3)
273+ }
274+ let exchangeCounter = $t095349640._1
275+ let amountWithoutFee = $t095349640._2
276+ let assetIdSend = $t095349640._3
277+ let amountWithFee = fraction(amountWithoutFee, (feeScale6 - routingFee), feeScale6)
278+ if (if ((exchangeCounter == routingSize))
279+ then (amountWithFee >= minAmountToReceive)
280+ else false)
281+ then [ScriptTransfer(i.caller, amountWithFee, assetIdSend), ScriptTransfer(moneyBoxAddress, (amountWithoutFee - amountWithFee), assetIdSend)]
282+ else throw("routing != routingSize or amountToRecieve < minAmountToReceive")
283+ }
71284 })
72285
73286
74287
75288 @Callable(i)
76-func renamePool (poolAddress,newPoolName) = valueOrElse(isSelfCall(i), {
77- let validatedAddress = getAddressIfValid(poolAddress)
78- let keyName = (kPrefixPoolName + validatedAddress)
79- let possiblyAlreadyAddedPool = getString(this, keyName)
80- if (isDefined(possiblyAlreadyAddedPool))
81- then [StringEntry(keyName, newPoolName)]
82- else throw((("Pool with address \"" + validatedAddress) + "\" has not yet been added"))
83- })
289+func shutdown () = valueOrElse(isAdminCall(i), if (!(active))
290+ then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, kCause), "the cause wasn't specified")))
291+ else suspend("Paused by admin"))
84292
85293
86294
87295 @Callable(i)
88-func launchpadDataTransactionStatus (status) = valueOrElse(isSelfCall(i), [BooleanEntry(kLaunchpadDataTransactionStatus, status)])
89-
90-
91-
92-@Callable(i)
93-func addAchievementsWriter (address) = valueOrElse(isSelfCall(i), {
94- let writers = valueOrElse(getString(this, kAchievementsWriters), "")
95- let data = if ((writers == ""))
96- then nil
97- else split(writers, ",")
98-[StringEntry(kAchievementsWriters, makeString((data :+ address), ","))]
99- })
100-
101-
102-
103-@Callable(i)
104-func removeAchievementsWriter (address) = valueOrElse(isSelfCall(i), {
105- let writers = split(valueOrElse(getString(this, kAchievementsWriters), ""), ",")
106- let index = valueOrErrorMessage(indexOf(writers, address), "Can't find address in the list")
107-[StringEntry(kAchievementsWriters, makeString(removeByIndex(writers, index), ","))]
108- })
296+func activate () = valueOrElse(isAdminCall(i), if (active)
297+ then throwIsActive()
298+ else [BooleanEntry(kActive, true), DeleteEntry(kCause)])
109299
110300
111301 @Verifier(tx)
112302 func verify () = {
113- let adminPubKey1Signed = if (sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey1))
114- then 1
115- else 0
116- let adminPubKey2Signed = if (sigVerify(tx.bodyBytes, tx.proofs[1], adminPubKey2))
117- then 1
118- else 0
119- let adminPubKey3Signed = if (sigVerify(tx.bodyBytes, tx.proofs[2], adminPubKey3))
120- then 1
121- else 0
122- let signedByAdmin = (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 2)
123- let signedByAdminToCallAddPool = (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 1)
303+ let multiSignedByAdmins = {
304+ let adminPubKey1Signed = if (sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey1))
305+ then 1
306+ else 0
307+ let adminPubKey2Signed = if (sigVerify(tx.bodyBytes, tx.proofs[1], adminPubKey2))
308+ then 1
309+ else 0
310+ let adminPubKey3Signed = if (sigVerify(tx.bodyBytes, tx.proofs[2], adminPubKey3))
311+ then 1
312+ else 0
313+ (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 2)
314+ }
124315 match tx {
125- case inv: InvokeScriptTransaction =>
126- let isSelfInvokeRenamePool = if ((inv.dApp == this))
127- then containsElement(["renamePool"], inv.function)
128- else false
129- let isSelfInvokeSetAdmin = if ((inv.dApp == this))
130- then containsElement(["setAdmin"], inv.function)
131- else false
132- let isSelfInvokeAddPool = if ((inv.dApp == this))
133- then containsElement(["addPool"], inv.function)
134- else false
135- let isSelfInvokeLaunchpadDataTxStatus = if ((inv.dApp == this))
136- then containsElement(["launchpadDataTransactionStatus"], inv.function)
137- else false
138- let isSelfInvokeAddAchievementsWriter = if ((inv.dApp == this))
139- then containsElement(["addAchievementsWriter"], inv.function)
140- else false
141- let isSelfInvokeRemoveAchievementsWriter = if ((inv.dApp == this))
142- then containsElement(["removeAchievementsWriter"], inv.function)
143- else false
144- if (if (if (if (if (if (if (signedByAdmin)
145- then (size(inv.payments) == 0)
146- else false)
147- then isSelfInvokeRenamePool
148- else false)
149- then true
150- else if (if (signedByAdminToCallAddPool)
151- then (size(inv.payments) == 0)
152- else false)
153- then isSelfInvokeAddPool
154- else false)
155- then true
156- else if (if (signedByAdmin)
157- then (size(inv.payments) == 0)
158- else false)
159- then isSelfInvokeSetAdmin
160- else false)
161- then true
162- else if (if (signedByAdmin)
163- then (size(inv.payments) == 0)
164- else false)
165- then isSelfInvokeLaunchpadDataTxStatus
166- else false)
167- then true
168- else if (if (signedByAdmin)
169- then (size(inv.payments) == 0)
170- else false)
171- then isSelfInvokeAddAchievementsWriter
172- else false)
173- then true
174- else if (if (signedByAdmin)
175- then (size(inv.payments) == 0)
176- else false)
177- then isSelfInvokeRemoveAchievementsWriter
178- else false
179- case _: Order|DataTransaction|SponsorFeeTransaction|SetScriptTransaction|CreateAliasTransaction|LeaseCancelTransaction|LeaseTransaction|IssueTransaction|InvokeExpressionTransaction|UpdateAssetInfoTransaction|InvokeScriptTransaction|SetAssetScriptTransaction|TransferTransaction|ExchangeTransaction|MassTransferTransaction|BurnTransaction|ReissueTransaction =>
180- signedByAdmin
181316 case _ =>
182- throw("Match error")
317+ multiSignedByAdmins
183318 }
184319 }
185320
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let kPrefixPoolName = "pool_"
4+let kActive = "active"
55
6-let kPair = "pair_"
6+let kCause = "shutdown_cause"
77
8-let kAssetIdA = "A_asset_id"
8+let kPoolInOracle = "pool_"
99
10-let kAssetIdB = "B_asset_id"
10+let kUserSwopInGov = "_SWOP_amount"
1111
12-let kLaunchpadDataTransactionStatus = "launchpad_data_transaction_status"
12+let kDiscounts = "discounts"
13+
14+let kDiscountValues = "discount_values"
15+
16+let kRoutingFee = "routing_fee"
1317
1418 let kAdminPubKey1 = "admin_pub_1"
1519
1620 let kAdminPubKey2 = "admin_pub_2"
1721
1822 let kAdminPubKey3 = "admin_pub_3"
1923
20-let kAdminInvokePubKey = "admin_invoke_pub"
24+let kMoneyBoxAddress = "money_box_address"
2125
22-let kAchievementsWriters = "achievements_writers"
26+let kGovAddress = "governance_address"
2327
24-let adminPubKey1 = base58'GFmKZ2naZFRoCvNbwKAQVGmLb1uBeWGDgFabdGBuZiuy'
28+let kFee = "commission"
2529
26-let adminPubKey2 = base58'GmJXRyhRA79g8yUGgKBAVdnFfQFDMjQG98b1MmLDh5kk'
30+let kMultyAssetBalance = "_balance"
2731
28-let adminPubKey3 = base58'CFhbV6h41hVjbGHudGtS3fYUv7QAKRxFQzKNtx4B5PqP'
32+let digits8 = 8
2933
30-let adminPubKeyInvoke = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK'
34+let scale8 = 100000000
3135
32-func isSelfCall (i) = if ((i.caller == this))
33- then unit
34- else throw("Only the Oracle itself can invoke this function")
36+let scale16 = 10000000000000000
37+
38+let alpha = 50
39+
40+let alphaDigits = 2
41+
42+let beta = 4600000000000000
43+
44+let oracle = Address(base58'3NBBWfzZtZtszaXbitTKnrB2xXwv26Bn7H9')
45+
46+func getBase58FromOracle (key) = match getString(oracle, key) {
47+ case string: String =>
48+ fromBase58String(string)
49+ case nothing =>
50+ throw((key + "is empty"))
51+}
3552
3653
37-func getPoolType (poolAddress) = {
38- let version = valueOrErrorMessage(getString(poolAddress, "version"), "Pool is not initialized")
39- if ((version == "1.0.0"))
40- then "cpmm"
41- else if ((version == "2.0.0"))
42- then "flat"
43- else if ((version == "3.0.0"))
44- then "multycurve"
45- else throw("Unknown version of pool")
54+let adminPubKey1 = getBase58FromOracle(kAdminPubKey1)
55+
56+let adminPubKey2 = getBase58FromOracle(kAdminPubKey2)
57+
58+let adminPubKey3 = getBase58FromOracle(kAdminPubKey3)
59+
60+let moneyBoxAddress = Address(getBase58FromOracle(kMoneyBoxAddress))
61+
62+let govAddress = Address(getBase58FromOracle(kGovAddress))
63+
64+let active = valueOrElse(getBoolean(this, kActive), true)
65+
66+let routingFee = valueOrErrorMessage(getInteger(oracle, kRoutingFee), "routing_fee is empty")
67+
68+let feeScale6 = 1000000
69+
70+func isActive () = if (active)
71+ then unit
72+ else throw("DApp is inactive at this moment")
73+
74+
75+func isAdminCall (i) = if (containsElement([adminPubKey1, adminPubKey2, adminPubKey3], i.callerPublicKey))
76+ then unit
77+ else throw("Only admin can call this function")
78+
79+
80+func throwIsActive () = throw("DApp is already active")
81+
82+
83+func suspend (cause) = [BooleanEntry(kActive, false), StringEntry(kCause, cause)]
84+
85+
86+func skewness (x,y) = ((fraction(scale16, x, y) + fraction(scale16, y, x)) / 2)
87+
88+
89+func invariantCalc (x,y) = {
90+ let sk = skewness(x, y)
91+ (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)))
4692 }
4793
4894
49-func getAddressIfValid (address) = toString(valueOrErrorMessage(addressFromString(address), (("Can't parse \"" + address) + "\" as address")))
95+func calculateFeeDiscount (userAddr) = {
96+ let swopAmount = valueOrElse(getInteger(govAddress, (toString(userAddr) + kUserSwopInGov)), 0)
97+ let discountValues = split(getStringValue(oracle, kDiscountValues), ",")
98+ let discounts = split(getStringValue(oracle, kDiscounts), ",")
99+ if (if ((swopAmount >= parseIntValue(discountValues[0])))
100+ then (parseIntValue(discountValues[1]) > swopAmount)
101+ else false)
102+ then (feeScale6 - parseIntValue(discounts[0]))
103+ else if (if ((swopAmount >= parseIntValue(discountValues[1])))
104+ then (parseIntValue(discountValues[2]) > swopAmount)
105+ else false)
106+ then (feeScale6 - parseIntValue(discounts[1]))
107+ else if (if ((swopAmount >= parseIntValue(discountValues[2])))
108+ then (parseIntValue(discountValues[3]) > swopAmount)
109+ else false)
110+ then (feeScale6 - parseIntValue(discounts[2]))
111+ else if (if ((swopAmount >= parseIntValue(discountValues[3])))
112+ then (parseIntValue(discountValues[4]) > swopAmount)
113+ else false)
114+ then (feeScale6 - parseIntValue(discounts[3]))
115+ else if ((swopAmount >= parseIntValue(discountValues[4])))
116+ then (feeScale6 - parseIntValue(discounts[4]))
117+ else feeScale6
118+ }
119+
120+
121+func checkPossibility (caller,pmtAmount,minAmountToReceive,exchangers,exchangersType,routingAssetsKeys,args1,args2) = {
122+ let feeDiscount = calculateFeeDiscount(caller)
123+ let getFrom1TradeWithFee = if ((exchangersType[0] == "curveMultyFlat"))
124+ 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)"))
130+ }
131+ if ((inv == inv))
132+ then inv._1
133+ else throw("Strict value is not equal to itself.")
134+ }
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)"))
162+ }
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+ }
187+ (getFrom2TradeWithFee >= minAmountToReceive)
188+ }
50189
51190
52191 @Callable(i)
53-func setAdmin () = valueOrElse(isSelfCall(i), [StringEntry(kAdminPubKey1, toBase58String(adminPubKey1)), StringEntry(kAdminPubKey2, toBase58String(adminPubKey2)), StringEntry(kAdminPubKey3, toBase58String(adminPubKey3)), StringEntry(kAdminInvokePubKey, toBase58String(adminPubKeyInvoke))])
192+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
196+ if (!(checkPossibility(i.caller, pmtAmount, minAmountToReceive, exchangers, exchangersType, routingAssetsKeys, args1, args2)))
197+ then throw("Check transaction possibilty: declined")
198+ else if (if (!(isDefined(getString(oracle, (kPoolInOracle + exchangers[0])))))
199+ then true
200+ else !(isDefined(getString(oracle, (kPoolInOracle + exchangers[1])))))
201+ then throw("Pool is not in oracle")
202+ else {
203+ let routingSize = size(exchangers)
204+ 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))
210+ then $Tuple2(pmtAssetId, pmtAmount)
211+ else $Tuple2(assetsIdSend, amountsWithFee)
212+ let pmtAssetIdRout = $t081078305._1
213+ let pmtAmountRout = $t081078305._2
214+ if (((if ((exchangeCounter >= 0))
215+ then (routingSize > exchangeCounter)
216+ else false) == true))
217+ then {
218+ 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 $Tuple2(inv._1, inv._2)
229+ else throw("Strict value is not equal to itself.")
230+ }
231+ 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")
256+ }
257+ else accumulated
258+ }
54259
260+ let $t095349640 = {
261+ let $l = exchangers
262+ let $s = size($l)
263+ let $acc0 = $Tuple3(0, 0, base58'')
264+ func $f0_1 ($a,$i) = if (($i >= $s))
265+ then $a
266+ else exchangeFold($a, $l[$i])
55267
268+ func $f0_2 ($a,$i) = if (($i >= $s))
269+ then $a
270+ else throw("List size exceeds 3")
56271
57-@Callable(i)
58-func addPool (poolAddress,poolName) = valueOrElse(isSelfCall(i), {
59- let validatedAddress = getAddressIfValid(poolAddress)
60- let keyName = (kPrefixPoolName + validatedAddress)
61- let possiblyAlreadyAddedPool = getString(this, keyName)
62- if (isDefined(possiblyAlreadyAddedPool))
63- then throw((((("Pool with address \"" + validatedAddress) + "\" is already defined with name \"") + value(possiblyAlreadyAddedPool)) + "\""))
64- else ([StringEntry(keyName, poolName)] ++ (if ((getPoolType(value(addressFromString(poolAddress))) == "multycurve"))
65- then nil
66- else {
67- let assetIdA = valueOrErrorMessage(getString(value(addressFromString(poolAddress)), kAssetIdA), "Asset id A is incorrect")
68- let assetIdB = valueOrErrorMessage(getString(value(addressFromString(poolAddress)), kAssetIdB), "Asset id B is incorrect")
69-[StringEntry((((kPair + assetIdA) + "_") + assetIdB), poolAddress)]
70- }))
272+ $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3)
273+ }
274+ let exchangeCounter = $t095349640._1
275+ let amountWithoutFee = $t095349640._2
276+ let assetIdSend = $t095349640._3
277+ let amountWithFee = fraction(amountWithoutFee, (feeScale6 - routingFee), feeScale6)
278+ if (if ((exchangeCounter == routingSize))
279+ then (amountWithFee >= minAmountToReceive)
280+ else false)
281+ then [ScriptTransfer(i.caller, amountWithFee, assetIdSend), ScriptTransfer(moneyBoxAddress, (amountWithoutFee - amountWithFee), assetIdSend)]
282+ else throw("routing != routingSize or amountToRecieve < minAmountToReceive")
283+ }
71284 })
72285
73286
74287
75288 @Callable(i)
76-func renamePool (poolAddress,newPoolName) = valueOrElse(isSelfCall(i), {
77- let validatedAddress = getAddressIfValid(poolAddress)
78- let keyName = (kPrefixPoolName + validatedAddress)
79- let possiblyAlreadyAddedPool = getString(this, keyName)
80- if (isDefined(possiblyAlreadyAddedPool))
81- then [StringEntry(keyName, newPoolName)]
82- else throw((("Pool with address \"" + validatedAddress) + "\" has not yet been added"))
83- })
289+func shutdown () = valueOrElse(isAdminCall(i), if (!(active))
290+ then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, kCause), "the cause wasn't specified")))
291+ else suspend("Paused by admin"))
84292
85293
86294
87295 @Callable(i)
88-func launchpadDataTransactionStatus (status) = valueOrElse(isSelfCall(i), [BooleanEntry(kLaunchpadDataTransactionStatus, status)])
89-
90-
91-
92-@Callable(i)
93-func addAchievementsWriter (address) = valueOrElse(isSelfCall(i), {
94- let writers = valueOrElse(getString(this, kAchievementsWriters), "")
95- let data = if ((writers == ""))
96- then nil
97- else split(writers, ",")
98-[StringEntry(kAchievementsWriters, makeString((data :+ address), ","))]
99- })
100-
101-
102-
103-@Callable(i)
104-func removeAchievementsWriter (address) = valueOrElse(isSelfCall(i), {
105- let writers = split(valueOrElse(getString(this, kAchievementsWriters), ""), ",")
106- let index = valueOrErrorMessage(indexOf(writers, address), "Can't find address in the list")
107-[StringEntry(kAchievementsWriters, makeString(removeByIndex(writers, index), ","))]
108- })
296+func activate () = valueOrElse(isAdminCall(i), if (active)
297+ then throwIsActive()
298+ else [BooleanEntry(kActive, true), DeleteEntry(kCause)])
109299
110300
111301 @Verifier(tx)
112302 func verify () = {
113- let adminPubKey1Signed = if (sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey1))
114- then 1
115- else 0
116- let adminPubKey2Signed = if (sigVerify(tx.bodyBytes, tx.proofs[1], adminPubKey2))
117- then 1
118- else 0
119- let adminPubKey3Signed = if (sigVerify(tx.bodyBytes, tx.proofs[2], adminPubKey3))
120- then 1
121- else 0
122- let signedByAdmin = (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 2)
123- let signedByAdminToCallAddPool = (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 1)
303+ let multiSignedByAdmins = {
304+ let adminPubKey1Signed = if (sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey1))
305+ then 1
306+ else 0
307+ let adminPubKey2Signed = if (sigVerify(tx.bodyBytes, tx.proofs[1], adminPubKey2))
308+ then 1
309+ else 0
310+ let adminPubKey3Signed = if (sigVerify(tx.bodyBytes, tx.proofs[2], adminPubKey3))
311+ then 1
312+ else 0
313+ (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 2)
314+ }
124315 match tx {
125- case inv: InvokeScriptTransaction =>
126- let isSelfInvokeRenamePool = if ((inv.dApp == this))
127- then containsElement(["renamePool"], inv.function)
128- else false
129- let isSelfInvokeSetAdmin = if ((inv.dApp == this))
130- then containsElement(["setAdmin"], inv.function)
131- else false
132- let isSelfInvokeAddPool = if ((inv.dApp == this))
133- then containsElement(["addPool"], inv.function)
134- else false
135- let isSelfInvokeLaunchpadDataTxStatus = if ((inv.dApp == this))
136- then containsElement(["launchpadDataTransactionStatus"], inv.function)
137- else false
138- let isSelfInvokeAddAchievementsWriter = if ((inv.dApp == this))
139- then containsElement(["addAchievementsWriter"], inv.function)
140- else false
141- let isSelfInvokeRemoveAchievementsWriter = if ((inv.dApp == this))
142- then containsElement(["removeAchievementsWriter"], inv.function)
143- else false
144- if (if (if (if (if (if (if (signedByAdmin)
145- then (size(inv.payments) == 0)
146- else false)
147- then isSelfInvokeRenamePool
148- else false)
149- then true
150- else if (if (signedByAdminToCallAddPool)
151- then (size(inv.payments) == 0)
152- else false)
153- then isSelfInvokeAddPool
154- else false)
155- then true
156- else if (if (signedByAdmin)
157- then (size(inv.payments) == 0)
158- else false)
159- then isSelfInvokeSetAdmin
160- else false)
161- then true
162- else if (if (signedByAdmin)
163- then (size(inv.payments) == 0)
164- else false)
165- then isSelfInvokeLaunchpadDataTxStatus
166- else false)
167- then true
168- else if (if (signedByAdmin)
169- then (size(inv.payments) == 0)
170- else false)
171- then isSelfInvokeAddAchievementsWriter
172- else false)
173- then true
174- else if (if (signedByAdmin)
175- then (size(inv.payments) == 0)
176- else false)
177- then isSelfInvokeRemoveAchievementsWriter
178- else false
179- case _: Order|DataTransaction|SponsorFeeTransaction|SetScriptTransaction|CreateAliasTransaction|LeaseCancelTransaction|LeaseTransaction|IssueTransaction|InvokeExpressionTransaction|UpdateAssetInfoTransaction|InvokeScriptTransaction|SetAssetScriptTransaction|TransferTransaction|ExchangeTransaction|MassTransferTransaction|BurnTransaction|ReissueTransaction =>
180- signedByAdmin
181316 case _ =>
182- throw("Match error")
317+ multiSignedByAdmins
183318 }
184319 }
185320

github/deemru/w8io/169f3d6 
91.88 ms