tx · 6yneKwVnCjbjZUpiA1UZNRgH23tGANzEaF7vCBHr8htr 3NCCxt72qfGYBPUNx6zM49UDV9r4LvrtzeY: -0.01800000 Waves 2024.11.21 12:40 [3381042] smart account 3NCCxt72qfGYBPUNx6zM49UDV9r4LvrtzeY > SELF 0.00000000 Waves
{ "type": 13, "id": "6yneKwVnCjbjZUpiA1UZNRgH23tGANzEaF7vCBHr8htr", "fee": 1800000, "feeAssetId": null, "timestamp": 1732181951578, "version": 2, "chainId": 84, "sender": "3NCCxt72qfGYBPUNx6zM49UDV9r4LvrtzeY", "senderPublicKey": "D14bs2ieC42BPAapbooQT637A3iD7mXwJ9bgfDGXBHcX", "proofs": [ "3MRTX2Ad8HntJMepsUCRumuS6MR9kxoC2eKtgfcY9FJt6ecFjVk2NVsUeKnL4967UgBTKmaP5G5ybDCWUBkd2Wf9" ], "script": "base64:BwItCAISBQoDCAgIEgYKBAgICAgSBQoDCAgIEgQKAggEEgMKAQgSAwoBCBIDCgEIPgAJU0VQQVJBVE9SAgJfXwAMS0VZX01VTFRJU0lHAghNVUxUSVNJRwAKS0VZX1NUQVRVUwIGU1RBVFVTAAhLRVlfSU5JVAIESU5JVAANS0VZX1NFUVVFTkNFUgIJU0VRVUVOQ0VSABNLRVlfQUNDT1VOVF9TVE9SQUdFAg9BQ0NPVU5UX1NUT1JBR0UAEUtFWV9GRUVfUkVDSVBJRU5UAg1GRUVfUkVDSVBJRU5UAApLRVlfU1lNQk9MAgZTWU1CT0wAF0tFWV9PUkRFUl9GSUxMRURfQU1PVU5UAhNPUkRFUl9GSUxMRURfQU1PVU5UABZLRVlfUkVXQVJEX0RJU1RSSUJVVE9SAhJSRVdBUkRfRElTVFJJQlVUT1IAFkZVTkNfRVhURVJOQUxfVFJBTlNGRVICEGV4dGVybmFsVHJhbnNmZXIAEUZVTkNfQ0xBSU1fUkVXQVJEAgtjbGFpbVJld2FyZAALU1BPVF9XQUxMRVQCBFNQT1QAEE9SREVSX1RZUEVfTElNSVQAA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qG6LqJN5fkVxdEayVeEnhuH5qtM3 Diff:
Old | New | Differences | |
---|---|---|---|
245 | 245 | else throw((err_ + ": inv alg")) | |
246 | 246 | ||
247 | 247 | ||
248 | - | func _ | |
249 | - | then if ((size( | |
248 | + | func _validateWeb3Id (web3Id_,alg_,err_) = if ((alg_ == ALG_TYPE_WAVES)) | |
249 | + | then if ((size(web3Id_) != 32)) | |
250 | 250 | then throw(err_) | |
251 | 251 | else true | |
252 | 252 | else if ((alg_ == ALG_TYPE_EVM)) | |
253 | - | then if ((size( | |
253 | + | then if ((size(web3Id_) != 20)) | |
254 | 254 | then throw(err_) | |
255 | 255 | else true | |
256 | 256 | else throw((err_ + ": inv alg")) | |
257 | 257 | ||
258 | 258 | ||
259 | - | func _ | |
260 | - | then toString(addressFromPublicKey( | |
259 | + | func _convertWeb3IdToAddress (web3Id_,alg_) = if ((alg_ == ALG_TYPE_WAVES)) | |
260 | + | then toString(addressFromPublicKey(web3Id_)) | |
261 | 261 | else if ((alg_ == ALG_TYPE_EVM)) | |
262 | - | then ("0x" + toBase16String( | |
263 | - | else throw("_ | |
262 | + | then ("0x" + toBase16String(web3Id_)) | |
263 | + | else throw("_convertWeb3IdToAddress: revert") | |
264 | 264 | ||
265 | 265 | ||
266 | - | func _validateOrderSignature (orderHash_,signature_, | |
266 | + | func _validateOrderSignature (orderHash_,signature_,web3Id_,alg_,err_) = { | |
267 | 267 | let result = if ((alg_ == ALG_TYPE_WAVES)) | |
268 | - | then sigVerify(orderHash_, signature_, | |
268 | + | then sigVerify(orderHash_, signature_, web3Id_) | |
269 | 269 | else if ((alg_ == ALG_TYPE_EVM)) | |
270 | 270 | then { | |
271 | 271 | let hashWithPrefix = keccak256_16Kb((EVM_PREFIX + orderHash_)) | |
272 | - | (takeRight(keccak256_16Kb(ecrecover(hashWithPrefix, signature_)), 20) == | |
272 | + | (takeRight(keccak256_16Kb(ecrecover(hashWithPrefix, signature_)), 20) == web3Id_) | |
273 | 273 | } | |
274 | 274 | else throw((err_ + ": inv alg")) | |
275 | 275 | if (!(result)) | |
290 | 290 | let symbol = fields[2] | |
291 | 291 | let side = valueOrErrorMessage(parseInt(fields[3]), (err_ + ": inv side")) | |
292 | 292 | let ts = valueOrErrorMessage(parseInt(fields[4]), (err_ + ": inv ts")) | |
293 | - | let | |
293 | + | let web3Id = fromBase58String(fields[5]) | |
294 | 294 | let alg = valueOrErrorMessage(parseInt(fields[6]), (err_ + ": inv alg")) | |
295 | 295 | let signature = fromBase58String(fields[7]) | |
296 | - | let $ | |
296 | + | let $t083589396 = if (if ((type == ORDER_TYPE_LIMIT)) | |
297 | 297 | then (version == ORDER_VERSION_1) | |
298 | 298 | else false) | |
299 | 299 | then { | |
315 | 315 | else $Tuple4(ZERO_BIGINT, ZERO_BIGINT, amount, (toBytes(amount) + toBytes(ZERO_BIGINT))) | |
316 | 316 | } | |
317 | 317 | else throw((err_ + ": inv type & version")) | |
318 | - | let price = $ | |
319 | - | let baseAmount = $ | |
320 | - | let quoteAmount = $ | |
321 | - | let orderDetailsBytes = $ | |
322 | - | let orderBytes = ((((((((toBytes(type) + toBytes(version)) + toBytes(size(symbol))) + toBytes(symbol)) + toBytes(side)) + toBytes(ts)) + | |
318 | + | let price = $t083589396._1 | |
319 | + | let baseAmount = $t083589396._2 | |
320 | + | let quoteAmount = $t083589396._3 | |
321 | + | let orderDetailsBytes = $t083589396._4 | |
322 | + | let orderBytes = ((((((((toBytes(type) + toBytes(version)) + toBytes(size(symbol))) + toBytes(symbol)) + toBytes(side)) + toBytes(ts)) + web3Id) + toBytes(alg)) + orderDetailsBytes) | |
323 | 323 | let orderHash = keccak256_32Kb(orderBytes) | |
324 | 324 | let err = if (if (if (if (if (if (if (_validateOrderType(type, version, (err_ + ": inv order type"))) | |
325 | 325 | then _validateOrderSymbol(symbol, (err_ + ": inv order symbol")) | |
326 | 326 | else false) | |
327 | 327 | then _validateOrderSide(side, (err_ + ": inv order side")) | |
328 | 328 | else false) | |
329 | - | then _ | |
329 | + | then _validateWeb3Id(web3Id, alg, (err_ + ": inv order web3Id")) | |
330 | 330 | else false) | |
331 | 331 | then _validateSignatureFormat(signature, alg, (err_ + ": inv sig format")) | |
332 | 332 | else false) | |
337 | 337 | then _validateBigInt(quoteAmount, ZERO_BIGINT, (err_ + ": neg quote amount")) | |
338 | 338 | else false | |
339 | 339 | if ((err == err)) | |
340 | - | then $Tuple10(type, symbol, side, price, baseAmount, quoteAmount, orderHash, | |
340 | + | then $Tuple10(type, symbol, side, price, baseAmount, quoteAmount, orderHash, web3Id, alg, signature) | |
341 | 341 | else throw("Strict value is not equal to itself.") | |
342 | 342 | } | |
343 | 343 | ||
364 | 364 | ||
365 | 365 | @Callable(i) | |
366 | 366 | func trade (makerOrder_,takerOrder_,baseFee_,quoteFee_) = { | |
367 | - | let $ | |
368 | - | let makerOrderType = $ | |
369 | - | let makerOrderSymbol = $ | |
370 | - | let makerOrderSide = $ | |
371 | - | let makerOrderPrice = $ | |
372 | - | let makerOrderBaseAmount = $ | |
373 | - | let makerOrderQuoteAmount = $ | |
374 | - | let makerOrderHash = $ | |
375 | - | let | |
376 | - | let makerOrderAlg = $ | |
377 | - | let makerOrderSignature = $ | |
378 | - | let $ | |
379 | - | let takerOrderType = $ | |
380 | - | let takerOrderSymbol = $ | |
381 | - | let takerOrderSide = $ | |
382 | - | let takerOrderPrice = $ | |
383 | - | let takerOrderBaseAmount = $ | |
384 | - | let takerOrderQuoteAmount = $ | |
385 | - | let takerOrderHash = $ | |
386 | - | let | |
387 | - | let takerOrderAlg = $ | |
388 | - | let takerOrderSignature = $ | |
367 | + | let $t01121211541 = _parseOrder(makerOrder_, "trade: invalid maker order") | |
368 | + | let makerOrderType = $t01121211541._1 | |
369 | + | let makerOrderSymbol = $t01121211541._2 | |
370 | + | let makerOrderSide = $t01121211541._3 | |
371 | + | let makerOrderPrice = $t01121211541._4 | |
372 | + | let makerOrderBaseAmount = $t01121211541._5 | |
373 | + | let makerOrderQuoteAmount = $t01121211541._6 | |
374 | + | let makerOrderHash = $t01121211541._7 | |
375 | + | let makerOrderWeb3Id = $t01121211541._8 | |
376 | + | let makerOrderAlg = $t01121211541._9 | |
377 | + | let makerOrderSignature = $t01121211541._10 | |
378 | + | let $t01154711876 = _parseOrder(takerOrder_, "trade: invalid taker order") | |
379 | + | let takerOrderType = $t01154711876._1 | |
380 | + | let takerOrderSymbol = $t01154711876._2 | |
381 | + | let takerOrderSide = $t01154711876._3 | |
382 | + | let takerOrderPrice = $t01154711876._4 | |
383 | + | let takerOrderBaseAmount = $t01154711876._5 | |
384 | + | let takerOrderQuoteAmount = $t01154711876._6 | |
385 | + | let takerOrderHash = $t01154711876._7 | |
386 | + | let takerOrderWeb3Id = $t01154711876._8 | |
387 | + | let takerOrderAlg = $t01154711876._9 | |
388 | + | let takerOrderSignature = $t01154711876._10 | |
389 | 389 | let baseFee = valueOrErrorMessage(parseBigInt(baseFee_), "trade: baseFee not int") | |
390 | 390 | let quoteFee = valueOrErrorMessage(parseBigInt(quoteFee_), "trade: quoteFee not int") | |
391 | 391 | let tradePrice = makerOrderPrice | |
406 | 406 | else false) | |
407 | 407 | then _validateIntNotEqual(makerOrderSide, takerOrderSide, "trade: side mismatch") | |
408 | 408 | else false) | |
409 | - | then _validateOrderSignature(makerOrderHash, makerOrderSignature, | |
409 | + | then _validateOrderSignature(makerOrderHash, makerOrderSignature, makerOrderWeb3Id, makerOrderAlg, "trade: invalid maker sig") | |
410 | 410 | else false) | |
411 | - | then _validateOrderSignature(takerOrderHash, takerOrderSignature, | |
411 | + | then _validateOrderSignature(takerOrderHash, takerOrderSignature, takerOrderWeb3Id, takerOrderAlg, "trade: invalid taker sig") | |
412 | 412 | else false) | |
413 | 413 | then _validateFeeTolerance(tradeBaseAmount, baseFee, "trade: base fee too much") | |
414 | 414 | else false) | |
418 | 418 | else false | |
419 | 419 | if ((err == err)) | |
420 | 420 | then { | |
421 | - | let makerAddress = _ | |
422 | - | let takerAddress = _ | |
423 | - | let $ | |
421 | + | let makerAddress = _convertWeb3IdToAddress(makerOrderWeb3Id, makerOrderAlg) | |
422 | + | let takerAddress = _convertWeb3IdToAddress(takerOrderWeb3Id, takerOrderAlg) | |
423 | + | let $t01403314456 = if ((makerOrderSide == ORDER_SIDE_BUY)) | |
424 | 424 | then $Tuple2(makerAddress, takerAddress) | |
425 | 425 | else $Tuple2(takerAddress, makerAddress) | |
426 | - | let buyer = $ | |
427 | - | let seller = $ | |
426 | + | let buyer = $t01403314456._1 | |
427 | + | let seller = $t01403314456._2 | |
428 | 428 | let assets = split(makerOrderSymbol, "-") | |
429 | 429 | let baseAsset = assets[0] | |
430 | 430 | let quoteAsset = assets[1] |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 7 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEPARATOR = "__" | |
5 | 5 | ||
6 | 6 | let KEY_MULTISIG = "MULTISIG" | |
7 | 7 | ||
8 | 8 | let KEY_STATUS = "STATUS" | |
9 | 9 | ||
10 | 10 | let KEY_INIT = "INIT" | |
11 | 11 | ||
12 | 12 | let KEY_SEQUENCER = "SEQUENCER" | |
13 | 13 | ||
14 | 14 | let KEY_ACCOUNT_STORAGE = "ACCOUNT_STORAGE" | |
15 | 15 | ||
16 | 16 | let KEY_FEE_RECIPIENT = "FEE_RECIPIENT" | |
17 | 17 | ||
18 | 18 | let KEY_SYMBOL = "SYMBOL" | |
19 | 19 | ||
20 | 20 | let KEY_ORDER_FILLED_AMOUNT = "ORDER_FILLED_AMOUNT" | |
21 | 21 | ||
22 | 22 | let KEY_REWARD_DISTRIBUTOR = "REWARD_DISTRIBUTOR" | |
23 | 23 | ||
24 | 24 | let FUNC_EXTERNAL_TRANSFER = "externalTransfer" | |
25 | 25 | ||
26 | 26 | let FUNC_CLAIM_REWARD = "claimReward" | |
27 | 27 | ||
28 | 28 | let SPOT_WALLET = "SPOT" | |
29 | 29 | ||
30 | 30 | let ORDER_TYPE_LIMIT = 1 | |
31 | 31 | ||
32 | 32 | let ORDER_TYPE_MARKET = 2 | |
33 | 33 | ||
34 | 34 | let ORDER_VERSION_1 = 1 | |
35 | 35 | ||
36 | 36 | let ORDER_SIDE_BUY = 1 | |
37 | 37 | ||
38 | 38 | let ORDER_SIDE_SELL = 2 | |
39 | 39 | ||
40 | 40 | let ALG_TYPE_WAVES = 1 | |
41 | 41 | ||
42 | 42 | let ALG_TYPE_EVM = 2 | |
43 | 43 | ||
44 | 44 | let ZERO_BIGINT = toBigInt(0) | |
45 | 45 | ||
46 | 46 | let ONE_BIGINT = toBigInt(1) | |
47 | 47 | ||
48 | 48 | let MULTIPLIER = toBigInt(100000000) | |
49 | 49 | ||
50 | 50 | let FEE_MAX_TOLERANCE = toBigInt(100000) | |
51 | 51 | ||
52 | 52 | let EVM_PREFIX = base58'G5Nu92G2p7moXW9qjjN3na7gtq4dWCeVdaSjry' | |
53 | 53 | ||
54 | 54 | func _validateAddress (address_,err_) = match addressFromString(address_) { | |
55 | 55 | case a: Address => | |
56 | 56 | true | |
57 | 57 | case _ => | |
58 | 58 | throw(err_) | |
59 | 59 | } | |
60 | 60 | ||
61 | 61 | ||
62 | 62 | func _validateBigInt (val_,lowerBoundary_,err_) = if ((lowerBoundary_ > val_)) | |
63 | 63 | then throw(err_) | |
64 | 64 | else true | |
65 | 65 | ||
66 | 66 | ||
67 | 67 | func _validateIntEqual (val1_,val2_,err_) = if ((val1_ != val2_)) | |
68 | 68 | then throw(err_) | |
69 | 69 | else true | |
70 | 70 | ||
71 | 71 | ||
72 | 72 | func _validateIntNotEqual (val1_,val2_,err_) = if ((val1_ == val2_)) | |
73 | 73 | then throw(err_) | |
74 | 74 | else true | |
75 | 75 | ||
76 | 76 | ||
77 | 77 | func _validateString (val_,err_) = if (if ((0 >= size(val_))) | |
78 | 78 | then true | |
79 | 79 | else contains(val_, SEPARATOR)) | |
80 | 80 | then throw(err_) | |
81 | 81 | else true | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | func _validateStringEqual (val1_,val2_,err_) = if ((val1_ != val2_)) | |
85 | 85 | then throw(err_) | |
86 | 86 | else true | |
87 | 87 | ||
88 | 88 | ||
89 | 89 | func _loadInit () = match getBoolean(KEY_INIT) { | |
90 | 90 | case a: Boolean => | |
91 | 91 | a | |
92 | 92 | case _ => | |
93 | 93 | false | |
94 | 94 | } | |
95 | 95 | ||
96 | 96 | ||
97 | 97 | func _saveInit (isInit_) = [BooleanEntry(KEY_INIT, isInit_)] | |
98 | 98 | ||
99 | 99 | ||
100 | 100 | func _loadMultisig () = match getString(KEY_MULTISIG) { | |
101 | 101 | case a: String => | |
102 | 102 | addressFromStringValue(a) | |
103 | 103 | case _ => | |
104 | 104 | Address(base58'') | |
105 | 105 | } | |
106 | 106 | ||
107 | 107 | ||
108 | 108 | func _saveMultisig (multisig_) = [StringEntry(KEY_MULTISIG, toString(multisig_))] | |
109 | 109 | ||
110 | 110 | ||
111 | 111 | func _loadSequencer () = match getString(KEY_SEQUENCER) { | |
112 | 112 | case a: String => | |
113 | 113 | addressFromStringValue(a) | |
114 | 114 | case _ => | |
115 | 115 | Address(base58'') | |
116 | 116 | } | |
117 | 117 | ||
118 | 118 | ||
119 | 119 | func _saveSequencer (sequencer_) = [StringEntry(KEY_SEQUENCER, toString(sequencer_))] | |
120 | 120 | ||
121 | 121 | ||
122 | 122 | func _loadAccountStorage () = match getString(KEY_ACCOUNT_STORAGE) { | |
123 | 123 | case a: String => | |
124 | 124 | addressFromStringValue(a) | |
125 | 125 | case _ => | |
126 | 126 | Address(base58'') | |
127 | 127 | } | |
128 | 128 | ||
129 | 129 | ||
130 | 130 | func _saveAccountStorage (accountStorage_) = [StringEntry(KEY_ACCOUNT_STORAGE, toString(accountStorage_))] | |
131 | 131 | ||
132 | 132 | ||
133 | 133 | func _loadFeeRecipient () = match getString(KEY_FEE_RECIPIENT) { | |
134 | 134 | case a: String => | |
135 | 135 | a | |
136 | 136 | case _ => | |
137 | 137 | "" | |
138 | 138 | } | |
139 | 139 | ||
140 | 140 | ||
141 | 141 | func _saveFeeRecipient (feeRecipient_) = [StringEntry(KEY_FEE_RECIPIENT, feeRecipient_)] | |
142 | 142 | ||
143 | 143 | ||
144 | 144 | func _loadRewardDistributor () = match getString(KEY_REWARD_DISTRIBUTOR) { | |
145 | 145 | case a: String => | |
146 | 146 | a | |
147 | 147 | case _ => | |
148 | 148 | "" | |
149 | 149 | } | |
150 | 150 | ||
151 | 151 | ||
152 | 152 | func _saveRewardDistributor (distributor_) = [StringEntry(KEY_REWARD_DISTRIBUTOR, distributor_)] | |
153 | 153 | ||
154 | 154 | ||
155 | 155 | func _loadSymbol (symbol_) = match getBoolean(makeString([KEY_SYMBOL, symbol_], SEPARATOR)) { | |
156 | 156 | case a: Boolean => | |
157 | 157 | a | |
158 | 158 | case _ => | |
159 | 159 | false | |
160 | 160 | } | |
161 | 161 | ||
162 | 162 | ||
163 | 163 | func _saveSymbol (symbol_,val_) = [BooleanEntry(makeString([KEY_SYMBOL, symbol_], SEPARATOR), val_)] | |
164 | 164 | ||
165 | 165 | ||
166 | 166 | func _loadOrderFilledAmount (orderHash_) = match getString(makeString([KEY_ORDER_FILLED_AMOUNT, toBase58String(orderHash_)], SEPARATOR)) { | |
167 | 167 | case a: String => | |
168 | 168 | parseBigIntValue(a) | |
169 | 169 | case _ => | |
170 | 170 | ZERO_BIGINT | |
171 | 171 | } | |
172 | 172 | ||
173 | 173 | ||
174 | 174 | func _saveOrderFilledAmount (orderHash_,amount_) = [StringEntry(makeString([KEY_ORDER_FILLED_AMOUNT, toBase58String(orderHash_)], SEPARATOR), toString(amount_))] | |
175 | 175 | ||
176 | 176 | ||
177 | 177 | func _onlyThisContract (caller_) = if ((caller_ != this)) | |
178 | 178 | then throw("_onlyThisContract: revert") | |
179 | 179 | else true | |
180 | 180 | ||
181 | 181 | ||
182 | 182 | func _whenMultisigSet () = if ((_loadMultisig() == Address(base58''))) | |
183 | 183 | then throw("_whenMultisigSet: revert") | |
184 | 184 | else true | |
185 | 185 | ||
186 | 186 | ||
187 | 187 | func _whenNotInitialized () = if (_loadInit()) | |
188 | 188 | then throw("_whenNotInitialized: revert") | |
189 | 189 | else true | |
190 | 190 | ||
191 | 191 | ||
192 | 192 | func _whenInitialized () = if (!(_loadInit())) | |
193 | 193 | then throw("_whenInitialized: revert") | |
194 | 194 | else true | |
195 | 195 | ||
196 | 196 | ||
197 | 197 | func _validateSequencer (caller,err_) = if ((_loadSequencer() != caller)) | |
198 | 198 | then throw(err_) | |
199 | 199 | else true | |
200 | 200 | ||
201 | 201 | ||
202 | 202 | func _validateOrderType (type_,version_,err_) = if (if ((type_ != ORDER_TYPE_LIMIT)) | |
203 | 203 | then (type_ != ORDER_TYPE_MARKET) | |
204 | 204 | else false) | |
205 | 205 | then throw(err_) | |
206 | 206 | else if ((version_ != ORDER_VERSION_1)) | |
207 | 207 | then throw(err_) | |
208 | 208 | else true | |
209 | 209 | ||
210 | 210 | ||
211 | 211 | func _validateOrderSymbol (symbol_,err_) = if (!(_loadSymbol(symbol_))) | |
212 | 212 | then throw(err_) | |
213 | 213 | else true | |
214 | 214 | ||
215 | 215 | ||
216 | 216 | func _validateOrderSide (side_,err_) = if (if ((side_ != ORDER_SIDE_BUY)) | |
217 | 217 | then (side_ != ORDER_SIDE_SELL) | |
218 | 218 | else false) | |
219 | 219 | then throw(err_) | |
220 | 220 | else true | |
221 | 221 | ||
222 | 222 | ||
223 | 223 | func _validateOrderPrices (makerOrderPrice_,takerOrderPrice_,takerOrderSide_,takerOrderType_,err_) = { | |
224 | 224 | let result = if ((takerOrderType_ == ORDER_TYPE_MARKET)) | |
225 | 225 | then true | |
226 | 226 | else if ((takerOrderSide_ == ORDER_SIDE_BUY)) | |
227 | 227 | then (takerOrderPrice_ >= makerOrderPrice_) | |
228 | 228 | else if ((takerOrderSide_ == ORDER_SIDE_SELL)) | |
229 | 229 | then (makerOrderPrice_ >= takerOrderPrice_) | |
230 | 230 | else false | |
231 | 231 | if (!(result)) | |
232 | 232 | then throw(err_) | |
233 | 233 | else true | |
234 | 234 | } | |
235 | 235 | ||
236 | 236 | ||
237 | 237 | func _validateSignatureFormat (signature_,alg_,err_) = if ((alg_ == ALG_TYPE_WAVES)) | |
238 | 238 | then if ((size(signature_) != 64)) | |
239 | 239 | then throw(err_) | |
240 | 240 | else true | |
241 | 241 | else if ((alg_ == ALG_TYPE_EVM)) | |
242 | 242 | then if ((size(signature_) != 65)) | |
243 | 243 | then throw(err_) | |
244 | 244 | else true | |
245 | 245 | else throw((err_ + ": inv alg")) | |
246 | 246 | ||
247 | 247 | ||
248 | - | func _ | |
249 | - | then if ((size( | |
248 | + | func _validateWeb3Id (web3Id_,alg_,err_) = if ((alg_ == ALG_TYPE_WAVES)) | |
249 | + | then if ((size(web3Id_) != 32)) | |
250 | 250 | then throw(err_) | |
251 | 251 | else true | |
252 | 252 | else if ((alg_ == ALG_TYPE_EVM)) | |
253 | - | then if ((size( | |
253 | + | then if ((size(web3Id_) != 20)) | |
254 | 254 | then throw(err_) | |
255 | 255 | else true | |
256 | 256 | else throw((err_ + ": inv alg")) | |
257 | 257 | ||
258 | 258 | ||
259 | - | func _ | |
260 | - | then toString(addressFromPublicKey( | |
259 | + | func _convertWeb3IdToAddress (web3Id_,alg_) = if ((alg_ == ALG_TYPE_WAVES)) | |
260 | + | then toString(addressFromPublicKey(web3Id_)) | |
261 | 261 | else if ((alg_ == ALG_TYPE_EVM)) | |
262 | - | then ("0x" + toBase16String( | |
263 | - | else throw("_ | |
262 | + | then ("0x" + toBase16String(web3Id_)) | |
263 | + | else throw("_convertWeb3IdToAddress: revert") | |
264 | 264 | ||
265 | 265 | ||
266 | - | func _validateOrderSignature (orderHash_,signature_, | |
266 | + | func _validateOrderSignature (orderHash_,signature_,web3Id_,alg_,err_) = { | |
267 | 267 | let result = if ((alg_ == ALG_TYPE_WAVES)) | |
268 | - | then sigVerify(orderHash_, signature_, | |
268 | + | then sigVerify(orderHash_, signature_, web3Id_) | |
269 | 269 | else if ((alg_ == ALG_TYPE_EVM)) | |
270 | 270 | then { | |
271 | 271 | let hashWithPrefix = keccak256_16Kb((EVM_PREFIX + orderHash_)) | |
272 | - | (takeRight(keccak256_16Kb(ecrecover(hashWithPrefix, signature_)), 20) == | |
272 | + | (takeRight(keccak256_16Kb(ecrecover(hashWithPrefix, signature_)), 20) == web3Id_) | |
273 | 273 | } | |
274 | 274 | else throw((err_ + ": inv alg")) | |
275 | 275 | if (!(result)) | |
276 | 276 | then throw(err_) | |
277 | 277 | else true | |
278 | 278 | } | |
279 | 279 | ||
280 | 280 | ||
281 | 281 | func _validateFeeTolerance (amount_,fee_,err_) = if ((fee_ > fraction(amount_, FEE_MAX_TOLERANCE, MULTIPLIER, DOWN))) | |
282 | 282 | then throw(err_) | |
283 | 283 | else true | |
284 | 284 | ||
285 | 285 | ||
286 | 286 | func _parseOrder (order_,err_) = { | |
287 | 287 | let fields = split(order_, SEPARATOR) | |
288 | 288 | let type = valueOrErrorMessage(parseInt(fields[0]), (err_ + ": inv type")) | |
289 | 289 | let version = valueOrErrorMessage(parseInt(fields[1]), (err_ + ": inv version")) | |
290 | 290 | let symbol = fields[2] | |
291 | 291 | let side = valueOrErrorMessage(parseInt(fields[3]), (err_ + ": inv side")) | |
292 | 292 | let ts = valueOrErrorMessage(parseInt(fields[4]), (err_ + ": inv ts")) | |
293 | - | let | |
293 | + | let web3Id = fromBase58String(fields[5]) | |
294 | 294 | let alg = valueOrErrorMessage(parseInt(fields[6]), (err_ + ": inv alg")) | |
295 | 295 | let signature = fromBase58String(fields[7]) | |
296 | - | let $ | |
296 | + | let $t083589396 = if (if ((type == ORDER_TYPE_LIMIT)) | |
297 | 297 | then (version == ORDER_VERSION_1) | |
298 | 298 | else false) | |
299 | 299 | then { | |
300 | 300 | let price = valueOrErrorMessage(parseBigInt(fields[8]), (err_ + ": inv price")) | |
301 | 301 | let amount = valueOrErrorMessage(parseBigInt(fields[9]), (err_ + ": inv amount")) | |
302 | 302 | let orderDetailsBytes = (toBytes(price) + toBytes(amount)) | |
303 | 303 | $Tuple4(price, amount, ZERO_BIGINT, orderDetailsBytes) | |
304 | 304 | } | |
305 | 305 | else if (if ((type == ORDER_TYPE_MARKET)) | |
306 | 306 | then (version == ORDER_VERSION_1) | |
307 | 307 | else false) | |
308 | 308 | then { | |
309 | 309 | let amount = valueOrErrorMessage(parseBigInt(fields[8]), (err_ + ": inv amount")) | |
310 | 310 | let isBaseAmount = if ((valueOrErrorMessage(parseBigInt(fields[9]), (err_ + ": inv isBaseAmount")) == ZERO_BIGINT)) | |
311 | 311 | then false | |
312 | 312 | else true | |
313 | 313 | if (isBaseAmount) | |
314 | 314 | then $Tuple4(ZERO_BIGINT, amount, ZERO_BIGINT, (toBytes(amount) + toBytes(ONE_BIGINT))) | |
315 | 315 | else $Tuple4(ZERO_BIGINT, ZERO_BIGINT, amount, (toBytes(amount) + toBytes(ZERO_BIGINT))) | |
316 | 316 | } | |
317 | 317 | else throw((err_ + ": inv type & version")) | |
318 | - | let price = $ | |
319 | - | let baseAmount = $ | |
320 | - | let quoteAmount = $ | |
321 | - | let orderDetailsBytes = $ | |
322 | - | let orderBytes = ((((((((toBytes(type) + toBytes(version)) + toBytes(size(symbol))) + toBytes(symbol)) + toBytes(side)) + toBytes(ts)) + | |
318 | + | let price = $t083589396._1 | |
319 | + | let baseAmount = $t083589396._2 | |
320 | + | let quoteAmount = $t083589396._3 | |
321 | + | let orderDetailsBytes = $t083589396._4 | |
322 | + | let orderBytes = ((((((((toBytes(type) + toBytes(version)) + toBytes(size(symbol))) + toBytes(symbol)) + toBytes(side)) + toBytes(ts)) + web3Id) + toBytes(alg)) + orderDetailsBytes) | |
323 | 323 | let orderHash = keccak256_32Kb(orderBytes) | |
324 | 324 | let err = if (if (if (if (if (if (if (_validateOrderType(type, version, (err_ + ": inv order type"))) | |
325 | 325 | then _validateOrderSymbol(symbol, (err_ + ": inv order symbol")) | |
326 | 326 | else false) | |
327 | 327 | then _validateOrderSide(side, (err_ + ": inv order side")) | |
328 | 328 | else false) | |
329 | - | then _ | |
329 | + | then _validateWeb3Id(web3Id, alg, (err_ + ": inv order web3Id")) | |
330 | 330 | else false) | |
331 | 331 | then _validateSignatureFormat(signature, alg, (err_ + ": inv sig format")) | |
332 | 332 | else false) | |
333 | 333 | then _validateBigInt(price, ZERO_BIGINT, (err_ + ": neg price")) | |
334 | 334 | else false) | |
335 | 335 | then _validateBigInt(baseAmount, ZERO_BIGINT, (err_ + ": neg base amount")) | |
336 | 336 | else false) | |
337 | 337 | then _validateBigInt(quoteAmount, ZERO_BIGINT, (err_ + ": neg quote amount")) | |
338 | 338 | else false | |
339 | 339 | if ((err == err)) | |
340 | - | then $Tuple10(type, symbol, side, price, baseAmount, quoteAmount, orderHash, | |
340 | + | then $Tuple10(type, symbol, side, price, baseAmount, quoteAmount, orderHash, web3Id, alg, signature) | |
341 | 341 | else throw("Strict value is not equal to itself.") | |
342 | 342 | } | |
343 | 343 | ||
344 | 344 | ||
345 | 345 | @Callable(i) | |
346 | 346 | func init (sequencer_,accountStorage_,feeRecipient_) = { | |
347 | 347 | let err = if (if (if (if (if (_onlyThisContract(i.caller)) | |
348 | 348 | then _whenNotInitialized() | |
349 | 349 | else false) | |
350 | 350 | then _whenMultisigSet() | |
351 | 351 | else false) | |
352 | 352 | then _validateAddress(sequencer_, "init: invalid sequencer") | |
353 | 353 | else false) | |
354 | 354 | then _validateAddress(accountStorage_, "init: invalid accountStorage") | |
355 | 355 | else false) | |
356 | 356 | then _validateString(feeRecipient_, "init: invalid feeRecipient") | |
357 | 357 | else false | |
358 | 358 | if ((err == err)) | |
359 | 359 | then $Tuple2((((_saveInit(true) ++ _saveSequencer(addressFromStringValue(sequencer_))) ++ _saveAccountStorage(addressFromStringValue(accountStorage_))) ++ _saveFeeRecipient(feeRecipient_)), unit) | |
360 | 360 | else throw("Strict value is not equal to itself.") | |
361 | 361 | } | |
362 | 362 | ||
363 | 363 | ||
364 | 364 | ||
365 | 365 | @Callable(i) | |
366 | 366 | func trade (makerOrder_,takerOrder_,baseFee_,quoteFee_) = { | |
367 | - | let $ | |
368 | - | let makerOrderType = $ | |
369 | - | let makerOrderSymbol = $ | |
370 | - | let makerOrderSide = $ | |
371 | - | let makerOrderPrice = $ | |
372 | - | let makerOrderBaseAmount = $ | |
373 | - | let makerOrderQuoteAmount = $ | |
374 | - | let makerOrderHash = $ | |
375 | - | let | |
376 | - | let makerOrderAlg = $ | |
377 | - | let makerOrderSignature = $ | |
378 | - | let $ | |
379 | - | let takerOrderType = $ | |
380 | - | let takerOrderSymbol = $ | |
381 | - | let takerOrderSide = $ | |
382 | - | let takerOrderPrice = $ | |
383 | - | let takerOrderBaseAmount = $ | |
384 | - | let takerOrderQuoteAmount = $ | |
385 | - | let takerOrderHash = $ | |
386 | - | let | |
387 | - | let takerOrderAlg = $ | |
388 | - | let takerOrderSignature = $ | |
367 | + | let $t01121211541 = _parseOrder(makerOrder_, "trade: invalid maker order") | |
368 | + | let makerOrderType = $t01121211541._1 | |
369 | + | let makerOrderSymbol = $t01121211541._2 | |
370 | + | let makerOrderSide = $t01121211541._3 | |
371 | + | let makerOrderPrice = $t01121211541._4 | |
372 | + | let makerOrderBaseAmount = $t01121211541._5 | |
373 | + | let makerOrderQuoteAmount = $t01121211541._6 | |
374 | + | let makerOrderHash = $t01121211541._7 | |
375 | + | let makerOrderWeb3Id = $t01121211541._8 | |
376 | + | let makerOrderAlg = $t01121211541._9 | |
377 | + | let makerOrderSignature = $t01121211541._10 | |
378 | + | let $t01154711876 = _parseOrder(takerOrder_, "trade: invalid taker order") | |
379 | + | let takerOrderType = $t01154711876._1 | |
380 | + | let takerOrderSymbol = $t01154711876._2 | |
381 | + | let takerOrderSide = $t01154711876._3 | |
382 | + | let takerOrderPrice = $t01154711876._4 | |
383 | + | let takerOrderBaseAmount = $t01154711876._5 | |
384 | + | let takerOrderQuoteAmount = $t01154711876._6 | |
385 | + | let takerOrderHash = $t01154711876._7 | |
386 | + | let takerOrderWeb3Id = $t01154711876._8 | |
387 | + | let takerOrderAlg = $t01154711876._9 | |
388 | + | let takerOrderSignature = $t01154711876._10 | |
389 | 389 | let baseFee = valueOrErrorMessage(parseBigInt(baseFee_), "trade: baseFee not int") | |
390 | 390 | let quoteFee = valueOrErrorMessage(parseBigInt(quoteFee_), "trade: quoteFee not int") | |
391 | 391 | let tradePrice = makerOrderPrice | |
392 | 392 | let makerOrderFilledAmount = _loadOrderFilledAmount(makerOrderHash) | |
393 | 393 | let makerOrderBaseAmountFree = (makerOrderBaseAmount - makerOrderFilledAmount) | |
394 | 394 | let takerOrderFilledAmount = _loadOrderFilledAmount(takerOrderHash) | |
395 | 395 | let takerOrderBaseAmountFree = if ((takerOrderBaseAmount == ZERO_BIGINT)) | |
396 | 396 | then fraction((takerOrderQuoteAmount - takerOrderFilledAmount), MULTIPLIER, tradePrice, DOWN) | |
397 | 397 | else (takerOrderBaseAmount - takerOrderFilledAmount) | |
398 | 398 | let tradeBaseAmount = min([makerOrderBaseAmountFree, takerOrderBaseAmountFree]) | |
399 | 399 | let tradeQuoteAmount = fraction(tradeBaseAmount, tradePrice, MULTIPLIER, DOWN) | |
400 | 400 | let err = if (if (if (if (if (if (if (if (if (_validateSequencer(i.caller, "trade: invalid sequencer")) | |
401 | 401 | then _validateBigInt(tradeBaseAmount, ZERO_BIGINT, "trade: neg trade amount") | |
402 | 402 | else false) | |
403 | 403 | then _validateIntEqual(makerOrderType, ORDER_TYPE_LIMIT, "trade: maker is not limit") | |
404 | 404 | else false) | |
405 | 405 | then _validateStringEqual(makerOrderSymbol, takerOrderSymbol, "trade: symbol mismatch") | |
406 | 406 | else false) | |
407 | 407 | then _validateIntNotEqual(makerOrderSide, takerOrderSide, "trade: side mismatch") | |
408 | 408 | else false) | |
409 | - | then _validateOrderSignature(makerOrderHash, makerOrderSignature, | |
409 | + | then _validateOrderSignature(makerOrderHash, makerOrderSignature, makerOrderWeb3Id, makerOrderAlg, "trade: invalid maker sig") | |
410 | 410 | else false) | |
411 | - | then _validateOrderSignature(takerOrderHash, takerOrderSignature, | |
411 | + | then _validateOrderSignature(takerOrderHash, takerOrderSignature, takerOrderWeb3Id, takerOrderAlg, "trade: invalid taker sig") | |
412 | 412 | else false) | |
413 | 413 | then _validateFeeTolerance(tradeBaseAmount, baseFee, "trade: base fee too much") | |
414 | 414 | else false) | |
415 | 415 | then _validateFeeTolerance(tradeQuoteAmount, quoteFee, "trade: quote fee too much") | |
416 | 416 | else false) | |
417 | 417 | then _validateOrderPrices(makerOrderPrice, takerOrderPrice, takerOrderSide, takerOrderType, "trade: prices mismatch") | |
418 | 418 | else false | |
419 | 419 | if ((err == err)) | |
420 | 420 | then { | |
421 | - | let makerAddress = _ | |
422 | - | let takerAddress = _ | |
423 | - | let $ | |
421 | + | let makerAddress = _convertWeb3IdToAddress(makerOrderWeb3Id, makerOrderAlg) | |
422 | + | let takerAddress = _convertWeb3IdToAddress(takerOrderWeb3Id, takerOrderAlg) | |
423 | + | let $t01403314456 = if ((makerOrderSide == ORDER_SIDE_BUY)) | |
424 | 424 | then $Tuple2(makerAddress, takerAddress) | |
425 | 425 | else $Tuple2(takerAddress, makerAddress) | |
426 | - | let buyer = $ | |
427 | - | let seller = $ | |
426 | + | let buyer = $t01403314456._1 | |
427 | + | let seller = $t01403314456._2 | |
428 | 428 | let assets = split(makerOrderSymbol, "-") | |
429 | 429 | let baseAsset = assets[0] | |
430 | 430 | let quoteAsset = assets[1] | |
431 | 431 | let feeRecipient = _loadFeeRecipient() | |
432 | 432 | let storageInvocation = invoke(_loadAccountStorage(), FUNC_EXTERNAL_TRANSFER, [SPOT_WALLET, baseAsset, seller, buyer, toString(tradeBaseAmount), toString(baseFee), feeRecipient], nil) | |
433 | 433 | if ((storageInvocation == storageInvocation)) | |
434 | 434 | then { | |
435 | 435 | let storageInvocation1 = invoke(_loadAccountStorage(), FUNC_EXTERNAL_TRANSFER, [SPOT_WALLET, quoteAsset, buyer, seller, toString(tradeQuoteAmount), toString(quoteFee), feeRecipient], nil) | |
436 | 436 | if ((storageInvocation1 == storageInvocation1)) | |
437 | 437 | then { | |
438 | 438 | let newMakerOrderFilledAmount = (makerOrderFilledAmount + tradeBaseAmount) | |
439 | 439 | let newTakerOrderFilledAmount = if ((takerOrderBaseAmount == ZERO_BIGINT)) | |
440 | 440 | then (takerOrderFilledAmount + tradeQuoteAmount) | |
441 | 441 | else (takerOrderFilledAmount + tradeBaseAmount) | |
442 | 442 | $Tuple2((_saveOrderFilledAmount(makerOrderHash, newMakerOrderFilledAmount) ++ _saveOrderFilledAmount(takerOrderHash, newTakerOrderFilledAmount)), unit) | |
443 | 443 | } | |
444 | 444 | else throw("Strict value is not equal to itself.") | |
445 | 445 | } | |
446 | 446 | else throw("Strict value is not equal to itself.") | |
447 | 447 | } | |
448 | 448 | else throw("Strict value is not equal to itself.") | |
449 | 449 | } | |
450 | 450 | ||
451 | 451 | ||
452 | 452 | ||
453 | 453 | @Callable(i) | |
454 | 454 | func claimReward (user_,currency_,amount_) = { | |
455 | 455 | let amount = valueOrErrorMessage(parseBigInt(amount_), "claimReward: amount not int") | |
456 | 456 | let err = if (if (if (_validateSequencer(i.caller, "claimReward: invalid sequencer")) | |
457 | 457 | then _validateString(user_, "claimReward: invalid user") | |
458 | 458 | else false) | |
459 | 459 | then _validateString(currency_, "claimReward: invalid currency") | |
460 | 460 | else false) | |
461 | 461 | then _validateBigInt(amount, ZERO_BIGINT, "claimReward: neg amount") | |
462 | 462 | else false | |
463 | 463 | if ((err == err)) | |
464 | 464 | then { | |
465 | 465 | let storageInvocation = invoke(_loadAccountStorage(), FUNC_CLAIM_REWARD, [_loadRewardDistributor(), user_, currency_, amount_], nil) | |
466 | 466 | if ((storageInvocation == storageInvocation)) | |
467 | 467 | then $Tuple2(nil, unit) | |
468 | 468 | else throw("Strict value is not equal to itself.") | |
469 | 469 | } | |
470 | 470 | else throw("Strict value is not equal to itself.") | |
471 | 471 | } | |
472 | 472 | ||
473 | 473 | ||
474 | 474 | ||
475 | 475 | @Callable(i) | |
476 | 476 | func updateSymbol (symbol_,allowance_) = { | |
477 | 477 | let err = if (_onlyThisContract(i.caller)) | |
478 | 478 | then _validateString(symbol_, "updateSymbol: invalid symbol") | |
479 | 479 | else false | |
480 | 480 | if ((err == err)) | |
481 | 481 | then $Tuple2(_saveSymbol(symbol_, allowance_), unit) | |
482 | 482 | else throw("Strict value is not equal to itself.") | |
483 | 483 | } | |
484 | 484 | ||
485 | 485 | ||
486 | 486 | ||
487 | 487 | @Callable(i) | |
488 | 488 | func updateFeeRecipient (feeRecipient_) = { | |
489 | 489 | let err = if (if (_onlyThisContract(i.caller)) | |
490 | 490 | then _whenInitialized() | |
491 | 491 | else false) | |
492 | 492 | then _validateString(feeRecipient_, "updateFeeRecipient: invalid feeRecipient") | |
493 | 493 | else false | |
494 | 494 | if ((err == err)) | |
495 | 495 | then $Tuple2(_saveFeeRecipient(feeRecipient_), unit) | |
496 | 496 | else throw("Strict value is not equal to itself.") | |
497 | 497 | } | |
498 | 498 | ||
499 | 499 | ||
500 | 500 | ||
501 | 501 | @Callable(i) | |
502 | 502 | func updateRewardDistributor (rewardDistributor_) = { | |
503 | 503 | let err = if (if (_onlyThisContract(i.caller)) | |
504 | 504 | then _whenInitialized() | |
505 | 505 | else false) | |
506 | 506 | then _validateString(rewardDistributor_, "updateRewardDistributor: invalid rewardDistributor") | |
507 | 507 | else false | |
508 | 508 | if ((err == err)) | |
509 | 509 | then $Tuple2(_saveRewardDistributor(rewardDistributor_), unit) | |
510 | 510 | else throw("Strict value is not equal to itself.") | |
511 | 511 | } | |
512 | 512 | ||
513 | 513 | ||
514 | 514 | ||
515 | 515 | @Callable(i) | |
516 | 516 | func setMultisig (multisig_) = { | |
517 | 517 | let err = if (_onlyThisContract(i.caller)) | |
518 | 518 | then _validateAddress(multisig_, "setMultisig: invalid multisig") | |
519 | 519 | else false | |
520 | 520 | if ((err == err)) | |
521 | 521 | then $Tuple2(_saveMultisig(addressFromStringValue(multisig_)), unit) | |
522 | 522 | else throw("Strict value is not equal to itself.") | |
523 | 523 | } | |
524 | 524 | ||
525 | 525 | ||
526 | 526 | @Verifier(tx) | |
527 | 527 | func verify () = match getString(KEY_MULTISIG) { | |
528 | 528 | case multisig: String => | |
529 | 529 | valueOrElse(getBoolean(addressFromStringValue(multisig), makeString([KEY_STATUS, toString(this), toBase58String(tx.id)], SEPARATOR)), false) | |
530 | 530 | case _ => | |
531 | 531 | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
532 | 532 | } | |
533 | 533 |
github/deemru/w8io/169f3d6 65.52 ms ◑