tx · 9jHnHVPuMscKna1myC36s1PBTLjFY64GwwXQ3L4JnfHf 3MwbESaeBZhdxSPCzJ7JxDZ79xUm2erVzf6: -0.01000000 Waves 2024.07.04 11:17 [3179018] smart account 3MwbESaeBZhdxSPCzJ7JxDZ79xUm2erVzf6 > SELF 0.00000000 Waves
{ "type": 13, "id": "9jHnHVPuMscKna1myC36s1PBTLjFY64GwwXQ3L4JnfHf", "fee": 1000000, "feeAssetId": null, "timestamp": 1720081027427, "version": 2, "chainId": 84, "sender": "3MwbESaeBZhdxSPCzJ7JxDZ79xUm2erVzf6", "senderPublicKey": "39btfTSFXQDSgoUexr66RNeGJ45hGXiopFBuyG2zmRyn", "proofs": [ "XbPsQ5DQitK1S75iuCYdZPk7vsjb1R4mjk7mGco3Y6zXt8xLm3sukfzbgZsuU92r9ie9E6n6RXvyLzPu9pxGqCW" ], "script": "base64:BwIVCAISBQoDCAgIEgUKAwgIGBIDCgEIJAAJU0VQQVJBVE9SAgJfXwAPQkFUQ0hfU0VQQVJBVE9SAgI6OgAMS0VZX01VTFRJU0lHAghNVUxUSVNJRwAKS0VZX1NUQVRVUwIGU1RBVFVTAAhLRVlfSU5JVAIESU5JVAAUS0VZX1NFUVVFTkNFUl9DQUxMRVICEFNFUVVFTkNFUl9DQUxMRVIAFEtFWV9HQVRFV0FZX0NPTlRSQUNUAhBHQVRFV0FZX0NPTlRSQUNUABFLRVlfU1BPVF9DT05UUkFDVAINU1BPVF9DT05UUkFDVAATS0VZX0xBU1RfQkFUQ0hfSEFTSAIPTEFTVF9CQVRDSF9IQVNIAA1GVU5DX1dJVEhEUkFXAgh3aXRoZHJhdwAKRlVOQ19UUkFERQIFdHJhZGUAEUZVTkNfQ0xBSU1fUkVXQVJEAgtjbGFpbVJld2FyZAAQR0FURVdBWV9XSVRIRFJBVwIQR0FURVdBWV9XSVRIRFJBVwAKU1BPVF9UUkFERQIKU1BPVF9UUkFERQARU1BPVF9DTEFJTV9SRVdBUkQCEVNQT1RfQ0xBS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jWANURKe3AsaDBBVVDvquQpv Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 7 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let SEPARATOR = "__" | |
5 | + | ||
6 | + | let BATCH_SEPARATOR = "::" | |
7 | + | ||
8 | + | let KEY_MULTISIG = "MULTISIG" | |
9 | + | ||
10 | + | let KEY_STATUS = "STATUS" | |
11 | + | ||
12 | + | let KEY_INIT = "INIT" | |
13 | + | ||
14 | + | let KEY_SEQUENCER_CALLER = "SEQUENCER_CALLER" | |
15 | + | ||
16 | + | let KEY_GATEWAY_CONTRACT = "GATEWAY_CONTRACT" | |
17 | + | ||
18 | + | let KEY_SPOT_CONTRACT = "SPOT_CONTRACT" | |
19 | + | ||
20 | + | let KEY_LAST_BATCH_HASH = "LAST_BATCH_HASH" | |
21 | + | ||
22 | + | let FUNC_WITHDRAW = "withdraw" | |
23 | + | ||
24 | + | let FUNC_TRADE = "trade" | |
25 | + | ||
26 | + | let FUNC_CLAIM_REWARD = "claimReward" | |
27 | + | ||
28 | + | let GATEWAY_WITHDRAW = "GATEWAY_WITHDRAW" | |
29 | + | ||
30 | + | let SPOT_TRADE = "SPOT_TRADE" | |
31 | + | ||
32 | + | let SPOT_CLAIM_REWARD = "SPOT_CLAIM_REWARD" | |
33 | + | ||
34 | + | let MAX_INT = 9223372036854775807 | |
35 | + | ||
36 | + | func _validateAddress (address_,err_) = match addressFromString(address_) { | |
37 | + | case a: Address => | |
38 | + | true | |
39 | + | case _ => | |
40 | + | throw(err_) | |
41 | + | } | |
42 | + | ||
43 | + | ||
44 | + | func _validateInt (val_,lowerBoundary_,upperBoundary_,err_) = if (if ((lowerBoundary_ > val_)) | |
45 | + | then true | |
46 | + | else (val_ > upperBoundary_)) | |
47 | + | then throw(err_) | |
48 | + | else true | |
49 | + | ||
50 | + | ||
51 | + | func _loadInit () = match getBoolean(KEY_INIT) { | |
52 | + | case a: Boolean => | |
53 | + | a | |
54 | + | case _ => | |
55 | + | false | |
56 | + | } | |
57 | + | ||
58 | + | ||
59 | + | func _saveInit (isInit_) = [BooleanEntry(KEY_INIT, isInit_)] | |
60 | + | ||
61 | + | ||
62 | + | func _loadMultisig () = match getString(KEY_MULTISIG) { | |
63 | + | case a: String => | |
64 | + | addressFromStringValue(a) | |
65 | + | case _ => | |
66 | + | Address(base58'') | |
67 | + | } | |
68 | + | ||
69 | + | ||
70 | + | func _saveMultisig (multisig_) = [StringEntry(KEY_MULTISIG, toString(multisig_))] | |
71 | + | ||
72 | + | ||
73 | + | func _loadSequencerCaller () = match getString(KEY_SEQUENCER_CALLER) { | |
74 | + | case a: String => | |
75 | + | addressFromStringValue(a) | |
76 | + | case _ => | |
77 | + | Address(base58'') | |
78 | + | } | |
79 | + | ||
80 | + | ||
81 | + | func _saveSequencerCaller (sequencerCaller_) = [StringEntry(KEY_SEQUENCER_CALLER, toString(sequencerCaller_))] | |
82 | + | ||
83 | + | ||
84 | + | func _loadGatewayContract () = match getString(KEY_GATEWAY_CONTRACT) { | |
85 | + | case a: String => | |
86 | + | addressFromStringValue(a) | |
87 | + | case _ => | |
88 | + | Address(base58'') | |
89 | + | } | |
90 | + | ||
91 | + | ||
92 | + | func _saveGatewayContract (gatewayContract_) = [StringEntry(KEY_GATEWAY_CONTRACT, toString(gatewayContract_))] | |
93 | + | ||
94 | + | ||
95 | + | func _loadSpotContract () = match getString(KEY_SPOT_CONTRACT) { | |
96 | + | case a: String => | |
97 | + | addressFromStringValue(a) | |
98 | + | case _ => | |
99 | + | Address(base58'') | |
100 | + | } | |
101 | + | ||
102 | + | ||
103 | + | func _saveSpotContract (spotContract_) = [StringEntry(KEY_SPOT_CONTRACT, toString(spotContract_))] | |
104 | + | ||
105 | + | ||
106 | + | func _loadLastBatchHash () = match getString(KEY_LAST_BATCH_HASH) { | |
107 | + | case a: String => | |
108 | + | a | |
109 | + | case _ => | |
110 | + | "GENESIS" | |
111 | + | } | |
112 | + | ||
113 | + | ||
114 | + | func _saveLastBatchHash (lastBatchHash_) = [StringEntry(KEY_LAST_BATCH_HASH, lastBatchHash_)] | |
115 | + | ||
116 | + | ||
117 | + | func _onlyThisContract (caller_) = if ((caller_ != this)) | |
118 | + | then throw("_onlyThisContract: revert") | |
119 | + | else true | |
120 | + | ||
121 | + | ||
122 | + | func _whenMultisigSet () = if ((_loadMultisig() == Address(base58''))) | |
123 | + | then throw("_whenMultisigSet: revert") | |
124 | + | else true | |
125 | + | ||
126 | + | ||
127 | + | func _whenNotInitialized () = if (_loadInit()) | |
128 | + | then throw("_whenNotInitialized: revert") | |
129 | + | else true | |
130 | + | ||
131 | + | ||
132 | + | func _whenInitialized () = if (!(_loadInit())) | |
133 | + | then throw("_whenInitialized: revert") | |
134 | + | else true | |
135 | + | ||
136 | + | ||
137 | + | func _validateSequencerCaller (caller,err_) = if ((_loadSequencerCaller() != caller)) | |
138 | + | then throw(err_) | |
139 | + | else true | |
140 | + | ||
141 | + | ||
142 | + | func _validateBatchHash (lastBatchHash_,err_) = if ((_loadLastBatchHash() != lastBatchHash_)) | |
143 | + | then throw(err_) | |
144 | + | else true | |
145 | + | ||
146 | + | ||
147 | + | @Callable(i) | |
148 | + | func init (sequencerCaller_,gatewayContract_,spotContract_) = { | |
149 | + | let err = if (if (if (if (if (_onlyThisContract(i.caller)) | |
150 | + | then _whenNotInitialized() | |
151 | + | else false) | |
152 | + | then _whenMultisigSet() | |
153 | + | else false) | |
154 | + | then _validateAddress(sequencerCaller_, "init: invalid sequencerCaller") | |
155 | + | else false) | |
156 | + | then _validateAddress(gatewayContract_, "init: invalid gatewayContract") | |
157 | + | else false) | |
158 | + | then _validateAddress(spotContract_, "init: invalid spotContract") | |
159 | + | else false | |
160 | + | if ((err == err)) | |
161 | + | then $Tuple2((((_saveInit(true) ++ _saveSequencerCaller(addressFromStringValue(sequencerCaller_))) ++ _saveGatewayContract(addressFromStringValue(gatewayContract_))) ++ _saveSpotContract(addressFromStringValue(spotContract_))), unit) | |
162 | + | else throw("Strict value is not equal to itself.") | |
163 | + | } | |
164 | + | ||
165 | + | ||
166 | + | ||
167 | + | @Callable(i) | |
168 | + | func processBatch (currentBatchHash_,lastBatchHash_,batch_) = { | |
169 | + | let err = if (if (if (_validateSequencerCaller(i.caller, "processBatch: invalid sequencer caller")) | |
170 | + | then _validateInt(size(currentBatchHash_), 1, MAX_INT, "processBatch: invalid currentBatchHash") | |
171 | + | else false) | |
172 | + | then _validateBatchHash(lastBatchHash_, "processBatch: invalid lastBatchHash") | |
173 | + | else false) | |
174 | + | then _validateInt(size(batch_), 1, 10, "processBatch: invalid batch size") | |
175 | + | else false | |
176 | + | if ((err == err)) | |
177 | + | then { | |
178 | + | let spotContract = _loadSpotContract() | |
179 | + | let gatewayContract = _loadGatewayContract() | |
180 | + | func foldFunc (acc,elem) = { | |
181 | + | let fields = split_4C(elem, BATCH_SEPARATOR) | |
182 | + | let err1 = _validateInt(size(fields), 1, 23, "processBatch: invalid elem size") | |
183 | + | if ((err1 == err1)) | |
184 | + | then { | |
185 | + | let contractAction = fields[0] | |
186 | + | let functionArgs = removeByIndex(fields, 0) | |
187 | + | let invocation = if ((contractAction == SPOT_TRADE)) | |
188 | + | then invoke(spotContract, FUNC_TRADE, functionArgs, nil) | |
189 | + | else if ((contractAction == SPOT_CLAIM_REWARD)) | |
190 | + | then invoke(spotContract, FUNC_CLAIM_REWARD, functionArgs, nil) | |
191 | + | else if ((contractAction == GATEWAY_WITHDRAW)) | |
192 | + | then invoke(gatewayContract, FUNC_WITHDRAW, functionArgs, nil) | |
193 | + | else throw("processBatch: invalid operation") | |
194 | + | if ((invocation == invocation)) | |
195 | + | then acc | |
196 | + | else throw("Strict value is not equal to itself.") | |
197 | + | } | |
198 | + | else throw("Strict value is not equal to itself.") | |
199 | + | } | |
200 | + | ||
201 | + | let result = { | |
202 | + | let $l = batch_ | |
203 | + | let $s = size($l) | |
204 | + | let $acc0 = true | |
205 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
206 | + | then $a | |
207 | + | else foldFunc($a, $l[$i]) | |
208 | + | ||
209 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
210 | + | then $a | |
211 | + | else throw("List size exceeds 10") | |
212 | + | ||
213 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
214 | + | } | |
215 | + | if ((result == result)) | |
216 | + | then $Tuple2(_saveLastBatchHash(currentBatchHash_), unit) | |
217 | + | else throw("Strict value is not equal to itself.") | |
218 | + | } | |
219 | + | else throw("Strict value is not equal to itself.") | |
220 | + | } | |
221 | + | ||
222 | + | ||
223 | + | ||
224 | + | @Callable(i) | |
225 | + | func setMultisig (multisig_) = { | |
226 | + | let err = if (_onlyThisContract(i.caller)) | |
227 | + | then _validateAddress(multisig_, "setMultisig: invalid multisig") | |
228 | + | else false | |
229 | + | if ((err == err)) | |
230 | + | then $Tuple2(_saveMultisig(addressFromStringValue(multisig_)), unit) | |
231 | + | else throw("Strict value is not equal to itself.") | |
232 | + | } | |
233 | + | ||
234 | + | ||
235 | + | @Verifier(tx) | |
236 | + | func verify () = match getString(KEY_MULTISIG) { | |
237 | + | case multisig: String => | |
238 | + | valueOrElse(getBoolean(addressFromStringValue(multisig), makeString([KEY_STATUS, toString(this), toBase58String(tx.id)], SEPARATOR)), false) | |
239 | + | case _ => | |
240 | + | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
241 | + | } | |
242 | + |
github/deemru/w8io/169f3d6 18.17 ms ◑