Sui mainnet
Verified source
0xa5b1…fec9
0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9
The pipeline is behind the chain tip0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9
Everything already published is complete and correct; only newer blocks are missing. The chain summary reports this generation as behind the tip.
Verification
- Code hash
- 0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9
- Status
- full match
- Provider
- disassembly of package 0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9 as `sui replay` fetched it at the version that executed
- Compiler
- Language
- move-disassembly
- Bundle
- sha1:bf6ae8eded6033df42c84ceb4df3cd80571c08e2
Sources
0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/bank.mvb0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/evaluator.mvb0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/exchange.mvb0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/funding_rate.mvb0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/insurance_fund.mvb0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/isolated_trading.mvb0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/library.mvb0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/order.mvb0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/perpetual.mvb0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/position.mvb0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/price_feed.mvb0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/protocol.mvb0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/roles.mvb0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/s128.mvb0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/settlement.mvb0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/sub_accounts.mvb
0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/bank.mvb1003 lines
1// Move bytecode v7
2module 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001.bank {
3use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::library;
4use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::protocol;
5use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::roles;
6use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::sub_accounts;
7use 0000000000000000000000000000000000000000000000000000000000000001::string;
8use 0000000000000000000000000000000000000000000000000000000000000002::balance;
9use 0000000000000000000000000000000000000000000000000000000000000002::coin;
10use 0000000000000000000000000000000000000000000000000000000000000002::event;
11use 0000000000000000000000000000000000000000000000000000000000000002::object;
12use 0000000000000000000000000000000000000000000000000000000000000002::table;
13use 0000000000000000000000000000000000000000000000000000000000000002::transfer;
14use 0000000000000000000000000000000000000000000000000000000000000002::tx_context;
15
16struct BankBalanceUpdateEvent has copy, drop {
17 tx_index: u128,
18 action: u64,
19 src_address: address,
20 dest_address: address,
21 amount: u128,
22 src_balance: u128,
23 dest_balance: u128
24}
25
26struct WithdrawalStatusUpdateEvent has copy, drop {
27 status: bool
28}
29
30struct BankAccount has store {
31 balance: u128,
32 owner: address
33}
34
35struct Bank<phantom Ty0> has store, key {
36 id: UID,
37 accounts: Table<address, BankAccount>,
38 coin_balance: Balance<Ty0>,
39 is_withdrawal_allowed: bool,
40 supported_coin: String
41}
42
43entry set_relayer<Ty0>(Arg0: &ExchangeManagerCap, Arg1: &mut ProtocolConfig, Arg2: &mut Bank<Ty0>, Arg3: &mut TxIndexer, Arg4: address) {
44L5: loc0: address
45L6: loc1: u128
46B0:
47 0: CopyLoc[1](Arg1: &mut ProtocolConfig)
48 1: FreezeRef
49 2: Call protocol::check_basic(&ProtocolConfig)
50 3: CopyLoc[1](Arg1: &mut ProtocolConfig)
51 4: FreezeRef
52 5: CopyLoc[0](Arg0: &ExchangeManagerCap)
53 6: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
54 7: CopyLoc[4](Arg4: address)
55 8: LdConst[4](address: 0x00..)
56 9: Neq
57 10: BrFalse(12)
58B1:
59 11: Branch(22)
60B2:
61 12: MoveLoc[3](Arg3: &mut TxIndexer)
62 13: Pop
63 14: MoveLoc[0](Arg0: &ExchangeManagerCap)
64 15: Pop
65 16: MoveLoc[1](Arg1: &mut ProtocolConfig)
66 17: Pop
67 18: MoveLoc[2](Arg2: &mut Bank<Ty0>)
68 19: Pop
69 20: LdU64(105)
70 21: Abort
71B3:
72 22: CopyLoc[1](Arg1: &mut ProtocolConfig)
73 23: FreezeRef
74 24: Call protocol::gas_relayer(&ProtocolConfig): address
75 25: StLoc[5](loc0: address)
76 26: CopyLoc[5](loc0: address)
77 27: CopyLoc[4](Arg4: address)
78 28: Neq
79 29: BrFalse(39)
80B4:
81 30: MoveLoc[3](Arg3: &mut TxIndexer)
82 31: Call sub_accounts::increment_tx_index(&mut TxIndexer): u128
83 32: StLoc[6](loc1: u128)
84 33: MoveLoc[2](Arg2: &mut Bank<Ty0>)
85 34: MoveLoc[5](loc0: address)
86 35: CopyLoc[4](Arg4: address)
87 36: MoveLoc[6](loc1: u128)
88 37: Call migrate_gas_relayer_balance<Ty0>(&mut Bank<Ty0>, address, address, u128)
89 38: Branch(43)
90B5:
91 39: MoveLoc[3](Arg3: &mut TxIndexer)
92 40: Pop
93 41: MoveLoc[2](Arg2: &mut Bank<Ty0>)
94 42: Pop
95B6:
96 43: MoveLoc[0](Arg0: &ExchangeManagerCap)
97 44: MoveLoc[1](Arg1: &mut ProtocolConfig)
98 45: MoveLoc[4](Arg4: address)
99 46: Call roles::set_gas_relayer(&ExchangeManagerCap, &mut ProtocolConfig, address)
100 47: Ret
101}
102
103public set_withdrawal_status<Ty0>(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Bank<Ty0>, Arg3: bool) {
104B0:
105 0: CopyLoc[0](Arg0: &ProtocolConfig)
106 1: Call protocol::check_basic(&ProtocolConfig)
107 2: MoveLoc[0](Arg0: &ProtocolConfig)
108 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
109 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
110 5: CopyLoc[3](Arg3: bool)
111 6: MoveLoc[2](Arg2: &mut Bank<Ty0>)
112 7: MutBorrowFieldGeneric[0](Bank.is_withdrawal_allowed: bool)
113 8: WriteRef
114 9: MoveLoc[3](Arg3: bool)
115 10: Pack[1](WithdrawalStatusUpdateEvent)
116 11: Call event::emit<WithdrawalStatusUpdateEvent>(WithdrawalStatusUpdateEvent)
117 12: Ret
118}
119
120entry create_bank<Ty0>(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: String, Arg3: &mut TxContext) {
121L4: loc0: Balance<Ty0>
122B0:
123 0: CopyLoc[0](Arg0: &ProtocolConfig)
124 1: Call protocol::check_basic(&ProtocolConfig)
125 2: MoveLoc[0](Arg0: &ProtocolConfig)
126 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
127 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
128 5: Call balance::zero<Ty0>(): Balance<Ty0>
129 6: StLoc[4](loc0: Balance<Ty0>)
130 7: CopyLoc[3](Arg3: &mut TxContext)
131 8: Call object::new(&mut TxContext): UID
132 9: MoveLoc[3](Arg3: &mut TxContext)
133 10: Call table::new<address, BankAccount>(&mut TxContext): Table<address, BankAccount>
134 11: MoveLoc[4](loc0: Balance<Ty0>)
135 12: LdTrue
136 13: MoveLoc[2](Arg2: String)
137 14: PackGeneric[0](Bank<Ty0>)
138 15: Call transfer::share_object<Bank<Ty0>>(Bank<Ty0>)
139 16: Ret
140}
141
142entry deposit<Ty0>(Arg0: &ProtocolConfig, Arg1: &mut Bank<Ty0>, Arg2: &mut TxIndexer, Arg3: vector<u8>, Arg4: address, Arg5: u64, Arg6: Coin<Ty0>, Arg7: &mut TxContext) {
143B0:
144 0: LdU64(999)
145 1: Abort
146}
147
148entry deposit_v2<Ty0>(Arg0: &ProtocolConfig, Arg1: &mut Bank<Ty0>, Arg2: &mut TxIndexer, Arg3: address, Arg4: u64, Arg5: Coin<Ty0>, Arg6: &mut TxContext) {
149L7: loc0: Coin<Ty0>
150L8: loc1: u64
151L9: loc2: u128
152B0:
153 0: MoveLoc[0](Arg0: &ProtocolConfig)
154 1: Call protocol::check_basic(&ProtocolConfig)
155 2: CopyLoc[3](Arg3: address)
156 3: LdConst[4](address: 0x00..)
157 4: Neq
158 5: BrFalse(7)
159B1:
160 6: Branch(15)
161B2:
162 7: MoveLoc[2](Arg2: &mut TxIndexer)
163 8: Pop
164 9: MoveLoc[6](Arg6: &mut TxContext)
165 10: Pop
166 11: MoveLoc[1](Arg1: &mut Bank<Ty0>)
167 12: Pop
168 13: LdU64(105)
169 14: Abort
170B3:
171 15: ImmBorrowLoc[5](Arg5: Coin<Ty0>)
172 16: Call coin::value<Ty0>(&Coin<Ty0>): u64
173 17: StLoc[8](loc1: u64)
174 18: CopyLoc[4](Arg4: u64)
175 19: LdU64(0)
176 20: Gt
177 21: BrFalse(23)
178B4:
179 22: Branch(31)
180B5:
181 23: MoveLoc[2](Arg2: &mut TxIndexer)
182 24: Pop
183 25: MoveLoc[6](Arg6: &mut TxContext)
184 26: Pop
185 27: MoveLoc[1](Arg1: &mut Bank<Ty0>)
186 28: Pop
187 29: LdU64(1000)
188 30: Abort
189B6:
190 31: CopyLoc[4](Arg4: u64)
191 32: CopyLoc[8](loc1: u64)
192 33: Le
193 34: BrFalse(36)
194B7:
195 35: Branch(44)
196B8:
197 36: MoveLoc[2](Arg2: &mut TxIndexer)
198 37: Pop
199 38: MoveLoc[6](Arg6: &mut TxContext)
200 39: Pop
201 40: MoveLoc[1](Arg1: &mut Bank<Ty0>)
202 41: Pop
203 42: LdU64(107)
204 43: Abort
205B9:
206 44: MutBorrowLoc[5](Arg5: Coin<Ty0>)
207 45: CopyLoc[4](Arg4: u64)
208 46: CopyLoc[6](Arg6: &mut TxContext)
209 47: Call coin::split<Ty0>(&mut Coin<Ty0>, u64, &mut TxContext): Coin<Ty0>
210 48: StLoc[7](loc0: Coin<Ty0>)
211 49: MoveLoc[2](Arg2: &mut TxIndexer)
212 50: Call sub_accounts::increment_tx_index(&mut TxIndexer): u128
213 51: StLoc[9](loc2: u128)
214 52: MoveLoc[1](Arg1: &mut Bank<Ty0>)
215 53: MoveLoc[3](Arg3: address)
216 54: MoveLoc[7](loc0: Coin<Ty0>)
217 55: MoveLoc[9](loc2: u128)
218 56: CopyLoc[6](Arg6: &mut TxContext)
219 57: FreezeRef
220 58: Call deposit_internal<Ty0>(&mut Bank<Ty0>, address, Coin<Ty0>, u128, &TxContext)
221 59: MoveLoc[4](Arg4: u64)
222 60: MoveLoc[8](loc1: u64)
223 61: Lt
224 62: BrFalse(69)
225B10:
226 63: MoveLoc[5](Arg5: Coin<Ty0>)
227 64: MoveLoc[6](Arg6: &mut TxContext)
228 65: FreezeRef
229 66: Call tx_context::sender(&TxContext): address
230 67: Call transfer::public_transfer<Coin<Ty0>>(Coin<Ty0>, address)
231 68: Branch(73)
232B11:
233 69: MoveLoc[6](Arg6: &mut TxContext)
234 70: Pop
235 71: MoveLoc[5](Arg5: Coin<Ty0>)
236 72: Call coin::destroy_zero<Ty0>(Coin<Ty0>)
237B12:
238 73: Ret
239}
240
241public(friend) deposit_internal<Ty0>(Arg0: &mut Bank<Ty0>, Arg1: address, Arg2: Coin<Ty0>, Arg3: u128, Arg4: &TxContext) {
242B0:
243 0: MoveLoc[0](Arg0: &mut Bank<Ty0>)
244 1: MoveLoc[4](Arg4: &TxContext)
245 2: Call tx_context::sender(&TxContext): address
246 3: MoveLoc[1](Arg1: address)
247 4: MoveLoc[2](Arg2: Coin<Ty0>)
248 5: MoveLoc[3](Arg3: u128)
249 6: Call deposit_with_source<Ty0>(&mut Bank<Ty0>, address, address, Coin<Ty0>, u128)
250 7: Ret
251}
252
253entry withdraw<Ty0>(Arg0: &ProtocolConfig, Arg1: &mut Bank<Ty0>, Arg2: &mut TxIndexer, Arg3: vector<u8>, Arg4: address, Arg5: u128, Arg6: &mut TxContext) {
254B0:
255 0: LdU64(999)
256 1: Abort
257}
258
259entry withdraw_v2<Ty0>(Arg0: &ProtocolConfig, Arg1: &mut Bank<Ty0>, Arg2: &mut TxIndexer, Arg3: address, Arg4: u128, Arg5: &mut TxContext) {
260B0:
261 0: MoveLoc[0](Arg0: &ProtocolConfig)
262 1: Call protocol::check_basic(&ProtocolConfig)
263 2: MoveLoc[1](Arg1: &mut Bank<Ty0>)
264 3: MoveLoc[2](Arg2: &mut TxIndexer)
265 4: CopyLoc[5](Arg5: &mut TxContext)
266 5: FreezeRef
267 6: Call tx_context::sender(&TxContext): address
268 7: CopyLoc[3](Arg3: address)
269 8: MoveLoc[4](Arg4: u128)
270 9: MoveLoc[5](Arg5: &mut TxContext)
271 10: Call withdraw_internal<Ty0>(&mut Bank<Ty0>, &mut TxIndexer, address, address, u128, &mut TxContext): Coin<Ty0>
272 11: MoveLoc[3](Arg3: address)
273 12: Call transfer::public_transfer<Coin<Ty0>>(Coin<Ty0>, address)
274 13: Ret
275}
276
277public(friend) withdraw_internal<Ty0>(Arg0: &mut Bank<Ty0>, Arg1: &mut TxIndexer, Arg2: address, Arg3: address, Arg4: u128, Arg5: &mut TxContext): Coin<Ty0> {
278L6: loc0: u128
279B0:
280 0: MoveLoc[1](Arg1: &mut TxIndexer)
281 1: Call sub_accounts::increment_tx_index(&mut TxIndexer): u128
282 2: StLoc[6](loc0: u128)
283 3: MoveLoc[0](Arg0: &mut Bank<Ty0>)
284 4: MoveLoc[2](Arg2: address)
285 5: MoveLoc[3](Arg3: address)
286 6: MoveLoc[4](Arg4: u128)
287 7: MoveLoc[6](loc0: u128)
288 8: MoveLoc[5](Arg5: &mut TxContext)
289 9: Call withdraw_internal_with_tx_index<Ty0>(&mut Bank<Ty0>, address, address, u128, u128, &mut TxContext): Coin<Ty0>
290 10: Ret
291}
292
293public(friend) withdraw_internal_with_tx_index<Ty0>(Arg0: &mut Bank<Ty0>, Arg1: address, Arg2: address, Arg3: u128, Arg4: u128, Arg5: &mut TxContext): Coin<Ty0> {
294L6: loc0: u128
295L7: loc1: &mut Table<address, BankAccount>
296L8: loc2: u128
297L9: loc3: Coin<Ty0>
298L10: loc4: u128
299L11: loc5: &mut u128
300B0:
301 0: CopyLoc[2](Arg2: address)
302 1: LdConst[4](address: 0x00..)
303 2: Neq
304 3: BrFalse(5)
305B1:
306 4: Branch(11)
307B2:
308 5: MoveLoc[5](Arg5: &mut TxContext)
309 6: Pop
310 7: MoveLoc[0](Arg0: &mut Bank<Ty0>)
311 8: Pop
312 9: LdU64(105)
313 10: Abort
314B3:
315 11: CopyLoc[0](Arg0: &mut Bank<Ty0>)
316 12: ImmBorrowFieldGeneric[0](Bank.is_withdrawal_allowed: bool)
317 13: ReadRef
318 14: BrFalse(16)
319B4:
320 15: Branch(22)
321B5:
322 16: MoveLoc[5](Arg5: &mut TxContext)
323 17: Pop
324 18: MoveLoc[0](Arg0: &mut Bank<Ty0>)
325 19: Pop
326 20: LdU64(604)
327 21: Abort
328B6:
329 22: CopyLoc[0](Arg0: &mut Bank<Ty0>)
330 23: MutBorrowFieldGeneric[1](Bank.accounts: Table<address, BankAccount>)
331 24: StLoc[7](loc1: &mut Table<address, BankAccount>)
332 25: CopyLoc[7](loc1: &mut Table<address, BankAccount>)
333 26: FreezeRef
334 27: CopyLoc[1](Arg1: address)
335 28: Call table::contains<address, BankAccount>(&Table<address, BankAccount>, address): bool
336 29: BrFalse(31)
337B7:
338 30: Branch(39)
339B8:
340 31: MoveLoc[5](Arg5: &mut TxContext)
341 32: Pop
342 33: MoveLoc[0](Arg0: &mut Bank<Ty0>)
343 34: Pop
344 35: MoveLoc[7](loc1: &mut Table<address, BankAccount>)
345 36: Pop
346 37: LdU64(605)
347 38: Abort
348B9:
349 39: CopyLoc[3](Arg3: u128)
350 40: LdU128(0)
351 41: Gt
352 42: BrFalse(44)
353B10:
354 43: Branch(52)
355B11:
356 44: MoveLoc[5](Arg5: &mut TxContext)
357 45: Pop
358 46: MoveLoc[0](Arg0: &mut Bank<Ty0>)
359 47: Pop
360 48: MoveLoc[7](loc1: &mut Table<address, BankAccount>)
361 49: Pop
362 50: LdU64(1001)
363 51: Abort
364B12:
365 52: CopyLoc[3](Arg3: u128)
366 53: Call library::convert_usdc_to_base_decimals(u128): u128
367 54: StLoc[8](loc2: u128)
368 55: CopyLoc[7](loc1: &mut Table<address, BankAccount>)
369 56: FreezeRef
370 57: CopyLoc[2](Arg2: address)
371 58: Call table::contains<address, BankAccount>(&Table<address, BankAccount>, address): bool
372 59: BrFalse(68)
373B13:
374 60: CopyLoc[7](loc1: &mut Table<address, BankAccount>)
375 61: FreezeRef
376 62: CopyLoc[2](Arg2: address)
377 63: Call table::borrow<address, BankAccount>(&Table<address, BankAccount>, address): &BankAccount
378 64: ImmBorrowField[2](BankAccount.balance: u128)
379 65: ReadRef
380 66: StLoc[6](loc0: u128)
381 67: Branch(70)
382B14:
383 68: LdU128(0)
384 69: StLoc[6](loc0: u128)
385B15:
386 70: MoveLoc[6](loc0: u128)
387 71: StLoc[10](loc4: u128)
388 72: MoveLoc[7](loc1: &mut Table<address, BankAccount>)
389 73: CopyLoc[1](Arg1: address)
390 74: Call table::borrow_mut<address, BankAccount>(&mut Table<address, BankAccount>, address): &mut BankAccount
391 75: MutBorrowField[2](BankAccount.balance: u128)
392 76: StLoc[11](loc5: &mut u128)
393 77: CopyLoc[11](loc5: &mut u128)
394 78: ReadRef
395 79: CopyLoc[8](loc2: u128)
396 80: Ge
397 81: BrFalse(83)
398B16:
399 82: Branch(91)
400B17:
401 83: MoveLoc[11](loc5: &mut u128)
402 84: Pop
403 85: MoveLoc[5](Arg5: &mut TxContext)
404 86: Pop
405 87: MoveLoc[0](Arg0: &mut Bank<Ty0>)
406 88: Pop
407 89: LdU64(603)
408 90: Abort
409B18:
410 91: CopyLoc[11](loc5: &mut u128)
411 92: ReadRef
412 93: CopyLoc[8](loc2: u128)
413 94: Sub
414 95: CopyLoc[11](loc5: &mut u128)
415 96: WriteRef
416 97: MoveLoc[0](Arg0: &mut Bank<Ty0>)
417 98: MutBorrowFieldGeneric[2](Bank.coin_balance: Balance<Ty0>)
418 99: MoveLoc[3](Arg3: u128)
419 100: CastU64
420 101: MoveLoc[5](Arg5: &mut TxContext)
421 102: Call coin::take<Ty0>(&mut Balance<Ty0>, u64, &mut TxContext): Coin<Ty0>
422 103: StLoc[9](loc3: Coin<Ty0>)
423 104: MoveLoc[4](Arg4: u128)
424 105: LdConst[1](u64: 1)
425 106: MoveLoc[1](Arg1: address)
426 107: MoveLoc[2](Arg2: address)
427 108: MoveLoc[8](loc2: u128)
428 109: MoveLoc[11](loc5: &mut u128)
429 110: ReadRef
430 111: MoveLoc[10](loc4: u128)
431 112: Pack[0](BankBalanceUpdateEvent)
432 113: Call event::emit<BankBalanceUpdateEvent>(BankBalanceUpdateEvent)
433 114: MoveLoc[9](loc3: Coin<Ty0>)
434 115: Ret
435}
436
437entry withdraw_all<Ty0>(Arg0: &ProtocolConfig, Arg1: &mut Bank<Ty0>, Arg2: &mut TxIndexer, Arg3: vector<u8>, Arg4: address, Arg5: &mut TxContext) {
438B0:
439 0: LdU64(999)
440 1: Abort
441}
442
443entry withdraw_all_v2<Ty0>(Arg0: &ProtocolConfig, Arg1: &mut Bank<Ty0>, Arg2: &mut TxIndexer, Arg3: address, Arg4: &mut TxContext) {
444B0:
445 0: MoveLoc[0](Arg0: &ProtocolConfig)
446 1: Call protocol::check_basic(&ProtocolConfig)
447 2: MoveLoc[1](Arg1: &mut Bank<Ty0>)
448 3: MoveLoc[2](Arg2: &mut TxIndexer)
449 4: CopyLoc[4](Arg4: &mut TxContext)
450 5: FreezeRef
451 6: Call tx_context::sender(&TxContext): address
452 7: CopyLoc[3](Arg3: address)
453 8: MoveLoc[4](Arg4: &mut TxContext)
454 9: Call withdraw_all_internal<Ty0>(&mut Bank<Ty0>, &mut TxIndexer, address, address, &mut TxContext): Coin<Ty0>
455 10: MoveLoc[3](Arg3: address)
456 11: Call transfer::public_transfer<Coin<Ty0>>(Coin<Ty0>, address)
457 12: Ret
458}
459
460public(friend) create_account_if_not_exist<Ty0>(Arg0: &mut Bank<Ty0>, Arg1: address) {
461L2: loc0: &mut Table<address, BankAccount>
462B0:
463 0: MoveLoc[0](Arg0: &mut Bank<Ty0>)
464 1: MutBorrowFieldGeneric[1](Bank.accounts: Table<address, BankAccount>)
465 2: StLoc[2](loc0: &mut Table<address, BankAccount>)
466 3: CopyLoc[2](loc0: &mut Table<address, BankAccount>)
467 4: FreezeRef
468 5: CopyLoc[1](Arg1: address)
469 6: Call table::contains<address, BankAccount>(&Table<address, BankAccount>, address): bool
470 7: Not
471 8: BrFalse(16)
472B1:
473 9: MoveLoc[2](loc0: &mut Table<address, BankAccount>)
474 10: CopyLoc[1](Arg1: address)
475 11: LdU128(0)
476 12: MoveLoc[1](Arg1: address)
477 13: Pack[2](BankAccount)
478 14: Call table::add<address, BankAccount>(&mut Table<address, BankAccount>, address, BankAccount)
479 15: Branch(18)
480B2:
481 16: MoveLoc[2](loc0: &mut Table<address, BankAccount>)
482 17: Pop
483B3:
484 18: Ret
485}
486
487public(friend) deposit_with_source<Ty0>(Arg0: &mut Bank<Ty0>, Arg1: address, Arg2: address, Arg3: Coin<Ty0>, Arg4: u128) {
488L5: loc0: &mut Table<address, BankAccount>
489L6: loc1: u64
490L7: loc2: u128
491L8: loc3: &mut u128
492L9: loc4: u128
493B0:
494 0: CopyLoc[2](Arg2: address)
495 1: LdConst[4](address: 0x00..)
496 2: Neq
497 3: BrFalse(5)
498B1:
499 4: Branch(9)
500B2:
501 5: MoveLoc[0](Arg0: &mut Bank<Ty0>)
502 6: Pop
503 7: LdU64(105)
504 8: Abort
505B3:
506 9: CopyLoc[0](Arg0: &mut Bank<Ty0>)
507 10: CopyLoc[2](Arg2: address)
508 11: Call create_account_if_not_exist<Ty0>(&mut Bank<Ty0>, address)
509 12: CopyLoc[0](Arg0: &mut Bank<Ty0>)
510 13: CopyLoc[1](Arg1: address)
511 14: Call create_account_if_not_exist<Ty0>(&mut Bank<Ty0>, address)
512 15: CopyLoc[0](Arg0: &mut Bank<Ty0>)
513 16: MutBorrowFieldGeneric[1](Bank.accounts: Table<address, BankAccount>)
514 17: StLoc[5](loc0: &mut Table<address, BankAccount>)
515 18: CopyLoc[5](loc0: &mut Table<address, BankAccount>)
516 19: FreezeRef
517 20: CopyLoc[1](Arg1: address)
518 21: Call table::borrow<address, BankAccount>(&Table<address, BankAccount>, address): &BankAccount
519 22: ImmBorrowField[2](BankAccount.balance: u128)
520 23: ReadRef
521 24: StLoc[9](loc4: u128)
522 25: ImmBorrowLoc[3](Arg3: Coin<Ty0>)
523 26: Call coin::value<Ty0>(&Coin<Ty0>): u64
524 27: StLoc[6](loc1: u64)
525 28: CopyLoc[6](loc1: u64)
526 29: LdU64(0)
527 30: Gt
528 31: BrFalse(33)
529B4:
530 32: Branch(39)
531B5:
532 33: MoveLoc[0](Arg0: &mut Bank<Ty0>)
533 34: Pop
534 35: MoveLoc[5](loc0: &mut Table<address, BankAccount>)
535 36: Pop
536 37: LdU64(1000)
537 38: Abort
538B6:
539 39: MoveLoc[0](Arg0: &mut Bank<Ty0>)
540 40: MutBorrowFieldGeneric[2](Bank.coin_balance: Balance<Ty0>)
541 41: MoveLoc[3](Arg3: Coin<Ty0>)
542 42: Call coin::put<Ty0>(&mut Balance<Ty0>, Coin<Ty0>)
543 43: MoveLoc[5](loc0: &mut Table<address, BankAccount>)
544 44: CopyLoc[2](Arg2: address)
545 45: Call table::borrow_mut<address, BankAccount>(&mut Table<address, BankAccount>, address): &mut BankAccount
546 46: MutBorrowField[2](BankAccount.balance: u128)
547 47: StLoc[8](loc3: &mut u128)
548 48: MoveLoc[6](loc1: u64)
549 49: CastU128
550 50: Call library::convert_usdc_to_base_decimals(u128): u128
551 51: StLoc[7](loc2: u128)
552 52: CopyLoc[7](loc2: u128)
553 53: CopyLoc[8](loc3: &mut u128)
554 54: ReadRef
555 55: Add
556 56: CopyLoc[8](loc3: &mut u128)
557 57: WriteRef
558 58: MoveLoc[4](Arg4: u128)
559 59: LdConst[0](u64: 0)
560 60: MoveLoc[1](Arg1: address)
561 61: MoveLoc[2](Arg2: address)
562 62: MoveLoc[7](loc2: u128)
563 63: MoveLoc[9](loc4: u128)
564 64: MoveLoc[8](loc3: &mut u128)
565 65: ReadRef
566 66: Pack[0](BankBalanceUpdateEvent)
567 67: Call event::emit<BankBalanceUpdateEvent>(BankBalanceUpdateEvent)
568 68: Ret
569}
570
571public(friend) transfer<Ty0>(Arg0: &mut Bank<Ty0>, Arg1: address, Arg2: address, Arg3: u128, Arg4: u64, Arg5: u128) {
572B0:
573 0: MoveLoc[0](Arg0: &mut Bank<Ty0>)
574 1: MoveLoc[1](Arg1: address)
575 2: MoveLoc[2](Arg2: address)
576 3: MoveLoc[3](Arg3: u128)
577 4: MoveLoc[4](Arg4: u64)
578 5: MoveLoc[5](Arg5: u128)
579 6: LdConst[2](u64: 2)
580 7: Call transfer_with_action<Ty0>(&mut Bank<Ty0>, address, address, u128, u64, u128, u64)
581 8: Ret
582}
583
584public(friend) transfer_gas_fee<Ty0>(Arg0: &mut Bank<Ty0>, Arg1: address, Arg2: address, Arg3: u128, Arg4: u64, Arg5: u128) {
585B0:
586 0: MoveLoc[0](Arg0: &mut Bank<Ty0>)
587 1: MoveLoc[1](Arg1: address)
588 2: MoveLoc[2](Arg2: address)
589 3: MoveLoc[3](Arg3: u128)
590 4: MoveLoc[4](Arg4: u64)
591 5: MoveLoc[5](Arg5: u128)
592 6: LdConst[3](u64: 3)
593 7: Call transfer_with_action<Ty0>(&mut Bank<Ty0>, address, address, u128, u64, u128, u64)
594 8: Ret
595}
596
597transfer_with_action<Ty0>(Arg0: &mut Bank<Ty0>, Arg1: address, Arg2: address, Arg3: u128, Arg4: u64, Arg5: u128, Arg6: u64) {
598L7: loc0: &mut Table<address, BankAccount>
599L8: loc1: &mut u128
600L9: loc2: &mut u128
601B0:
602 0: MoveLoc[0](Arg0: &mut Bank<Ty0>)
603 1: MutBorrowFieldGeneric[1](Bank.accounts: Table<address, BankAccount>)
604 2: StLoc[7](loc0: &mut Table<address, BankAccount>)
605 3: CopyLoc[7](loc0: &mut Table<address, BankAccount>)
606 4: CopyLoc[1](Arg1: address)
607 5: Call table::borrow_mut<address, BankAccount>(&mut Table<address, BankAccount>, address): &mut BankAccount
608 6: MutBorrowField[2](BankAccount.balance: u128)
609 7: StLoc[9](loc2: &mut u128)
610 8: CopyLoc[9](loc2: &mut u128)
611 9: ReadRef
612 10: CopyLoc[3](Arg3: u128)
613 11: Ge
614 12: BrFalse(14)
615B1:
616 13: Branch(22)
617B2:
618 14: MoveLoc[9](loc2: &mut u128)
619 15: Pop
620 16: MoveLoc[7](loc0: &mut Table<address, BankAccount>)
621 17: Pop
622 18: LdU64(600)
623 19: MoveLoc[4](Arg4: u64)
624 20: Add
625 21: Abort
626B3:
627 22: CopyLoc[9](loc2: &mut u128)
628 23: ReadRef
629 24: CopyLoc[3](Arg3: u128)
630 25: Sub
631 26: MoveLoc[9](loc2: &mut u128)
632 27: WriteRef
633 28: CopyLoc[7](loc0: &mut Table<address, BankAccount>)
634 29: CopyLoc[2](Arg2: address)
635 30: Call table::borrow_mut<address, BankAccount>(&mut Table<address, BankAccount>, address): &mut BankAccount
636 31: MutBorrowField[2](BankAccount.balance: u128)
637 32: StLoc[8](loc1: &mut u128)
638 33: CopyLoc[8](loc1: &mut u128)
639 34: ReadRef
640 35: CopyLoc[3](Arg3: u128)
641 36: CastU128
642 37: Add
643 38: MoveLoc[8](loc1: &mut u128)
644 39: WriteRef
645 40: MoveLoc[5](Arg5: u128)
646 41: MoveLoc[6](Arg6: u64)
647 42: CopyLoc[1](Arg1: address)
648 43: CopyLoc[2](Arg2: address)
649 44: MoveLoc[3](Arg3: u128)
650 45: CopyLoc[7](loc0: &mut Table<address, BankAccount>)
651 46: FreezeRef
652 47: MoveLoc[1](Arg1: address)
653 48: Call table::borrow<address, BankAccount>(&Table<address, BankAccount>, address): &BankAccount
654 49: ImmBorrowField[2](BankAccount.balance: u128)
655 50: ReadRef
656 51: MoveLoc[7](loc0: &mut Table<address, BankAccount>)
657 52: FreezeRef
658 53: MoveLoc[2](Arg2: address)
659 54: Call table::borrow<address, BankAccount>(&Table<address, BankAccount>, address): &BankAccount
660 55: ImmBorrowField[2](BankAccount.balance: u128)
661 56: ReadRef
662 57: Pack[0](BankBalanceUpdateEvent)
663 58: Call event::emit<BankBalanceUpdateEvent>(BankBalanceUpdateEvent)
664 59: Ret
665}
666
667public(friend) migrate_gas_relayer_balance<Ty0>(Arg0: &mut Bank<Ty0>, Arg1: address, Arg2: address, Arg3: u128) {
668L4: loc0: u128
669B0:
670 0: CopyLoc[1](Arg1: address)
671 1: CopyLoc[2](Arg2: address)
672 2: Eq
673 3: BrFalse(7)
674B1:
675 4: MoveLoc[0](Arg0: &mut Bank<Ty0>)
676 5: Pop
677 6: Ret
678B2:
679 7: CopyLoc[0](Arg0: &mut Bank<Ty0>)
680 8: CopyLoc[2](Arg2: address)
681 9: Call create_account_if_not_exist<Ty0>(&mut Bank<Ty0>, address)
682 10: CopyLoc[0](Arg0: &mut Bank<Ty0>)
683 11: FreezeRef
684 12: CopyLoc[1](Arg1: address)
685 13: Call exists_account<Ty0>(&Bank<Ty0>, address): bool
686 14: Not
687 15: BrFalse(19)
688B3:
689 16: MoveLoc[0](Arg0: &mut Bank<Ty0>)
690 17: Pop
691 18: Ret
692B4:
693 19: CopyLoc[0](Arg0: &mut Bank<Ty0>)
694 20: FreezeRef
695 21: CopyLoc[1](Arg1: address)
696 22: Call get_balance<Ty0>(&Bank<Ty0>, address): u128
697 23: StLoc[4](loc0: u128)
698 24: CopyLoc[4](loc0: u128)
699 25: LdU128(0)
700 26: Gt
701 27: BrFalse(35)
702B5:
703 28: CopyLoc[0](Arg0: &mut Bank<Ty0>)
704 29: CopyLoc[1](Arg1: address)
705 30: MoveLoc[2](Arg2: address)
706 31: MoveLoc[4](loc0: u128)
707 32: LdU64(2)
708 33: MoveLoc[3](Arg3: u128)
709 34: Call transfer<Ty0>(&mut Bank<Ty0>, address, address, u128, u64, u128)
710B6:
711 35: MoveLoc[0](Arg0: &mut Bank<Ty0>)
712 36: MoveLoc[1](Arg1: address)
713 37: Call remove_empty_account_internal<Ty0>(&mut Bank<Ty0>, address)
714 38: Ret
715}
716
717public(friend) charge_relayer_gas_fee<Ty0>(Arg0: &mut Bank<Ty0>, Arg1: &ProtocolConfig, Arg2: address, Arg3: String, Arg4: u128, Arg5: &TxContext) {
718L6: loc0: u128
719L7: loc1: address
720B0:
721 0: CopyLoc[1](Arg1: &ProtocolConfig)
722 1: MoveLoc[3](Arg3: String)
723 2: MoveLoc[5](Arg5: &TxContext)
724 3: Call protocol::get_action_gas_fee(&ProtocolConfig, String, &TxContext): u128
725 4: StLoc[6](loc0: u128)
726 5: CopyLoc[6](loc0: u128)
727 6: LdU128(0)
728 7: Eq
729 8: BrFalse(14)
730B1:
731 9: MoveLoc[1](Arg1: &ProtocolConfig)
732 10: Pop
733 11: MoveLoc[0](Arg0: &mut Bank<Ty0>)
734 12: Pop
735 13: Ret
736B2:
737 14: MoveLoc[1](Arg1: &ProtocolConfig)
738 15: Call protocol::gas_relayer(&ProtocolConfig): address
739 16: StLoc[7](loc1: address)
740 17: CopyLoc[0](Arg0: &mut Bank<Ty0>)
741 18: CopyLoc[7](loc1: address)
742 19: Call create_account_if_not_exist<Ty0>(&mut Bank<Ty0>, address)
743 20: MoveLoc[0](Arg0: &mut Bank<Ty0>)
744 21: MoveLoc[2](Arg2: address)
745 22: MoveLoc[7](loc1: address)
746 23: MoveLoc[6](loc0: u128)
747 24: LdU64(3)
748 25: MoveLoc[4](Arg4: u128)
749 26: Call transfer_gas_fee<Ty0>(&mut Bank<Ty0>, address, address, u128, u64, u128)
750 27: Ret
751}
752
753public(friend) get_balance<Ty0>(Arg0: &Bank<Ty0>, Arg1: address): u128 {
754L2: loc0: &Table<address, BankAccount>
755B0:
756 0: MoveLoc[0](Arg0: &Bank<Ty0>)
757 1: ImmBorrowFieldGeneric[1](Bank.accounts: Table<address, BankAccount>)
758 2: StLoc[2](loc0: &Table<address, BankAccount>)
759 3: CopyLoc[2](loc0: &Table<address, BankAccount>)
760 4: CopyLoc[1](Arg1: address)
761 5: Call table::contains<address, BankAccount>(&Table<address, BankAccount>, address): bool
762 6: Not
763 7: BrFalse(12)
764B1:
765 8: MoveLoc[2](loc0: &Table<address, BankAccount>)
766 9: Pop
767 10: LdU128(0)
768 11: Ret
769B2:
770 12: MoveLoc[2](loc0: &Table<address, BankAccount>)
771 13: MoveLoc[1](Arg1: address)
772 14: Call table::borrow<address, BankAccount>(&Table<address, BankAccount>, address): &BankAccount
773 15: ImmBorrowField[2](BankAccount.balance: u128)
774 16: ReadRef
775 17: Ret
776}
777
778public(friend) is_withdrawal_allowed<Ty0>(Arg0: &Bank<Ty0>): bool {
779B0:
780 0: MoveLoc[0](Arg0: &Bank<Ty0>)
781 1: ImmBorrowFieldGeneric[0](Bank.is_withdrawal_allowed: bool)
782 2: ReadRef
783 3: Ret
784}
785
786public(friend) get_bank_id<Ty0>(Arg0: &Bank<Ty0>): ID {
787B0:
788 0: MoveLoc[0](Arg0: &Bank<Ty0>)
789 1: ImmBorrowFieldGeneric[3](Bank.id: UID)
790 2: Call object::uid_to_inner(&UID): ID
791 3: Ret
792}
793
794public(friend) bank_address<Ty0>(Arg0: &Bank<Ty0>): address {
795B0:
796 0: MoveLoc[0](Arg0: &Bank<Ty0>)
797 1: ImmBorrowFieldGeneric[3](Bank.id: UID)
798 2: Call object::uid_to_address(&UID): address
799 3: Ret
800}
801
802public(friend) withdraw_all_internal<Ty0>(Arg0: &mut Bank<Ty0>, Arg1: &mut TxIndexer, Arg2: address, Arg3: address, Arg4: &mut TxContext): Coin<Ty0> {
803L5: loc0: u128
804L6: loc1: &mut Table<address, BankAccount>
805L7: loc2: u128
806L8: loc3: &mut u128
807L9: loc4: Coin<Ty0>
808L10: loc5: u128
809L11: loc6: u128
810L12: loc7: u128
811B0:
812 0: CopyLoc[3](Arg3: address)
813 1: LdConst[4](address: 0x00..)
814 2: Neq
815 3: BrFalse(5)
816B1:
817 4: Branch(13)
818B2:
819 5: MoveLoc[1](Arg1: &mut TxIndexer)
820 6: Pop
821 7: MoveLoc[4](Arg4: &mut TxContext)
822 8: Pop
823 9: MoveLoc[0](Arg0: &mut Bank<Ty0>)
824 10: Pop
825 11: LdU64(105)
826 12: Abort
827B3:
828 13: MoveLoc[1](Arg1: &mut TxIndexer)
829 14: Call sub_accounts::increment_tx_index(&mut TxIndexer): u128
830 15: StLoc[11](loc6: u128)
831 16: CopyLoc[0](Arg0: &mut Bank<Ty0>)
832 17: ImmBorrowFieldGeneric[0](Bank.is_withdrawal_allowed: bool)
833 18: ReadRef
834 19: BrFalse(21)
835B4:
836 20: Branch(27)
837B5:
838 21: MoveLoc[4](Arg4: &mut TxContext)
839 22: Pop
840 23: MoveLoc[0](Arg0: &mut Bank<Ty0>)
841 24: Pop
842 25: LdU64(604)
843 26: Abort
844B6:
845 27: CopyLoc[0](Arg0: &mut Bank<Ty0>)
846 28: MutBorrowFieldGeneric[1](Bank.accounts: Table<address, BankAccount>)
847 29: StLoc[6](loc1: &mut Table<address, BankAccount>)
848 30: CopyLoc[6](loc1: &mut Table<address, BankAccount>)
849 31: FreezeRef
850 32: CopyLoc[2](Arg2: address)
851 33: Call table::contains<address, BankAccount>(&Table<address, BankAccount>, address): bool
852 34: BrFalse(36)
853B7:
854 35: Branch(44)
855B8:
856 36: MoveLoc[4](Arg4: &mut TxContext)
857 37: Pop
858 38: MoveLoc[0](Arg0: &mut Bank<Ty0>)
859 39: Pop
860 40: MoveLoc[6](loc1: &mut Table<address, BankAccount>)
861 41: Pop
862 42: LdU64(605)
863 43: Abort
864B9:
865 44: CopyLoc[6](loc1: &mut Table<address, BankAccount>)
866 45: FreezeRef
867 46: CopyLoc[3](Arg3: address)
868 47: Call table::contains<address, BankAccount>(&Table<address, BankAccount>, address): bool
869 48: BrFalse(57)
870B10:
871 49: CopyLoc[6](loc1: &mut Table<address, BankAccount>)
872 50: FreezeRef
873 51: CopyLoc[3](Arg3: address)
874 52: Call table::borrow<address, BankAccount>(&Table<address, BankAccount>, address): &BankAccount
875 53: ImmBorrowField[2](BankAccount.balance: u128)
876 54: ReadRef
877 55: StLoc[5](loc0: u128)
878 56: Branch(59)
879B11:
880 57: LdU128(0)
881 58: StLoc[5](loc0: u128)
882B12:
883 59: MoveLoc[5](loc0: u128)
884 60: StLoc[10](loc5: u128)
885 61: CopyLoc[6](loc1: &mut Table<address, BankAccount>)
886 62: CopyLoc[2](Arg2: address)
887 63: Call table::borrow_mut<address, BankAccount>(&mut Table<address, BankAccount>, address): &mut BankAccount
888 64: MutBorrowField[2](BankAccount.balance: u128)
889 65: StLoc[8](loc3: &mut u128)
890 66: CopyLoc[8](loc3: &mut u128)
891 67: ReadRef
892 68: LdU128(1000)
893 69: Div
894 70: StLoc[12](loc7: u128)
895 71: CopyLoc[12](loc7: u128)
896 72: LdU128(0)
897 73: Gt
898 74: BrFalse(76)
899B13:
900 75: Branch(86)
901B14:
902 76: MoveLoc[4](Arg4: &mut TxContext)
903 77: Pop
904 78: MoveLoc[0](Arg0: &mut Bank<Ty0>)
905 79: Pop
906 80: MoveLoc[8](loc3: &mut u128)
907 81: Pop
908 82: MoveLoc[6](loc1: &mut Table<address, BankAccount>)
909 83: Pop
910 84: LdU64(1001)
911 85: Abort
912B15:
913 86: CopyLoc[12](loc7: u128)
914 87: LdU128(1000)
915 88: Mul
916 89: StLoc[7](loc2: u128)
917 90: MoveLoc[0](Arg0: &mut Bank<Ty0>)
918 91: MutBorrowFieldGeneric[2](Bank.coin_balance: Balance<Ty0>)
919 92: MoveLoc[12](loc7: u128)
920 93: CastU64
921 94: MoveLoc[4](Arg4: &mut TxContext)
922 95: Call coin::take<Ty0>(&mut Balance<Ty0>, u64, &mut TxContext): Coin<Ty0>
923 96: StLoc[9](loc4: Coin<Ty0>)
924 97: CopyLoc[8](loc3: &mut u128)
925 98: ReadRef
926 99: CopyLoc[7](loc2: u128)
927 100: Sub
928 101: MoveLoc[8](loc3: &mut u128)
929 102: WriteRef
930 103: MoveLoc[11](loc6: u128)
931 104: LdConst[1](u64: 1)
932 105: CopyLoc[2](Arg2: address)
933 106: MoveLoc[3](Arg3: address)
934 107: MoveLoc[7](loc2: u128)
935 108: MoveLoc[6](loc1: &mut Table<address, BankAccount>)
936 109: FreezeRef
937 110: MoveLoc[2](Arg2: address)
938 111: Call table::borrow<address, BankAccount>(&Table<address, BankAccount>, address): &BankAccount
939 112: ImmBorrowField[2](BankAccount.balance: u128)
940 113: ReadRef
941 114: MoveLoc[10](loc5: u128)
942 115: Pack[0](BankBalanceUpdateEvent)
943 116: Call event::emit<BankBalanceUpdateEvent>(BankBalanceUpdateEvent)
944 117: MoveLoc[9](loc4: Coin<Ty0>)
945 118: Ret
946}
947
948public(friend) exists_account<Ty0>(Arg0: &Bank<Ty0>, Arg1: address): bool {
949B0:
950 0: MoveLoc[0](Arg0: &Bank<Ty0>)
951 1: ImmBorrowFieldGeneric[1](Bank.accounts: Table<address, BankAccount>)
952 2: MoveLoc[1](Arg1: address)
953 3: Call table::contains<address, BankAccount>(&Table<address, BankAccount>, address): bool
954 4: Ret
955}
956
957public remove_empty_account<Ty0>(Arg0: &mut Bank<Ty0>, Arg1: address) {
958B0:
959 0: LdU64(999)
960 1: Abort
961}
962
963public(friend) remove_empty_account_internal<Ty0>(Arg0: &mut Bank<Ty0>, Arg1: address) {
964L2: loc0: &mut Table<address, BankAccount>
965B0:
966 0: MoveLoc[0](Arg0: &mut Bank<Ty0>)
967 1: MutBorrowFieldGeneric[1](Bank.accounts: Table<address, BankAccount>)
968 2: StLoc[2](loc0: &mut Table<address, BankAccount>)
969 3: CopyLoc[2](loc0: &mut Table<address, BankAccount>)
970 4: FreezeRef
971 5: CopyLoc[1](Arg1: address)
972 6: Call table::contains<address, BankAccount>(&Table<address, BankAccount>, address): bool
973 7: BrFalse(19)
974B1:
975 8: MoveLoc[2](loc0: &mut Table<address, BankAccount>)
976 9: MoveLoc[1](Arg1: address)
977 10: Call table::remove<address, BankAccount>(&mut Table<address, BankAccount>, address): BankAccount
978 11: Unpack[2](BankAccount)
979 12: Pop
980 13: LdU128(0)
981 14: Eq
982 15: BrFalse(17)
983B2:
984 16: Branch(21)
985B3:
986 17: LdU64(607)
987 18: Abort
988B4:
989 19: MoveLoc[2](loc0: &mut Table<address, BankAccount>)
990 20: Pop
991B5:
992 21: Ret
993}
994
995Constants [
996 0 => u64: 0
997 1 => u64: 1
998 2 => u64: 2
999 3 => u64: 3
1000 4 => address: 0x0000000000000000000000000000000000000000000000000000000000000000
1001]
1002}
1003
0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/evaluator.mvb814 lines
1// Move bytecode v7
2module 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001.evaluator {
3use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::library;
4use 0000000000000000000000000000000000000000000000000000000000000001::vector;
5use 0000000000000000000000000000000000000000000000000000000000000002::event;
6use 0000000000000000000000000000000000000000000000000000000000000002::object;
7
8struct MinOrderPriceUpdateEvent has copy, drop {
9 id: ID,
10 price: u128
11}
12
13struct MaxOrderPriceUpdateEvent has copy, drop {
14 id: ID,
15 price: u128
16}
17
18struct StepSizeUpdateEvent has copy, drop {
19 id: ID,
20 size: u128
21}
22
23struct TickSizeUpdateEvent has copy, drop {
24 id: ID,
25 size: u128
26}
27
28struct MtbLongUpdateEvent has copy, drop {
29 id: ID,
30 mtb: u128
31}
32
33struct MtbShortUpdateEvent has copy, drop {
34 id: ID,
35 mtb: u128
36}
37
38struct MaxQtyLimitUpdateEvent has copy, drop {
39 id: ID,
40 qty: u128
41}
42
43struct MaxQtyMarketUpdateEvent has copy, drop {
44 id: ID,
45 qty: u128
46}
47
48struct MinQtyUpdateEvent has copy, drop {
49 id: ID,
50 qty: u128
51}
52
53struct MaxAllowedOIOpenUpdateEvent has copy, drop {
54 id: ID,
55 max_allowed_oi_open: vector<u128>
56}
57
58struct TradeChecks has copy, drop, store {
59 min_price: u128,
60 max_price: u128,
61 tick_size: u128,
62 min_qty: u128,
63 max_qty_limit: u128,
64 max_qty_market: u128,
65 step_size: u128,
66 mtb_long: u128,
67 mtb_short: u128,
68 max_allowed_oi_open: vector<u128>
69}
70
71public(friend) new_trade_checks(Arg0: u128, Arg1: u128, Arg2: u128, Arg3: u128, Arg4: u128, Arg5: u128, Arg6: u128, Arg7: u128, Arg8: u128, Arg9: vector<u128>): TradeChecks {
72L10: loc0: vector<u128>
73L11: loc1: TradeChecks
74B0:
75 0: VecPack(2, 0)
76 1: StLoc[10](loc0: vector<u128>)
77 2: MutBorrowLoc[10](loc0: vector<u128>)
78 3: LdU128(0)
79 4: VecPushBack(2)
80 5: MutBorrowLoc[10](loc0: vector<u128>)
81 6: MoveLoc[9](Arg9: vector<u128>)
82 7: Call vector::append<u128>(&mut vector<u128>, vector<u128>)
83 8: MoveLoc[0](Arg0: u128)
84 9: MoveLoc[1](Arg1: u128)
85 10: MoveLoc[2](Arg2: u128)
86 11: MoveLoc[3](Arg3: u128)
87 12: MoveLoc[4](Arg4: u128)
88 13: MoveLoc[5](Arg5: u128)
89 14: MoveLoc[6](Arg6: u128)
90 15: MoveLoc[7](Arg7: u128)
91 16: MoveLoc[8](Arg8: u128)
92 17: MoveLoc[10](loc0: vector<u128>)
93 18: Pack[10](TradeChecks)
94 19: StLoc[11](loc1: TradeChecks)
95 20: CopyLoc[11](loc1: TradeChecks)
96 21: Call verify_pre_init_checks(TradeChecks)
97 22: MoveLoc[11](loc1: TradeChecks)
98 23: Ret
99}
100
101public(friend) tick_size(Arg0: TradeChecks): u128 {
102B0:
103 0: ImmBorrowLoc[0](Arg0: TradeChecks)
104 1: ImmBorrowField[0](TradeChecks.tick_size: u128)
105 2: ReadRef
106 3: Ret
107}
108
109public(friend) set_min_price(Arg0: ID, Arg1: &mut TradeChecks, Arg2: u128) {
110B0:
111 0: CopyLoc[2](Arg2: u128)
112 1: LdU128(0)
113 2: Gt
114 3: BrFalse(5)
115B1:
116 4: Branch(9)
117B2:
118 5: MoveLoc[1](Arg1: &mut TradeChecks)
119 6: Pop
120 7: LdU64(1)
121 8: Abort
122B3:
123 9: CopyLoc[2](Arg2: u128)
124 10: CopyLoc[1](Arg1: &mut TradeChecks)
125 11: ImmBorrowField[1](TradeChecks.max_price: u128)
126 12: ReadRef
127 13: Lt
128 14: BrFalse(16)
129B4:
130 15: Branch(20)
131B5:
132 16: MoveLoc[1](Arg1: &mut TradeChecks)
133 17: Pop
134 18: LdU64(2)
135 19: Abort
136B6:
137 20: CopyLoc[2](Arg2: u128)
138 21: MoveLoc[1](Arg1: &mut TradeChecks)
139 22: MutBorrowField[2](TradeChecks.min_price: u128)
140 23: WriteRef
141 24: MoveLoc[0](Arg0: ID)
142 25: MoveLoc[2](Arg2: u128)
143 26: Pack[0](MinOrderPriceUpdateEvent)
144 27: Call event::emit<MinOrderPriceUpdateEvent>(MinOrderPriceUpdateEvent)
145 28: Ret
146}
147
148public(friend) set_max_price(Arg0: ID, Arg1: &mut TradeChecks, Arg2: u128) {
149B0:
150 0: CopyLoc[2](Arg2: u128)
151 1: CopyLoc[1](Arg1: &mut TradeChecks)
152 2: ImmBorrowField[2](TradeChecks.min_price: u128)
153 3: ReadRef
154 4: Gt
155 5: BrFalse(7)
156B1:
157 6: Branch(11)
158B2:
159 7: MoveLoc[1](Arg1: &mut TradeChecks)
160 8: Pop
161 9: LdU64(9)
162 10: Abort
163B3:
164 11: CopyLoc[2](Arg2: u128)
165 12: MoveLoc[1](Arg1: &mut TradeChecks)
166 13: MutBorrowField[1](TradeChecks.max_price: u128)
167 14: WriteRef
168 15: MoveLoc[0](Arg0: ID)
169 16: MoveLoc[2](Arg2: u128)
170 17: Pack[1](MaxOrderPriceUpdateEvent)
171 18: Call event::emit<MaxOrderPriceUpdateEvent>(MaxOrderPriceUpdateEvent)
172 19: Ret
173}
174
175public(friend) set_step_size(Arg0: ID, Arg1: &mut TradeChecks, Arg2: u128) {
176B0:
177 0: CopyLoc[2](Arg2: u128)
178 1: LdU128(0)
179 2: Gt
180 3: BrFalse(5)
181B1:
182 4: Branch(9)
183B2:
184 5: MoveLoc[1](Arg1: &mut TradeChecks)
185 6: Pop
186 7: LdU64(10)
187 8: Abort
188B3:
189 9: CopyLoc[2](Arg2: u128)
190 10: MoveLoc[1](Arg1: &mut TradeChecks)
191 11: MutBorrowField[3](TradeChecks.step_size: u128)
192 12: WriteRef
193 13: MoveLoc[0](Arg0: ID)
194 14: MoveLoc[2](Arg2: u128)
195 15: Pack[2](StepSizeUpdateEvent)
196 16: Call event::emit<StepSizeUpdateEvent>(StepSizeUpdateEvent)
197 17: Ret
198}
199
200public(friend) set_tick_size(Arg0: ID, Arg1: &mut TradeChecks, Arg2: u128) {
201B0:
202 0: CopyLoc[2](Arg2: u128)
203 1: LdU128(0)
204 2: Gt
205 3: BrFalse(5)
206B1:
207 4: Branch(9)
208B2:
209 5: MoveLoc[1](Arg1: &mut TradeChecks)
210 6: Pop
211 7: LdU64(11)
212 8: Abort
213B3:
214 9: CopyLoc[2](Arg2: u128)
215 10: MoveLoc[1](Arg1: &mut TradeChecks)
216 11: MutBorrowField[0](TradeChecks.tick_size: u128)
217 12: WriteRef
218 13: MoveLoc[0](Arg0: ID)
219 14: MoveLoc[2](Arg2: u128)
220 15: Pack[3](TickSizeUpdateEvent)
221 16: Call event::emit<TickSizeUpdateEvent>(TickSizeUpdateEvent)
222 17: Ret
223}
224
225public(friend) set_mtb_long(Arg0: ID, Arg1: &mut TradeChecks, Arg2: u128) {
226B0:
227 0: CopyLoc[2](Arg2: u128)
228 1: LdU128(0)
229 2: Gt
230 3: BrFalse(5)
231B1:
232 4: Branch(9)
233B2:
234 5: MoveLoc[1](Arg1: &mut TradeChecks)
235 6: Pop
236 7: LdU64(12)
237 8: Abort
238B3:
239 9: CopyLoc[2](Arg2: u128)
240 10: MoveLoc[1](Arg1: &mut TradeChecks)
241 11: MutBorrowField[4](TradeChecks.mtb_long: u128)
242 12: WriteRef
243 13: MoveLoc[0](Arg0: ID)
244 14: MoveLoc[2](Arg2: u128)
245 15: Pack[4](MtbLongUpdateEvent)
246 16: Call event::emit<MtbLongUpdateEvent>(MtbLongUpdateEvent)
247 17: Ret
248}
249
250public(friend) set_mtb_short(Arg0: ID, Arg1: &mut TradeChecks, Arg2: u128) {
251B0:
252 0: CopyLoc[2](Arg2: u128)
253 1: LdU128(0)
254 2: Gt
255 3: BrFalse(5)
256B1:
257 4: Branch(9)
258B2:
259 5: MoveLoc[1](Arg1: &mut TradeChecks)
260 6: Pop
261 7: LdU64(13)
262 8: Abort
263B3:
264 9: CopyLoc[2](Arg2: u128)
265 10: Call library::base_uint(): u128
266 11: Lt
267 12: BrFalse(14)
268B4:
269 13: Branch(18)
270B5:
271 14: MoveLoc[1](Arg1: &mut TradeChecks)
272 15: Pop
273 16: LdU64(14)
274 17: Abort
275B6:
276 18: CopyLoc[2](Arg2: u128)
277 19: MoveLoc[1](Arg1: &mut TradeChecks)
278 20: MutBorrowField[5](TradeChecks.mtb_short: u128)
279 21: WriteRef
280 22: MoveLoc[0](Arg0: ID)
281 23: MoveLoc[2](Arg2: u128)
282 24: Pack[5](MtbShortUpdateEvent)
283 25: Call event::emit<MtbShortUpdateEvent>(MtbShortUpdateEvent)
284 26: Ret
285}
286
287public(friend) set_max_qty_limit(Arg0: ID, Arg1: &mut TradeChecks, Arg2: u128) {
288B0:
289 0: CopyLoc[2](Arg2: u128)
290 1: CopyLoc[1](Arg1: &mut TradeChecks)
291 2: ImmBorrowField[6](TradeChecks.min_qty: u128)
292 3: ReadRef
293 4: Gt
294 5: BrFalse(7)
295B1:
296 6: Branch(11)
297B2:
298 7: MoveLoc[1](Arg1: &mut TradeChecks)
299 8: Pop
300 9: LdU64(15)
301 10: Abort
302B3:
303 11: CopyLoc[2](Arg2: u128)
304 12: MoveLoc[1](Arg1: &mut TradeChecks)
305 13: MutBorrowField[7](TradeChecks.max_qty_limit: u128)
306 14: WriteRef
307 15: MoveLoc[0](Arg0: ID)
308 16: MoveLoc[2](Arg2: u128)
309 17: Pack[6](MaxQtyLimitUpdateEvent)
310 18: Call event::emit<MaxQtyLimitUpdateEvent>(MaxQtyLimitUpdateEvent)
311 19: Ret
312}
313
314public(friend) set_max_qty_market(Arg0: ID, Arg1: &mut TradeChecks, Arg2: u128) {
315B0:
316 0: CopyLoc[2](Arg2: u128)
317 1: CopyLoc[1](Arg1: &mut TradeChecks)
318 2: ImmBorrowField[6](TradeChecks.min_qty: u128)
319 3: ReadRef
320 4: Gt
321 5: BrFalse(7)
322B1:
323 6: Branch(11)
324B2:
325 7: MoveLoc[1](Arg1: &mut TradeChecks)
326 8: Pop
327 9: LdU64(16)
328 10: Abort
329B3:
330 11: CopyLoc[2](Arg2: u128)
331 12: MoveLoc[1](Arg1: &mut TradeChecks)
332 13: MutBorrowField[8](TradeChecks.max_qty_market: u128)
333 14: WriteRef
334 15: MoveLoc[0](Arg0: ID)
335 16: MoveLoc[2](Arg2: u128)
336 17: Pack[7](MaxQtyMarketUpdateEvent)
337 18: Call event::emit<MaxQtyMarketUpdateEvent>(MaxQtyMarketUpdateEvent)
338 19: Ret
339}
340
341public(friend) set_min_qty(Arg0: ID, Arg1: &mut TradeChecks, Arg2: u128) {
342L3: loc0: bool
343B0:
344 0: CopyLoc[2](Arg2: u128)
345 1: CopyLoc[1](Arg1: &mut TradeChecks)
346 2: ImmBorrowField[7](TradeChecks.max_qty_limit: u128)
347 3: ReadRef
348 4: Lt
349 5: BrFalse(13)
350B1:
351 6: CopyLoc[2](Arg2: u128)
352 7: CopyLoc[1](Arg1: &mut TradeChecks)
353 8: ImmBorrowField[8](TradeChecks.max_qty_market: u128)
354 9: ReadRef
355 10: Lt
356 11: StLoc[3](loc0: bool)
357 12: Branch(15)
358B2:
359 13: LdFalse
360 14: StLoc[3](loc0: bool)
361B3:
362 15: MoveLoc[3](loc0: bool)
363 16: BrFalse(18)
364B4:
365 17: Branch(22)
366B5:
367 18: MoveLoc[1](Arg1: &mut TradeChecks)
368 19: Pop
369 20: LdU64(17)
370 21: Abort
371B6:
372 22: CopyLoc[2](Arg2: u128)
373 23: LdU128(0)
374 24: Gt
375 25: BrFalse(27)
376B7:
377 26: Branch(31)
378B8:
379 27: MoveLoc[1](Arg1: &mut TradeChecks)
380 28: Pop
381 29: LdU64(18)
382 30: Abort
383B9:
384 31: CopyLoc[2](Arg2: u128)
385 32: MoveLoc[1](Arg1: &mut TradeChecks)
386 33: MutBorrowField[6](TradeChecks.min_qty: u128)
387 34: WriteRef
388 35: MoveLoc[0](Arg0: ID)
389 36: MoveLoc[2](Arg2: u128)
390 37: Pack[8](MinQtyUpdateEvent)
391 38: Call event::emit<MinQtyUpdateEvent>(MinQtyUpdateEvent)
392 39: Ret
393}
394
395public(friend) set_max_oi_open(Arg0: ID, Arg1: &mut TradeChecks, Arg2: vector<u128>) {
396L3: loc0: vector<u128>
397B0:
398 0: VecPack(2, 0)
399 1: StLoc[3](loc0: vector<u128>)
400 2: MutBorrowLoc[3](loc0: vector<u128>)
401 3: LdU128(0)
402 4: VecPushBack(2)
403 5: MutBorrowLoc[3](loc0: vector<u128>)
404 6: MoveLoc[2](Arg2: vector<u128>)
405 7: Call vector::append<u128>(&mut vector<u128>, vector<u128>)
406 8: CopyLoc[3](loc0: vector<u128>)
407 9: MoveLoc[1](Arg1: &mut TradeChecks)
408 10: MutBorrowField[9](TradeChecks.max_allowed_oi_open: vector<u128>)
409 11: WriteRef
410 12: MoveLoc[0](Arg0: ID)
411 13: MoveLoc[3](loc0: vector<u128>)
412 14: Pack[9](MaxAllowedOIOpenUpdateEvent)
413 15: Call event::emit<MaxAllowedOIOpenUpdateEvent>(MaxAllowedOIOpenUpdateEvent)
414 16: Ret
415}
416
417verify_pre_init_checks(Arg0: TradeChecks) {
418L1: loc0: bool
419B0:
420 0: ImmBorrowLoc[0](Arg0: TradeChecks)
421 1: ImmBorrowField[2](TradeChecks.min_price: u128)
422 2: ReadRef
423 3: LdU128(0)
424 4: Gt
425 5: BrFalse(7)
426B1:
427 6: Branch(9)
428B2:
429 7: LdU64(1)
430 8: Abort
431B3:
432 9: ImmBorrowLoc[0](Arg0: TradeChecks)
433 10: ImmBorrowField[2](TradeChecks.min_price: u128)
434 11: ReadRef
435 12: ImmBorrowLoc[0](Arg0: TradeChecks)
436 13: ImmBorrowField[1](TradeChecks.max_price: u128)
437 14: ReadRef
438 15: Lt
439 16: BrFalse(18)
440B4:
441 17: Branch(20)
442B5:
443 18: LdU64(2)
444 19: Abort
445B6:
446 20: ImmBorrowLoc[0](Arg0: TradeChecks)
447 21: ImmBorrowField[3](TradeChecks.step_size: u128)
448 22: ReadRef
449 23: LdU128(0)
450 24: Gt
451 25: BrFalse(27)
452B7:
453 26: Branch(29)
454B8:
455 27: LdU64(10)
456 28: Abort
457B9:
458 29: ImmBorrowLoc[0](Arg0: TradeChecks)
459 30: ImmBorrowField[0](TradeChecks.tick_size: u128)
460 31: ReadRef
461 32: LdU128(0)
462 33: Gt
463 34: BrFalse(36)
464B10:
465 35: Branch(38)
466B11:
467 36: LdU64(11)
468 37: Abort
469B12:
470 38: ImmBorrowLoc[0](Arg0: TradeChecks)
471 39: ImmBorrowField[4](TradeChecks.mtb_long: u128)
472 40: ReadRef
473 41: LdU128(0)
474 42: Gt
475 43: BrFalse(45)
476B13:
477 44: Branch(47)
478B14:
479 45: LdU64(12)
480 46: Abort
481B15:
482 47: ImmBorrowLoc[0](Arg0: TradeChecks)
483 48: ImmBorrowField[5](TradeChecks.mtb_short: u128)
484 49: ReadRef
485 50: LdU128(0)
486 51: Gt
487 52: BrFalse(54)
488B16:
489 53: Branch(56)
490B17:
491 54: LdU64(13)
492 55: Abort
493B18:
494 56: ImmBorrowLoc[0](Arg0: TradeChecks)
495 57: ImmBorrowField[5](TradeChecks.mtb_short: u128)
496 58: ReadRef
497 59: Call library::base_uint(): u128
498 60: Lt
499 61: BrFalse(63)
500B19:
501 62: Branch(65)
502B20:
503 63: LdU64(14)
504 64: Abort
505B21:
506 65: ImmBorrowLoc[0](Arg0: TradeChecks)
507 66: ImmBorrowField[6](TradeChecks.min_qty: u128)
508 67: ReadRef
509 68: LdU128(0)
510 69: Gt
511 70: BrFalse(72)
512B22:
513 71: Branch(74)
514B23:
515 72: LdU64(18)
516 73: Abort
517B24:
518 74: ImmBorrowLoc[0](Arg0: TradeChecks)
519 75: ImmBorrowField[6](TradeChecks.min_qty: u128)
520 76: ReadRef
521 77: ImmBorrowLoc[0](Arg0: TradeChecks)
522 78: ImmBorrowField[7](TradeChecks.max_qty_limit: u128)
523 79: ReadRef
524 80: Lt
525 81: BrFalse(91)
526B25:
527 82: ImmBorrowLoc[0](Arg0: TradeChecks)
528 83: ImmBorrowField[6](TradeChecks.min_qty: u128)
529 84: ReadRef
530 85: ImmBorrowLoc[0](Arg0: TradeChecks)
531 86: ImmBorrowField[8](TradeChecks.max_qty_market: u128)
532 87: ReadRef
533 88: Lt
534 89: StLoc[1](loc0: bool)
535 90: Branch(93)
536B26:
537 91: LdFalse
538 92: StLoc[1](loc0: bool)
539B27:
540 93: MoveLoc[1](loc0: bool)
541 94: BrFalse(96)
542B28:
543 95: Branch(98)
544B29:
545 96: LdU64(17)
546 97: Abort
547B30:
548 98: Ret
549}
550
551public(friend) verify_min_max_price(Arg0: TradeChecks, Arg1: u128) {
552B0:
553 0: CopyLoc[1](Arg1: u128)
554 1: ImmBorrowLoc[0](Arg0: TradeChecks)
555 2: ImmBorrowField[2](TradeChecks.min_price: u128)
556 3: ReadRef
557 4: Ge
558 5: BrFalse(7)
559B1:
560 6: Branch(9)
561B2:
562 7: LdU64(3)
563 8: Abort
564B3:
565 9: MoveLoc[1](Arg1: u128)
566 10: ImmBorrowLoc[0](Arg0: TradeChecks)
567 11: ImmBorrowField[1](TradeChecks.max_price: u128)
568 12: ReadRef
569 13: Le
570 14: BrFalse(16)
571B4:
572 15: Branch(18)
573B5:
574 16: LdU64(4)
575 17: Abort
576B6:
577 18: Ret
578}
579
580public(friend) verify_tick_size(Arg0: TradeChecks, Arg1: u128) {
581B0:
582 0: MoveLoc[1](Arg1: u128)
583 1: ImmBorrowLoc[0](Arg0: TradeChecks)
584 2: ImmBorrowField[0](TradeChecks.tick_size: u128)
585 3: ReadRef
586 4: Mod
587 5: LdU128(0)
588 6: Eq
589 7: BrFalse(9)
590B1:
591 8: Branch(11)
592B2:
593 9: LdU64(5)
594 10: Abort
595B3:
596 11: Ret
597}
598
599public(friend) verify_price_checks(Arg0: TradeChecks, Arg1: u128) {
600B0:
601 0: CopyLoc[0](Arg0: TradeChecks)
602 1: CopyLoc[1](Arg1: u128)
603 2: Call verify_min_max_price(TradeChecks, u128)
604 3: MoveLoc[0](Arg0: TradeChecks)
605 4: MoveLoc[1](Arg1: u128)
606 5: Call verify_tick_size(TradeChecks, u128)
607 6: Ret
608}
609
610public(friend) verify_step_size(Arg0: TradeChecks, Arg1: u128) {
611B0:
612 0: MoveLoc[1](Arg1: u128)
613 1: ImmBorrowLoc[0](Arg0: TradeChecks)
614 2: ImmBorrowField[3](TradeChecks.step_size: u128)
615 3: ReadRef
616 4: Mod
617 5: LdU128(0)
618 6: Eq
619 7: BrFalse(9)
620B1:
621 8: Branch(11)
622B2:
623 9: LdU64(22)
624 10: Abort
625B3:
626 11: Ret
627}
628
629public(friend) verify_qty_checks(Arg0: TradeChecks, Arg1: u128, Arg2: bool) {
630B0:
631 0: CopyLoc[1](Arg1: u128)
632 1: ImmBorrowLoc[0](Arg0: TradeChecks)
633 2: ImmBorrowField[6](TradeChecks.min_qty: u128)
634 3: ReadRef
635 4: Ge
636 5: BrFalse(7)
637B1:
638 6: Branch(9)
639B2:
640 7: LdU64(19)
641 8: Abort
642B3:
643 9: CopyLoc[1](Arg1: u128)
644 10: ImmBorrowLoc[0](Arg0: TradeChecks)
645 11: ImmBorrowField[7](TradeChecks.max_qty_limit: u128)
646 12: ReadRef
647 13: Le
648 14: BrFalse(16)
649B4:
650 15: Branch(18)
651B5:
652 16: LdU64(20)
653 17: Abort
654B6:
655 18: MoveLoc[2](Arg2: bool)
656 19: BrFalse(29)
657B7:
658 20: CopyLoc[1](Arg1: u128)
659 21: ImmBorrowLoc[0](Arg0: TradeChecks)
660 22: ImmBorrowField[8](TradeChecks.max_qty_market: u128)
661 23: ReadRef
662 24: Le
663 25: BrFalse(27)
664B8:
665 26: Branch(29)
666B9:
667 27: LdU64(21)
668 28: Abort
669B10:
670 29: MoveLoc[0](Arg0: TradeChecks)
671 30: MoveLoc[1](Arg1: u128)
672 31: Call verify_step_size(TradeChecks, u128)
673 32: Ret
674}
675
676public(friend) verify_qty_checks_liquidation(Arg0: TradeChecks, Arg1: u128) {
677B0:
678 0: CopyLoc[1](Arg1: u128)
679 1: ImmBorrowLoc[0](Arg0: TradeChecks)
680 2: ImmBorrowField[6](TradeChecks.min_qty: u128)
681 3: ReadRef
682 4: Ge
683 5: BrFalse(7)
684B1:
685 6: Branch(9)
686B2:
687 7: LdU64(19)
688 8: Abort
689B3:
690 9: MoveLoc[0](Arg0: TradeChecks)
691 10: MoveLoc[1](Arg1: u128)
692 11: Call verify_step_size(TradeChecks, u128)
693 12: Ret
694}
695
696public(friend) verify_market_take_bound_checks(Arg0: TradeChecks, Arg1: u128, Arg2: u128, Arg3: bool) {
697B0:
698 0: MoveLoc[3](Arg3: bool)
699 1: BrFalse(15)
700B1:
701 2: MoveLoc[1](Arg1: u128)
702 3: CopyLoc[2](Arg2: u128)
703 4: MoveLoc[2](Arg2: u128)
704 5: ImmBorrowLoc[0](Arg0: TradeChecks)
705 6: ImmBorrowField[4](TradeChecks.mtb_long: u128)
706 7: ReadRef
707 8: Call library::base_mul(u128, u128): u128
708 9: Add
709 10: Le
710 11: BrFalse(13)
711B2:
712 12: Branch(28)
713B3:
714 13: LdU64(23)
715 14: Abort
716B4:
717 15: MoveLoc[1](Arg1: u128)
718 16: CopyLoc[2](Arg2: u128)
719 17: MoveLoc[2](Arg2: u128)
720 18: ImmBorrowLoc[0](Arg0: TradeChecks)
721 19: ImmBorrowField[5](TradeChecks.mtb_short: u128)
722 20: ReadRef
723 21: Call library::base_mul(u128, u128): u128
724 22: Sub
725 23: Ge
726 24: BrFalse(26)
727B5:
728 25: Branch(28)
729B6:
730 26: LdU64(24)
731 27: Abort
732B7:
733 28: Ret
734}
735
736public(friend) verify_oi_open_for_account(Arg0: TradeChecks, Arg1: u128, Arg2: u128, Arg3: u64, Arg4: bool) {
737L5: loc0: u128
738L6: loc1: u128
739B0:
740 0: Call library::base_uint(): u128
741 1: MoveLoc[1](Arg1: u128)
742 2: Call library::base_div(u128, u128): u128
743 3: StLoc[5](loc0: u128)
744 4: CopyLoc[5](loc0: u128)
745 5: Call library::base_uint(): u128
746 6: Mod
747 7: Call library::half_base_uint(): u128
748 8: Gt
749 9: BrFalse(15)
750B1:
751 10: MoveLoc[5](loc0: u128)
752 11: Call library::base_uint(): u128
753 12: Call library::ceil(u128, u128): u128
754 13: StLoc[5](loc0: u128)
755 14: Branch(21)
756B2:
757 15: MoveLoc[5](loc0: u128)
758 16: Call library::base_uint(): u128
759 17: Div
760 18: Call library::base_uint(): u128
761 19: Mul
762 20: StLoc[5](loc0: u128)
763B3:
764 21: MoveLoc[5](loc0: u128)
765 22: Call library::base_uint(): u128
766 23: Div
767 24: StLoc[5](loc0: u128)
768 25: CopyLoc[5](loc0: u128)
769 26: CastU64
770 27: ImmBorrowLoc[0](Arg0: TradeChecks)
771 28: ImmBorrowField[9](TradeChecks.max_allowed_oi_open: vector<u128>)
772 29: VecLen(2)
773 30: Lt
774 31: BrFalse(33)
775B4:
776 32: Branch(37)
777B5:
778 33: MoveLoc[3](Arg3: u64)
779 34: LdU64(40)
780 35: Add
781 36: Abort
782B6:
783 37: ImmBorrowLoc[0](Arg0: TradeChecks)
784 38: ImmBorrowField[9](TradeChecks.max_allowed_oi_open: vector<u128>)
785 39: MoveLoc[5](loc0: u128)
786 40: CastU64
787 41: VecImmBorrow(2)
788 42: ReadRef
789 43: StLoc[6](loc1: u128)
790 44: MoveLoc[4](Arg4: bool)
791 45: BrFalse(50)
792B7:
793 46: MoveLoc[6](loc1: u128)
794 47: LdU128(5)
795 48: Mul
796 49: StLoc[6](loc1: u128)
797B8:
798 50: MoveLoc[2](Arg2: u128)
799 51: MoveLoc[6](loc1: u128)
800 52: Le
801 53: BrFalse(55)
802B9:
803 54: Branch(59)
804B10:
805 55: MoveLoc[3](Arg3: u64)
806 56: LdU64(25)
807 57: Add
808 58: Abort
809B11:
810 59: Ret
811}
812
813}
814
0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/exchange.mvb2817 lines
1// Move bytecode v7
2module 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001.exchange {
3use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::bank;
4use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::evaluator;
5use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::funding_rate;
6use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::isolated_adl;
7use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::isolated_liquidation;
8use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::isolated_trading;
9use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::library;
10use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::order;
11use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::perpetual;
12use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::position;
13use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::price_feed;
14use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::protocol;
15use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::roles;
16use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::s128;
17use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::settlement;
18use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::sub_accounts;
19use 9041eddbe15edba576c8c0bd4237e07b19e2c17fb59b240658f96522261f10c4::payload;
20use 9041eddbe15edba576c8c0bd4237e07b19e2c17fb59b240658f96522261f10c4::signature;
21use 9041eddbe15edba576c8c0bd4237e07b19e2c17fb59b240658f96522261f10c4::unified_address;
22use 8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::price_info;
23use 0000000000000000000000000000000000000000000000000000000000000001::option;
24use 0000000000000000000000000000000000000000000000000000000000000001::string;
25use 0000000000000000000000000000000000000000000000000000000000000002::clock;
26use 0000000000000000000000000000000000000000000000000000000000000002::event;
27use 0000000000000000000000000000000000000000000000000000000000000002::object;
28use 0000000000000000000000000000000000000000000000000000000000000002::table;
29use 0000000000000000000000000000000000000000000000000000000000000002::tx_context;
30use 0000000000000000000000000000000000000000000000000000000000000002::vec_set;
31
32struct LiquidatorPaidForAccountSettlementEvent has copy, drop {
33 tx_index: u128,
34 id: ID,
35 liquidator: address,
36 account: address,
37 amount: u128
38}
39
40struct SettlementAmountNotPaidCompletelyEvent has copy, drop {
41 tx_index: u128,
42 account: address,
43 amount: u128
44}
45
46struct SettlementAmtDueByMakerEvent has copy, drop {
47 tx_index: u128,
48 account: address,
49 amount: u128
50}
51
52struct AccountSettlementUpdateEvent has copy, drop {
53 tx_index: u128,
54 account: address,
55 balance: Position,
56 settlement_is_positive: bool,
57 settlement_amount: u128,
58 price: u128,
59 funding_rate: S128
60}
61
62entry create_perpetual<Ty0>(Arg0: &mut ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Bank<Ty0>, Arg3: vector<u8>, Arg4: u128, Arg5: u128, Arg6: u128, Arg7: u128, Arg8: u128, Arg9: u128, Arg10: u128, Arg11: u128, Arg12: u128, Arg13: vector<u128>, Arg14: u128, Arg15: u128, Arg16: u128, Arg17: u128, Arg18: u128, Arg19: address, Arg20: address, Arg21: address, Arg22: address, Arg23: u64, Arg24: vector<u8>, Arg25: &mut TxContext) {
63B0:
64 0: LdU64(999)
65 1: Abort
66}
67
68entry create_perpetual_v2<Ty0>(Arg0: &mut ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Bank<Ty0>, Arg3: &mut PriceFeed, Arg4: vector<u8>, Arg5: u128, Arg6: u128, Arg7: u128, Arg8: u128, Arg9: u128, Arg10: u128, Arg11: u128, Arg12: u128, Arg13: u128, Arg14: vector<u128>, Arg15: u128, Arg16: u128, Arg17: u128, Arg18: u128, Arg19: u128, Arg20: address, Arg21: address, Arg22: address, Arg23: address, Arg24: u64, Arg25: &mut TxContext) {
69L26: loc0: vector<u128>
70L27: loc1: ID
71B0:
72 0: CopyLoc[0](Arg0: &mut ProtocolConfig)
73 1: FreezeRef
74 2: Call protocol::check_basic(&ProtocolConfig)
75 3: CopyLoc[0](Arg0: &mut ProtocolConfig)
76 4: FreezeRef
77 5: MoveLoc[1](Arg1: &ExchangeManagerCap)
78 6: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
79 7: CopyLoc[22](Arg22: address)
80 8: LdConst[4](address: 0x00..)
81 9: Neq
82 10: BrFalse(12)
83B1:
84 11: Branch(22)
85B2:
86 12: MoveLoc[3](Arg3: &mut PriceFeed)
87 13: Pop
88 14: MoveLoc[25](Arg25: &mut TxContext)
89 15: Pop
90 16: MoveLoc[0](Arg0: &mut ProtocolConfig)
91 17: Pop
92 18: MoveLoc[2](Arg2: &mut Bank<Ty0>)
93 19: Pop
94 20: LdU64(105)
95 21: Abort
96B3:
97 22: CopyLoc[23](Arg23: address)
98 23: LdConst[4](address: 0x00..)
99 24: Neq
100 25: BrFalse(27)
101B4:
102 26: Branch(37)
103B5:
104 27: MoveLoc[3](Arg3: &mut PriceFeed)
105 28: Pop
106 29: MoveLoc[25](Arg25: &mut TxContext)
107 30: Pop
108 31: MoveLoc[0](Arg0: &mut ProtocolConfig)
109 32: Pop
110 33: MoveLoc[2](Arg2: &mut Bank<Ty0>)
111 34: Pop
112 35: LdU64(105)
113 36: Abort
114B6:
115 37: MoveLoc[5](Arg5: u128)
116 38: Call library::base_uint(): u128
117 39: Div
118 40: StLoc[5](Arg5: u128)
119 41: MoveLoc[6](Arg6: u128)
120 42: Call library::base_uint(): u128
121 43: Div
122 44: StLoc[6](Arg6: u128)
123 45: MoveLoc[7](Arg7: u128)
124 46: Call library::base_uint(): u128
125 47: Div
126 48: StLoc[7](Arg7: u128)
127 49: MoveLoc[8](Arg8: u128)
128 50: Call library::base_uint(): u128
129 51: Div
130 52: StLoc[8](Arg8: u128)
131 53: MoveLoc[9](Arg9: u128)
132 54: Call library::base_uint(): u128
133 55: Div
134 56: StLoc[9](Arg9: u128)
135 57: MoveLoc[10](Arg10: u128)
136 58: Call library::base_uint(): u128
137 59: Div
138 60: StLoc[10](Arg10: u128)
139 61: MoveLoc[11](Arg11: u128)
140 62: Call library::base_uint(): u128
141 63: Div
142 64: StLoc[11](Arg11: u128)
143 65: MoveLoc[12](Arg12: u128)
144 66: Call library::base_uint(): u128
145 67: Div
146 68: StLoc[12](Arg12: u128)
147 69: MoveLoc[13](Arg13: u128)
148 70: Call library::base_uint(): u128
149 71: Div
150 72: StLoc[13](Arg13: u128)
151 73: MoveLoc[15](Arg15: u128)
152 74: Call library::base_uint(): u128
153 75: Div
154 76: StLoc[15](Arg15: u128)
155 77: MoveLoc[16](Arg16: u128)
156 78: Call library::base_uint(): u128
157 79: Div
158 80: StLoc[16](Arg16: u128)
159 81: MoveLoc[17](Arg17: u128)
160 82: Call library::base_uint(): u128
161 83: Div
162 84: StLoc[17](Arg17: u128)
163 85: MoveLoc[18](Arg18: u128)
164 86: Call library::base_uint(): u128
165 87: Div
166 88: StLoc[18](Arg18: u128)
167 89: MoveLoc[19](Arg19: u128)
168 90: Call library::base_uint(): u128
169 91: Div
170 92: StLoc[19](Arg19: u128)
171 93: MoveLoc[14](Arg14: vector<u128>)
172 94: Call library::to_1x9_vec(vector<u128>): vector<u128>
173 95: StLoc[26](loc0: vector<u128>)
174 96: MoveLoc[4](Arg4: vector<u8>)
175 97: MoveLoc[15](Arg15: u128)
176 98: MoveLoc[16](Arg16: u128)
177 99: MoveLoc[17](Arg17: u128)
178 100: MoveLoc[18](Arg18: u128)
179 101: CopyLoc[20](Arg20: address)
180 102: CopyLoc[21](Arg21: address)
181 103: CopyLoc[22](Arg22: address)
182 104: CopyLoc[23](Arg23: address)
183 105: MoveLoc[5](Arg5: u128)
184 106: MoveLoc[6](Arg6: u128)
185 107: MoveLoc[7](Arg7: u128)
186 108: MoveLoc[8](Arg8: u128)
187 109: MoveLoc[9](Arg9: u128)
188 110: MoveLoc[10](Arg10: u128)
189 111: MoveLoc[11](Arg11: u128)
190 112: MoveLoc[12](Arg12: u128)
191 113: MoveLoc[13](Arg13: u128)
192 114: MoveLoc[19](Arg19: u128)
193 115: MoveLoc[24](Arg24: u64)
194 116: MoveLoc[26](loc0: vector<u128>)
195 117: LdConst[5](vector<u8>: "" /..)
196 118: LdU64(86400000)
197 119: LdU128(1000000)
198 120: Call library::base_uint(): u128
199 121: Mul
200 122: MoveLoc[25](Arg25: &mut TxContext)
201 123: Call perpetual::create(vector<u8>, u128, u128, u128, u128, address, address, address, address, u128, u128, u128, u128, u128, u128, u128, u128, u128, u128, u64, vector<u128>, vector<u8>, u64, u128, &mut TxContext): ID
202 124: StLoc[27](loc1: ID)
203 125: MoveLoc[0](Arg0: &mut ProtocolConfig)
204 126: CopyLoc[27](loc1: ID)
205 127: Call protocol::register_perpetual(&mut ProtocolConfig, ID)
206 128: MoveLoc[3](Arg3: &mut PriceFeed)
207 129: CopyLoc[27](loc1: ID)
208 130: LdU128(0)
209 131: LdU64(0)
210 132: Call price_feed::insert_price_info(&mut PriceFeed, ID, u128, u64)
211 133: CopyLoc[2](Arg2: &mut Bank<Ty0>)
212 134: ImmBorrowLoc[27](loc1: ID)
213 135: Call object::id_to_address(&ID): address
214 136: Call bank::create_account_if_not_exist<Ty0>(&mut Bank<Ty0>, address)
215 137: CopyLoc[2](Arg2: &mut Bank<Ty0>)
216 138: MoveLoc[20](Arg20: address)
217 139: Call bank::create_account_if_not_exist<Ty0>(&mut Bank<Ty0>, address)
218 140: CopyLoc[2](Arg2: &mut Bank<Ty0>)
219 141: MoveLoc[21](Arg21: address)
220 142: Call bank::create_account_if_not_exist<Ty0>(&mut Bank<Ty0>, address)
221 143: CopyLoc[2](Arg2: &mut Bank<Ty0>)
222 144: MoveLoc[22](Arg22: address)
223 145: Call bank::create_account_if_not_exist<Ty0>(&mut Bank<Ty0>, address)
224 146: MoveLoc[2](Arg2: &mut Bank<Ty0>)
225 147: MoveLoc[23](Arg23: address)
226 148: Call bank::create_account_if_not_exist<Ty0>(&mut Bank<Ty0>, address)
227 149: Ret
228}
229
230public trade<Ty0>(Arg0: &ProtocolConfig, Arg1: &Clock, Arg2: &mut Perpetual, Arg3: &mut Bank<Ty0>, Arg4: &SubAccounts, Arg5: &mut Table<vector<u8>, OrderStatus>, Arg6: &mut TxIndexer, Arg7: &SettlementCap, Arg8: &PriceInfoObject, Arg9: u8, Arg10: u128, Arg11: u128, Arg12: u128, Arg13: u64, Arg14: u128, Arg15: address, Arg16: vector<u8>, Arg17: vector<u8>, Arg18: u8, Arg19: u128, Arg20: u128, Arg21: u128, Arg22: u64, Arg23: u128, Arg24: address, Arg25: vector<u8>, Arg26: vector<u8>, Arg27: u128, Arg28: u128, Arg29: vector<u8>, Arg30: &TxContext) {
231B0:
232 0: LdU64(999)
233 1: Abort
234}
235
236public trade_v2<Ty0>(Arg0: &ProtocolConfig, Arg1: &Clock, Arg2: &mut Perpetual, Arg3: &mut Bank<Ty0>, Arg4: &SubAccounts, Arg5: &mut Table<vector<u8>, OrderStatus>, Arg6: &mut TxIndexer, Arg7: &SettlementCap, Arg8: &PriceFeed, Arg9: u8, Arg10: u128, Arg11: u128, Arg12: u128, Arg13: u64, Arg14: u128, Arg15: address, Arg16: vector<u8>, Arg17: vector<u8>, Arg18: u8, Arg19: u128, Arg20: u128, Arg21: u128, Arg22: u64, Arg23: u128, Arg24: address, Arg25: vector<u8>, Arg26: vector<u8>, Arg27: u128, Arg28: u128, Arg29: vector<u8>, Arg30: &TxContext) {
237B0:
238 0: LdU64(999)
239 1: Abort
240}
241
242verify_user_signature(Arg0: &SubAccounts, Arg1: &UnifiedAddress, Arg2: vector<u8>, Arg3: vector<u8>, Arg4: vector<u8>, Arg5: u64): UnifiedAddress {
243B0:
244 0: CopyLoc[1](Arg1: &UnifiedAddress)
245 1: MoveLoc[0](Arg0: &SubAccounts)
246 2: MoveLoc[1](Arg1: &UnifiedAddress)
247 3: Call unified_address::identifier(&UnifiedAddress): address
248 4: Call sub_accounts::get_all_sub_accounts(&SubAccounts, address): vector<address>
249 5: MoveLoc[2](Arg2: vector<u8>)
250 6: MoveLoc[3](Arg3: vector<u8>)
251 7: MoveLoc[4](Arg4: vector<u8>)
252 8: MoveLoc[5](Arg5: u64)
253 9: Call signature::verify_user_signature(&UnifiedAddress, vector<address>, vector<u8>, vector<u8>, vector<u8>, u64): UnifiedAddress
254 10: Ret
255}
256
257public trade_v3<Ty0>(Arg0: &ProtocolConfig, Arg1: &Clock, Arg2: &mut Perpetual, Arg3: &mut Bank<Ty0>, Arg4: &SubAccounts, Arg5: &mut Table<vector<u8>, OrderStatus>, Arg6: &mut TxIndexer, Arg7: &SettlementCap, Arg8: &PriceFeed, Arg9: u8, Arg10: u128, Arg11: u128, Arg12: u128, Arg13: u64, Arg14: u128, Arg15: vector<u8>, Arg16: u32, Arg17: vector<u8>, Arg18: vector<u8>, Arg19: u8, Arg20: u128, Arg21: u128, Arg22: u128, Arg23: u64, Arg24: u128, Arg25: vector<u8>, Arg26: u32, Arg27: vector<u8>, Arg28: vector<u8>, Arg29: u128, Arg30: u128, Arg31: vector<u8>, Arg32: &TxContext) {
258B0:
259 0: LdU64(999)
260 1: Abort
261}
262
263public trade_v4<Ty0>(Arg0: &ProtocolConfig, Arg1: &Clock, Arg2: &mut Perpetual, Arg3: &mut Bank<Ty0>, Arg4: &SubAccounts, Arg5: &mut Table<vector<u8>, OrderStatus>, Arg6: &mut TxIndexer, Arg7: &PriceFeed, Arg8: u8, Arg9: u128, Arg10: u128, Arg11: u128, Arg12: u64, Arg13: u128, Arg14: vector<u8>, Arg15: u32, Arg16: vector<u8>, Arg17: vector<u8>, Arg18: u8, Arg19: u128, Arg20: u128, Arg21: u128, Arg22: u64, Arg23: u128, Arg24: vector<u8>, Arg25: u32, Arg26: vector<u8>, Arg27: vector<u8>, Arg28: u128, Arg29: u128, Arg30: vector<u8>, Arg31: &TxContext) {
264L32: loc0: vector<u8>
265L33: loc1: vector<u8>
266L34: loc2: UnifiedAddress
267L35: loc3: &UnifiedAddress
268L36: loc4: &SubAccounts
269L37: loc5: vector<u8>
270L38: loc6: vector<u8>
271L39: loc7: vector<u8>
272L40: loc8: UnifiedAddress
273L41: loc9: &UnifiedAddress
274L42: loc10: &SubAccounts
275L43: loc11: vector<u8>
276L44: loc12: UnifiedAddress
277L45: loc13: OrderV2
278L46: loc14: UnifiedAddress
279L47: loc15: address
280L48: loc16: UnifiedAddress
281L49: loc17: OrderV2
282L50: loc18: UnifiedAddress
283L51: loc19: u128
284B0:
285 0: CopyLoc[0](Arg0: &ProtocolConfig)
286 1: Call protocol::check_basic(&ProtocolConfig)
287 2: MoveLoc[6](Arg6: &mut TxIndexer)
288 3: MoveLoc[30](Arg30: vector<u8>)
289 4: Call sub_accounts::validate_unique_tx(&mut TxIndexer, vector<u8>): u128
290 5: StLoc[51](loc19: u128)
291 6: CopyLoc[2](Arg2: &mut Perpetual)
292 7: MoveLoc[7](Arg7: &PriceFeed)
293 8: CopyLoc[1](Arg1: &Clock)
294 9: Call perpetual::update_oracle_price_v2(&mut Perpetual, &PriceFeed, &Clock)
295 10: MoveLoc[14](Arg14: vector<u8>)
296 11: Call unified_address::from_tagged_bytes(vector<u8>): UnifiedAddress
297 12: StLoc[44](loc12: UnifiedAddress)
298 13: MoveLoc[24](Arg24: vector<u8>)
299 14: Call unified_address::from_tagged_bytes(vector<u8>): UnifiedAddress
300 15: StLoc[48](loc16: UnifiedAddress)
301 16: CopyLoc[2](Arg2: &mut Perpetual)
302 17: FreezeRef
303 18: Call perpetual::perp_address(&Perpetual): address
304 19: StLoc[47](loc15: address)
305 20: CopyLoc[47](loc15: address)
306 21: MoveLoc[8](Arg8: u8)
307 22: MoveLoc[9](Arg9: u128)
308 23: MoveLoc[10](Arg10: u128)
309 24: MoveLoc[11](Arg11: u128)
310 25: MoveLoc[44](loc12: UnifiedAddress)
311 26: MoveLoc[12](Arg12: u64)
312 27: MoveLoc[13](Arg13: u128)
313 28: Call order::pack_order(address, u8, u128, u128, u128, UnifiedAddress, u64, u128): OrderV2
314 29: StLoc[45](loc13: OrderV2)
315 30: MoveLoc[47](loc15: address)
316 31: MoveLoc[18](Arg18: u8)
317 32: MoveLoc[19](Arg19: u128)
318 33: MoveLoc[20](Arg20: u128)
319 34: MoveLoc[21](Arg21: u128)
320 35: MoveLoc[48](loc16: UnifiedAddress)
321 36: MoveLoc[22](Arg22: u64)
322 37: MoveLoc[23](Arg23: u128)
323 38: Call order::pack_order(address, u8, u128, u128, u128, UnifiedAddress, u64, u128): OrderV2
324 39: StLoc[49](loc17: OrderV2)
325 40: CopyLoc[4](Arg4: &SubAccounts)
326 41: StLoc[42](loc10: &SubAccounts)
327 42: CopyLoc[45](loc13: OrderV2)
328 43: Call order::creator(OrderV2): UnifiedAddress
329 44: StLoc[40](loc8: UnifiedAddress)
330 45: ImmBorrowLoc[40](loc8: UnifiedAddress)
331 46: StLoc[41](loc9: &UnifiedAddress)
332 47: CopyLoc[45](loc13: OrderV2)
333 48: CopyLoc[15](Arg15: u32)
334 49: Call order::to_json_bytes(OrderV2, u32): vector<u8>
335 50: StLoc[39](loc7: vector<u8>)
336 51: MoveLoc[16](Arg16: vector<u8>)
337 52: StLoc[38](loc6: vector<u8>)
338 53: MoveLoc[17](Arg17: vector<u8>)
339 54: StLoc[37](loc5: vector<u8>)
340 55: MoveLoc[42](loc10: &SubAccounts)
341 56: MoveLoc[41](loc9: &UnifiedAddress)
342 57: MoveLoc[39](loc7: vector<u8>)
343 58: MoveLoc[38](loc6: vector<u8>)
344 59: MoveLoc[37](loc5: vector<u8>)
345 60: LdU64(30)
346 61: Call verify_user_signature(&SubAccounts, &UnifiedAddress, vector<u8>, vector<u8>, vector<u8>, u64): UnifiedAddress
347 62: StLoc[46](loc14: UnifiedAddress)
348 63: MoveLoc[4](Arg4: &SubAccounts)
349 64: StLoc[36](loc4: &SubAccounts)
350 65: CopyLoc[49](loc17: OrderV2)
351 66: Call order::creator(OrderV2): UnifiedAddress
352 67: StLoc[34](loc2: UnifiedAddress)
353 68: ImmBorrowLoc[34](loc2: UnifiedAddress)
354 69: StLoc[35](loc3: &UnifiedAddress)
355 70: CopyLoc[49](loc17: OrderV2)
356 71: CopyLoc[25](Arg25: u32)
357 72: Call order::to_json_bytes(OrderV2, u32): vector<u8>
358 73: StLoc[33](loc1: vector<u8>)
359 74: MoveLoc[26](Arg26: vector<u8>)
360 75: StLoc[32](loc0: vector<u8>)
361 76: MoveLoc[27](Arg27: vector<u8>)
362 77: StLoc[43](loc11: vector<u8>)
363 78: MoveLoc[36](loc4: &SubAccounts)
364 79: MoveLoc[35](loc3: &UnifiedAddress)
365 80: MoveLoc[33](loc1: vector<u8>)
366 81: MoveLoc[32](loc0: vector<u8>)
367 82: MoveLoc[43](loc11: vector<u8>)
368 83: LdU64(31)
369 84: Call verify_user_signature(&SubAccounts, &UnifiedAddress, vector<u8>, vector<u8>, vector<u8>, u64): UnifiedAddress
370 85: StLoc[50](loc18: UnifiedAddress)
371 86: CopyLoc[0](Arg0: &ProtocolConfig)
372 87: CopyLoc[31](Arg31: &TxContext)
373 88: Call tx_context::sender(&TxContext): address
374 89: Call roles::check_settlement_sender_validity(&ProtocolConfig, address)
375 90: MoveLoc[0](Arg0: &ProtocolConfig)
376 91: MoveLoc[1](Arg1: &Clock)
377 92: MoveLoc[2](Arg2: &mut Perpetual)
378 93: MoveLoc[3](Arg3: &mut Bank<Ty0>)
379 94: MoveLoc[5](Arg5: &mut Table<vector<u8>, OrderStatus>)
380 95: MoveLoc[51](loc19: u128)
381 96: MoveLoc[45](loc13: OrderV2)
382 97: MoveLoc[46](loc14: UnifiedAddress)
383 98: MoveLoc[15](Arg15: u32)
384 99: MoveLoc[49](loc17: OrderV2)
385 100: MoveLoc[50](loc18: UnifiedAddress)
386 101: MoveLoc[25](Arg25: u32)
387 102: MoveLoc[28](Arg28: u128)
388 103: MoveLoc[29](Arg29: u128)
389 104: MoveLoc[31](Arg31: &TxContext)
390 105: Call trade_impl<Ty0>(&ProtocolConfig, &Clock, &mut Perpetual, &mut Bank<Ty0>, &mut Table<vector<u8>, OrderStatus>, u128, OrderV2, UnifiedAddress, u32, OrderV2, UnifiedAddress, u32, u128, u128, &TxContext)
391 106: Ret
392}
393
394trade_impl<Ty0>(Arg0: &ProtocolConfig, Arg1: &Clock, Arg2: &mut Perpetual, Arg3: &mut Bank<Ty0>, Arg4: &mut Table<vector<u8>, OrderStatus>, Arg5: u128, Arg6: OrderV2, Arg7: UnifiedAddress, Arg8: u32, Arg9: OrderV2, Arg10: UnifiedAddress, Arg11: u32, Arg12: u128, Arg13: u128, Arg14: &TxContext) {
395L15: loc0: TradeDataV2
396L16: loc1: u128
397L17: loc2: u128
398L18: loc3: u128
399L19: loc4: address
400L20: loc5: address
401L21: loc6: ID
402L22: loc7: address
403L23: loc8: address
404L24: loc9: u128
405L25: loc10: TradeResponse
406B0:
407 0: MoveLoc[14](Arg14: &TxContext)
408 1: Call tx_context::sender(&TxContext): address
409 2: StLoc[22](loc7: address)
410 3: CopyLoc[2](Arg2: &mut Perpetual)
411 4: FreezeRef
412 5: Call perpetual::delisted(&Perpetual): bool
413 6: Not
414 7: BrFalse(9)
415B1:
416 8: Branch(21)
417B2:
418 9: MoveLoc[2](Arg2: &mut Perpetual)
419 10: Pop
420 11: MoveLoc[4](Arg4: &mut Table<vector<u8>, OrderStatus>)
421 12: Pop
422 13: MoveLoc[0](Arg0: &ProtocolConfig)
423 14: Pop
424 15: MoveLoc[1](Arg1: &Clock)
425 16: Pop
426 17: MoveLoc[3](Arg3: &mut Bank<Ty0>)
427 18: Pop
428 19: LdU64(61)
429 20: Abort
430B3:
431 21: CopyLoc[2](Arg2: &mut Perpetual)
432 22: FreezeRef
433 23: Call perpetual::is_trading_permitted(&Perpetual): bool
434 24: BrFalse(26)
435B4:
436 25: Branch(38)
437B5:
438 26: MoveLoc[2](Arg2: &mut Perpetual)
439 27: Pop
440 28: MoveLoc[4](Arg4: &mut Table<vector<u8>, OrderStatus>)
441 29: Pop
442 30: MoveLoc[0](Arg0: &ProtocolConfig)
443 31: Pop
444 32: MoveLoc[1](Arg1: &Clock)
445 33: Pop
446 34: MoveLoc[3](Arg3: &mut Bank<Ty0>)
447 35: Pop
448 36: LdU64(63)
449 37: Abort
450B6:
451 38: CopyLoc[1](Arg1: &Clock)
452 39: Call clock::timestamp_ms(&Clock): u64
453 40: CopyLoc[2](Arg2: &mut Perpetual)
454 41: FreezeRef
455 42: Call perpetual::start_time(&Perpetual): u64
456 43: Gt
457 44: BrFalse(46)
458B7:
459 45: Branch(58)
460B8:
461 46: MoveLoc[2](Arg2: &mut Perpetual)
462 47: Pop
463 48: MoveLoc[4](Arg4: &mut Table<vector<u8>, OrderStatus>)
464 49: Pop
465 50: MoveLoc[0](Arg0: &ProtocolConfig)
466 51: Pop
467 52: MoveLoc[1](Arg1: &Clock)
468 53: Pop
469 54: MoveLoc[3](Arg3: &mut Bank<Ty0>)
470 55: Pop
471 56: LdU64(56)
472 57: Abort
473B9:
474 58: CopyLoc[2](Arg2: &mut Perpetual)
475 59: FreezeRef
476 60: Call perpetual::id(&Perpetual): &UID
477 61: Call object::uid_to_inner(&UID): ID
478 62: StLoc[21](loc6: ID)
479 63: CopyLoc[2](Arg2: &mut Perpetual)
480 64: FreezeRef
481 65: Call perpetual::perp_address(&Perpetual): address
482 66: StLoc[20](loc5: address)
483 67: ImmBorrowLoc[6](Arg6: OrderV2)
484 68: Call order::creator_identifier(&OrderV2): address
485 69: StLoc[19](loc4: address)
486 70: ImmBorrowLoc[9](Arg9: OrderV2)
487 71: Call order::creator_identifier(&OrderV2): address
488 72: StLoc[23](loc8: address)
489 73: CopyLoc[21](loc6: ID)
490 74: CopyLoc[2](Arg2: &mut Perpetual)
491 75: Call perpetual::positions(&mut Perpetual): &mut Table<address, Position>
492 76: CopyLoc[19](loc4: address)
493 77: Call position::create_position(ID, &mut Table<address, Position>, address)
494 78: MoveLoc[21](loc6: ID)
495 79: CopyLoc[2](Arg2: &mut Perpetual)
496 80: Call perpetual::positions(&mut Perpetual): &mut Table<address, Position>
497 81: CopyLoc[23](loc8: address)
498 82: Call position::create_position(ID, &mut Table<address, Position>, address)
499 83: CopyLoc[3](Arg3: &mut Bank<Ty0>)
500 84: FreezeRef
501 85: CopyLoc[2](Arg2: &mut Perpetual)
502 86: FreezeRef
503 87: CopyLoc[19](loc4: address)
504 88: CopyLoc[23](loc8: address)
505 89: Call option::some<address>(address): Option<address>
506 90: Call sum_transaction_balance<Ty0>(&Bank<Ty0>, &Perpetual, address, Option<address>): u128
507 91: StLoc[18](loc3: u128)
508 92: CopyLoc[5](Arg5: u128)
509 93: CopyLoc[3](Arg3: &mut Bank<Ty0>)
510 94: CopyLoc[2](Arg2: &mut Perpetual)
511 95: CopyLoc[19](loc4: address)
512 96: Call isolated_trading::trade_type(): u8
513 97: LdU64(0)
514 98: Call apply_funding_rate<Ty0>(u128, &mut Bank<Ty0>, &mut Perpetual, address, u8, u64)
515 99: CopyLoc[5](Arg5: u128)
516 100: CopyLoc[3](Arg3: &mut Bank<Ty0>)
517 101: CopyLoc[2](Arg2: &mut Perpetual)
518 102: CopyLoc[23](loc8: address)
519 103: Call isolated_trading::trade_type(): u8
520 104: LdU64(1)
521 105: Call apply_funding_rate<Ty0>(u128, &mut Bank<Ty0>, &mut Perpetual, address, u8, u64)
522 106: MoveLoc[6](Arg6: OrderV2)
523 107: MoveLoc[7](Arg7: UnifiedAddress)
524 108: MoveLoc[8](Arg8: u32)
525 109: MoveLoc[9](Arg9: OrderV2)
526 110: MoveLoc[10](Arg10: UnifiedAddress)
527 111: MoveLoc[11](Arg11: u32)
528 112: MoveLoc[12](Arg12: u128)
529 113: MoveLoc[13](Arg13: u128)
530 114: MoveLoc[1](Arg1: &Clock)
531 115: Call clock::timestamp_ms(&Clock): u64
532 116: Call isolated_trading::pack_trade_data(OrderV2, UnifiedAddress, u32, OrderV2, UnifiedAddress, u32, u128, u128, u64): TradeDataV2
533 117: StLoc[15](loc0: TradeDataV2)
534 118: MoveLoc[0](Arg0: &ProtocolConfig)
535 119: MoveLoc[22](loc7: address)
536 120: CopyLoc[2](Arg2: &mut Perpetual)
537 121: MoveLoc[4](Arg4: &mut Table<vector<u8>, OrderStatus>)
538 122: MoveLoc[15](loc0: TradeDataV2)
539 123: CopyLoc[5](Arg5: u128)
540 124: Call isolated_trading::trade(&ProtocolConfig, address, &mut Perpetual, &mut Table<vector<u8>, OrderStatus>, TradeDataV2, u128): TradeResponse
541 125: StLoc[25](loc10: TradeResponse)
542 126: CopyLoc[3](Arg3: &mut Bank<Ty0>)
543 127: CopyLoc[20](loc5: address)
544 128: CopyLoc[19](loc4: address)
545 129: CopyLoc[23](loc8: address)
546 130: CopyLoc[25](loc10: TradeResponse)
547 131: Call isolated_trading::maker_funds_flow(TradeResponse): S128
548 132: CopyLoc[25](loc10: TradeResponse)
549 133: Call isolated_trading::taker_funds_flow(TradeResponse): S128
550 134: CopyLoc[5](Arg5: u128)
551 135: Call settlement::trade_margin_settlement<Ty0>(&mut Bank<Ty0>, address, address, address, S128, S128, u128)
552 136: CopyLoc[25](loc10: TradeResponse)
553 137: Call isolated_trading::trade_fee(TradeResponse): u128
554 138: StLoc[24](loc9: u128)
555 139: CopyLoc[24](loc9: u128)
556 140: LdU128(0)
557 141: Gt
558 142: BrFalse(152)
559B10:
560 143: CopyLoc[3](Arg3: &mut Bank<Ty0>)
561 144: CopyLoc[20](loc5: address)
562 145: CopyLoc[2](Arg2: &mut Perpetual)
563 146: FreezeRef
564 147: Call perpetual::fee_pool(&Perpetual): address
565 148: MoveLoc[24](loc9: u128)
566 149: LdU64(2)
567 150: CopyLoc[5](Arg5: u128)
568 151: Call bank::transfer<Ty0>(&mut Bank<Ty0>, address, address, u128, u64, u128)
569B11:
570 152: MoveLoc[25](loc10: TradeResponse)
571 153: Call isolated_trading::gas_fee(TradeResponse): u128
572 154: StLoc[17](loc2: u128)
573 155: CopyLoc[17](loc2: u128)
574 156: LdU128(0)
575 157: Gt
576 158: BrFalse(168)
577B12:
578 159: CopyLoc[3](Arg3: &mut Bank<Ty0>)
579 160: MoveLoc[20](loc5: address)
580 161: CopyLoc[2](Arg2: &mut Perpetual)
581 162: FreezeRef
582 163: Call perpetual::gas_pool(&Perpetual): address
583 164: MoveLoc[17](loc2: u128)
584 165: LdU64(2)
585 166: MoveLoc[5](Arg5: u128)
586 167: Call bank::transfer<Ty0>(&mut Bank<Ty0>, address, address, u128, u64, u128)
587B13:
588 168: MoveLoc[3](Arg3: &mut Bank<Ty0>)
589 169: FreezeRef
590 170: MoveLoc[2](Arg2: &mut Perpetual)
591 171: FreezeRef
592 172: MoveLoc[19](loc4: address)
593 173: MoveLoc[23](loc8: address)
594 174: Call option::some<address>(address): Option<address>
595 175: Call sum_transaction_balance<Ty0>(&Bank<Ty0>, &Perpetual, address, Option<address>): u128
596 176: StLoc[16](loc1: u128)
597 177: MoveLoc[18](loc3: u128)
598 178: MoveLoc[16](loc1: u128)
599 179: Eq
600 180: BrFalse(182)
601B14:
602 181: Branch(184)
603B15:
604 182: LdU64(99989)
605 183: Abort
606B16:
607 184: Ret
608}
609
610public liquidate<Ty0>(Arg0: &ProtocolConfig, Arg1: &Clock, Arg2: &mut Perpetual, Arg3: &mut Bank<Ty0>, Arg4: &SubAccounts, Arg5: &mut TxIndexer, Arg6: &PriceInfoObject, Arg7: address, Arg8: u128, Arg9: bool, Arg10: vector<u8>, Arg11: &TxContext) {
611B0:
612 0: LdU64(999)
613 1: Abort
614}
615
616public liquidate_v2<Ty0>(Arg0: &ProtocolConfig, Arg1: &Clock, Arg2: &mut Perpetual, Arg3: &mut Bank<Ty0>, Arg4: &SubAccounts, Arg5: &mut TxIndexer, Arg6: &PriceFeed, Arg7: address, Arg8: u128, Arg9: bool, Arg10: vector<u8>, Arg11: &TxContext) {
617L12: loc0: u128
618B0:
619 0: CopyLoc[0](Arg0: &ProtocolConfig)
620 1: Call protocol::check_basic(&ProtocolConfig)
621 2: MoveLoc[5](Arg5: &mut TxIndexer)
622 3: MoveLoc[10](Arg10: vector<u8>)
623 4: Call sub_accounts::validate_unique_tx(&mut TxIndexer, vector<u8>): u128
624 5: StLoc[12](loc0: u128)
625 6: MoveLoc[8](Arg8: u128)
626 7: Call library::base_uint(): u128
627 8: Div
628 9: StLoc[8](Arg8: u128)
629 10: CopyLoc[2](Arg2: &mut Perpetual)
630 11: MoveLoc[6](Arg6: &PriceFeed)
631 12: CopyLoc[1](Arg1: &Clock)
632 13: Call perpetual::update_oracle_price_v2(&mut Perpetual, &PriceFeed, &Clock)
633 14: MoveLoc[0](Arg0: &ProtocolConfig)
634 15: MoveLoc[1](Arg1: &Clock)
635 16: MoveLoc[2](Arg2: &mut Perpetual)
636 17: MoveLoc[3](Arg3: &mut Bank<Ty0>)
637 18: MoveLoc[4](Arg4: &SubAccounts)
638 19: MoveLoc[12](loc0: u128)
639 20: MoveLoc[7](Arg7: address)
640 21: MoveLoc[8](Arg8: u128)
641 22: MoveLoc[9](Arg9: bool)
642 23: MoveLoc[11](Arg11: &TxContext)
643 24: Call liquidate_impl<Ty0>(&ProtocolConfig, &Clock, &mut Perpetual, &mut Bank<Ty0>, &SubAccounts, u128, address, u128, bool, &TxContext)
644 25: Ret
645}
646
647liquidate_impl<Ty0>(Arg0: &ProtocolConfig, Arg1: &Clock, Arg2: &mut Perpetual, Arg3: &mut Bank<Ty0>, Arg4: &SubAccounts, Arg5: u128, Arg6: address, Arg7: u128, Arg8: bool, Arg9: &TxContext) {
648L10: loc0: bool
649L11: loc1: TradeData
650L12: loc2: u128
651L13: loc3: u128
652L14: loc4: address
653L15: loc5: address
654L16: loc6: ID
655L17: loc7: S128
656L18: loc8: address
657L19: loc9: u128
658L20: loc10: &mut Position
659L21: loc11: TradeResponse
660B0:
661 0: CopyLoc[2](Arg2: &mut Perpetual)
662 1: FreezeRef
663 2: Call perpetual::delisted(&Perpetual): bool
664 3: Not
665 4: BrFalse(6)
666B1:
667 5: Branch(18)
668B2:
669 6: MoveLoc[4](Arg4: &SubAccounts)
670 7: Pop
671 8: MoveLoc[2](Arg2: &mut Perpetual)
672 9: Pop
673 10: MoveLoc[9](Arg9: &TxContext)
674 11: Pop
675 12: MoveLoc[1](Arg1: &Clock)
676 13: Pop
677 14: MoveLoc[3](Arg3: &mut Bank<Ty0>)
678 15: Pop
679 16: LdU64(61)
680 17: Abort
681B3:
682 18: CopyLoc[2](Arg2: &mut Perpetual)
683 19: FreezeRef
684 20: Call perpetual::is_trading_permitted(&Perpetual): bool
685 21: BrFalse(23)
686B4:
687 22: Branch(35)
688B5:
689 23: MoveLoc[4](Arg4: &SubAccounts)
690 24: Pop
691 25: MoveLoc[2](Arg2: &mut Perpetual)
692 26: Pop
693 27: MoveLoc[9](Arg9: &TxContext)
694 28: Pop
695 29: MoveLoc[1](Arg1: &Clock)
696 30: Pop
697 31: MoveLoc[3](Arg3: &mut Bank<Ty0>)
698 32: Pop
699 33: LdU64(63)
700 34: Abort
701B6:
702 35: MoveLoc[1](Arg1: &Clock)
703 36: Call clock::timestamp_ms(&Clock): u64
704 37: CopyLoc[2](Arg2: &mut Perpetual)
705 38: FreezeRef
706 39: Call perpetual::start_time(&Perpetual): u64
707 40: Gt
708 41: BrFalse(43)
709B7:
710 42: Branch(53)
711B8:
712 43: MoveLoc[4](Arg4: &SubAccounts)
713 44: Pop
714 45: MoveLoc[2](Arg2: &mut Perpetual)
715 46: Pop
716 47: MoveLoc[9](Arg9: &TxContext)
717 48: Pop
718 49: MoveLoc[3](Arg3: &mut Bank<Ty0>)
719 50: Pop
720 51: LdU64(56)
721 52: Abort
722B9:
723 53: MoveLoc[9](Arg9: &TxContext)
724 54: Call tx_context::sender(&TxContext): address
725 55: StLoc[18](loc8: address)
726 56: CopyLoc[2](Arg2: &mut Perpetual)
727 57: FreezeRef
728 58: Call perpetual::insurance_active_pool(&Perpetual): address
729 59: StLoc[14](loc4: address)
730 60: CopyLoc[18](loc8: address)
731 61: CopyLoc[14](loc4: address)
732 62: Eq
733 63: BrFalse(69)
734B10:
735 64: MoveLoc[4](Arg4: &SubAccounts)
736 65: Pop
737 66: LdTrue
738 67: StLoc[10](loc0: bool)
739 68: Branch(74)
740B11:
741 69: MoveLoc[4](Arg4: &SubAccounts)
742 70: CopyLoc[14](loc4: address)
743 71: CopyLoc[18](loc8: address)
744 72: Call sub_accounts::is_sub_account(&SubAccounts, address, address): bool
745 73: StLoc[10](loc0: bool)
746B12:
747 74: MoveLoc[10](loc0: bool)
748 75: BrFalse(77)
749B13:
750 76: Branch(83)
751B14:
752 77: MoveLoc[2](Arg2: &mut Perpetual)
753 78: Pop
754 79: MoveLoc[3](Arg3: &mut Bank<Ty0>)
755 80: Pop
756 81: LdU64(51)
757 82: Abort
758B15:
759 83: CopyLoc[14](loc4: address)
760 84: CopyLoc[6](Arg6: address)
761 85: Neq
762 86: BrFalse(88)
763B16:
764 87: Branch(94)
765B17:
766 88: MoveLoc[2](Arg2: &mut Perpetual)
767 89: Pop
768 90: MoveLoc[3](Arg3: &mut Bank<Ty0>)
769 91: Pop
770 92: LdU64(704)
771 93: Abort
772B18:
773 94: CopyLoc[2](Arg2: &mut Perpetual)
774 95: FreezeRef
775 96: Call perpetual::id(&Perpetual): &UID
776 97: Call object::uid_to_inner(&UID): ID
777 98: StLoc[16](loc6: ID)
778 99: CopyLoc[2](Arg2: &mut Perpetual)
779 100: FreezeRef
780 101: Call perpetual::perp_address(&Perpetual): address
781 102: StLoc[15](loc5: address)
782 103: CopyLoc[16](loc6: ID)
783 104: CopyLoc[2](Arg2: &mut Perpetual)
784 105: Call perpetual::positions(&mut Perpetual): &mut Table<address, Position>
785 106: CopyLoc[6](Arg6: address)
786 107: Call position::create_position(ID, &mut Table<address, Position>, address)
787 108: MoveLoc[16](loc6: ID)
788 109: CopyLoc[2](Arg2: &mut Perpetual)
789 110: Call perpetual::positions(&mut Perpetual): &mut Table<address, Position>
790 111: CopyLoc[14](loc4: address)
791 112: Call position::create_position(ID, &mut Table<address, Position>, address)
792 113: CopyLoc[3](Arg3: &mut Bank<Ty0>)
793 114: FreezeRef
794 115: CopyLoc[2](Arg2: &mut Perpetual)
795 116: FreezeRef
796 117: CopyLoc[6](Arg6: address)
797 118: Call option::none<address>(): Option<address>
798 119: Call sum_transaction_balance<Ty0>(&Bank<Ty0>, &Perpetual, address, Option<address>): u128
799 120: StLoc[13](loc3: u128)
800 121: CopyLoc[5](Arg5: u128)
801 122: CopyLoc[3](Arg3: &mut Bank<Ty0>)
802 123: CopyLoc[2](Arg2: &mut Perpetual)
803 124: CopyLoc[6](Arg6: address)
804 125: Call isolated_liquidation::trade_type(): u8
805 126: LdU64(0)
806 127: Call apply_funding_rate<Ty0>(u128, &mut Bank<Ty0>, &mut Perpetual, address, u8, u64)
807 128: CopyLoc[5](Arg5: u128)
808 129: CopyLoc[3](Arg3: &mut Bank<Ty0>)
809 130: CopyLoc[2](Arg2: &mut Perpetual)
810 131: CopyLoc[14](loc4: address)
811 132: Call isolated_liquidation::trade_type(): u8
812 133: LdU64(1)
813 134: Call apply_funding_rate<Ty0>(u128, &mut Bank<Ty0>, &mut Perpetual, address, u8, u64)
814 135: CopyLoc[2](Arg2: &mut Perpetual)
815 136: Call perpetual::positions(&mut Perpetual): &mut Table<address, Position>
816 137: CopyLoc[14](loc4: address)
817 138: Call table::borrow_mut<address, Position>(&mut Table<address, Position>, address): &mut Position
818 139: StLoc[20](loc10: &mut Position)
819 140: CopyLoc[20](loc10: &mut Position)
820 141: FreezeRef
821 142: Call position::margin(&Position): u128
822 143: StLoc[19](loc9: u128)
823 144: CopyLoc[19](loc9: u128)
824 145: LdU128(0)
825 146: Gt
826 147: BrFalse(159)
827B19:
828 148: CopyLoc[3](Arg3: &mut Bank<Ty0>)
829 149: CopyLoc[15](loc5: address)
830 150: CopyLoc[14](loc4: address)
831 151: MoveLoc[19](loc9: u128)
832 152: LdU64(2)
833 153: CopyLoc[5](Arg5: u128)
834 154: Call bank::transfer<Ty0>(&mut Bank<Ty0>, address, address, u128, u64, u128)
835 155: MoveLoc[20](loc10: &mut Position)
836 156: LdU128(0)
837 157: Call position::set_margin(&mut Position, u128)
838 158: Branch(161)
839B20:
840 159: MoveLoc[20](loc10: &mut Position)
841 160: Pop
842B21:
843 161: CopyLoc[14](loc4: address)
844 162: CopyLoc[6](Arg6: address)
845 163: MoveLoc[7](Arg7: u128)
846 164: MoveLoc[8](Arg8: bool)
847 165: Call isolated_liquidation::pack_trade_data(address, address, u128, bool): TradeData
848 166: StLoc[11](loc1: TradeData)
849 167: MoveLoc[18](loc8: address)
850 168: CopyLoc[2](Arg2: &mut Perpetual)
851 169: MoveLoc[11](loc1: TradeData)
852 170: CopyLoc[5](Arg5: u128)
853 171: Call isolated_liquidation::trade(address, &mut Perpetual, TradeData, u128): TradeResponse
854 172: StLoc[21](loc11: TradeResponse)
855 173: CopyLoc[21](loc11: TradeResponse)
856 174: Call isolated_liquidation::premium(TradeResponse): S128
857 175: StLoc[17](loc7: S128)
858 176: CopyLoc[17](loc7: S128)
859 177: LdU128(0)
860 178: Call s128::gt_u128(S128, u128): bool
861 179: BrFalse(189)
862B22:
863 180: CopyLoc[3](Arg3: &mut Bank<Ty0>)
864 181: CopyLoc[15](loc5: address)
865 182: CopyLoc[14](loc4: address)
866 183: MoveLoc[17](loc7: S128)
867 184: Call s128::value(S128): u128
868 185: LdU64(2)
869 186: CopyLoc[5](Arg5: u128)
870 187: Call bank::transfer<Ty0>(&mut Bank<Ty0>, address, address, u128, u64, u128)
871 188: Branch(201)
872B23:
873 189: CopyLoc[17](loc7: S128)
874 190: LdU128(0)
875 191: Call s128::lt_u128(S128, u128): bool
876 192: BrFalse(201)
877B24:
878 193: CopyLoc[3](Arg3: &mut Bank<Ty0>)
879 194: CopyLoc[14](loc4: address)
880 195: CopyLoc[15](loc5: address)
881 196: MoveLoc[17](loc7: S128)
882 197: Call s128::value(S128): u128
883 198: LdU64(1)
884 199: CopyLoc[5](Arg5: u128)
885 200: Call bank::transfer<Ty0>(&mut Bank<Ty0>, address, address, u128, u64, u128)
886B25:
887 201: CopyLoc[3](Arg3: &mut Bank<Ty0>)
888 202: MoveLoc[15](loc5: address)
889 203: CopyLoc[6](Arg6: address)
890 204: MoveLoc[14](loc4: address)
891 205: CopyLoc[21](loc11: TradeResponse)
892 206: Call isolated_liquidation::maker_funds_flow(TradeResponse): S128
893 207: MoveLoc[21](loc11: TradeResponse)
894 208: Call isolated_liquidation::taker_funds_flow(TradeResponse): S128
895 209: MoveLoc[5](Arg5: u128)
896 210: Call settlement::trade_margin_settlement<Ty0>(&mut Bank<Ty0>, address, address, address, S128, S128, u128)
897 211: MoveLoc[3](Arg3: &mut Bank<Ty0>)
898 212: FreezeRef
899 213: MoveLoc[2](Arg2: &mut Perpetual)
900 214: FreezeRef
901 215: MoveLoc[6](Arg6: address)
902 216: Call option::none<address>(): Option<address>
903 217: Call sum_transaction_balance<Ty0>(&Bank<Ty0>, &Perpetual, address, Option<address>): u128
904 218: StLoc[12](loc2: u128)
905 219: MoveLoc[13](loc3: u128)
906 220: MoveLoc[12](loc2: u128)
907 221: Eq
908 222: BrFalse(224)
909B26:
910 223: Branch(226)
911B27:
912 224: LdU64(99989)
913 225: Abort
914B28:
915 226: Ret
916}
917
918public deleverage<Ty0>(Arg0: &ProtocolConfig, Arg1: &Clock, Arg2: &mut Perpetual, Arg3: &mut Bank<Ty0>, Arg4: &mut TxIndexer, Arg5: &DeleveragingCap, Arg6: &PriceInfoObject, Arg7: address, Arg8: address, Arg9: u128, Arg10: bool, Arg11: vector<u8>, Arg12: &TxContext) {
919B0:
920 0: LdU64(999)
921 1: Abort
922}
923
924public deleverage_v2<Ty0>(Arg0: &ProtocolConfig, Arg1: &Clock, Arg2: &mut Perpetual, Arg3: &mut Bank<Ty0>, Arg4: &mut TxIndexer, Arg5: &DeleveragingCap, Arg6: &PriceFeed, Arg7: address, Arg8: address, Arg9: u128, Arg10: bool, Arg11: vector<u8>, Arg12: &TxContext) {
925L13: loc0: u128
926B0:
927 0: CopyLoc[0](Arg0: &ProtocolConfig)
928 1: Call protocol::check_basic(&ProtocolConfig)
929 2: MoveLoc[4](Arg4: &mut TxIndexer)
930 3: MoveLoc[11](Arg11: vector<u8>)
931 4: Call sub_accounts::validate_unique_tx(&mut TxIndexer, vector<u8>): u128
932 5: StLoc[13](loc0: u128)
933 6: MoveLoc[9](Arg9: u128)
934 7: Call library::base_uint(): u128
935 8: Div
936 9: StLoc[9](Arg9: u128)
937 10: CopyLoc[2](Arg2: &mut Perpetual)
938 11: MoveLoc[6](Arg6: &PriceFeed)
939 12: CopyLoc[1](Arg1: &Clock)
940 13: Call perpetual::update_oracle_price_v2(&mut Perpetual, &PriceFeed, &Clock)
941 14: MoveLoc[0](Arg0: &ProtocolConfig)
942 15: MoveLoc[1](Arg1: &Clock)
943 16: MoveLoc[2](Arg2: &mut Perpetual)
944 17: MoveLoc[3](Arg3: &mut Bank<Ty0>)
945 18: MoveLoc[5](Arg5: &DeleveragingCap)
946 19: MoveLoc[13](loc0: u128)
947 20: MoveLoc[7](Arg7: address)
948 21: MoveLoc[8](Arg8: address)
949 22: MoveLoc[9](Arg9: u128)
950 23: MoveLoc[10](Arg10: bool)
951 24: MoveLoc[12](Arg12: &TxContext)
952 25: Call deleverage_impl<Ty0>(&ProtocolConfig, &Clock, &mut Perpetual, &mut Bank<Ty0>, &DeleveragingCap, u128, address, address, u128, bool, &TxContext)
953 26: Ret
954}
955
956deleverage_impl<Ty0>(Arg0: &ProtocolConfig, Arg1: &Clock, Arg2: &mut Perpetual, Arg3: &mut Bank<Ty0>, Arg4: &DeleveragingCap, Arg5: u128, Arg6: address, Arg7: address, Arg8: u128, Arg9: bool, Arg10: &TxContext) {
957L11: loc0: TradeData
958L12: loc1: u128
959L13: loc2: u128
960L14: loc3: address
961L15: loc4: ID
962L16: loc5: address
963L17: loc6: TradeResponse
964B0:
965 0: CopyLoc[2](Arg2: &mut Perpetual)
966 1: FreezeRef
967 2: Call perpetual::delisted(&Perpetual): bool
968 3: Not
969 4: BrFalse(6)
970B1:
971 5: Branch(20)
972B2:
973 6: MoveLoc[2](Arg2: &mut Perpetual)
974 7: Pop
975 8: MoveLoc[10](Arg10: &TxContext)
976 9: Pop
977 10: MoveLoc[0](Arg0: &ProtocolConfig)
978 11: Pop
979 12: MoveLoc[1](Arg1: &Clock)
980 13: Pop
981 14: MoveLoc[4](Arg4: &DeleveragingCap)
982 15: Pop
983 16: MoveLoc[3](Arg3: &mut Bank<Ty0>)
984 17: Pop
985 18: LdU64(61)
986 19: Abort
987B3:
988 20: CopyLoc[2](Arg2: &mut Perpetual)
989 21: FreezeRef
990 22: Call perpetual::is_trading_permitted(&Perpetual): bool
991 23: BrFalse(25)
992B4:
993 24: Branch(39)
994B5:
995 25: MoveLoc[2](Arg2: &mut Perpetual)
996 26: Pop
997 27: MoveLoc[10](Arg10: &TxContext)
998 28: Pop
999 29: MoveLoc[0](Arg0: &ProtocolConfig)
1000 30: Pop
1001 31: MoveLoc[1](Arg1: &Clock)
1002 32: Pop
1003 33: MoveLoc[4](Arg4: &DeleveragingCap)
1004 34: Pop
1005 35: MoveLoc[3](Arg3: &mut Bank<Ty0>)
1006 36: Pop
1007 37: LdU64(63)
1008 38: Abort
1009B6:
1010 39: MoveLoc[1](Arg1: &Clock)
1011 40: Call clock::timestamp_ms(&Clock): u64
1012 41: CopyLoc[2](Arg2: &mut Perpetual)
1013 42: FreezeRef
1014 43: Call perpetual::start_time(&Perpetual): u64
1015 44: Gt
1016 45: BrFalse(47)
1017B7:
1018 46: Branch(59)
1019B8:
1020 47: MoveLoc[2](Arg2: &mut Perpetual)
1021 48: Pop
1022 49: MoveLoc[10](Arg10: &TxContext)
1023 50: Pop
1024 51: MoveLoc[0](Arg0: &ProtocolConfig)
1025 52: Pop
1026 53: MoveLoc[4](Arg4: &DeleveragingCap)
1027 54: Pop
1028 55: MoveLoc[3](Arg3: &mut Bank<Ty0>)
1029 56: Pop
1030 57: LdU64(56)
1031 58: Abort
1032B9:
1033 59: MoveLoc[0](Arg0: &ProtocolConfig)
1034 60: MoveLoc[4](Arg4: &DeleveragingCap)
1035 61: Call roles::check_deleveraging_operator_validity(&ProtocolConfig, &DeleveragingCap)
1036 62: MoveLoc[10](Arg10: &TxContext)
1037 63: Call tx_context::sender(&TxContext): address
1038 64: StLoc[16](loc5: address)
1039 65: CopyLoc[2](Arg2: &mut Perpetual)
1040 66: FreezeRef
1041 67: Call perpetual::id(&Perpetual): &UID
1042 68: Call object::uid_to_inner(&UID): ID
1043 69: StLoc[15](loc4: ID)
1044 70: CopyLoc[2](Arg2: &mut Perpetual)
1045 71: FreezeRef
1046 72: Call perpetual::perp_address(&Perpetual): address
1047 73: StLoc[14](loc3: address)
1048 74: CopyLoc[15](loc4: ID)
1049 75: CopyLoc[2](Arg2: &mut Perpetual)
1050 76: Call perpetual::positions(&mut Perpetual): &mut Table<address, Position>
1051 77: CopyLoc[6](Arg6: address)
1052 78: Call position::create_position(ID, &mut Table<address, Position>, address)
1053 79: MoveLoc[15](loc4: ID)
1054 80: CopyLoc[2](Arg2: &mut Perpetual)
1055 81: Call perpetual::positions(&mut Perpetual): &mut Table<address, Position>
1056 82: CopyLoc[7](Arg7: address)
1057 83: Call position::create_position(ID, &mut Table<address, Position>, address)
1058 84: CopyLoc[3](Arg3: &mut Bank<Ty0>)
1059 85: FreezeRef
1060 86: CopyLoc[2](Arg2: &mut Perpetual)
1061 87: FreezeRef
1062 88: CopyLoc[6](Arg6: address)
1063 89: CopyLoc[7](Arg7: address)
1064 90: Call option::some<address>(address): Option<address>
1065 91: Call sum_transaction_balance<Ty0>(&Bank<Ty0>, &Perpetual, address, Option<address>): u128
1066 92: StLoc[13](loc2: u128)
1067 93: CopyLoc[5](Arg5: u128)
1068 94: CopyLoc[3](Arg3: &mut Bank<Ty0>)
1069 95: CopyLoc[2](Arg2: &mut Perpetual)
1070 96: CopyLoc[6](Arg6: address)
1071 97: Call isolated_adl::trade_type(): u8
1072 98: LdU64(0)
1073 99: Call apply_funding_rate<Ty0>(u128, &mut Bank<Ty0>, &mut Perpetual, address, u8, u64)
1074 100: CopyLoc[5](Arg5: u128)
1075 101: CopyLoc[3](Arg3: &mut Bank<Ty0>)
1076 102: CopyLoc[2](Arg2: &mut Perpetual)
1077 103: CopyLoc[7](Arg7: address)
1078 104: Call isolated_adl::trade_type(): u8
1079 105: LdU64(1)
1080 106: Call apply_funding_rate<Ty0>(u128, &mut Bank<Ty0>, &mut Perpetual, address, u8, u64)
1081 107: CopyLoc[6](Arg6: address)
1082 108: CopyLoc[7](Arg7: address)
1083 109: MoveLoc[8](Arg8: u128)
1084 110: MoveLoc[9](Arg9: bool)
1085 111: Call isolated_adl::pack_trade_data(address, address, u128, bool): TradeData
1086 112: StLoc[11](loc0: TradeData)
1087 113: MoveLoc[16](loc5: address)
1088 114: CopyLoc[2](Arg2: &mut Perpetual)
1089 115: CopyLoc[3](Arg3: &mut Bank<Ty0>)
1090 116: FreezeRef
1091 117: MoveLoc[11](loc0: TradeData)
1092 118: CopyLoc[5](Arg5: u128)
1093 119: Call isolated_adl::trade<Ty0>(address, &mut Perpetual, &Bank<Ty0>, TradeData, u128): TradeResponse
1094 120: StLoc[17](loc6: TradeResponse)
1095 121: CopyLoc[3](Arg3: &mut Bank<Ty0>)
1096 122: MoveLoc[14](loc3: address)
1097 123: CopyLoc[6](Arg6: address)
1098 124: CopyLoc[7](Arg7: address)
1099 125: CopyLoc[17](loc6: TradeResponse)
1100 126: Call isolated_adl::maker_funds_flow(TradeResponse): S128
1101 127: MoveLoc[17](loc6: TradeResponse)
1102 128: Call isolated_adl::taker_funds_flow(TradeResponse): S128
1103 129: MoveLoc[5](Arg5: u128)
1104 130: Call settlement::trade_margin_settlement<Ty0>(&mut Bank<Ty0>, address, address, address, S128, S128, u128)
1105 131: MoveLoc[3](Arg3: &mut Bank<Ty0>)
1106 132: FreezeRef
1107 133: MoveLoc[2](Arg2: &mut Perpetual)
1108 134: FreezeRef
1109 135: MoveLoc[6](Arg6: address)
1110 136: MoveLoc[7](Arg7: address)
1111 137: Call option::some<address>(address): Option<address>
1112 138: Call sum_transaction_balance<Ty0>(&Bank<Ty0>, &Perpetual, address, Option<address>): u128
1113 139: StLoc[12](loc1: u128)
1114 140: MoveLoc[13](loc2: u128)
1115 141: MoveLoc[12](loc1: u128)
1116 142: Eq
1117 143: BrFalse(145)
1118B10:
1119 144: Branch(147)
1120B11:
1121 145: LdU64(99989)
1122 146: Abort
1123B12:
1124 147: Ret
1125}
1126
1127public add_margin<Ty0>(Arg0: &ProtocolConfig, Arg1: &Clock, Arg2: &mut Perpetual, Arg3: &mut Bank<Ty0>, Arg4: &SubAccounts, Arg5: &mut TxIndexer, Arg6: &PriceInfoObject, Arg7: address, Arg8: u128, Arg9: vector<u8>, Arg10: &TxContext) {
1128B0:
1129 0: LdU64(999)
1130 1: Abort
1131}
1132
1133public add_margin_v2<Ty0>(Arg0: &ProtocolConfig, Arg1: &Clock, Arg2: &mut Perpetual, Arg3: &mut Bank<Ty0>, Arg4: &SubAccounts, Arg5: &mut TxIndexer, Arg6: &PriceInfoObject, Arg7: address, Arg8: u128, Arg9: &TxContext) {
1134B0:
1135 0: LdU64(999)
1136 1: Abort
1137}
1138
1139public add_margin_v3<Ty0>(Arg0: &ProtocolConfig, Arg1: &Clock, Arg2: &mut Perpetual, Arg3: &mut Bank<Ty0>, Arg4: &SubAccounts, Arg5: &mut TxIndexer, Arg6: &PriceFeed, Arg7: address, Arg8: u128, Arg9: &TxContext) {
1140B0:
1141 0: LdU64(999)
1142 1: Abort
1143}
1144
1145public add_margin_v4<Ty0>(Arg0: &ProtocolConfig, Arg1: &Clock, Arg2: &mut Perpetual, Arg3: &mut Bank<Ty0>, Arg4: &SubAccounts, Arg5: &mut TxIndexer, Arg6: &PriceFeed, Arg7: vector<u8>, Arg8: u128, Arg9: u128, Arg10: u64, Arg11: vector<u8>, Arg12: vector<u8>, Arg13: &TxContext) {
1146L14: loc0: u64
1147L15: loc1: &Clock
1148L16: loc2: vector<u8>
1149L17: loc3: vector<u8>
1150L18: loc4: vector<u8>
1151L19: loc5: &UnifiedAddress
1152L20: loc6: &SubAccounts
1153L21: loc7: UnifiedAddress
1154L22: loc8: vector<u8>
1155L23: loc9: u128
1156L24: loc10: UnifiedAddress
1157B0:
1158 0: CopyLoc[0](Arg0: &ProtocolConfig)
1159 1: Call protocol::check_basic(&ProtocolConfig)
1160 2: CopyLoc[1](Arg1: &Clock)
1161 3: StLoc[15](loc1: &Clock)
1162 4: CopyLoc[10](Arg10: u64)
1163 5: StLoc[14](loc0: u64)
1164 6: MoveLoc[15](loc1: &Clock)
1165 7: MoveLoc[14](loc0: u64)
1166 8: LdU64(34)
1167 9: Call signature::assert_signed_payload_fresh(&Clock, u64, u64)
1168 10: CopyLoc[2](Arg2: &mut Perpetual)
1169 11: MoveLoc[6](Arg6: &PriceFeed)
1170 12: MoveLoc[1](Arg1: &Clock)
1171 13: Call perpetual::update_oracle_price_v2(&mut Perpetual, &PriceFeed, &Clock)
1172 14: MoveLoc[7](Arg7: vector<u8>)
1173 15: Call unified_address::from_tagged_bytes(vector<u8>): UnifiedAddress
1174 16: StLoc[24](loc10: UnifiedAddress)
1175 17: CopyLoc[0](Arg0: &ProtocolConfig)
1176 18: CopyLoc[4](Arg4: &SubAccounts)
1177 19: ImmBorrowLoc[24](loc10: UnifiedAddress)
1178 20: CopyLoc[13](Arg13: &TxContext)
1179 21: Call sub_accounts::assert_signed_action_sender_authorized(&ProtocolConfig, &SubAccounts, &UnifiedAddress, &TxContext)
1180 22: CopyLoc[2](Arg2: &mut Perpetual)
1181 23: FreezeRef
1182 24: Call perpetual::perp_address(&Perpetual): address
1183 25: CopyLoc[24](loc10: UnifiedAddress)
1184 26: CopyLoc[8](Arg8: u128)
1185 27: MoveLoc[9](Arg9: u128)
1186 28: MoveLoc[10](Arg10: u64)
1187 29: Call payload::add_margin(address, UnifiedAddress, u128, u128, u64): vector<u8>
1188 30: StLoc[22](loc8: vector<u8>)
1189 31: MoveLoc[4](Arg4: &SubAccounts)
1190 32: StLoc[20](loc6: &SubAccounts)
1191 33: ImmBorrowLoc[24](loc10: UnifiedAddress)
1192 34: StLoc[19](loc5: &UnifiedAddress)
1193 35: CopyLoc[22](loc8: vector<u8>)
1194 36: StLoc[18](loc4: vector<u8>)
1195 37: MoveLoc[11](Arg11: vector<u8>)
1196 38: StLoc[17](loc3: vector<u8>)
1197 39: MoveLoc[12](Arg12: vector<u8>)
1198 40: StLoc[16](loc2: vector<u8>)
1199 41: MoveLoc[20](loc6: &SubAccounts)
1200 42: MoveLoc[19](loc5: &UnifiedAddress)
1201 43: MoveLoc[18](loc4: vector<u8>)
1202 44: MoveLoc[17](loc3: vector<u8>)
1203 45: MoveLoc[16](loc2: vector<u8>)
1204 46: LdU64(52)
1205 47: Call verify_user_signature(&SubAccounts, &UnifiedAddress, vector<u8>, vector<u8>, vector<u8>, u64): UnifiedAddress
1206 48: StLoc[21](loc7: UnifiedAddress)
1207 49: MoveLoc[5](Arg5: &mut TxIndexer)
1208 50: MoveLoc[22](loc8: vector<u8>)
1209 51: Call library::get_hash(vector<u8>): vector<u8>
1210 52: Call sub_accounts::validate_unique_tx(&mut TxIndexer, vector<u8>): u128
1211 53: StLoc[23](loc9: u128)
1212 54: MoveLoc[8](Arg8: u128)
1213 55: Call library::base_uint(): u128
1214 56: Div
1215 57: StLoc[8](Arg8: u128)
1216 58: CopyLoc[3](Arg3: &mut Bank<Ty0>)
1217 59: MoveLoc[0](Arg0: &ProtocolConfig)
1218 60: ImmBorrowLoc[24](loc10: UnifiedAddress)
1219 61: Call unified_address::identifier(&UnifiedAddress): address
1220 62: LdConst[6](vector<u8>: "Add..)
1221 63: Call string::utf8(vector<u8>): String
1222 64: CopyLoc[23](loc9: u128)
1223 65: MoveLoc[13](Arg13: &TxContext)
1224 66: Call bank::charge_relayer_gas_fee<Ty0>(&mut Bank<Ty0>, &ProtocolConfig, address, String, u128, &TxContext)
1225 67: MoveLoc[2](Arg2: &mut Perpetual)
1226 68: MoveLoc[3](Arg3: &mut Bank<Ty0>)
1227 69: MoveLoc[23](loc9: u128)
1228 70: ImmBorrowLoc[24](loc10: UnifiedAddress)
1229 71: Call unified_address::identifier(&UnifiedAddress): address
1230 72: MoveLoc[8](Arg8: u128)
1231 73: ImmBorrowLoc[21](loc7: UnifiedAddress)
1232 74: Call unified_address::identifier(&UnifiedAddress): address
1233 75: Call add_margin_impl<Ty0>(&mut Perpetual, &mut Bank<Ty0>, u128, address, u128, address)
1234 76: Ret
1235}
1236
1237add_margin_impl<Ty0>(Arg0: &mut Perpetual, Arg1: &mut Bank<Ty0>, Arg2: u128, Arg3: address, Arg4: u128, Arg5: address) {
1238L6: loc0: &mut Position
1239L7: loc1: u128
1240L8: loc2: u128
1241L9: loc3: u128
1242L10: loc4: address
1243L11: loc5: u128
1244B0:
1245 0: CopyLoc[0](Arg0: &mut Perpetual)
1246 1: FreezeRef
1247 2: Call perpetual::delisted(&Perpetual): bool
1248 3: Not
1249 4: BrFalse(6)
1250B1:
1251 5: Branch(12)
1252B2:
1253 6: MoveLoc[0](Arg0: &mut Perpetual)
1254 7: Pop
1255 8: MoveLoc[1](Arg1: &mut Bank<Ty0>)
1256 9: Pop
1257 10: LdU64(61)
1258 11: Abort
1259B3:
1260 12: CopyLoc[4](Arg4: u128)
1261 13: LdU128(0)
1262 14: Gt
1263 15: BrFalse(17)
1264B4:
1265 16: Branch(23)
1266B5:
1267 17: MoveLoc[0](Arg0: &mut Perpetual)
1268 18: Pop
1269 19: MoveLoc[1](Arg1: &mut Bank<Ty0>)
1270 20: Pop
1271 21: LdU64(500)
1272 22: Abort
1273B6:
1274 23: CopyLoc[0](Arg0: &mut Perpetual)
1275 24: Call perpetual::positions(&mut Perpetual): &mut Table<address, Position>
1276 25: FreezeRef
1277 26: CopyLoc[3](Arg3: address)
1278 27: Call table::contains<address, Position>(&Table<address, Position>, address): bool
1279 28: BrFalse(30)
1280B7:
1281 29: Branch(36)
1282B8:
1283 30: MoveLoc[0](Arg0: &mut Perpetual)
1284 31: Pop
1285 32: MoveLoc[1](Arg1: &mut Bank<Ty0>)
1286 33: Pop
1287 34: LdU64(507)
1288 35: Abort
1289B9:
1290 36: CopyLoc[0](Arg0: &mut Perpetual)
1291 37: FreezeRef
1292 38: Call perpetual::perp_address(&Perpetual): address
1293 39: StLoc[10](loc4: address)
1294 40: CopyLoc[1](Arg1: &mut Bank<Ty0>)
1295 41: FreezeRef
1296 42: CopyLoc[0](Arg0: &mut Perpetual)
1297 43: FreezeRef
1298 44: CopyLoc[3](Arg3: address)
1299 45: Call option::none<address>(): Option<address>
1300 46: Call sum_transaction_balance<Ty0>(&Bank<Ty0>, &Perpetual, address, Option<address>): u128
1301 47: StLoc[8](loc2: u128)
1302 48: CopyLoc[0](Arg0: &mut Perpetual)
1303 49: Call perpetual::positions(&mut Perpetual): &mut Table<address, Position>
1304 50: CopyLoc[3](Arg3: address)
1305 51: Call table::borrow_mut<address, Position>(&mut Table<address, Position>, address): &mut Position
1306 52: StLoc[6](loc0: &mut Position)
1307 53: CopyLoc[6](loc0: &mut Position)
1308 54: FreezeRef
1309 55: Call position::size(&Position): u128
1310 56: StLoc[11](loc5: u128)
1311 57: CopyLoc[6](loc0: &mut Position)
1312 58: FreezeRef
1313 59: Call position::margin(&Position): u128
1314 60: StLoc[9](loc3: u128)
1315 61: MoveLoc[11](loc5: u128)
1316 62: LdU128(0)
1317 63: Gt
1318 64: BrFalse(66)
1319B10:
1320 65: Branch(74)
1321B11:
1322 66: MoveLoc[0](Arg0: &mut Perpetual)
1323 67: Pop
1324 68: MoveLoc[1](Arg1: &mut Bank<Ty0>)
1325 69: Pop
1326 70: MoveLoc[6](loc0: &mut Position)
1327 71: Pop
1328 72: LdU64(512)
1329 73: Abort
1330B12:
1331 74: CopyLoc[1](Arg1: &mut Bank<Ty0>)
1332 75: CopyLoc[3](Arg3: address)
1333 76: MoveLoc[10](loc4: address)
1334 77: CopyLoc[4](Arg4: u128)
1335 78: LdU64(3)
1336 79: CopyLoc[2](Arg2: u128)
1337 80: Call bank::transfer<Ty0>(&mut Bank<Ty0>, address, address, u128, u64, u128)
1338 81: MoveLoc[6](loc0: &mut Position)
1339 82: MoveLoc[9](loc3: u128)
1340 83: MoveLoc[4](Arg4: u128)
1341 84: Add
1342 85: Call position::set_margin(&mut Position, u128)
1343 86: CopyLoc[2](Arg2: u128)
1344 87: CopyLoc[1](Arg1: &mut Bank<Ty0>)
1345 88: CopyLoc[0](Arg0: &mut Perpetual)
1346 89: CopyLoc[3](Arg3: address)
1347 90: LdU8(0)
1348 91: LdU64(2)
1349 92: Call apply_funding_rate<Ty0>(u128, &mut Bank<Ty0>, &mut Perpetual, address, u8, u64)
1350 93: MoveLoc[1](Arg1: &mut Bank<Ty0>)
1351 94: FreezeRef
1352 95: CopyLoc[0](Arg0: &mut Perpetual)
1353 96: FreezeRef
1354 97: CopyLoc[3](Arg3: address)
1355 98: Call option::none<address>(): Option<address>
1356 99: Call sum_transaction_balance<Ty0>(&Bank<Ty0>, &Perpetual, address, Option<address>): u128
1357 100: StLoc[7](loc1: u128)
1358 101: MoveLoc[8](loc2: u128)
1359 102: MoveLoc[7](loc1: u128)
1360 103: Eq
1361 104: BrFalse(106)
1362B13:
1363 105: Branch(110)
1364B14:
1365 106: MoveLoc[0](Arg0: &mut Perpetual)
1366 107: Pop
1367 108: LdU64(99989)
1368 109: Abort
1369B15:
1370 110: MoveLoc[0](Arg0: &mut Perpetual)
1371 111: Call perpetual::positions(&mut Perpetual): &mut Table<address, Position>
1372 112: FreezeRef
1373 113: MoveLoc[3](Arg3: address)
1374 114: Call table::borrow<address, Position>(&Table<address, Position>, address): &Position
1375 115: ReadRef
1376 116: MoveLoc[5](Arg5: address)
1377 117: LdConst[0](u8: 1)
1378 118: MoveLoc[2](Arg2: u128)
1379 119: Call position::emit_position_update_event(Position, address, u8, u128)
1380 120: Ret
1381}
1382
1383public remove_margin<Ty0>(Arg0: &ProtocolConfig, Arg1: &Clock, Arg2: &mut Perpetual, Arg3: &mut Bank<Ty0>, Arg4: &SubAccounts, Arg5: &mut TxIndexer, Arg6: &PriceInfoObject, Arg7: address, Arg8: u128, Arg9: vector<u8>, Arg10: &TxContext) {
1384B0:
1385 0: LdU64(999)
1386 1: Abort
1387}
1388
1389public remove_margin_v2<Ty0>(Arg0: &ProtocolConfig, Arg1: &Clock, Arg2: &mut Perpetual, Arg3: &mut Bank<Ty0>, Arg4: &SubAccounts, Arg5: &mut TxIndexer, Arg6: &PriceInfoObject, Arg7: address, Arg8: u128, Arg9: &TxContext) {
1390B0:
1391 0: LdU64(999)
1392 1: Abort
1393}
1394
1395public remove_margin_v3<Ty0>(Arg0: &ProtocolConfig, Arg1: &Clock, Arg2: &mut Perpetual, Arg3: &mut Bank<Ty0>, Arg4: &SubAccounts, Arg5: &mut TxIndexer, Arg6: &PriceFeed, Arg7: address, Arg8: u128, Arg9: &TxContext) {
1396B0:
1397 0: LdU64(999)
1398 1: Abort
1399}
1400
1401public remove_margin_v4<Ty0>(Arg0: &ProtocolConfig, Arg1: &Clock, Arg2: &mut Perpetual, Arg3: &mut Bank<Ty0>, Arg4: &SubAccounts, Arg5: &mut TxIndexer, Arg6: &PriceFeed, Arg7: vector<u8>, Arg8: u128, Arg9: u128, Arg10: u64, Arg11: vector<u8>, Arg12: vector<u8>, Arg13: &TxContext) {
1402L14: loc0: u64
1403L15: loc1: &Clock
1404L16: loc2: vector<u8>
1405L17: loc3: vector<u8>
1406L18: loc4: vector<u8>
1407L19: loc5: &UnifiedAddress
1408L20: loc6: &SubAccounts
1409L21: loc7: UnifiedAddress
1410L22: loc8: vector<u8>
1411L23: loc9: u128
1412L24: loc10: UnifiedAddress
1413B0:
1414 0: CopyLoc[0](Arg0: &ProtocolConfig)
1415 1: Call protocol::check_basic(&ProtocolConfig)
1416 2: CopyLoc[1](Arg1: &Clock)
1417 3: StLoc[15](loc1: &Clock)
1418 4: CopyLoc[10](Arg10: u64)
1419 5: StLoc[14](loc0: u64)
1420 6: MoveLoc[15](loc1: &Clock)
1421 7: MoveLoc[14](loc0: u64)
1422 8: LdU64(34)
1423 9: Call signature::assert_signed_payload_fresh(&Clock, u64, u64)
1424 10: CopyLoc[2](Arg2: &mut Perpetual)
1425 11: MoveLoc[6](Arg6: &PriceFeed)
1426 12: MoveLoc[1](Arg1: &Clock)
1427 13: Call perpetual::update_oracle_price_v2(&mut Perpetual, &PriceFeed, &Clock)
1428 14: MoveLoc[7](Arg7: vector<u8>)
1429 15: Call unified_address::from_tagged_bytes(vector<u8>): UnifiedAddress
1430 16: StLoc[24](loc10: UnifiedAddress)
1431 17: CopyLoc[0](Arg0: &ProtocolConfig)
1432 18: CopyLoc[4](Arg4: &SubAccounts)
1433 19: ImmBorrowLoc[24](loc10: UnifiedAddress)
1434 20: CopyLoc[13](Arg13: &TxContext)
1435 21: Call sub_accounts::assert_signed_action_sender_authorized(&ProtocolConfig, &SubAccounts, &UnifiedAddress, &TxContext)
1436 22: CopyLoc[2](Arg2: &mut Perpetual)
1437 23: FreezeRef
1438 24: Call perpetual::perp_address(&Perpetual): address
1439 25: CopyLoc[24](loc10: UnifiedAddress)
1440 26: CopyLoc[8](Arg8: u128)
1441 27: MoveLoc[9](Arg9: u128)
1442 28: MoveLoc[10](Arg10: u64)
1443 29: Call payload::remove_margin(address, UnifiedAddress, u128, u128, u64): vector<u8>
1444 30: StLoc[22](loc8: vector<u8>)
1445 31: MoveLoc[4](Arg4: &SubAccounts)
1446 32: StLoc[20](loc6: &SubAccounts)
1447 33: ImmBorrowLoc[24](loc10: UnifiedAddress)
1448 34: StLoc[19](loc5: &UnifiedAddress)
1449 35: CopyLoc[22](loc8: vector<u8>)
1450 36: StLoc[18](loc4: vector<u8>)
1451 37: MoveLoc[11](Arg11: vector<u8>)
1452 38: StLoc[17](loc3: vector<u8>)
1453 39: MoveLoc[12](Arg12: vector<u8>)
1454 40: StLoc[16](loc2: vector<u8>)
1455 41: MoveLoc[20](loc6: &SubAccounts)
1456 42: MoveLoc[19](loc5: &UnifiedAddress)
1457 43: MoveLoc[18](loc4: vector<u8>)
1458 44: MoveLoc[17](loc3: vector<u8>)
1459 45: MoveLoc[16](loc2: vector<u8>)
1460 46: LdU64(52)
1461 47: Call verify_user_signature(&SubAccounts, &UnifiedAddress, vector<u8>, vector<u8>, vector<u8>, u64): UnifiedAddress
1462 48: StLoc[21](loc7: UnifiedAddress)
1463 49: MoveLoc[5](Arg5: &mut TxIndexer)
1464 50: MoveLoc[22](loc8: vector<u8>)
1465 51: Call library::get_hash(vector<u8>): vector<u8>
1466 52: Call sub_accounts::validate_unique_tx(&mut TxIndexer, vector<u8>): u128
1467 53: StLoc[23](loc9: u128)
1468 54: MoveLoc[8](Arg8: u128)
1469 55: Call library::base_uint(): u128
1470 56: Div
1471 57: StLoc[8](Arg8: u128)
1472 58: CopyLoc[3](Arg3: &mut Bank<Ty0>)
1473 59: MoveLoc[0](Arg0: &ProtocolConfig)
1474 60: ImmBorrowLoc[24](loc10: UnifiedAddress)
1475 61: Call unified_address::identifier(&UnifiedAddress): address
1476 62: LdConst[7](vector<u8>: "Rem..)
1477 63: Call string::utf8(vector<u8>): String
1478 64: CopyLoc[23](loc9: u128)
1479 65: MoveLoc[13](Arg13: &TxContext)
1480 66: Call bank::charge_relayer_gas_fee<Ty0>(&mut Bank<Ty0>, &ProtocolConfig, address, String, u128, &TxContext)
1481 67: MoveLoc[2](Arg2: &mut Perpetual)
1482 68: MoveLoc[3](Arg3: &mut Bank<Ty0>)
1483 69: MoveLoc[23](loc9: u128)
1484 70: ImmBorrowLoc[24](loc10: UnifiedAddress)
1485 71: Call unified_address::identifier(&UnifiedAddress): address
1486 72: MoveLoc[8](Arg8: u128)
1487 73: ImmBorrowLoc[21](loc7: UnifiedAddress)
1488 74: Call unified_address::identifier(&UnifiedAddress): address
1489 75: Call remove_margin_impl<Ty0>(&mut Perpetual, &mut Bank<Ty0>, u128, address, u128, address)
1490 76: Ret
1491}
1492
1493remove_margin_impl<Ty0>(Arg0: &mut Perpetual, Arg1: &mut Bank<Ty0>, Arg2: u128, Arg3: address, Arg4: u128, Arg5: address) {
1494L6: loc0: &mut Position
1495L7: loc1: Position
1496L8: loc2: u128
1497L9: loc3: Position
1498L10: loc4: u128
1499L11: loc5: u128
1500L12: loc6: u128
1501L13: loc7: address
1502L14: loc8: u128
1503L15: loc9: u128
1504B0:
1505 0: CopyLoc[0](Arg0: &mut Perpetual)
1506 1: FreezeRef
1507 2: Call perpetual::delisted(&Perpetual): bool
1508 3: Not
1509 4: BrFalse(6)
1510B1:
1511 5: Branch(12)
1512B2:
1513 6: MoveLoc[0](Arg0: &mut Perpetual)
1514 7: Pop
1515 8: MoveLoc[1](Arg1: &mut Bank<Ty0>)
1516 9: Pop
1517 10: LdU64(61)
1518 11: Abort
1519B3:
1520 12: CopyLoc[4](Arg4: u128)
1521 13: LdU128(0)
1522 14: Gt
1523 15: BrFalse(17)
1524B4:
1525 16: Branch(23)
1526B5:
1527 17: MoveLoc[0](Arg0: &mut Perpetual)
1528 18: Pop
1529 19: MoveLoc[1](Arg1: &mut Bank<Ty0>)
1530 20: Pop
1531 21: LdU64(500)
1532 22: Abort
1533B6:
1534 23: CopyLoc[0](Arg0: &mut Perpetual)
1535 24: FreezeRef
1536 25: Call perpetual::price_oracle(&Perpetual): u128
1537 26: StLoc[14](loc8: u128)
1538 27: CopyLoc[0](Arg0: &mut Perpetual)
1539 28: Call perpetual::positions(&mut Perpetual): &mut Table<address, Position>
1540 29: FreezeRef
1541 30: CopyLoc[3](Arg3: address)
1542 31: Call table::contains<address, Position>(&Table<address, Position>, address): bool
1543 32: BrFalse(34)
1544B7:
1545 33: Branch(40)
1546B8:
1547 34: MoveLoc[0](Arg0: &mut Perpetual)
1548 35: Pop
1549 36: MoveLoc[1](Arg1: &mut Bank<Ty0>)
1550 37: Pop
1551 38: LdU64(507)
1552 39: Abort
1553B9:
1554 40: CopyLoc[0](Arg0: &mut Perpetual)
1555 41: FreezeRef
1556 42: Call perpetual::perp_address(&Perpetual): address
1557 43: StLoc[13](loc7: address)
1558 44: CopyLoc[1](Arg1: &mut Bank<Ty0>)
1559 45: FreezeRef
1560 46: CopyLoc[0](Arg0: &mut Perpetual)
1561 47: FreezeRef
1562 48: CopyLoc[3](Arg3: address)
1563 49: Call option::none<address>(): Option<address>
1564 50: Call sum_transaction_balance<Ty0>(&Bank<Ty0>, &Perpetual, address, Option<address>): u128
1565 51: StLoc[10](loc4: u128)
1566 52: CopyLoc[0](Arg0: &mut Perpetual)
1567 53: Call perpetual::positions(&mut Perpetual): &mut Table<address, Position>
1568 54: FreezeRef
1569 55: CopyLoc[3](Arg3: address)
1570 56: Call table::borrow<address, Position>(&Table<address, Position>, address): &Position
1571 57: ReadRef
1572 58: StLoc[9](loc3: Position)
1573 59: CopyLoc[0](Arg0: &mut Perpetual)
1574 60: Call perpetual::positions(&mut Perpetual): &mut Table<address, Position>
1575 61: CopyLoc[3](Arg3: address)
1576 62: Call table::borrow_mut<address, Position>(&mut Table<address, Position>, address): &mut Position
1577 63: StLoc[6](loc0: &mut Position)
1578 64: CopyLoc[6](loc0: &mut Position)
1579 65: FreezeRef
1580 66: Call position::size(&Position): u128
1581 67: StLoc[15](loc9: u128)
1582 68: CopyLoc[6](loc0: &mut Position)
1583 69: FreezeRef
1584 70: Call position::margin(&Position): u128
1585 71: StLoc[11](loc5: u128)
1586 72: MoveLoc[15](loc9: u128)
1587 73: LdU128(0)
1588 74: Gt
1589 75: BrFalse(77)
1590B10:
1591 76: Branch(85)
1592B11:
1593 77: MoveLoc[0](Arg0: &mut Perpetual)
1594 78: Pop
1595 79: MoveLoc[1](Arg1: &mut Bank<Ty0>)
1596 80: Pop
1597 81: MoveLoc[6](loc0: &mut Position)
1598 82: Pop
1599 83: LdU64(512)
1600 84: Abort
1601B12:
1602 85: CopyLoc[6](loc0: &mut Position)
1603 86: ReadRef
1604 87: CopyLoc[14](loc8: u128)
1605 88: Call settlement::get_max_removeable_margin(Position, u128): u128
1606 89: StLoc[12](loc6: u128)
1607 90: CopyLoc[4](Arg4: u128)
1608 91: MoveLoc[12](loc6: u128)
1609 92: Le
1610 93: BrFalse(95)
1611B13:
1612 94: Branch(103)
1613B14:
1614 95: MoveLoc[0](Arg0: &mut Perpetual)
1615 96: Pop
1616 97: MoveLoc[1](Arg1: &mut Bank<Ty0>)
1617 98: Pop
1618 99: MoveLoc[6](loc0: &mut Position)
1619 100: Pop
1620 101: LdU64(503)
1621 102: Abort
1622B15:
1623 103: CopyLoc[1](Arg1: &mut Bank<Ty0>)
1624 104: MoveLoc[13](loc7: address)
1625 105: CopyLoc[3](Arg3: address)
1626 106: CopyLoc[4](Arg4: u128)
1627 107: LdU64(2)
1628 108: CopyLoc[2](Arg2: u128)
1629 109: Call bank::transfer<Ty0>(&mut Bank<Ty0>, address, address, u128, u64, u128)
1630 110: MoveLoc[6](loc0: &mut Position)
1631 111: MoveLoc[11](loc5: u128)
1632 112: MoveLoc[4](Arg4: u128)
1633 113: Sub
1634 114: Call position::set_margin(&mut Position, u128)
1635 115: CopyLoc[2](Arg2: u128)
1636 116: CopyLoc[1](Arg1: &mut Bank<Ty0>)
1637 117: CopyLoc[0](Arg0: &mut Perpetual)
1638 118: CopyLoc[3](Arg3: address)
1639 119: LdU8(0)
1640 120: LdU64(2)
1641 121: Call apply_funding_rate<Ty0>(u128, &mut Bank<Ty0>, &mut Perpetual, address, u8, u64)
1642 122: CopyLoc[0](Arg0: &mut Perpetual)
1643 123: Call perpetual::positions(&mut Perpetual): &mut Table<address, Position>
1644 124: FreezeRef
1645 125: CopyLoc[3](Arg3: address)
1646 126: Call table::borrow<address, Position>(&Table<address, Position>, address): &Position
1647 127: ReadRef
1648 128: StLoc[7](loc1: Position)
1649 129: ImmBorrowLoc[9](loc3: Position)
1650 130: ImmBorrowLoc[7](loc1: Position)
1651 131: CopyLoc[0](Arg0: &mut Perpetual)
1652 132: FreezeRef
1653 133: Call perpetual::imr(&Perpetual): u128
1654 134: CopyLoc[0](Arg0: &mut Perpetual)
1655 135: FreezeRef
1656 136: Call perpetual::mmr(&Perpetual): u128
1657 137: MoveLoc[14](loc8: u128)
1658 138: LdU8(0)
1659 139: LdU64(0)
1660 140: Call position::verify_collat_checks(&Position, &Position, u128, u128, u128, u8, u64)
1661 141: MoveLoc[7](loc1: Position)
1662 142: MoveLoc[5](Arg5: address)
1663 143: LdConst[1](u8: 2)
1664 144: MoveLoc[2](Arg2: u128)
1665 145: Call position::emit_position_update_event(Position, address, u8, u128)
1666 146: MoveLoc[1](Arg1: &mut Bank<Ty0>)
1667 147: FreezeRef
1668 148: MoveLoc[0](Arg0: &mut Perpetual)
1669 149: FreezeRef
1670 150: MoveLoc[3](Arg3: address)
1671 151: Call option::none<address>(): Option<address>
1672 152: Call sum_transaction_balance<Ty0>(&Bank<Ty0>, &Perpetual, address, Option<address>): u128
1673 153: StLoc[8](loc2: u128)
1674 154: MoveLoc[10](loc4: u128)
1675 155: MoveLoc[8](loc2: u128)
1676 156: Eq
1677 157: BrFalse(159)
1678B16:
1679 158: Branch(161)
1680B17:
1681 159: LdU64(99989)
1682 160: Abort
1683B18:
1684 161: Ret
1685}
1686
1687public adjust_leverage<Ty0>(Arg0: &ProtocolConfig, Arg1: &Clock, Arg2: &mut Perpetual, Arg3: &mut Bank<Ty0>, Arg4: &SubAccounts, Arg5: &mut TxIndexer, Arg6: &PriceInfoObject, Arg7: address, Arg8: u128, Arg9: vector<u8>, Arg10: &TxContext) {
1688B0:
1689 0: LdU64(999)
1690 1: Abort
1691}
1692
1693public adjust_leverage_v2<Ty0>(Arg0: &ProtocolConfig, Arg1: &Clock, Arg2: &mut Perpetual, Arg3: &mut Bank<Ty0>, Arg4: &SubAccounts, Arg5: &mut TxIndexer, Arg6: &PriceInfoObject, Arg7: address, Arg8: u128, Arg9: &TxContext) {
1694B0:
1695 0: LdU64(999)
1696 1: Abort
1697}
1698
1699public adjust_leverage_v3<Ty0>(Arg0: &ProtocolConfig, Arg1: &Clock, Arg2: &mut Perpetual, Arg3: &mut Bank<Ty0>, Arg4: &SubAccounts, Arg5: &mut TxIndexer, Arg6: &PriceFeed, Arg7: address, Arg8: u128, Arg9: &TxContext) {
1700B0:
1701 0: LdU64(999)
1702 1: Abort
1703}
1704
1705public adjust_leverage_v4<Ty0>(Arg0: &ProtocolConfig, Arg1: &Clock, Arg2: &mut Perpetual, Arg3: &mut Bank<Ty0>, Arg4: &SubAccounts, Arg5: &mut TxIndexer, Arg6: &PriceFeed, Arg7: vector<u8>, Arg8: u128, Arg9: u128, Arg10: u64, Arg11: vector<u8>, Arg12: vector<u8>, Arg13: &TxContext) {
1706L14: loc0: u64
1707L15: loc1: &Clock
1708L16: loc2: vector<u8>
1709L17: loc3: vector<u8>
1710L18: loc4: vector<u8>
1711L19: loc5: &UnifiedAddress
1712L20: loc6: &SubAccounts
1713L21: loc7: UnifiedAddress
1714L22: loc8: vector<u8>
1715L23: loc9: u128
1716L24: loc10: UnifiedAddress
1717B0:
1718 0: CopyLoc[0](Arg0: &ProtocolConfig)
1719 1: Call protocol::check_basic(&ProtocolConfig)
1720 2: CopyLoc[1](Arg1: &Clock)
1721 3: StLoc[15](loc1: &Clock)
1722 4: CopyLoc[10](Arg10: u64)
1723 5: StLoc[14](loc0: u64)
1724 6: MoveLoc[15](loc1: &Clock)
1725 7: MoveLoc[14](loc0: u64)
1726 8: LdU64(34)
1727 9: Call signature::assert_signed_payload_fresh(&Clock, u64, u64)
1728 10: CopyLoc[2](Arg2: &mut Perpetual)
1729 11: MoveLoc[6](Arg6: &PriceFeed)
1730 12: MoveLoc[1](Arg1: &Clock)
1731 13: Call perpetual::update_oracle_price_v2(&mut Perpetual, &PriceFeed, &Clock)
1732 14: MoveLoc[7](Arg7: vector<u8>)
1733 15: Call unified_address::from_tagged_bytes(vector<u8>): UnifiedAddress
1734 16: StLoc[24](loc10: UnifiedAddress)
1735 17: CopyLoc[0](Arg0: &ProtocolConfig)
1736 18: CopyLoc[4](Arg4: &SubAccounts)
1737 19: ImmBorrowLoc[24](loc10: UnifiedAddress)
1738 20: CopyLoc[13](Arg13: &TxContext)
1739 21: Call sub_accounts::assert_signed_action_sender_authorized(&ProtocolConfig, &SubAccounts, &UnifiedAddress, &TxContext)
1740 22: CopyLoc[2](Arg2: &mut Perpetual)
1741 23: FreezeRef
1742 24: Call perpetual::perp_address(&Perpetual): address
1743 25: CopyLoc[24](loc10: UnifiedAddress)
1744 26: CopyLoc[8](Arg8: u128)
1745 27: MoveLoc[9](Arg9: u128)
1746 28: MoveLoc[10](Arg10: u64)
1747 29: Call payload::adjust_leverage(address, UnifiedAddress, u128, u128, u64): vector<u8>
1748 30: StLoc[22](loc8: vector<u8>)
1749 31: MoveLoc[4](Arg4: &SubAccounts)
1750 32: StLoc[20](loc6: &SubAccounts)
1751 33: ImmBorrowLoc[24](loc10: UnifiedAddress)
1752 34: StLoc[19](loc5: &UnifiedAddress)
1753 35: CopyLoc[22](loc8: vector<u8>)
1754 36: StLoc[18](loc4: vector<u8>)
1755 37: MoveLoc[11](Arg11: vector<u8>)
1756 38: StLoc[17](loc3: vector<u8>)
1757 39: MoveLoc[12](Arg12: vector<u8>)
1758 40: StLoc[16](loc2: vector<u8>)
1759 41: MoveLoc[20](loc6: &SubAccounts)
1760 42: MoveLoc[19](loc5: &UnifiedAddress)
1761 43: MoveLoc[18](loc4: vector<u8>)
1762 44: MoveLoc[17](loc3: vector<u8>)
1763 45: MoveLoc[16](loc2: vector<u8>)
1764 46: LdU64(52)
1765 47: Call verify_user_signature(&SubAccounts, &UnifiedAddress, vector<u8>, vector<u8>, vector<u8>, u64): UnifiedAddress
1766 48: StLoc[21](loc7: UnifiedAddress)
1767 49: MoveLoc[5](Arg5: &mut TxIndexer)
1768 50: MoveLoc[22](loc8: vector<u8>)
1769 51: Call library::get_hash(vector<u8>): vector<u8>
1770 52: Call sub_accounts::validate_unique_tx(&mut TxIndexer, vector<u8>): u128
1771 53: StLoc[23](loc9: u128)
1772 54: MoveLoc[8](Arg8: u128)
1773 55: Call library::base_uint(): u128
1774 56: Div
1775 57: StLoc[8](Arg8: u128)
1776 58: CopyLoc[3](Arg3: &mut Bank<Ty0>)
1777 59: CopyLoc[0](Arg0: &ProtocolConfig)
1778 60: ImmBorrowLoc[24](loc10: UnifiedAddress)
1779 61: Call unified_address::identifier(&UnifiedAddress): address
1780 62: LdConst[8](vector<u8>: "Adj..)
1781 63: Call string::utf8(vector<u8>): String
1782 64: CopyLoc[23](loc9: u128)
1783 65: MoveLoc[13](Arg13: &TxContext)
1784 66: Call bank::charge_relayer_gas_fee<Ty0>(&mut Bank<Ty0>, &ProtocolConfig, address, String, u128, &TxContext)
1785 67: MoveLoc[0](Arg0: &ProtocolConfig)
1786 68: MoveLoc[2](Arg2: &mut Perpetual)
1787 69: MoveLoc[3](Arg3: &mut Bank<Ty0>)
1788 70: MoveLoc[23](loc9: u128)
1789 71: ImmBorrowLoc[24](loc10: UnifiedAddress)
1790 72: Call unified_address::identifier(&UnifiedAddress): address
1791 73: MoveLoc[8](Arg8: u128)
1792 74: ImmBorrowLoc[21](loc7: UnifiedAddress)
1793 75: Call unified_address::identifier(&UnifiedAddress): address
1794 76: Call adjust_leverage_impl<Ty0>(&ProtocolConfig, &mut Perpetual, &mut Bank<Ty0>, u128, address, u128, address)
1795 77: Ret
1796}
1797
1798adjust_leverage_impl<Ty0>(Arg0: &ProtocolConfig, Arg1: &mut Perpetual, Arg2: &mut Bank<Ty0>, Arg3: u128, Arg4: address, Arg5: u128, Arg6: address) {
1799L7: loc0: &mut Position
1800L8: loc1: Position
1801L9: loc2: u128
1802L10: loc3: Position
1803L11: loc4: u128
1804L12: loc5: u128
1805L13: loc6: address
1806L14: loc7: u128
1807L15: loc8: u128
1808L16: loc9: TradeChecks
1809B0:
1810 0: CopyLoc[1](Arg1: &mut Perpetual)
1811 1: FreezeRef
1812 2: Call perpetual::delisted(&Perpetual): bool
1813 3: Not
1814 4: BrFalse(6)
1815B1:
1816 5: Branch(14)
1817B2:
1818 6: MoveLoc[1](Arg1: &mut Perpetual)
1819 7: Pop
1820 8: MoveLoc[0](Arg0: &ProtocolConfig)
1821 9: Pop
1822 10: MoveLoc[2](Arg2: &mut Bank<Ty0>)
1823 11: Pop
1824 12: LdU64(61)
1825 13: Abort
1826B3:
1827 14: MoveLoc[5](Arg5: u128)
1828 15: Call library::round_down(u128): u128
1829 16: StLoc[5](Arg5: u128)
1830 17: CopyLoc[5](Arg5: u128)
1831 18: LdU128(0)
1832 19: Gt
1833 20: BrFalse(22)
1834B4:
1835 21: Branch(30)
1836B5:
1837 22: MoveLoc[1](Arg1: &mut Perpetual)
1838 23: Pop
1839 24: MoveLoc[0](Arg0: &ProtocolConfig)
1840 25: Pop
1841 26: MoveLoc[2](Arg2: &mut Bank<Ty0>)
1842 27: Pop
1843 28: LdU64(504)
1844 29: Abort
1845B6:
1846 30: CopyLoc[1](Arg1: &mut Perpetual)
1847 31: FreezeRef
1848 32: Call perpetual::price_oracle(&Perpetual): u128
1849 33: StLoc[14](loc7: u128)
1850 34: CopyLoc[1](Arg1: &mut Perpetual)
1851 35: FreezeRef
1852 36: Call perpetual::checks(&Perpetual): TradeChecks
1853 37: StLoc[16](loc9: TradeChecks)
1854 38: CopyLoc[1](Arg1: &mut Perpetual)
1855 39: FreezeRef
1856 40: Call perpetual::perp_address(&Perpetual): address
1857 41: StLoc[13](loc6: address)
1858 42: CopyLoc[1](Arg1: &mut Perpetual)
1859 43: Call perpetual::positions(&mut Perpetual): &mut Table<address, Position>
1860 44: FreezeRef
1861 45: CopyLoc[4](Arg4: address)
1862 46: Call table::contains<address, Position>(&Table<address, Position>, address): bool
1863 47: BrFalse(49)
1864B7:
1865 48: Branch(57)
1866B8:
1867 49: MoveLoc[1](Arg1: &mut Perpetual)
1868 50: Pop
1869 51: MoveLoc[0](Arg0: &ProtocolConfig)
1870 52: Pop
1871 53: MoveLoc[2](Arg2: &mut Bank<Ty0>)
1872 54: Pop
1873 55: LdU64(507)
1874 56: Abort
1875B9:
1876 57: CopyLoc[2](Arg2: &mut Bank<Ty0>)
1877 58: FreezeRef
1878 59: CopyLoc[1](Arg1: &mut Perpetual)
1879 60: FreezeRef
1880 61: CopyLoc[4](Arg4: address)
1881 62: Call option::none<address>(): Option<address>
1882 63: Call sum_transaction_balance<Ty0>(&Bank<Ty0>, &Perpetual, address, Option<address>): u128
1883 64: StLoc[11](loc4: u128)
1884 65: CopyLoc[3](Arg3: u128)
1885 66: CopyLoc[2](Arg2: &mut Bank<Ty0>)
1886 67: CopyLoc[1](Arg1: &mut Perpetual)
1887 68: CopyLoc[4](Arg4: address)
1888 69: LdU8(0)
1889 70: LdU64(2)
1890 71: Call apply_funding_rate<Ty0>(u128, &mut Bank<Ty0>, &mut Perpetual, address, u8, u64)
1891 72: CopyLoc[1](Arg1: &mut Perpetual)
1892 73: Call perpetual::positions(&mut Perpetual): &mut Table<address, Position>
1893 74: FreezeRef
1894 75: CopyLoc[4](Arg4: address)
1895 76: Call table::borrow<address, Position>(&Table<address, Position>, address): &Position
1896 77: ReadRef
1897 78: StLoc[10](loc3: Position)
1898 79: CopyLoc[1](Arg1: &mut Perpetual)
1899 80: Call perpetual::positions(&mut Perpetual): &mut Table<address, Position>
1900 81: CopyLoc[4](Arg4: address)
1901 82: Call table::borrow_mut<address, Position>(&mut Table<address, Position>, address): &mut Position
1902 83: StLoc[7](loc0: &mut Position)
1903 84: CopyLoc[7](loc0: &mut Position)
1904 85: FreezeRef
1905 86: Call position::margin(&Position): u128
1906 87: StLoc[12](loc5: u128)
1907 88: CopyLoc[7](loc0: &mut Position)
1908 89: FreezeRef
1909 90: CopyLoc[5](Arg5: u128)
1910 91: CopyLoc[14](loc7: u128)
1911 92: Call settlement::get_target_margin(&Position, u128, u128): u128
1912 93: StLoc[15](loc8: u128)
1913 94: CopyLoc[12](loc5: u128)
1914 95: CopyLoc[15](loc8: u128)
1915 96: Gt
1916 97: BrFalse(108)
1917B10:
1918 98: CopyLoc[2](Arg2: &mut Bank<Ty0>)
1919 99: MoveLoc[13](loc6: address)
1920 100: CopyLoc[4](Arg4: address)
1921 101: MoveLoc[12](loc5: u128)
1922 102: CopyLoc[15](loc8: u128)
1923 103: Sub
1924 104: LdU64(2)
1925 105: CopyLoc[3](Arg3: u128)
1926 106: Call bank::transfer<Ty0>(&mut Bank<Ty0>, address, address, u128, u64, u128)
1927 107: Branch(121)
1928B11:
1929 108: CopyLoc[12](loc5: u128)
1930 109: CopyLoc[15](loc8: u128)
1931 110: Lt
1932 111: BrFalse(121)
1933B12:
1934 112: CopyLoc[2](Arg2: &mut Bank<Ty0>)
1935 113: CopyLoc[4](Arg4: address)
1936 114: MoveLoc[13](loc6: address)
1937 115: CopyLoc[15](loc8: u128)
1938 116: MoveLoc[12](loc5: u128)
1939 117: Sub
1940 118: LdU64(3)
1941 119: CopyLoc[3](Arg3: u128)
1942 120: Call bank::transfer<Ty0>(&mut Bank<Ty0>, address, address, u128, u64, u128)
1943B13:
1944 121: CopyLoc[7](loc0: &mut Position)
1945 122: Call library::base_uint(): u128
1946 123: MoveLoc[5](Arg5: u128)
1947 124: Call library::base_div(u128, u128): u128
1948 125: Call position::set_mro(&mut Position, u128)
1949 126: CopyLoc[7](loc0: &mut Position)
1950 127: MoveLoc[15](loc8: u128)
1951 128: Call position::set_margin(&mut Position, u128)
1952 129: MoveLoc[16](loc9: TradeChecks)
1953 130: CopyLoc[7](loc0: &mut Position)
1954 131: FreezeRef
1955 132: Call position::mro(&Position): u128
1956 133: MoveLoc[7](loc0: &mut Position)
1957 134: FreezeRef
1958 135: Call position::oi_open(&Position): u128
1959 136: LdU64(0)
1960 137: MoveLoc[0](Arg0: &ProtocolConfig)
1961 138: Call protocol::privileged_addresses(&ProtocolConfig): &VecSet<address>
1962 139: ImmBorrowLoc[4](Arg4: address)
1963 140: Call vec_set::contains<address>(&VecSet<address>, &address): bool
1964 141: Call evaluator::verify_oi_open_for_account(TradeChecks, u128, u128, u64, bool)
1965 142: CopyLoc[1](Arg1: &mut Perpetual)
1966 143: Call perpetual::positions(&mut Perpetual): &mut Table<address, Position>
1967 144: FreezeRef
1968 145: CopyLoc[4](Arg4: address)
1969 146: Call table::borrow<address, Position>(&Table<address, Position>, address): &Position
1970 147: ReadRef
1971 148: StLoc[8](loc1: Position)
1972 149: ImmBorrowLoc[10](loc3: Position)
1973 150: ImmBorrowLoc[8](loc1: Position)
1974 151: CopyLoc[1](Arg1: &mut Perpetual)
1975 152: FreezeRef
1976 153: Call perpetual::imr(&Perpetual): u128
1977 154: CopyLoc[1](Arg1: &mut Perpetual)
1978 155: FreezeRef
1979 156: Call perpetual::mmr(&Perpetual): u128
1980 157: MoveLoc[14](loc7: u128)
1981 158: LdU8(0)
1982 159: LdU64(0)
1983 160: Call position::verify_collat_checks(&Position, &Position, u128, u128, u128, u8, u64)
1984 161: MoveLoc[8](loc1: Position)
1985 162: MoveLoc[6](Arg6: address)
1986 163: LdConst[2](u8: 3)
1987 164: MoveLoc[3](Arg3: u128)
1988 165: Call position::emit_position_update_event(Position, address, u8, u128)
1989 166: MoveLoc[2](Arg2: &mut Bank<Ty0>)
1990 167: FreezeRef
1991 168: MoveLoc[1](Arg1: &mut Perpetual)
1992 169: FreezeRef
1993 170: MoveLoc[4](Arg4: address)
1994 171: Call option::none<address>(): Option<address>
1995 172: Call sum_transaction_balance<Ty0>(&Bank<Ty0>, &Perpetual, address, Option<address>): u128
1996 173: StLoc[9](loc2: u128)
1997 174: MoveLoc[11](loc4: u128)
1998 175: MoveLoc[9](loc2: u128)
1999 176: Eq
2000 177: BrFalse(179)
2001B14:
2002 178: Branch(181)
2003B15:
2004 179: LdU64(99989)
2005 180: Abort
2006B16:
2007 181: Ret
2008}
2009
2010entry cancel_order<Ty0>(Arg0: &ProtocolConfig, Arg1: &mut Bank<Ty0>, Arg2: &SubAccounts, Arg3: &mut TxIndexer, Arg4: &mut Table<vector<u8>, OrderStatus>, Arg5: address, Arg6: u8, Arg7: u128, Arg8: u128, Arg9: u128, Arg10: u64, Arg11: u128, Arg12: vector<u8>, Arg13: u128, Arg14: u64, Arg15: vector<u8>, Arg16: vector<u8>, Arg17: &Clock, Arg18: &TxContext) {
2011L19: loc0: u64
2012L20: loc1: &Clock
2013L21: loc2: vector<u8>
2014L22: loc3: vector<u8>
2015L23: loc4: vector<u8>
2016L24: loc5: &UnifiedAddress
2017L25: loc6: &SubAccounts
2018L26: loc7: address
2019L27: loc8: UnifiedAddress
2020L28: loc9: vector<u8>
2021L29: loc10: UnifiedAddress
2022L30: loc11: vector<u8>
2023L31: loc12: u128
2024B0:
2025 0: CopyLoc[0](Arg0: &ProtocolConfig)
2026 1: Call protocol::check_basic(&ProtocolConfig)
2027 2: MoveLoc[17](Arg17: &Clock)
2028 3: StLoc[20](loc1: &Clock)
2029 4: CopyLoc[14](Arg14: u64)
2030 5: StLoc[19](loc0: u64)
2031 6: MoveLoc[20](loc1: &Clock)
2032 7: MoveLoc[19](loc0: u64)
2033 8: LdU64(34)
2034 9: Call signature::assert_signed_payload_fresh(&Clock, u64, u64)
2035 10: MoveLoc[12](Arg12: vector<u8>)
2036 11: Call unified_address::from_tagged_bytes(vector<u8>): UnifiedAddress
2037 12: StLoc[27](loc8: UnifiedAddress)
2038 13: CopyLoc[0](Arg0: &ProtocolConfig)
2039 14: CopyLoc[2](Arg2: &SubAccounts)
2040 15: ImmBorrowLoc[27](loc8: UnifiedAddress)
2041 16: CopyLoc[18](Arg18: &TxContext)
2042 17: Call sub_accounts::assert_signed_action_sender_authorized(&ProtocolConfig, &SubAccounts, &UnifiedAddress, &TxContext)
2043 18: CopyLoc[5](Arg5: address)
2044 19: CopyLoc[27](loc8: UnifiedAddress)
2045 20: CopyLoc[6](Arg6: u8)
2046 21: CopyLoc[7](Arg7: u128)
2047 22: CopyLoc[8](Arg8: u128)
2048 23: CopyLoc[9](Arg9: u128)
2049 24: CopyLoc[10](Arg10: u64)
2050 25: CopyLoc[11](Arg11: u128)
2051 26: MoveLoc[13](Arg13: u128)
2052 27: MoveLoc[14](Arg14: u64)
2053 28: Call payload::cancel_order(address, UnifiedAddress, u8, u128, u128, u128, u64, u128, u128, u64): vector<u8>
2054 29: StLoc[30](loc11: vector<u8>)
2055 30: MoveLoc[2](Arg2: &SubAccounts)
2056 31: StLoc[25](loc6: &SubAccounts)
2057 32: ImmBorrowLoc[27](loc8: UnifiedAddress)
2058 33: StLoc[24](loc5: &UnifiedAddress)
2059 34: CopyLoc[30](loc11: vector<u8>)
2060 35: StLoc[23](loc4: vector<u8>)
2061 36: MoveLoc[15](Arg15: vector<u8>)
2062 37: StLoc[22](loc3: vector<u8>)
2063 38: MoveLoc[16](Arg16: vector<u8>)
2064 39: StLoc[21](loc2: vector<u8>)
2065 40: MoveLoc[25](loc6: &SubAccounts)
2066 41: MoveLoc[24](loc5: &UnifiedAddress)
2067 42: MoveLoc[23](loc4: vector<u8>)
2068 43: MoveLoc[22](loc3: vector<u8>)
2069 44: MoveLoc[21](loc2: vector<u8>)
2070 45: LdU64(52)
2071 46: Call verify_user_signature(&SubAccounts, &UnifiedAddress, vector<u8>, vector<u8>, vector<u8>, u64): UnifiedAddress
2072 47: StLoc[29](loc10: UnifiedAddress)
2073 48: MoveLoc[3](Arg3: &mut TxIndexer)
2074 49: MoveLoc[30](loc11: vector<u8>)
2075 50: Call library::get_hash(vector<u8>): vector<u8>
2076 51: Call sub_accounts::validate_unique_tx(&mut TxIndexer, vector<u8>): u128
2077 52: StLoc[31](loc12: u128)
2078 53: MoveLoc[1](Arg1: &mut Bank<Ty0>)
2079 54: MoveLoc[0](Arg0: &ProtocolConfig)
2080 55: ImmBorrowLoc[27](loc8: UnifiedAddress)
2081 56: Call unified_address::identifier(&UnifiedAddress): address
2082 57: LdConst[9](vector<u8>: "Can..)
2083 58: Call string::utf8(vector<u8>): String
2084 59: CopyLoc[31](loc12: u128)
2085 60: MoveLoc[18](Arg18: &TxContext)
2086 61: Call bank::charge_relayer_gas_fee<Ty0>(&mut Bank<Ty0>, &ProtocolConfig, address, String, u128, &TxContext)
2087 62: CopyLoc[5](Arg5: address)
2088 63: MoveLoc[6](Arg6: u8)
2089 64: MoveLoc[7](Arg7: u128)
2090 65: MoveLoc[8](Arg8: u128)
2091 66: MoveLoc[9](Arg9: u128)
2092 67: MoveLoc[27](loc8: UnifiedAddress)
2093 68: MoveLoc[10](Arg10: u64)
2094 69: MoveLoc[11](Arg11: u128)
2095 70: Call order::pack_order(address, u8, u128, u128, u128, UnifiedAddress, u64, u128): OrderV2
2096 71: LdU32(2)
2097 72: Call order::to_json_bytes(OrderV2, u32): vector<u8>
2098 73: Call library::get_hash(vector<u8>): vector<u8>
2099 74: StLoc[28](loc9: vector<u8>)
2100 75: ImmBorrowLoc[29](loc10: UnifiedAddress)
2101 76: Call unified_address::identifier(&UnifiedAddress): address
2102 77: StLoc[26](loc7: address)
2103 78: MoveLoc[4](Arg4: &mut Table<vector<u8>, OrderStatus>)
2104 79: MoveLoc[28](loc9: vector<u8>)
2105 80: MoveLoc[5](Arg5: address)
2106 81: MoveLoc[26](loc7: address)
2107 82: MoveLoc[31](loc12: u128)
2108 83: Call order::cancel(&mut Table<vector<u8>, OrderStatus>, vector<u8>, address, address, u128)
2109 84: Ret
2110}
2111
2112entry close_position<Ty0>(Arg0: &ProtocolConfig, Arg1: &mut Perpetual, Arg2: &mut Bank<Ty0>, Arg3: &mut TxIndexer, Arg4: vector<u8>, Arg5: &TxContext) {
2113B0:
2114 0: LdU64(999)
2115 1: Abort
2116}
2117
2118entry close_position_v2<Ty0>(Arg0: &ProtocolConfig, Arg1: &mut Perpetual, Arg2: &mut Bank<Ty0>, Arg3: &mut TxIndexer, Arg4: &TxContext) {
2119B0:
2120 0: LdU64(999)
2121 1: Abort
2122}
2123
2124entry close_position_v3<Ty0>(Arg0: &ProtocolConfig, Arg1: &mut Perpetual, Arg2: &mut Bank<Ty0>, Arg3: &SubAccounts, Arg4: &mut TxIndexer, Arg5: &Clock, Arg6: vector<u8>, Arg7: u128, Arg8: u64, Arg9: vector<u8>, Arg10: vector<u8>, Arg11: &TxContext) {
2125L12: loc0: u64
2126L13: loc1: &Clock
2127L14: loc2: vector<u8>
2128L15: loc3: vector<u8>
2129L16: loc4: vector<u8>
2130L17: loc5: &UnifiedAddress
2131L18: loc6: &SubAccounts
2132L19: loc7: UnifiedAddress
2133L20: loc8: vector<u8>
2134L21: loc9: u128
2135L22: loc10: UnifiedAddress
2136B0:
2137 0: CopyLoc[0](Arg0: &ProtocolConfig)
2138 1: Call protocol::check_basic(&ProtocolConfig)
2139 2: MoveLoc[5](Arg5: &Clock)
2140 3: StLoc[13](loc1: &Clock)
2141 4: CopyLoc[8](Arg8: u64)
2142 5: StLoc[12](loc0: u64)
2143 6: MoveLoc[13](loc1: &Clock)
2144 7: MoveLoc[12](loc0: u64)
2145 8: LdU64(34)
2146 9: Call signature::assert_signed_payload_fresh(&Clock, u64, u64)
2147 10: MoveLoc[6](Arg6: vector<u8>)
2148 11: Call unified_address::from_tagged_bytes(vector<u8>): UnifiedAddress
2149 12: StLoc[22](loc10: UnifiedAddress)
2150 13: CopyLoc[0](Arg0: &ProtocolConfig)
2151 14: CopyLoc[3](Arg3: &SubAccounts)
2152 15: ImmBorrowLoc[22](loc10: UnifiedAddress)
2153 16: CopyLoc[11](Arg11: &TxContext)
2154 17: Call sub_accounts::assert_signed_action_sender_authorized(&ProtocolConfig, &SubAccounts, &UnifiedAddress, &TxContext)
2155 18: CopyLoc[1](Arg1: &mut Perpetual)
2156 19: FreezeRef
2157 20: Call perpetual::perp_address(&Perpetual): address
2158 21: CopyLoc[22](loc10: UnifiedAddress)
2159 22: MoveLoc[7](Arg7: u128)
2160 23: MoveLoc[8](Arg8: u64)
2161 24: Call payload::close_position(address, UnifiedAddress, u128, u64): vector<u8>
2162 25: StLoc[20](loc8: vector<u8>)
2163 26: MoveLoc[3](Arg3: &SubAccounts)
2164 27: StLoc[18](loc6: &SubAccounts)
2165 28: ImmBorrowLoc[22](loc10: UnifiedAddress)
2166 29: StLoc[17](loc5: &UnifiedAddress)
2167 30: CopyLoc[20](loc8: vector<u8>)
2168 31: StLoc[16](loc4: vector<u8>)
2169 32: MoveLoc[9](Arg9: vector<u8>)
2170 33: StLoc[15](loc3: vector<u8>)
2171 34: MoveLoc[10](Arg10: vector<u8>)
2172 35: StLoc[14](loc2: vector<u8>)
2173 36: MoveLoc[18](loc6: &SubAccounts)
2174 37: MoveLoc[17](loc5: &UnifiedAddress)
2175 38: MoveLoc[16](loc4: vector<u8>)
2176 39: MoveLoc[15](loc3: vector<u8>)
2177 40: MoveLoc[14](loc2: vector<u8>)
2178 41: LdU64(52)
2179 42: Call verify_user_signature(&SubAccounts, &UnifiedAddress, vector<u8>, vector<u8>, vector<u8>, u64): UnifiedAddress
2180 43: StLoc[19](loc7: UnifiedAddress)
2181 44: MoveLoc[4](Arg4: &mut TxIndexer)
2182 45: MoveLoc[20](loc8: vector<u8>)
2183 46: Call library::get_hash(vector<u8>): vector<u8>
2184 47: Call sub_accounts::validate_unique_tx(&mut TxIndexer, vector<u8>): u128
2185 48: StLoc[21](loc9: u128)
2186 49: CopyLoc[2](Arg2: &mut Bank<Ty0>)
2187 50: MoveLoc[0](Arg0: &ProtocolConfig)
2188 51: ImmBorrowLoc[22](loc10: UnifiedAddress)
2189 52: Call unified_address::identifier(&UnifiedAddress): address
2190 53: LdConst[10](vector<u8>: "Clo..)
2191 54: Call string::utf8(vector<u8>): String
2192 55: CopyLoc[21](loc9: u128)
2193 56: MoveLoc[11](Arg11: &TxContext)
2194 57: Call bank::charge_relayer_gas_fee<Ty0>(&mut Bank<Ty0>, &ProtocolConfig, address, String, u128, &TxContext)
2195 58: MoveLoc[1](Arg1: &mut Perpetual)
2196 59: MoveLoc[2](Arg2: &mut Bank<Ty0>)
2197 60: MoveLoc[21](loc9: u128)
2198 61: ImmBorrowLoc[22](loc10: UnifiedAddress)
2199 62: Call unified_address::identifier(&UnifiedAddress): address
2200 63: ImmBorrowLoc[19](loc7: UnifiedAddress)
2201 64: Call unified_address::identifier(&UnifiedAddress): address
2202 65: Call close_position_impl<Ty0>(&mut Perpetual, &mut Bank<Ty0>, u128, address, address)
2203 66: Ret
2204}
2205
2206close_position_impl<Ty0>(Arg0: &mut Perpetual, Arg1: &mut Bank<Ty0>, Arg2: u128, Arg3: address, Arg4: address) {
2207L5: loc0: u128
2208L6: loc1: u128
2209L7: loc2: u128
2210L8: loc3: u128
2211L9: loc4: address
2212L10: loc5: u128
2213L11: loc6: ID
2214L12: loc7: &mut Position
2215B0:
2216 0: CopyLoc[0](Arg0: &mut Perpetual)
2217 1: FreezeRef
2218 2: Call perpetual::delisted(&Perpetual): bool
2219 3: BrFalse(5)
2220B1:
2221 4: Branch(11)
2222B2:
2223 5: MoveLoc[0](Arg0: &mut Perpetual)
2224 6: Pop
2225 7: MoveLoc[1](Arg1: &mut Bank<Ty0>)
2226 8: Pop
2227 9: LdU64(62)
2228 10: Abort
2229B3:
2230 11: CopyLoc[0](Arg0: &mut Perpetual)
2231 12: Call perpetual::positions(&mut Perpetual): &mut Table<address, Position>
2232 13: FreezeRef
2233 14: CopyLoc[3](Arg3: address)
2234 15: Call table::contains<address, Position>(&Table<address, Position>, address): bool
2235 16: BrFalse(18)
2236B4:
2237 17: Branch(24)
2238B5:
2239 18: MoveLoc[0](Arg0: &mut Perpetual)
2240 19: Pop
2241 20: MoveLoc[1](Arg1: &mut Bank<Ty0>)
2242 21: Pop
2243 22: LdU64(507)
2244 23: Abort
2245B6:
2246 24: CopyLoc[0](Arg0: &mut Perpetual)
2247 25: FreezeRef
2248 26: Call perpetual::id(&Perpetual): &UID
2249 27: Call object::uid_to_inner(&UID): ID
2250 28: StLoc[11](loc6: ID)
2251 29: CopyLoc[0](Arg0: &mut Perpetual)
2252 30: FreezeRef
2253 31: Call perpetual::perp_address(&Perpetual): address
2254 32: StLoc[9](loc4: address)
2255 33: CopyLoc[0](Arg0: &mut Perpetual)
2256 34: FreezeRef
2257 35: Call perpetual::delisting_price(&Perpetual): u128
2258 36: StLoc[5](loc0: u128)
2259 37: CopyLoc[1](Arg1: &mut Bank<Ty0>)
2260 38: FreezeRef
2261 39: CopyLoc[0](Arg0: &mut Perpetual)
2262 40: FreezeRef
2263 41: CopyLoc[3](Arg3: address)
2264 42: Call option::none<address>(): Option<address>
2265 43: Call sum_transaction_balance<Ty0>(&Bank<Ty0>, &Perpetual, address, Option<address>): u128
2266 44: StLoc[7](loc2: u128)
2267 45: CopyLoc[2](Arg2: u128)
2268 46: CopyLoc[1](Arg1: &mut Bank<Ty0>)
2269 47: CopyLoc[0](Arg0: &mut Perpetual)
2270 48: CopyLoc[3](Arg3: address)
2271 49: LdU8(0)
2272 50: LdU64(2)
2273 51: Call apply_funding_rate<Ty0>(u128, &mut Bank<Ty0>, &mut Perpetual, address, u8, u64)
2274 52: CopyLoc[0](Arg0: &mut Perpetual)
2275 53: Call perpetual::positions(&mut Perpetual): &mut Table<address, Position>
2276 54: CopyLoc[3](Arg3: address)
2277 55: Call table::borrow_mut<address, Position>(&mut Table<address, Position>, address): &mut Position
2278 56: StLoc[12](loc7: &mut Position)
2279 57: CopyLoc[12](loc7: &mut Position)
2280 58: FreezeRef
2281 59: Call position::size(&Position): u128
2282 60: LdU128(0)
2283 61: Gt
2284 62: BrFalse(64)
2285B7:
2286 63: Branch(72)
2287B8:
2288 64: MoveLoc[12](loc7: &mut Position)
2289 65: Pop
2290 66: MoveLoc[0](Arg0: &mut Perpetual)
2291 67: Pop
2292 68: MoveLoc[1](Arg1: &mut Bank<Ty0>)
2293 69: Pop
2294 70: LdU64(512)
2295 71: Abort
2296B9:
2297 72: CopyLoc[1](Arg1: &mut Bank<Ty0>)
2298 73: FreezeRef
2299 74: CopyLoc[9](loc4: address)
2300 75: Call bank::get_balance<Ty0>(&Bank<Ty0>, address): u128
2301 76: StLoc[10](loc5: u128)
2302 77: CopyLoc[12](loc7: &mut Position)
2303 78: FreezeRef
2304 79: MoveLoc[5](loc0: u128)
2305 80: MoveLoc[10](loc5: u128)
2306 81: Call settlement::get_margin_left(&Position, u128, u128): u128
2307 82: StLoc[8](loc3: u128)
2308 83: CopyLoc[12](loc7: &mut Position)
2309 84: LdU128(0)
2310 85: Call position::set_size(&mut Position, u128)
2311 86: CopyLoc[1](Arg1: &mut Bank<Ty0>)
2312 87: MoveLoc[9](loc4: address)
2313 88: CopyLoc[3](Arg3: address)
2314 89: CopyLoc[8](loc3: u128)
2315 90: LdU64(2)
2316 91: CopyLoc[2](Arg2: u128)
2317 92: Call bank::transfer<Ty0>(&mut Bank<Ty0>, address, address, u128, u64, u128)
2318 93: MoveLoc[11](loc6: ID)
2319 94: CopyLoc[3](Arg3: address)
2320 95: MoveLoc[8](loc3: u128)
2321 96: CopyLoc[2](Arg2: u128)
2322 97: Call position::emit_position_closed_event(ID, address, u128, u128)
2323 98: MoveLoc[12](loc7: &mut Position)
2324 99: ReadRef
2325 100: MoveLoc[4](Arg4: address)
2326 101: LdConst[3](u8: 4)
2327 102: MoveLoc[2](Arg2: u128)
2328 103: Call position::emit_position_update_event(Position, address, u8, u128)
2329 104: MoveLoc[1](Arg1: &mut Bank<Ty0>)
2330 105: FreezeRef
2331 106: MoveLoc[0](Arg0: &mut Perpetual)
2332 107: FreezeRef
2333 108: MoveLoc[3](Arg3: address)
2334 109: Call option::none<address>(): Option<address>
2335 110: Call sum_transaction_balance<Ty0>(&Bank<Ty0>, &Perpetual, address, Option<address>): u128
2336 111: StLoc[6](loc1: u128)
2337 112: MoveLoc[7](loc2: u128)
2338 113: MoveLoc[6](loc1: u128)
2339 114: Eq
2340 115: BrFalse(117)
2341B10:
2342 116: Branch(119)
2343B11:
2344 117: LdU64(99989)
2345 118: Abort
2346B12:
2347 119: Ret
2348}
2349
2350apply_funding_rate<Ty0>(Arg0: u128, Arg1: &mut Bank<Ty0>, Arg2: &mut Perpetual, Arg3: address, Arg4: u8, Arg5: u64) {
2351L6: loc0: bool
2352L7: loc1: S128
2353L8: loc2: bool
2354L9: loc3: bool
2355L10: loc4: u128
2356L11: loc5: FundingRate
2357L12: loc6: FundingIndex
2358L13: loc7: S128
2359L14: loc8: address
2360L15: loc9: bool
2361L16: loc10: bool
2362L17: loc11: FundingIndex
2363L18: loc12: u128
2364L19: loc13: u128
2365L20: loc14: address
2366L21: loc15: ID
2367L22: loc16: u128
2368L23: loc17: u128
2369L24: loc18: u128
2370L25: loc19: &mut Position
2371B0:
2372 0: CopyLoc[2](Arg2: &mut Perpetual)
2373 1: FreezeRef
2374 2: Call perpetual::id(&Perpetual): &UID
2375 3: Call object::uid_to_inner(&UID): ID
2376 4: StLoc[21](loc15: ID)
2377 5: CopyLoc[2](Arg2: &mut Perpetual)
2378 6: FreezeRef
2379 7: Call perpetual::perp_address(&Perpetual): address
2380 8: StLoc[20](loc14: address)
2381 9: CopyLoc[2](Arg2: &mut Perpetual)
2382 10: FreezeRef
2383 11: Call perpetual::insurance_active_pool(&Perpetual): address
2384 12: StLoc[14](loc8: address)
2385 13: CopyLoc[14](loc8: address)
2386 14: CopyLoc[3](Arg3: address)
2387 15: Eq
2388 16: StLoc[15](loc9: bool)
2389 17: CopyLoc[2](Arg2: &mut Perpetual)
2390 18: FreezeRef
2391 19: Call perpetual::price_oracle(&Perpetual): u128
2392 20: StLoc[22](loc16: u128)
2393 21: CopyLoc[2](Arg2: &mut Perpetual)
2394 22: FreezeRef
2395 23: Call perpetual::funding_rate(&Perpetual): FundingRate
2396 24: StLoc[11](loc5: FundingRate)
2397 25: CopyLoc[11](loc5: FundingRate)
2398 26: Call funding_rate::index(FundingRate): FundingIndex
2399 27: StLoc[12](loc6: FundingIndex)
2400 28: MoveLoc[2](Arg2: &mut Perpetual)
2401 29: Call perpetual::positions(&mut Perpetual): &mut Table<address, Position>
2402 30: CopyLoc[3](Arg3: address)
2403 31: Call table::borrow_mut<address, Position>(&mut Table<address, Position>, address): &mut Position
2404 32: StLoc[25](loc19: &mut Position)
2405 33: CopyLoc[25](loc19: &mut Position)
2406 34: FreezeRef
2407 35: Call position::index(&Position): FundingIndex
2408 36: StLoc[17](loc11: FundingIndex)
2409 37: CopyLoc[25](loc19: &mut Position)
2410 38: FreezeRef
2411 39: Call position::margin(&Position): u128
2412 40: StLoc[18](loc12: u128)
2413 41: CopyLoc[25](loc19: &mut Position)
2414 42: FreezeRef
2415 43: Call position::size(&Position): u128
2416 44: StLoc[24](loc18: u128)
2417 45: CopyLoc[25](loc19: &mut Position)
2418 46: FreezeRef
2419 47: Call position::oi_open(&Position): u128
2420 48: StLoc[19](loc13: u128)
2421 49: CopyLoc[25](loc19: &mut Position)
2422 50: FreezeRef
2423 51: Call position::is_long(&Position): bool
2424 52: StLoc[16](loc10: bool)
2425 53: CopyLoc[25](loc19: &mut Position)
2426 54: CopyLoc[12](loc6: FundingIndex)
2427 55: Call position::set_index(&mut Position, FundingIndex)
2428 56: CopyLoc[17](loc11: FundingIndex)
2429 57: CopyLoc[12](loc6: FundingIndex)
2430 58: Call funding_rate::are_indexes_equal(FundingIndex, FundingIndex): bool
2431 59: BrFalse(63)
2432B1:
2433 60: LdTrue
2434 61: StLoc[6](loc0: bool)
2435 62: Branch(67)
2436B2:
2437 63: CopyLoc[24](loc18: u128)
2438 64: LdU128(0)
2439 65: Eq
2440 66: StLoc[6](loc0: bool)
2441B3:
2442 67: MoveLoc[6](loc0: bool)
2443 68: BrFalse(74)
2444B4:
2445 69: MoveLoc[25](loc19: &mut Position)
2446 70: Pop
2447 71: MoveLoc[1](Arg1: &mut Bank<Ty0>)
2448 72: Pop
2449 73: Ret
2450B5:
2451 74: CopyLoc[16](loc10: bool)
2452 75: BrFalse(83)
2453B6:
2454 76: MoveLoc[17](loc11: FundingIndex)
2455 77: Call funding_rate::index_value(FundingIndex): S128
2456 78: MoveLoc[12](loc6: FundingIndex)
2457 79: Call funding_rate::index_value(FundingIndex): S128
2458 80: Call s128::sub(S128, S128): S128
2459 81: StLoc[7](loc1: S128)
2460 82: Branch(89)
2461B7:
2462 83: MoveLoc[12](loc6: FundingIndex)
2463 84: Call funding_rate::index_value(FundingIndex): S128
2464 85: MoveLoc[17](loc11: FundingIndex)
2465 86: Call funding_rate::index_value(FundingIndex): S128
2466 87: Call s128::sub(S128, S128): S128
2467 88: StLoc[7](loc1: S128)
2468B8:
2469 89: MoveLoc[7](loc1: S128)
2470 90: StLoc[13](loc7: S128)
2471 91: CopyLoc[13](loc7: S128)
2472 92: Call s128::value(S128): u128
2473 93: CopyLoc[24](loc18: u128)
2474 94: Call library::base_mul(u128, u128): u128
2475 95: StLoc[23](loc17: u128)
2476 96: CopyLoc[13](loc7: S128)
2477 97: LdU128(0)
2478 98: Call s128::gt_u128(S128, u128): bool
2479 99: BrFalse(118)
2480B9:
2481 100: MoveLoc[15](loc9: bool)
2482 101: BrFalse(110)
2483B10:
2484 102: MoveLoc[1](Arg1: &mut Bank<Ty0>)
2485 103: MoveLoc[20](loc14: address)
2486 104: CopyLoc[3](Arg3: address)
2487 105: CopyLoc[23](loc17: u128)
2488 106: LdU64(2)
2489 107: CopyLoc[0](Arg0: u128)
2490 108: Call bank::transfer<Ty0>(&mut Bank<Ty0>, address, address, u128, u64, u128)
2491 109: Branch(274)
2492B11:
2493 110: MoveLoc[1](Arg1: &mut Bank<Ty0>)
2494 111: Pop
2495 112: CopyLoc[25](loc19: &mut Position)
2496 113: MoveLoc[18](loc12: u128)
2497 114: CopyLoc[23](loc17: u128)
2498 115: Add
2499 116: Call position::set_margin(&mut Position, u128)
2500 117: Branch(274)
2501B12:
2502 118: CopyLoc[4](Arg4: u8)
2503 119: LdU8(3)
2504 120: Le
2505 121: BrFalse(123)
2506B13:
2507 122: Branch(129)
2508B14:
2509 123: MoveLoc[25](loc19: &mut Position)
2510 124: Pop
2511 125: MoveLoc[1](Arg1: &mut Bank<Ty0>)
2512 126: Pop
2513 127: LdU64(99999)
2514 128: Abort
2515B15:
2516 129: CopyLoc[13](loc7: S128)
2517 130: Call s128::value(S128): u128
2518 131: MoveLoc[24](loc18: u128)
2519 132: Call library::base_mul_up(u128, u128): u128
2520 133: StLoc[23](loc17: u128)
2521 134: CopyLoc[4](Arg4: u8)
2522 135: LdU8(0)
2523 136: Eq
2524 137: BrFalse(141)
2525B16:
2526 138: LdTrue
2527 139: StLoc[8](loc2: bool)
2528 140: Branch(145)
2529B17:
2530 141: CopyLoc[4](Arg4: u8)
2531 142: LdU8(1)
2532 143: Eq
2533 144: StLoc[8](loc2: bool)
2534B18:
2535 145: MoveLoc[8](loc2: bool)
2536 146: BrFalse(172)
2537B19:
2538 147: MoveLoc[15](loc9: bool)
2539 148: BrFalse(159)
2540B20:
2541 149: MoveLoc[1](Arg1: &mut Bank<Ty0>)
2542 150: CopyLoc[3](Arg3: address)
2543 151: MoveLoc[20](loc14: address)
2544 152: MoveLoc[23](loc17: u128)
2545 153: MoveLoc[5](Arg5: u64)
2546 154: CopyLoc[0](Arg0: u128)
2547 155: Call bank::transfer<Ty0>(&mut Bank<Ty0>, address, address, u128, u64, u128)
2548 156: LdU128(0)
2549 157: StLoc[23](loc17: u128)
2550 158: Branch(269)
2551B21:
2552 159: MoveLoc[1](Arg1: &mut Bank<Ty0>)
2553 160: Pop
2554 161: CopyLoc[18](loc12: u128)
2555 162: CopyLoc[23](loc17: u128)
2556 163: Ge
2557 164: BrFalse(166)
2558B22:
2559 165: Branch(269)
2560B23:
2561 166: MoveLoc[25](loc19: &mut Position)
2562 167: Pop
2563 168: LdU64(53)
2564 169: MoveLoc[5](Arg5: u64)
2565 170: Add
2566 171: Abort
2567B24:
2568 172: MoveLoc[4](Arg4: u8)
2569 173: LdU8(2)
2570 174: Eq
2571 175: BrFalse(228)
2572B25:
2573 176: MoveLoc[5](Arg5: u64)
2574 177: LdU64(1)
2575 178: Eq
2576 179: BrFalse(185)
2577B26:
2578 180: CopyLoc[18](loc12: u128)
2579 181: LdU128(0)
2580 182: Gt
2581 183: StLoc[9](loc3: bool)
2582 184: Branch(187)
2583B27:
2584 185: LdFalse
2585 186: StLoc[9](loc3: bool)
2586B28:
2587 187: MoveLoc[9](loc3: bool)
2588 188: BrFalse(195)
2589B29:
2590 189: MoveLoc[25](loc19: &mut Position)
2591 190: Pop
2592 191: MoveLoc[1](Arg1: &mut Bank<Ty0>)
2593 192: Pop
2594 193: LdU64(99999)
2595 194: Abort
2596B30:
2597 195: CopyLoc[18](loc12: u128)
2598 196: CopyLoc[23](loc17: u128)
2599 197: Lt
2600 198: BrFalse(225)
2601B31:
2602 199: CopyLoc[23](loc17: u128)
2603 200: CopyLoc[18](loc12: u128)
2604 201: Sub
2605 202: StLoc[10](loc4: u128)
2606 203: MoveLoc[1](Arg1: &mut Bank<Ty0>)
2607 204: CopyLoc[14](loc8: address)
2608 205: MoveLoc[20](loc14: address)
2609 206: CopyLoc[10](loc4: u128)
2610 207: LdU64(1)
2611 208: CopyLoc[0](Arg0: u128)
2612 209: Call bank::transfer<Ty0>(&mut Bank<Ty0>, address, address, u128, u64, u128)
2613 210: MoveLoc[15](loc9: bool)
2614 211: Not
2615 212: BrFalse(220)
2616B32:
2617 213: CopyLoc[0](Arg0: u128)
2618 214: MoveLoc[21](loc15: ID)
2619 215: MoveLoc[14](loc8: address)
2620 216: CopyLoc[3](Arg3: address)
2621 217: CopyLoc[10](loc4: u128)
2622 218: Pack[0](LiquidatorPaidForAccountSettlementEvent)
2623 219: Call event::emit<LiquidatorPaidForAccountSettlementEvent>(LiquidatorPaidForAccountSettlementEvent)
2624B33:
2625 220: MoveLoc[23](loc17: u128)
2626 221: MoveLoc[10](loc4: u128)
2627 222: Sub
2628 223: StLoc[23](loc17: u128)
2629 224: Branch(269)
2630B34:
2631 225: MoveLoc[1](Arg1: &mut Bank<Ty0>)
2632 226: Pop
2633 227: Branch(269)
2634B35:
2635 228: MoveLoc[1](Arg1: &mut Bank<Ty0>)
2636 229: Pop
2637 230: CopyLoc[18](loc12: u128)
2638 231: CopyLoc[23](loc17: u128)
2639 232: Lt
2640 233: BrFalse(269)
2641B36:
2642 234: MoveLoc[16](loc10: bool)
2643 235: BrFalse(242)
2644B37:
2645 236: CopyLoc[25](loc19: &mut Position)
2646 237: MoveLoc[19](loc13: u128)
2647 238: CopyLoc[23](loc17: u128)
2648 239: Add
2649 240: Call position::set_oi_open(&mut Position, u128)
2650 241: Branch(262)
2651B38:
2652 242: CopyLoc[23](loc17: u128)
2653 243: CopyLoc[19](loc13: u128)
2654 244: Gt
2655 245: BrFalse(257)
2656B39:
2657 246: CopyLoc[25](loc19: &mut Position)
2658 247: LdU128(0)
2659 248: Call position::set_oi_open(&mut Position, u128)
2660 249: CopyLoc[0](Arg0: u128)
2661 250: CopyLoc[3](Arg3: address)
2662 251: CopyLoc[23](loc17: u128)
2663 252: MoveLoc[19](loc13: u128)
2664 253: Sub
2665 254: Pack[1](SettlementAmountNotPaidCompletelyEvent)
2666 255: Call event::emit<SettlementAmountNotPaidCompletelyEvent>(SettlementAmountNotPaidCompletelyEvent)
2667 256: Branch(262)
2668B40:
2669 257: CopyLoc[25](loc19: &mut Position)
2670 258: MoveLoc[19](loc13: u128)
2671 259: CopyLoc[23](loc17: u128)
2672 260: Sub
2673 261: Call position::set_oi_open(&mut Position, u128)
2674B41:
2675 262: CopyLoc[0](Arg0: u128)
2676 263: CopyLoc[3](Arg3: address)
2677 264: MoveLoc[23](loc17: u128)
2678 265: Pack[2](SettlementAmtDueByMakerEvent)
2679 266: Call event::emit<SettlementAmtDueByMakerEvent>(SettlementAmtDueByMakerEvent)
2680 267: LdU128(0)
2681 268: StLoc[23](loc17: u128)
2682B42:
2683 269: CopyLoc[25](loc19: &mut Position)
2684 270: MoveLoc[18](loc12: u128)
2685 271: CopyLoc[23](loc17: u128)
2686 272: Sub
2687 273: Call position::set_margin(&mut Position, u128)
2688B43:
2689 274: MoveLoc[0](Arg0: u128)
2690 275: MoveLoc[3](Arg3: address)
2691 276: MoveLoc[25](loc19: &mut Position)
2692 277: ReadRef
2693 278: MoveLoc[13](loc7: S128)
2694 279: Call s128::sign(S128): bool
2695 280: MoveLoc[23](loc17: u128)
2696 281: MoveLoc[22](loc16: u128)
2697 282: MoveLoc[11](loc5: FundingRate)
2698 283: Call funding_rate::rate(FundingRate): S128
2699 284: Pack[3](AccountSettlementUpdateEvent)
2700 285: Call event::emit<AccountSettlementUpdateEvent>(AccountSettlementUpdateEvent)
2701 286: Ret
2702}
2703
2704public(friend) sum_transaction_balance<Ty0>(Arg0: &Bank<Ty0>, Arg1: &Perpetual, Arg2: address, Arg3: Option<address>): u128 {
2705L4: loc0: bool
2706L5: loc1: u128
2707L6: loc2: u128
2708L7: loc3: address
2709L8: loc4: u128
2710L9: loc5: address
2711L10: loc6: u128
2712L11: loc7: address
2713L12: loc8: u128
2714B0:
2715 0: CopyLoc[1](Arg1: &Perpetual)
2716 1: Call perpetual::perp_address(&Perpetual): address
2717 2: StLoc[9](loc5: address)
2718 3: CopyLoc[0](Arg0: &Bank<Ty0>)
2719 4: MoveLoc[9](loc5: address)
2720 5: Call bank::get_balance<Ty0>(&Bank<Ty0>, address): u128
2721 6: StLoc[10](loc6: u128)
2722 7: CopyLoc[0](Arg0: &Bank<Ty0>)
2723 8: CopyLoc[1](Arg1: &Perpetual)
2724 9: Call perpetual::fee_pool(&Perpetual): address
2725 10: Call bank::get_balance<Ty0>(&Bank<Ty0>, address): u128
2726 11: StLoc[5](loc1: u128)
2727 12: CopyLoc[0](Arg0: &Bank<Ty0>)
2728 13: CopyLoc[1](Arg1: &Perpetual)
2729 14: Call perpetual::gas_pool(&Perpetual): address
2730 15: Call bank::get_balance<Ty0>(&Bank<Ty0>, address): u128
2731 16: StLoc[6](loc2: u128)
2732 17: MoveLoc[1](Arg1: &Perpetual)
2733 18: Call perpetual::insurance_active_pool(&Perpetual): address
2734 19: StLoc[7](loc3: address)
2735 20: CopyLoc[0](Arg0: &Bank<Ty0>)
2736 21: CopyLoc[7](loc3: address)
2737 22: Call bank::get_balance<Ty0>(&Bank<Ty0>, address): u128
2738 23: StLoc[8](loc4: u128)
2739 24: MoveLoc[10](loc6: u128)
2740 25: MoveLoc[5](loc1: u128)
2741 26: Add
2742 27: MoveLoc[6](loc2: u128)
2743 28: Add
2744 29: MoveLoc[8](loc4: u128)
2745 30: Add
2746 31: StLoc[12](loc8: u128)
2747 32: CopyLoc[2](Arg2: address)
2748 33: CopyLoc[7](loc3: address)
2749 34: Neq
2750 35: BrFalse(42)
2751B1:
2752 36: MoveLoc[12](loc8: u128)
2753 37: CopyLoc[0](Arg0: &Bank<Ty0>)
2754 38: CopyLoc[2](Arg2: address)
2755 39: Call bank::get_balance<Ty0>(&Bank<Ty0>, address): u128
2756 40: Add
2757 41: StLoc[12](loc8: u128)
2758B2:
2759 42: ImmBorrowLoc[3](Arg3: Option<address>)
2760 43: Call option::is_some<address>(&Option<address>): bool
2761 44: BrFalse(72)
2762B3:
2763 45: ImmBorrowLoc[3](Arg3: Option<address>)
2764 46: Call option::borrow<address>(&Option<address>): &address
2765 47: ReadRef
2766 48: StLoc[11](loc7: address)
2767 49: CopyLoc[11](loc7: address)
2768 50: MoveLoc[7](loc3: address)
2769 51: Neq
2770 52: BrFalse(58)
2771B4:
2772 53: CopyLoc[11](loc7: address)
2773 54: MoveLoc[2](Arg2: address)
2774 55: Neq
2775 56: StLoc[4](loc0: bool)
2776 57: Branch(60)
2777B5:
2778 58: LdFalse
2779 59: StLoc[4](loc0: bool)
2780B6:
2781 60: MoveLoc[4](loc0: bool)
2782 61: BrFalse(69)
2783B7:
2784 62: MoveLoc[12](loc8: u128)
2785 63: MoveLoc[0](Arg0: &Bank<Ty0>)
2786 64: MoveLoc[11](loc7: address)
2787 65: Call bank::get_balance<Ty0>(&Bank<Ty0>, address): u128
2788 66: Add
2789 67: StLoc[12](loc8: u128)
2790 68: Branch(74)
2791B8:
2792 69: MoveLoc[0](Arg0: &Bank<Ty0>)
2793 70: Pop
2794 71: Branch(74)
2795B9:
2796 72: MoveLoc[0](Arg0: &Bank<Ty0>)
2797 73: Pop
2798B10:
2799 74: MoveLoc[12](loc8: u128)
2800 75: Ret
2801}
2802
2803Constants [
2804 0 => u8: 1
2805 1 => u8: 2
2806 2 => u8: 3
2807 3 => u8: 4
2808 4 => address: 0x0000000000000000000000000000000000000000000000000000000000000000
2809 5 => vector<u8>: "" // interpreted as UTF8 string
2810 6 => vector<u8>: "AddMargin" // interpreted as UTF8 string
2811 7 => vector<u8>: "RemoveMargin" // interpreted as UTF8 string
2812 8 => vector<u8>: "AdjustLeverage" // interpreted as UTF8 string
2813 9 => vector<u8>: "CancelOrder" // interpreted as UTF8 string
2814 10 => vector<u8>: "ClosePosition" // interpreted as UTF8 string
2815]
2816}
2817
0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/funding_rate.mvb361 lines
1// Move bytecode v7
2module 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001.funding_rate {
3use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::library;
4use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::s128;
5use 0000000000000000000000000000000000000000000000000000000000000002::clock;
6use 0000000000000000000000000000000000000000000000000000000000000002::event;
7use 0000000000000000000000000000000000000000000000000000000000000002::object;
8
9struct MaxAllowedFRUpdateEvent has copy, drop {
10 id: ID,
11 value: u128
12}
13
14struct GlobalIndexUpdateEvent has copy, drop {
15 id: ID,
16 index: FundingIndex
17}
18
19struct FundingRateUpdateEvent has copy, drop {
20 id: ID,
21 rate: S128,
22 window: u64,
23 min_application_time: u64
24}
25
26struct FundingIndex has copy, drop, store {
27 value: S128,
28 timestamp: u64
29}
30
31struct FundingRate has copy, drop, store {
32 start_time: u64,
33 max_funding: u128,
34 window: u64,
35 rate: S128,
36 index: FundingIndex
37}
38
39public(friend) new_index(Arg0: u64): FundingIndex {
40B0:
41 0: Call s128::zero(): S128
42 1: MoveLoc[0](Arg0: u64)
43 2: Pack[3](FundingIndex)
44 3: Ret
45}
46
47public(friend) initialize(Arg0: u64, Arg1: u128): FundingRate {
48B0:
49 0: CopyLoc[0](Arg0: u64)
50 1: MoveLoc[1](Arg1: u128)
51 2: LdU64(0)
52 3: Call s128::zero(): S128
53 4: MoveLoc[0](Arg0: u64)
54 5: Call new_index(u64): FundingIndex
55 6: Pack[4](FundingRate)
56 7: Ret
57}
58
59public(friend) set_funding_rate(Arg0: &mut FundingRate, Arg1: u128, Arg2: bool, Arg3: u64, Arg4: ID) {
60L5: loc0: u64
61B0:
62 0: CopyLoc[0](Arg0: &mut FundingRate)
63 1: ReadRef
64 2: CopyLoc[3](Arg3: u64)
65 3: Call expected_funding_window(FundingRate, u64): u64
66 4: StLoc[5](loc0: u64)
67 5: CopyLoc[5](loc0: u64)
68 6: LdU64(1)
69 7: Le
70 8: BrFalse(12)
71B1:
72 9: MoveLoc[0](Arg0: &mut FundingRate)
73 10: Pop
74 11: Ret
75B2:
76 12: CopyLoc[0](Arg0: &mut FundingRate)
77 13: ImmBorrowField[0](FundingRate.window: u64)
78 14: ReadRef
79 15: CopyLoc[5](loc0: u64)
80 16: LdU64(1)
81 17: Sub
82 18: Lt
83 19: BrFalse(21)
84B3:
85 20: Branch(25)
86B4:
87 21: MoveLoc[0](Arg0: &mut FundingRate)
88 22: Pop
89 23: LdU64(902)
90 24: Abort
91B5:
92 25: CopyLoc[1](Arg1: u128)
93 26: CopyLoc[0](Arg0: &mut FundingRate)
94 27: ImmBorrowField[1](FundingRate.max_funding: u128)
95 28: ReadRef
96 29: Le
97 30: BrFalse(32)
98B6:
99 31: Branch(36)
100B7:
101 32: MoveLoc[0](Arg0: &mut FundingRate)
102 33: Pop
103 34: LdU64(904)
104 35: Abort
105B8:
106 36: MoveLoc[1](Arg1: u128)
107 37: MoveLoc[2](Arg2: bool)
108 38: Call s128::from(u128, bool): S128
109 39: CopyLoc[0](Arg0: &mut FundingRate)
110 40: MutBorrowField[2](FundingRate.rate: S128)
111 41: WriteRef
112 42: CopyLoc[5](loc0: u64)
113 43: LdU64(1)
114 44: Sub
115 45: CopyLoc[0](Arg0: &mut FundingRate)
116 46: MutBorrowField[0](FundingRate.window: u64)
117 47: WriteRef
118 48: MoveLoc[4](Arg4: ID)
119 49: CopyLoc[0](Arg0: &mut FundingRate)
120 50: ImmBorrowField[2](FundingRate.rate: S128)
121 51: ReadRef
122 52: CopyLoc[0](Arg0: &mut FundingRate)
123 53: ImmBorrowField[0](FundingRate.window: u64)
124 54: ReadRef
125 55: MoveLoc[5](loc0: u64)
126 56: LdConst[0](u64: 3600..)
127 57: Mul
128 58: MoveLoc[0](Arg0: &mut FundingRate)
129 59: ImmBorrowField[3](FundingRate.start_time: u64)
130 60: ReadRef
131 61: Add
132 62: MoveLoc[3](Arg3: u64)
133 63: Sub
134 64: Pack[2](FundingRateUpdateEvent)
135 65: Call event::emit<FundingRateUpdateEvent>(FundingRateUpdateEvent)
136 66: Ret
137}
138
139public(friend) set_max_allowed_funding_rate(Arg0: &mut FundingRate, Arg1: u128, Arg2: ID) {
140B0:
141 0: CopyLoc[1](Arg1: u128)
142 1: Call library::base_uint(): u128
143 2: Le
144 3: BrFalse(5)
145B1:
146 4: Branch(9)
147B2:
148 5: MoveLoc[0](Arg0: &mut FundingRate)
149 6: Pop
150 7: LdU64(104)
151 8: Abort
152B3:
153 9: CopyLoc[1](Arg1: u128)
154 10: MoveLoc[0](Arg0: &mut FundingRate)
155 11: MutBorrowField[1](FundingRate.max_funding: u128)
156 12: WriteRef
157 13: MoveLoc[2](Arg2: ID)
158 14: MoveLoc[1](Arg1: u128)
159 15: Pack[0](MaxAllowedFRUpdateEvent)
160 16: Call event::emit<MaxAllowedFRUpdateEvent>(MaxAllowedFRUpdateEvent)
161 17: Ret
162}
163
164public(friend) set_global_index(Arg0: &mut FundingRate, Arg1: FundingIndex, Arg2: ID) {
165B0:
166 0: CopyLoc[0](Arg0: &mut FundingRate)
167 1: ImmBorrowField[4](FundingRate.index: FundingIndex)
168 2: ImmBorrowField[5](FundingIndex.timestamp: u64)
169 3: ReadRef
170 4: ImmBorrowLoc[1](Arg1: FundingIndex)
171 5: ImmBorrowField[5](FundingIndex.timestamp: u64)
172 6: ReadRef
173 7: Neq
174 8: BrFalse(18)
175B1:
176 9: CopyLoc[1](Arg1: FundingIndex)
177 10: MoveLoc[0](Arg0: &mut FundingRate)
178 11: MutBorrowField[4](FundingRate.index: FundingIndex)
179 12: WriteRef
180 13: MoveLoc[2](Arg2: ID)
181 14: MoveLoc[1](Arg1: FundingIndex)
182 15: Pack[1](GlobalIndexUpdateEvent)
183 16: Call event::emit<GlobalIndexUpdateEvent>(GlobalIndexUpdateEvent)
184 17: Branch(20)
185B2:
186 18: MoveLoc[0](Arg0: &mut FundingRate)
187 19: Pop
188B3:
189 20: Ret
190}
191
192public(friend) compute_new_global_index(Arg0: &Clock, Arg1: FundingRate, Arg2: u128): FundingIndex {
193L3: loc0: u128
194L4: loc1: u128
195L5: loc2: u64
196L6: loc3: S128
197L7: loc4: u128
198B0:
199 0: MoveLoc[0](Arg0: &Clock)
200 1: Call clock::timestamp_ms(&Clock): u64
201 2: StLoc[5](loc2: u64)
202 3: CopyLoc[5](loc2: u64)
203 4: ImmBorrowLoc[1](Arg1: FundingRate)
204 5: ImmBorrowField[4](FundingRate.index: FundingIndex)
205 6: ImmBorrowField[5](FundingIndex.timestamp: u64)
206 7: ReadRef
207 8: Gt
208 9: BrFalse(19)
209B1:
210 10: CopyLoc[5](loc2: u64)
211 11: ImmBorrowLoc[1](Arg1: FundingRate)
212 12: ImmBorrowField[4](FundingRate.index: FundingIndex)
213 13: ImmBorrowField[5](FundingIndex.timestamp: u64)
214 14: ReadRef
215 15: Sub
216 16: CastU128
217 17: StLoc[3](loc0: u128)
218 18: Branch(21)
219B2:
220 19: LdU128(0)
221 20: StLoc[3](loc0: u128)
222B3:
223 21: MoveLoc[3](loc0: u128)
224 22: StLoc[7](loc4: u128)
225 23: CopyLoc[7](loc4: u128)
226 24: LdU128(0)
227 25: Gt
228 26: BrFalse(71)
229B4:
230 27: CopyLoc[7](loc4: u128)
231 28: LdConst[0](u64: 3600..)
232 29: CastU128
233 30: Lt
234 31: BrFalse(35)
235B5:
236 32: LdU128(1)
237 33: StLoc[4](loc1: u128)
238 34: Branch(40)
239B6:
240 35: MoveLoc[7](loc4: u128)
241 36: LdConst[0](u64: 3600..)
242 37: CastU128
243 38: Div
244 39: StLoc[4](loc1: u128)
245B7:
246 40: MoveLoc[4](loc1: u128)
247 41: StLoc[7](loc4: u128)
248 42: ImmBorrowLoc[1](Arg1: FundingRate)
249 43: ImmBorrowField[2](FundingRate.rate: S128)
250 44: ReadRef
251 45: Call s128::value(S128): u128
252 46: MoveLoc[7](loc4: u128)
253 47: Mul
254 48: MoveLoc[2](Arg2: u128)
255 49: Call library::base_mul(u128, u128): u128
256 50: ImmBorrowLoc[1](Arg1: FundingRate)
257 51: ImmBorrowField[2](FundingRate.rate: S128)
258 52: ReadRef
259 53: Call s128::sign(S128): bool
260 54: Call s128::from(u128, bool): S128
261 55: StLoc[6](loc3: S128)
262 56: ImmBorrowLoc[1](Arg1: FundingRate)
263 57: ImmBorrowField[4](FundingRate.index: FundingIndex)
264 58: ImmBorrowField[6](FundingIndex.value: S128)
265 59: ReadRef
266 60: MoveLoc[6](loc3: S128)
267 61: Call s128::add(S128, S128): S128
268 62: MutBorrowLoc[1](Arg1: FundingRate)
269 63: MutBorrowField[4](FundingRate.index: FundingIndex)
270 64: MutBorrowField[6](FundingIndex.value: S128)
271 65: WriteRef
272 66: MoveLoc[5](loc2: u64)
273 67: MutBorrowLoc[1](Arg1: FundingRate)
274 68: MutBorrowField[4](FundingRate.index: FundingIndex)
275 69: MutBorrowField[5](FundingIndex.timestamp: u64)
276 70: WriteRef
277B8:
278 71: ImmBorrowLoc[1](Arg1: FundingRate)
279 72: ImmBorrowField[4](FundingRate.index: FundingIndex)
280 73: ReadRef
281 74: Ret
282}
283
284public(friend) index(Arg0: FundingRate): FundingIndex {
285B0:
286 0: ImmBorrowLoc[0](Arg0: FundingRate)
287 1: ImmBorrowField[4](FundingRate.index: FundingIndex)
288 2: ReadRef
289 3: Ret
290}
291
292public(friend) index_value(Arg0: FundingIndex): S128 {
293B0:
294 0: ImmBorrowLoc[0](Arg0: FundingIndex)
295 1: ImmBorrowField[6](FundingIndex.value: S128)
296 2: ReadRef
297 3: Ret
298}
299
300public(friend) rate(Arg0: FundingRate): S128 {
301B0:
302 0: ImmBorrowLoc[0](Arg0: FundingRate)
303 1: ImmBorrowField[2](FundingRate.rate: S128)
304 2: ReadRef
305 3: Ret
306}
307
308public(friend) index_timestamp(Arg0: FundingIndex): u64 {
309B0:
310 0: ImmBorrowLoc[0](Arg0: FundingIndex)
311 1: ImmBorrowField[5](FundingIndex.timestamp: u64)
312 2: ReadRef
313 3: Ret
314}
315
316public(friend) are_indexes_equal(Arg0: FundingIndex, Arg1: FundingIndex): bool {
317B0:
318 0: ImmBorrowLoc[0](Arg0: FundingIndex)
319 1: ImmBorrowField[5](FundingIndex.timestamp: u64)
320 2: ReadRef
321 3: ImmBorrowLoc[1](Arg1: FundingIndex)
322 4: ImmBorrowField[5](FundingIndex.timestamp: u64)
323 5: ReadRef
324 6: Eq
325 7: Ret
326}
327
328expected_funding_window(Arg0: FundingRate, Arg1: u64): u64 {
329L2: loc0: u64
330B0:
331 0: CopyLoc[1](Arg1: u64)
332 1: ImmBorrowLoc[0](Arg0: FundingRate)
333 2: ImmBorrowField[3](FundingRate.start_time: u64)
334 3: ReadRef
335 4: Lt
336 5: BrFalse(9)
337B1:
338 6: LdU64(0)
339 7: StLoc[2](loc0: u64)
340 8: Branch(19)
341B2:
342 9: MoveLoc[1](Arg1: u64)
343 10: ImmBorrowLoc[0](Arg0: FundingRate)
344 11: ImmBorrowField[3](FundingRate.start_time: u64)
345 12: ReadRef
346 13: Sub
347 14: LdConst[0](u64: 3600..)
348 15: Div
349 16: LdU64(1)
350 17: Add
351 18: StLoc[2](loc0: u64)
352B3:
353 19: MoveLoc[2](loc0: u64)
354 20: Ret
355}
356
357Constants [
358 0 => u64: 3600000
359]
360}
361
0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/insurance_fund.mvb446 lines
1// Move bytecode v7
2module 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001.insurance_fund {
3use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::bank;
4use 0000000000000000000000000000000000000000000000000000000000000002::clock;
5use 0000000000000000000000000000000000000000000000000000000000000002::event;
6use 0000000000000000000000000000000000000000000000000000000000000002::object;
7
8struct InsuranceFund has store {
9 perp_id: ID,
10 active_account: address,
11 security_account: address,
12 transfer_interval: u64,
13 transfer_amount_limit: u128,
14 last_transfer_time: u64
15}
16
17struct InsuranceFundUpdateActiveAccountEvent has copy, drop {
18 perp_id: ID,
19 account: address
20}
21
22struct InsuranceFundUpdateSecurityAccountEvent has copy, drop {
23 perp_id: ID,
24 account: address
25}
26
27struct InsuranceFundUpdateTransferIntervalEvent has copy, drop {
28 perp_id: ID,
29 transfer_interval: u64
30}
31
32struct InsuranceFundUpdateTransferAmountLimitEvent has copy, drop {
33 perp_id: ID,
34 transfer_amount_limit: u128
35}
36
37struct InsuranceFundCreateEvent has copy, drop {
38 perp_id: ID,
39 active_account: address,
40 security_account: address,
41 transfer_interval: u64,
42 transfer_amount_limit: u128
43}
44
45struct InsuranceFundTransferEvent has copy, drop {
46 perp_id: ID,
47 from_security_account: bool,
48 amount: u128,
49 timestamp: u64
50}
51
52public(friend) create_insurance_fund(Arg0: ID, Arg1: address, Arg2: address, Arg3: u64, Arg4: u128): InsuranceFund {
53L5: loc0: InsuranceFund
54B0:
55 0: CopyLoc[1](Arg1: address)
56 1: LdConst[0](address: 0x00..)
57 2: Neq
58 3: BrFalse(5)
59B1:
60 4: Branch(7)
61B2:
62 5: LdU64(105)
63 6: Abort
64B3:
65 7: CopyLoc[2](Arg2: address)
66 8: LdConst[0](address: 0x00..)
67 9: Neq
68 10: BrFalse(12)
69B4:
70 11: Branch(14)
71B5:
72 12: LdU64(105)
73 13: Abort
74B6:
75 14: CopyLoc[1](Arg1: address)
76 15: CopyLoc[2](Arg2: address)
77 16: Neq
78 17: BrFalse(19)
79B7:
80 18: Branch(21)
81B8:
82 19: LdU64(114)
83 20: Abort
84B9:
85 21: CopyLoc[3](Arg3: u64)
86 22: LdU64(0)
87 23: Gt
88 24: BrFalse(26)
89B10:
90 25: Branch(28)
91B11:
92 26: LdU64(115)
93 27: Abort
94B12:
95 28: CopyLoc[4](Arg4: u128)
96 29: LdU128(0)
97 30: Gt
98 31: BrFalse(33)
99B13:
100 32: Branch(35)
101B14:
102 33: LdU64(117)
103 34: Abort
104B15:
105 35: CopyLoc[0](Arg0: ID)
106 36: CopyLoc[1](Arg1: address)
107 37: CopyLoc[2](Arg2: address)
108 38: CopyLoc[3](Arg3: u64)
109 39: CopyLoc[4](Arg4: u128)
110 40: LdU64(0)
111 41: Pack[0](InsuranceFund)
112 42: StLoc[5](loc0: InsuranceFund)
113 43: MoveLoc[0](Arg0: ID)
114 44: MoveLoc[1](Arg1: address)
115 45: MoveLoc[2](Arg2: address)
116 46: MoveLoc[3](Arg3: u64)
117 47: MoveLoc[4](Arg4: u128)
118 48: Pack[5](InsuranceFundCreateEvent)
119 49: Call event::emit<InsuranceFundCreateEvent>(InsuranceFundCreateEvent)
120 50: MoveLoc[5](loc0: InsuranceFund)
121 51: Ret
122}
123
124public(friend) active_account(Arg0: &InsuranceFund): address {
125B0:
126 0: MoveLoc[0](Arg0: &InsuranceFund)
127 1: ImmBorrowField[0](InsuranceFund.active_account: address)
128 2: ReadRef
129 3: Ret
130}
131
132public(friend) security_account(Arg0: &InsuranceFund): address {
133B0:
134 0: MoveLoc[0](Arg0: &InsuranceFund)
135 1: ImmBorrowField[1](InsuranceFund.security_account: address)
136 2: ReadRef
137 3: Ret
138}
139
140public(friend) perp_id(Arg0: &InsuranceFund): ID {
141B0:
142 0: MoveLoc[0](Arg0: &InsuranceFund)
143 1: ImmBorrowField[2](InsuranceFund.perp_id: ID)
144 2: ReadRef
145 3: Ret
146}
147
148public(friend) transfer_interval(Arg0: &InsuranceFund): u64 {
149B0:
150 0: MoveLoc[0](Arg0: &InsuranceFund)
151 1: ImmBorrowField[3](InsuranceFund.transfer_interval: u64)
152 2: ReadRef
153 3: Ret
154}
155
156public(friend) last_transfer_time(Arg0: &InsuranceFund): u64 {
157B0:
158 0: MoveLoc[0](Arg0: &InsuranceFund)
159 1: ImmBorrowField[4](InsuranceFund.last_transfer_time: u64)
160 2: ReadRef
161 3: Ret
162}
163
164public(friend) transfer_amount_limit(Arg0: &InsuranceFund): u128 {
165B0:
166 0: MoveLoc[0](Arg0: &InsuranceFund)
167 1: ImmBorrowField[5](InsuranceFund.transfer_amount_limit: u128)
168 2: ReadRef
169 3: Ret
170}
171
172public(friend) set_active_account(Arg0: &mut InsuranceFund, Arg1: address) {
173B0:
174 0: CopyLoc[1](Arg1: address)
175 1: LdConst[0](address: 0x00..)
176 2: Neq
177 3: BrFalse(5)
178B1:
179 4: Branch(9)
180B2:
181 5: MoveLoc[0](Arg0: &mut InsuranceFund)
182 6: Pop
183 7: LdU64(105)
184 8: Abort
185B3:
186 9: CopyLoc[1](Arg1: address)
187 10: CopyLoc[0](Arg0: &mut InsuranceFund)
188 11: ImmBorrowField[1](InsuranceFund.security_account: address)
189 12: ReadRef
190 13: Neq
191 14: BrFalse(16)
192B4:
193 15: Branch(20)
194B5:
195 16: MoveLoc[0](Arg0: &mut InsuranceFund)
196 17: Pop
197 18: LdU64(114)
198 19: Abort
199B6:
200 20: CopyLoc[1](Arg1: address)
201 21: CopyLoc[0](Arg0: &mut InsuranceFund)
202 22: MutBorrowField[0](InsuranceFund.active_account: address)
203 23: WriteRef
204 24: MoveLoc[0](Arg0: &mut InsuranceFund)
205 25: ImmBorrowField[2](InsuranceFund.perp_id: ID)
206 26: ReadRef
207 27: MoveLoc[1](Arg1: address)
208 28: Pack[1](InsuranceFundUpdateActiveAccountEvent)
209 29: Call event::emit<InsuranceFundUpdateActiveAccountEvent>(InsuranceFundUpdateActiveAccountEvent)
210 30: Ret
211}
212
213public(friend) set_security_account(Arg0: &mut InsuranceFund, Arg1: address) {
214B0:
215 0: CopyLoc[1](Arg1: address)
216 1: LdConst[0](address: 0x00..)
217 2: Neq
218 3: BrFalse(5)
219B1:
220 4: Branch(9)
221B2:
222 5: MoveLoc[0](Arg0: &mut InsuranceFund)
223 6: Pop
224 7: LdU64(105)
225 8: Abort
226B3:
227 9: CopyLoc[1](Arg1: address)
228 10: CopyLoc[0](Arg0: &mut InsuranceFund)
229 11: ImmBorrowField[0](InsuranceFund.active_account: address)
230 12: ReadRef
231 13: Neq
232 14: BrFalse(16)
233B4:
234 15: Branch(20)
235B5:
236 16: MoveLoc[0](Arg0: &mut InsuranceFund)
237 17: Pop
238 18: LdU64(114)
239 19: Abort
240B6:
241 20: CopyLoc[1](Arg1: address)
242 21: CopyLoc[0](Arg0: &mut InsuranceFund)
243 22: MutBorrowField[1](InsuranceFund.security_account: address)
244 23: WriteRef
245 24: MoveLoc[0](Arg0: &mut InsuranceFund)
246 25: ImmBorrowField[2](InsuranceFund.perp_id: ID)
247 26: ReadRef
248 27: MoveLoc[1](Arg1: address)
249 28: Pack[2](InsuranceFundUpdateSecurityAccountEvent)
250 29: Call event::emit<InsuranceFundUpdateSecurityAccountEvent>(InsuranceFundUpdateSecurityAccountEvent)
251 30: Ret
252}
253
254public(friend) set_amount_limit(Arg0: &mut InsuranceFund, Arg1: u128) {
255B0:
256 0: CopyLoc[1](Arg1: u128)
257 1: LdU128(0)
258 2: Gt
259 3: BrFalse(5)
260B1:
261 4: Branch(9)
262B2:
263 5: MoveLoc[0](Arg0: &mut InsuranceFund)
264 6: Pop
265 7: LdU64(117)
266 8: Abort
267B3:
268 9: CopyLoc[1](Arg1: u128)
269 10: CopyLoc[0](Arg0: &mut InsuranceFund)
270 11: MutBorrowField[5](InsuranceFund.transfer_amount_limit: u128)
271 12: WriteRef
272 13: MoveLoc[0](Arg0: &mut InsuranceFund)
273 14: ImmBorrowField[2](InsuranceFund.perp_id: ID)
274 15: ReadRef
275 16: MoveLoc[1](Arg1: u128)
276 17: Pack[4](InsuranceFundUpdateTransferAmountLimitEvent)
277 18: Call event::emit<InsuranceFundUpdateTransferAmountLimitEvent>(InsuranceFundUpdateTransferAmountLimitEvent)
278 19: Ret
279}
280
281public(friend) set_transfer_interval(Arg0: &mut InsuranceFund, Arg1: u64) {
282B0:
283 0: CopyLoc[1](Arg1: u64)
284 1: LdU64(0)
285 2: Gt
286 3: BrFalse(5)
287B1:
288 4: Branch(9)
289B2:
290 5: MoveLoc[0](Arg0: &mut InsuranceFund)
291 6: Pop
292 7: LdU64(115)
293 8: Abort
294B3:
295 9: CopyLoc[1](Arg1: u64)
296 10: CopyLoc[0](Arg0: &mut InsuranceFund)
297 11: MutBorrowField[3](InsuranceFund.transfer_interval: u64)
298 12: WriteRef
299 13: MoveLoc[0](Arg0: &mut InsuranceFund)
300 14: ImmBorrowField[2](InsuranceFund.perp_id: ID)
301 15: ReadRef
302 16: MoveLoc[1](Arg1: u64)
303 17: Pack[3](InsuranceFundUpdateTransferIntervalEvent)
304 18: Call event::emit<InsuranceFundUpdateTransferIntervalEvent>(InsuranceFundUpdateTransferIntervalEvent)
305 19: Ret
306}
307
308public(friend) transfer_from_security_to_active<Ty0>(Arg0: &mut InsuranceFund, Arg1: &Clock, Arg2: &mut Bank<Ty0>, Arg3: u128, Arg4: u128) {
309L5: loc0: u64
310B0:
311 0: CopyLoc[3](Arg3: u128)
312 1: LdU128(0)
313 2: Gt
314 3: BrFalse(5)
315B1:
316 4: Branch(13)
317B2:
318 5: MoveLoc[0](Arg0: &mut InsuranceFund)
319 6: Pop
320 7: MoveLoc[1](Arg1: &Clock)
321 8: Pop
322 9: MoveLoc[2](Arg2: &mut Bank<Ty0>)
323 10: Pop
324 11: LdU64(117)
325 12: Abort
326B3:
327 13: CopyLoc[3](Arg3: u128)
328 14: CopyLoc[0](Arg0: &mut InsuranceFund)
329 15: ImmBorrowField[5](InsuranceFund.transfer_amount_limit: u128)
330 16: ReadRef
331 17: Le
332 18: BrFalse(20)
333B4:
334 19: Branch(28)
335B5:
336 20: MoveLoc[0](Arg0: &mut InsuranceFund)
337 21: Pop
338 22: MoveLoc[1](Arg1: &Clock)
339 23: Pop
340 24: MoveLoc[2](Arg2: &mut Bank<Ty0>)
341 25: Pop
342 26: LdU64(116)
343 27: Abort
344B6:
345 28: MoveLoc[1](Arg1: &Clock)
346 29: Call clock::timestamp_ms(&Clock): u64
347 30: StLoc[5](loc0: u64)
348 31: CopyLoc[0](Arg0: &mut InsuranceFund)
349 32: ImmBorrowField[4](InsuranceFund.last_transfer_time: u64)
350 33: ReadRef
351 34: LdU64(0)
352 35: Gt
353 36: BrFalse(54)
354B7:
355 37: CopyLoc[5](loc0: u64)
356 38: CopyLoc[0](Arg0: &mut InsuranceFund)
357 39: ImmBorrowField[4](InsuranceFund.last_transfer_time: u64)
358 40: ReadRef
359 41: Sub
360 42: CopyLoc[0](Arg0: &mut InsuranceFund)
361 43: ImmBorrowField[3](InsuranceFund.transfer_interval: u64)
362 44: ReadRef
363 45: Ge
364 46: BrFalse(48)
365B8:
366 47: Branch(54)
367B9:
368 48: MoveLoc[0](Arg0: &mut InsuranceFund)
369 49: Pop
370 50: MoveLoc[2](Arg2: &mut Bank<Ty0>)
371 51: Pop
372 52: LdU64(115)
373 53: Abort
374B10:
375 54: MoveLoc[2](Arg2: &mut Bank<Ty0>)
376 55: CopyLoc[0](Arg0: &mut InsuranceFund)
377 56: ImmBorrowField[1](InsuranceFund.security_account: address)
378 57: ReadRef
379 58: CopyLoc[0](Arg0: &mut InsuranceFund)
380 59: ImmBorrowField[0](InsuranceFund.active_account: address)
381 60: ReadRef
382 61: CopyLoc[3](Arg3: u128)
383 62: LdU64(0)
384 63: MoveLoc[4](Arg4: u128)
385 64: Call bank::transfer<Ty0>(&mut Bank<Ty0>, address, address, u128, u64, u128)
386 65: CopyLoc[5](loc0: u64)
387 66: CopyLoc[0](Arg0: &mut InsuranceFund)
388 67: MutBorrowField[4](InsuranceFund.last_transfer_time: u64)
389 68: WriteRef
390 69: MoveLoc[0](Arg0: &mut InsuranceFund)
391 70: ImmBorrowField[2](InsuranceFund.perp_id: ID)
392 71: ReadRef
393 72: LdTrue
394 73: MoveLoc[3](Arg3: u128)
395 74: MoveLoc[5](loc0: u64)
396 75: Pack[6](InsuranceFundTransferEvent)
397 76: Call event::emit<InsuranceFundTransferEvent>(InsuranceFundTransferEvent)
398 77: Ret
399}
400
401public(friend) transfer_from_active_to_security<Ty0>(Arg0: &InsuranceFund, Arg1: &Clock, Arg2: &mut Bank<Ty0>, Arg3: u128, Arg4: u128) {
402B0:
403 0: CopyLoc[3](Arg3: u128)
404 1: LdU128(0)
405 2: Gt
406 3: BrFalse(5)
407B1:
408 4: Branch(13)
409B2:
410 5: MoveLoc[0](Arg0: &InsuranceFund)
411 6: Pop
412 7: MoveLoc[1](Arg1: &Clock)
413 8: Pop
414 9: MoveLoc[2](Arg2: &mut Bank<Ty0>)
415 10: Pop
416 11: LdU64(117)
417 12: Abort
418B3:
419 13: MoveLoc[2](Arg2: &mut Bank<Ty0>)
420 14: CopyLoc[0](Arg0: &InsuranceFund)
421 15: ImmBorrowField[0](InsuranceFund.active_account: address)
422 16: ReadRef
423 17: CopyLoc[0](Arg0: &InsuranceFund)
424 18: ImmBorrowField[1](InsuranceFund.security_account: address)
425 19: ReadRef
426 20: CopyLoc[3](Arg3: u128)
427 21: LdU64(0)
428 22: MoveLoc[4](Arg4: u128)
429 23: Call bank::transfer<Ty0>(&mut Bank<Ty0>, address, address, u128, u64, u128)
430 24: MoveLoc[0](Arg0: &InsuranceFund)
431 25: ImmBorrowField[2](InsuranceFund.perp_id: ID)
432 26: ReadRef
433 27: LdFalse
434 28: MoveLoc[3](Arg3: u128)
435 29: MoveLoc[1](Arg1: &Clock)
436 30: Call clock::timestamp_ms(&Clock): u64
437 31: Pack[6](InsuranceFundTransferEvent)
438 32: Call event::emit<InsuranceFundTransferEvent>(InsuranceFundTransferEvent)
439 33: Ret
440}
441
442Constants [
443 0 => address: 0x0000000000000000000000000000000000000000000000000000000000000000
444]
445}
446
0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/isolated_trading.mvb1246 lines
1// Move bytecode v7
2module 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001.isolated_trading {
3use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::evaluator;
4use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::library;
5use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::order;
6use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::perpetual;
7use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::position;
8use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::protocol;
9use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::s128;
10use 9041eddbe15edba576c8c0bd4237e07b19e2c17fb59b240658f96522261f10c4::unified_address;
11use 0000000000000000000000000000000000000000000000000000000000000002::event;
12use 0000000000000000000000000000000000000000000000000000000000000002::object;
13use 0000000000000000000000000000000000000000000000000000000000000002::table;
14use 0000000000000000000000000000000000000000000000000000000000000002::transfer;
15use 0000000000000000000000000000000000000000000000000000000000000002::tx_context;
16use 0000000000000000000000000000000000000000000000000000000000000002::vec_set;
17
18struct TradeExecutedEvent has copy, drop {
19 tx_index: u128,
20 sender: address,
21 perp_id: ID,
22 trade_type: u8,
23 maker: address,
24 taker: address,
25 make_order_hash: vector<u8>,
26 taker_order_hash: vector<u8>,
27 maker_mro: u128,
28 taker_mro: u128,
29 maker_trade_fee: u128,
30 maker_gas_fee: u128,
31 taker_trade_fee: u128,
32 taker_gas_fee: u128,
33 maker_pnl: S128,
34 taker_pnl: S128,
35 trade_quantity: u128,
36 trade_price: u128,
37 is_long: bool
38}
39
40struct TradeData has copy, drop {
41 maker_signature: vector<u8>,
42 taker_signature: vector<u8>,
43 maker_publicKey: vector<u8>,
44 taker_publicKey: vector<u8>,
45 maker_order: Order,
46 taker_order: Order,
47 fill: Fill,
48 current_time: u64
49}
50
51struct TradeDataV2 has copy, drop {
52 maker_order: OrderV2,
53 taker_order: OrderV2,
54 maker_signatory: UnifiedAddress,
55 maker_payload_version: u32,
56 taker_signatory: UnifiedAddress,
57 taker_payload_version: u32,
58 fill: Fill,
59 current_time: u64
60}
61
62struct Fill has copy, drop {
63 quantity: u128,
64 price: u128
65}
66
67struct IMResponse has drop {
68 funds_flow: S128,
69 pnl: S128,
70 trade_fee: u128
71}
72
73struct TradeResponse has copy, drop, store {
74 maker_funds_flow: S128,
75 taker_funds_flow: S128,
76 trade_fee: u128,
77 gas_fee: u128
78}
79
80init(Arg0: &mut TxContext) {
81B0:
82 0: MoveLoc[0](Arg0: &mut TxContext)
83 1: Call table::new<vector<u8>, OrderStatus>(&mut TxContext): Table<vector<u8>, OrderStatus>
84 2: Call transfer::public_share_object<Table<vector<u8>, OrderStatus>>(Table<vector<u8>, OrderStatus>)
85 3: Ret
86}
87
88public(friend) trade(Arg0: &ProtocolConfig, Arg1: address, Arg2: &mut Perpetual, Arg3: &mut Table<vector<u8>, OrderStatus>, Arg4: TradeDataV2, Arg5: u128): TradeResponse {
89L6: loc0: bool
90L7: loc1: u64
91L8: loc2: TradeDataV2
92L9: loc3: Fill
93L10: loc4: bool
94L11: loc5: u128
95L12: loc6: Position
96L13: loc7: Position
97L14: loc8: address
98L15: loc9: address
99L16: loc10: S128
100L17: loc11: u128
101L18: loc12: vector<u8>
102L19: loc13: u128
103L20: loc14: &mut OrderV2
104L21: loc15: IMResponse
105L22: loc16: UnifiedAddress
106L23: loc17: u128
107L24: loc18: u128
108L25: loc19: u128
109L26: loc20: Position
110L27: loc21: Position
111L28: loc22: u128
112L29: loc23: ID
113L30: loc24: &mut Table<address, Position>
114L31: loc25: address
115L32: loc26: S128
116L33: loc27: u128
117L34: loc28: vector<u8>
118L35: loc29: u128
119L36: loc30: &mut OrderV2
120L37: loc31: IMResponse
121L38: loc32: UnifiedAddress
122L39: loc33: u128
123L40: loc34: u128
124L41: loc35: TradeChecks
125B0:
126 0: CopyLoc[4](Arg4: TradeDataV2)
127 1: StLoc[8](loc2: TradeDataV2)
128 2: ImmBorrowLoc[8](loc2: TradeDataV2)
129 3: ImmBorrowField[0](TradeDataV2.fill: Fill)
130 4: ImmBorrowField[1](Fill.quantity: u128)
131 5: ReadRef
132 6: Call library::base_uint(): u128
133 7: Div
134 8: MutBorrowLoc[8](loc2: TradeDataV2)
135 9: MutBorrowField[0](TradeDataV2.fill: Fill)
136 10: MutBorrowField[1](Fill.quantity: u128)
137 11: WriteRef
138 12: ImmBorrowLoc[8](loc2: TradeDataV2)
139 13: ImmBorrowField[0](TradeDataV2.fill: Fill)
140 14: ImmBorrowField[2](Fill.price: u128)
141 15: ReadRef
142 16: Call library::base_uint(): u128
143 17: Div
144 18: MutBorrowLoc[8](loc2: TradeDataV2)
145 19: MutBorrowField[0](TradeDataV2.fill: Fill)
146 20: MutBorrowField[2](Fill.price: u128)
147 21: WriteRef
148 22: ImmBorrowLoc[8](loc2: TradeDataV2)
149 23: ImmBorrowField[3](TradeDataV2.maker_order: OrderV2)
150 24: ReadRef
151 25: Call order::to_1x9(OrderV2): OrderV2
152 26: MutBorrowLoc[8](loc2: TradeDataV2)
153 27: MutBorrowField[3](TradeDataV2.maker_order: OrderV2)
154 28: WriteRef
155 29: ImmBorrowLoc[8](loc2: TradeDataV2)
156 30: ImmBorrowField[4](TradeDataV2.taker_order: OrderV2)
157 31: ReadRef
158 32: Call order::to_1x9(OrderV2): OrderV2
159 33: MutBorrowLoc[8](loc2: TradeDataV2)
160 34: MutBorrowField[4](TradeDataV2.taker_order: OrderV2)
161 35: WriteRef
162 36: ImmBorrowLoc[8](loc2: TradeDataV2)
163 37: ImmBorrowField[0](TradeDataV2.fill: Fill)
164 38: ReadRef
165 39: StLoc[9](loc3: Fill)
166 40: ImmBorrowLoc[8](loc2: TradeDataV2)
167 41: ImmBorrowField[5](TradeDataV2.current_time: u64)
168 42: ReadRef
169 43: StLoc[7](loc1: u64)
170 44: ImmBorrowLoc[8](loc2: TradeDataV2)
171 45: ImmBorrowField[3](TradeDataV2.maker_order: OrderV2)
172 46: Call order::creator_identifier(&OrderV2): address
173 47: StLoc[15](loc9: address)
174 48: ImmBorrowLoc[8](loc2: TradeDataV2)
175 49: ImmBorrowField[4](TradeDataV2.taker_order: OrderV2)
176 50: Call order::creator_identifier(&OrderV2): address
177 51: StLoc[31](loc25: address)
178 52: ImmBorrowLoc[8](loc2: TradeDataV2)
179 53: ImmBorrowField[6](TradeDataV2.maker_signatory: UnifiedAddress)
180 54: ReadRef
181 55: StLoc[22](loc16: UnifiedAddress)
182 56: ImmBorrowLoc[8](loc2: TradeDataV2)
183 57: ImmBorrowField[7](TradeDataV2.taker_signatory: UnifiedAddress)
184 58: ReadRef
185 59: StLoc[38](loc32: UnifiedAddress)
186 60: MutBorrowLoc[8](loc2: TradeDataV2)
187 61: MutBorrowField[3](TradeDataV2.maker_order: OrderV2)
188 62: StLoc[20](loc14: &mut OrderV2)
189 63: MutBorrowLoc[8](loc2: TradeDataV2)
190 64: MutBorrowField[4](TradeDataV2.taker_order: OrderV2)
191 65: StLoc[36](loc30: &mut OrderV2)
192 66: CopyLoc[20](loc14: &mut OrderV2)
193 67: FreezeRef
194 68: Call order::is_long(&OrderV2): bool
195 69: CopyLoc[36](loc30: &mut OrderV2)
196 70: FreezeRef
197 71: Call order::is_long(&OrderV2): bool
198 72: Neq
199 73: BrFalse(75)
200B1:
201 74: Branch(87)
202B2:
203 75: MoveLoc[36](loc30: &mut OrderV2)
204 76: Pop
205 77: MoveLoc[0](Arg0: &ProtocolConfig)
206 78: Pop
207 79: MoveLoc[2](Arg2: &mut Perpetual)
208 80: Pop
209 81: MoveLoc[3](Arg3: &mut Table<vector<u8>, OrderStatus>)
210 82: Pop
211 83: MoveLoc[20](loc14: &mut OrderV2)
212 84: Pop
213 85: LdU64(48)
214 86: Abort
215B3:
216 87: CopyLoc[2](Arg2: &mut Perpetual)
217 88: FreezeRef
218 89: Call perpetual::price_oracle(&Perpetual): u128
219 90: StLoc[28](loc22: u128)
220 91: CopyLoc[2](Arg2: &mut Perpetual)
221 92: FreezeRef
222 93: Call perpetual::checks(&Perpetual): TradeChecks
223 94: StLoc[41](loc35: TradeChecks)
224 95: CopyLoc[2](Arg2: &mut Perpetual)
225 96: FreezeRef
226 97: CopyLoc[15](loc9: address)
227 98: LdTrue
228 99: Call perpetual::get_fee(&Perpetual, address, bool): u128
229 100: StLoc[23](loc17: u128)
230 101: CopyLoc[2](Arg2: &mut Perpetual)
231 102: FreezeRef
232 103: CopyLoc[31](loc25: address)
233 104: LdFalse
234 105: Call perpetual::get_fee(&Perpetual, address, bool): u128
235 106: StLoc[39](loc33: u128)
236 107: CopyLoc[2](Arg2: &mut Perpetual)
237 108: FreezeRef
238 109: Call perpetual::id(&Perpetual): &UID
239 110: Call object::uid_to_inner(&UID): ID
240 111: StLoc[29](loc23: ID)
241 112: CopyLoc[2](Arg2: &mut Perpetual)
242 113: FreezeRef
243 114: Call perpetual::imr(&Perpetual): u128
244 115: StLoc[11](loc5: u128)
245 116: CopyLoc[2](Arg2: &mut Perpetual)
246 117: FreezeRef
247 118: Call perpetual::mmr(&Perpetual): u128
248 119: StLoc[25](loc19: u128)
249 120: CopyLoc[2](Arg2: &mut Perpetual)
250 121: FreezeRef
251 122: Call perpetual::insurance_active_pool(&Perpetual): address
252 123: StLoc[14](loc8: address)
253 124: MoveLoc[2](Arg2: &mut Perpetual)
254 125: Call perpetual::positions(&mut Perpetual): &mut Table<address, Position>
255 126: StLoc[30](loc24: &mut Table<address, Position>)
256 127: ImmBorrowLoc[4](Arg4: TradeDataV2)
257 128: ImmBorrowField[3](TradeDataV2.maker_order: OrderV2)
258 129: ReadRef
259 130: ImmBorrowLoc[4](Arg4: TradeDataV2)
260 131: ImmBorrowField[8](TradeDataV2.maker_payload_version: u32)
261 132: ReadRef
262 133: Call order::to_json_bytes(OrderV2, u32): vector<u8>
263 134: Call library::get_hash(vector<u8>): vector<u8>
264 135: StLoc[18](loc12: vector<u8>)
265 136: ImmBorrowLoc[4](Arg4: TradeDataV2)
266 137: ImmBorrowField[4](TradeDataV2.taker_order: OrderV2)
267 138: ReadRef
268 139: ImmBorrowLoc[4](Arg4: TradeDataV2)
269 140: ImmBorrowField[9](TradeDataV2.taker_payload_version: u32)
270 141: ReadRef
271 142: Call order::to_json_bytes(OrderV2, u32): vector<u8>
272 143: Call library::get_hash(vector<u8>): vector<u8>
273 144: StLoc[34](loc28: vector<u8>)
274 145: CopyLoc[3](Arg3: &mut Table<vector<u8>, OrderStatus>)
275 146: CopyLoc[18](loc12: vector<u8>)
276 147: Call order::create_order(&mut Table<vector<u8>, OrderStatus>, vector<u8>)
277 148: CopyLoc[3](Arg3: &mut Table<vector<u8>, OrderStatus>)
278 149: CopyLoc[34](loc28: vector<u8>)
279 150: Call order::create_order(&mut Table<vector<u8>, OrderStatus>, vector<u8>)
280 151: CopyLoc[36](loc30: &mut OrderV2)
281 152: ReadRef
282 153: Call order::price(OrderV2): u128
283 154: LdU128(0)
284 155: Eq
285 156: BrFalse(165)
286B4:
287 157: CopyLoc[36](loc30: &mut OrderV2)
288 158: ImmBorrowLoc[9](loc3: Fill)
289 159: ImmBorrowField[2](Fill.price: u128)
290 160: ReadRef
291 161: Call order::set_price(&mut OrderV2, u128)
292 162: LdTrue
293 163: StLoc[6](loc0: bool)
294 164: Branch(167)
295B5:
296 165: LdFalse
297 166: StLoc[6](loc0: bool)
298B6:
299 167: MoveLoc[6](loc0: bool)
300 168: StLoc[10](loc4: bool)
301 169: CopyLoc[20](loc14: &mut OrderV2)
302 170: ReadRef
303 171: Call order::leverage(OrderV2): u128
304 172: Call library::round_down(u128): u128
305 173: StLoc[19](loc13: u128)
306 174: CopyLoc[20](loc14: &mut OrderV2)
307 175: MoveLoc[19](loc13: u128)
308 176: Call order::set_leverage(&mut OrderV2, u128)
309 177: CopyLoc[36](loc30: &mut OrderV2)
310 178: ReadRef
311 179: Call order::leverage(OrderV2): u128
312 180: Call library::round_down(u128): u128
313 181: StLoc[35](loc29: u128)
314 182: CopyLoc[36](loc30: &mut OrderV2)
315 183: MoveLoc[35](loc29: u128)
316 184: Call order::set_leverage(&mut OrderV2, u128)
317 185: CopyLoc[30](loc24: &mut Table<address, Position>)
318 186: FreezeRef
319 187: CopyLoc[15](loc9: address)
320 188: Call table::borrow<address, Position>(&Table<address, Position>, address): &Position
321 189: ReadRef
322 190: StLoc[12](loc6: Position)
323 191: CopyLoc[30](loc24: &mut Table<address, Position>)
324 192: FreezeRef
325 193: CopyLoc[31](loc25: address)
326 194: Call table::borrow<address, Position>(&Table<address, Position>, address): &Position
327 195: ReadRef
328 196: StLoc[13](loc7: Position)
329 197: CopyLoc[12](loc6: Position)
330 198: CopyLoc[3](Arg3: &mut Table<vector<u8>, OrderStatus>)
331 199: CopyLoc[20](loc14: &mut OrderV2)
332 200: ReadRef
333 201: CopyLoc[18](loc12: vector<u8>)
334 202: MoveLoc[22](loc16: UnifiedAddress)
335 203: CopyLoc[9](loc3: Fill)
336 204: CopyLoc[7](loc1: u64)
337 205: LdU64(0)
338 206: CopyLoc[5](Arg5: u128)
339 207: CopyLoc[14](loc8: address)
340 208: CopyLoc[15](loc9: address)
341 209: Eq
342 210: Call verify_order(Position, &mut Table<vector<u8>, OrderStatus>, OrderV2, vector<u8>, UnifiedAddress, Fill, u64, u64, u128, bool)
343 211: CopyLoc[13](loc7: Position)
344 212: CopyLoc[3](Arg3: &mut Table<vector<u8>, OrderStatus>)
345 213: CopyLoc[36](loc30: &mut OrderV2)
346 214: ReadRef
347 215: CopyLoc[34](loc28: vector<u8>)
348 216: MoveLoc[38](loc32: UnifiedAddress)
349 217: CopyLoc[9](loc3: Fill)
350 218: MoveLoc[7](loc1: u64)
351 219: LdU64(1)
352 220: CopyLoc[5](Arg5: u128)
353 221: CopyLoc[14](loc8: address)
354 222: CopyLoc[31](loc25: address)
355 223: Eq
356 224: Call verify_order(Position, &mut Table<vector<u8>, OrderStatus>, OrderV2, vector<u8>, UnifiedAddress, Fill, u64, u64, u128, bool)
357 225: CopyLoc[41](loc35: TradeChecks)
358 226: ImmBorrowLoc[9](loc3: Fill)
359 227: ImmBorrowField[2](Fill.price: u128)
360 228: ReadRef
361 229: Call evaluator::verify_price_checks(TradeChecks, u128)
362 230: CopyLoc[41](loc35: TradeChecks)
363 231: ImmBorrowLoc[9](loc3: Fill)
364 232: ImmBorrowField[1](Fill.quantity: u128)
365 233: ReadRef
366 234: MoveLoc[10](loc4: bool)
367 235: Call evaluator::verify_qty_checks(TradeChecks, u128, bool)
368 236: CopyLoc[41](loc35: TradeChecks)
369 237: ImmBorrowLoc[9](loc3: Fill)
370 238: ImmBorrowField[2](Fill.price: u128)
371 239: ReadRef
372 240: CopyLoc[28](loc22: u128)
373 241: CopyLoc[36](loc30: &mut OrderV2)
374 242: FreezeRef
375 243: Call order::is_long(&OrderV2): bool
376 244: Call evaluator::verify_market_take_bound_checks(TradeChecks, u128, u128, bool)
377 245: CopyLoc[3](Arg3: &mut Table<vector<u8>, OrderStatus>)
378 246: FreezeRef
379 247: CopyLoc[18](loc12: vector<u8>)
380 248: ImmBorrowLoc[9](loc3: Fill)
381 249: ImmBorrowField[1](Fill.quantity: u128)
382 250: ReadRef
383 251: CopyLoc[0](Arg0: &ProtocolConfig)
384 252: Call protocol::maker_gas_fee(&ProtocolConfig): u128
385 253: Call caculate_gas_fee(&Table<vector<u8>, OrderStatus>, vector<u8>, u128, u128): u128
386 254: StLoc[17](loc11: u128)
387 255: MoveLoc[3](Arg3: &mut Table<vector<u8>, OrderStatus>)
388 256: FreezeRef
389 257: CopyLoc[34](loc28: vector<u8>)
390 258: ImmBorrowLoc[9](loc3: Fill)
391 259: ImmBorrowField[1](Fill.quantity: u128)
392 260: ReadRef
393 261: CopyLoc[0](Arg0: &ProtocolConfig)
394 262: Call protocol::taker_gas_fee(&ProtocolConfig): u128
395 263: Call caculate_gas_fee(&Table<vector<u8>, OrderStatus>, vector<u8>, u128, u128): u128
396 264: StLoc[33](loc27: u128)
397 265: CopyLoc[15](loc9: address)
398 266: CopyLoc[31](loc25: address)
399 267: Eq
400 268: BrFalse(346)
401B7:
402 269: MoveLoc[0](Arg0: &ProtocolConfig)
403 270: Pop
404 271: MoveLoc[30](loc24: &mut Table<address, Position>)
405 272: Pop
406 273: MoveLoc[20](loc14: &mut OrderV2)
407 274: Pop
408 275: ImmBorrowLoc[9](loc3: Fill)
409 276: ImmBorrowField[2](Fill.price: u128)
410 277: ReadRef
411 278: MoveLoc[23](loc17: u128)
412 279: Call library::base_mul(u128, u128): u128
413 280: ImmBorrowLoc[9](loc3: Fill)
414 281: ImmBorrowField[1](Fill.quantity: u128)
415 282: ReadRef
416 283: Call library::base_mul(u128, u128): u128
417 284: StLoc[24](loc18: u128)
418 285: CopyLoc[24](loc18: u128)
419 286: LdTrue
420 287: Call s128::from(u128, bool): S128
421 288: CopyLoc[17](loc11: u128)
422 289: Call s128::add_u128(S128, u128): S128
423 290: StLoc[16](loc10: S128)
424 291: ImmBorrowLoc[9](loc3: Fill)
425 292: ImmBorrowField[2](Fill.price: u128)
426 293: ReadRef
427 294: MoveLoc[39](loc33: u128)
428 295: Call library::base_mul(u128, u128): u128
429 296: ImmBorrowLoc[9](loc3: Fill)
430 297: ImmBorrowField[1](Fill.quantity: u128)
431 298: ReadRef
432 299: Call library::base_mul(u128, u128): u128
433 300: StLoc[40](loc34: u128)
434 301: CopyLoc[40](loc34: u128)
435 302: LdTrue
436 303: Call s128::from(u128, bool): S128
437 304: CopyLoc[33](loc27: u128)
438 305: Call s128::add_u128(S128, u128): S128
439 306: StLoc[32](loc26: S128)
440 307: MoveLoc[5](Arg5: u128)
441 308: MoveLoc[1](Arg1: address)
442 309: MoveLoc[29](loc23: ID)
443 310: LdConst[0](u8: 1)
444 311: MoveLoc[15](loc9: address)
445 312: MoveLoc[31](loc25: address)
446 313: MoveLoc[18](loc12: vector<u8>)
447 314: MoveLoc[34](loc28: vector<u8>)
448 315: ImmBorrowLoc[12](loc6: Position)
449 316: Call position::mro(&Position): u128
450 317: ImmBorrowLoc[13](loc7: Position)
451 318: Call position::mro(&Position): u128
452 319: CopyLoc[24](loc18: u128)
453 320: CopyLoc[17](loc11: u128)
454 321: CopyLoc[40](loc34: u128)
455 322: CopyLoc[33](loc27: u128)
456 323: Call s128::zero(): S128
457 324: Call s128::zero(): S128
458 325: ImmBorrowLoc[9](loc3: Fill)
459 326: ImmBorrowField[1](Fill.quantity: u128)
460 327: ReadRef
461 328: ImmBorrowLoc[9](loc3: Fill)
462 329: ImmBorrowField[2](Fill.price: u128)
463 330: ReadRef
464 331: MoveLoc[36](loc30: &mut OrderV2)
465 332: FreezeRef
466 333: Call order::is_long(&OrderV2): bool
467 334: Pack[0](TradeExecutedEvent)
468 335: Call event::emit<TradeExecutedEvent>(TradeExecutedEvent)
469 336: MoveLoc[16](loc10: S128)
470 337: MoveLoc[32](loc26: S128)
471 338: MoveLoc[24](loc18: u128)
472 339: MoveLoc[40](loc34: u128)
473 340: Add
474 341: MoveLoc[17](loc11: u128)
475 342: MoveLoc[33](loc27: u128)
476 343: Add
477 344: Pack[5](TradeResponse)
478 345: Ret
479B8:
480 346: CopyLoc[41](loc35: TradeChecks)
481 347: CopyLoc[30](loc24: &mut Table<address, Position>)
482 348: CopyLoc[15](loc9: address)
483 349: Call table::borrow_mut<address, Position>(&mut Table<address, Position>, address): &mut Position
484 350: MoveLoc[20](loc14: &mut OrderV2)
485 351: ReadRef
486 352: CopyLoc[9](loc3: Fill)
487 353: ImmBorrowLoc[9](loc3: Fill)
488 354: ImmBorrowField[2](Fill.price: u128)
489 355: ReadRef
490 356: MoveLoc[23](loc17: u128)
491 357: Call library::base_mul_up(u128, u128): u128
492 358: LdU64(0)
493 359: CopyLoc[0](Arg0: &ProtocolConfig)
494 360: Call protocol::privileged_addresses(&ProtocolConfig): &VecSet<address>
495 361: ImmBorrowLoc[15](loc9: address)
496 362: Call vec_set::contains<address>(&VecSet<address>, &address): bool
497 363: CopyLoc[14](loc8: address)
498 364: CopyLoc[15](loc9: address)
499 365: Eq
500 366: Call apply_isolated_margin(TradeChecks, &mut Position, OrderV2, Fill, u128, u64, bool, bool): IMResponse
501 367: StLoc[21](loc15: IMResponse)
502 368: MoveLoc[41](loc35: TradeChecks)
503 369: CopyLoc[30](loc24: &mut Table<address, Position>)
504 370: CopyLoc[31](loc25: address)
505 371: Call table::borrow_mut<address, Position>(&mut Table<address, Position>, address): &mut Position
506 372: CopyLoc[36](loc30: &mut OrderV2)
507 373: ReadRef
508 374: CopyLoc[9](loc3: Fill)
509 375: ImmBorrowLoc[9](loc3: Fill)
510 376: ImmBorrowField[2](Fill.price: u128)
511 377: ReadRef
512 378: MoveLoc[39](loc33: u128)
513 379: Call library::base_mul_up(u128, u128): u128
514 380: LdU64(1)
515 381: MoveLoc[0](Arg0: &ProtocolConfig)
516 382: Call protocol::privileged_addresses(&ProtocolConfig): &VecSet<address>
517 383: ImmBorrowLoc[31](loc25: address)
518 384: Call vec_set::contains<address>(&VecSet<address>, &address): bool
519 385: CopyLoc[14](loc8: address)
520 386: CopyLoc[31](loc25: address)
521 387: Eq
522 388: Call apply_isolated_margin(TradeChecks, &mut Position, OrderV2, Fill, u128, u64, bool, bool): IMResponse
523 389: StLoc[37](loc31: IMResponse)
524 390: CopyLoc[30](loc24: &mut Table<address, Position>)
525 391: FreezeRef
526 392: CopyLoc[15](loc9: address)
527 393: Call table::borrow<address, Position>(&Table<address, Position>, address): &Position
528 394: ReadRef
529 395: StLoc[26](loc20: Position)
530 396: MoveLoc[30](loc24: &mut Table<address, Position>)
531 397: FreezeRef
532 398: CopyLoc[31](loc25: address)
533 399: Call table::borrow<address, Position>(&Table<address, Position>, address): &Position
534 400: ReadRef
535 401: StLoc[27](loc21: Position)
536 402: CopyLoc[14](loc8: address)
537 403: CopyLoc[15](loc9: address)
538 404: Neq
539 405: BrFalse(414)
540B9:
541 406: ImmBorrowLoc[12](loc6: Position)
542 407: ImmBorrowLoc[26](loc20: Position)
543 408: CopyLoc[11](loc5: u128)
544 409: CopyLoc[25](loc19: u128)
545 410: CopyLoc[28](loc22: u128)
546 411: LdConst[0](u8: 1)
547 412: LdU64(0)
548 413: Call position::verify_collat_checks(&Position, &Position, u128, u128, u128, u8, u64)
549B10:
550 414: MoveLoc[14](loc8: address)
551 415: CopyLoc[31](loc25: address)
552 416: Neq
553 417: BrFalse(426)
554B11:
555 418: ImmBorrowLoc[13](loc7: Position)
556 419: ImmBorrowLoc[27](loc21: Position)
557 420: MoveLoc[11](loc5: u128)
558 421: MoveLoc[25](loc19: u128)
559 422: MoveLoc[28](loc22: u128)
560 423: LdConst[0](u8: 1)
561 424: LdU64(1)
562 425: Call position::verify_collat_checks(&Position, &Position, u128, u128, u128, u8, u64)
563B12:
564 426: ImmBorrowLoc[21](loc15: IMResponse)
565 427: ImmBorrowField[10](IMResponse.funds_flow: S128)
566 428: ReadRef
567 429: CopyLoc[17](loc11: u128)
568 430: Call s128::add_u128(S128, u128): S128
569 431: MutBorrowLoc[21](loc15: IMResponse)
570 432: MutBorrowField[10](IMResponse.funds_flow: S128)
571 433: WriteRef
572 434: ImmBorrowLoc[37](loc31: IMResponse)
573 435: ImmBorrowField[10](IMResponse.funds_flow: S128)
574 436: ReadRef
575 437: CopyLoc[33](loc27: u128)
576 438: Call s128::add_u128(S128, u128): S128
577 439: MutBorrowLoc[37](loc31: IMResponse)
578 440: MutBorrowField[10](IMResponse.funds_flow: S128)
579 441: WriteRef
580 442: CopyLoc[26](loc20: Position)
581 443: CopyLoc[1](Arg1: address)
582 444: LdConst[1](u8: 0)
583 445: CopyLoc[5](Arg5: u128)
584 446: Call position::emit_position_update_event(Position, address, u8, u128)
585 447: CopyLoc[27](loc21: Position)
586 448: CopyLoc[1](Arg1: address)
587 449: LdConst[1](u8: 0)
588 450: CopyLoc[5](Arg5: u128)
589 451: Call position::emit_position_update_event(Position, address, u8, u128)
590 452: MoveLoc[5](Arg5: u128)
591 453: MoveLoc[1](Arg1: address)
592 454: MoveLoc[29](loc23: ID)
593 455: LdConst[0](u8: 1)
594 456: MoveLoc[15](loc9: address)
595 457: MoveLoc[31](loc25: address)
596 458: MoveLoc[18](loc12: vector<u8>)
597 459: MoveLoc[34](loc28: vector<u8>)
598 460: ImmBorrowLoc[26](loc20: Position)
599 461: Call position::mro(&Position): u128
600 462: ImmBorrowLoc[27](loc21: Position)
601 463: Call position::mro(&Position): u128
602 464: ImmBorrowLoc[21](loc15: IMResponse)
603 465: ImmBorrowField[11](IMResponse.trade_fee: u128)
604 466: ReadRef
605 467: CopyLoc[17](loc11: u128)
606 468: ImmBorrowLoc[37](loc31: IMResponse)
607 469: ImmBorrowField[11](IMResponse.trade_fee: u128)
608 470: ReadRef
609 471: CopyLoc[33](loc27: u128)
610 472: ImmBorrowLoc[21](loc15: IMResponse)
611 473: ImmBorrowField[12](IMResponse.pnl: S128)
612 474: ReadRef
613 475: ImmBorrowLoc[37](loc31: IMResponse)
614 476: ImmBorrowField[12](IMResponse.pnl: S128)
615 477: ReadRef
616 478: ImmBorrowLoc[9](loc3: Fill)
617 479: ImmBorrowField[1](Fill.quantity: u128)
618 480: ReadRef
619 481: ImmBorrowLoc[9](loc3: Fill)
620 482: ImmBorrowField[2](Fill.price: u128)
621 483: ReadRef
622 484: MoveLoc[36](loc30: &mut OrderV2)
623 485: FreezeRef
624 486: Call order::is_long(&OrderV2): bool
625 487: Pack[0](TradeExecutedEvent)
626 488: Call event::emit<TradeExecutedEvent>(TradeExecutedEvent)
627 489: ImmBorrowLoc[21](loc15: IMResponse)
628 490: ImmBorrowField[10](IMResponse.funds_flow: S128)
629 491: ReadRef
630 492: ImmBorrowLoc[37](loc31: IMResponse)
631 493: ImmBorrowField[10](IMResponse.funds_flow: S128)
632 494: ReadRef
633 495: ImmBorrowLoc[37](loc31: IMResponse)
634 496: ImmBorrowField[11](IMResponse.trade_fee: u128)
635 497: ReadRef
636 498: ImmBorrowLoc[21](loc15: IMResponse)
637 499: ImmBorrowField[11](IMResponse.trade_fee: u128)
638 500: ReadRef
639 501: Add
640 502: MoveLoc[17](loc11: u128)
641 503: MoveLoc[33](loc27: u128)
642 504: Add
643 505: Pack[5](TradeResponse)
644 506: Ret
645}
646
647public(friend) pack_trade_data(Arg0: OrderV2, Arg1: UnifiedAddress, Arg2: u32, Arg3: OrderV2, Arg4: UnifiedAddress, Arg5: u32, Arg6: u128, Arg7: u128, Arg8: u64): TradeDataV2 {
648L9: loc0: Fill
649B0:
650 0: MoveLoc[6](Arg6: u128)
651 1: MoveLoc[7](Arg7: u128)
652 2: Pack[3](Fill)
653 3: StLoc[9](loc0: Fill)
654 4: MoveLoc[0](Arg0: OrderV2)
655 5: MoveLoc[3](Arg3: OrderV2)
656 6: MoveLoc[1](Arg1: UnifiedAddress)
657 7: MoveLoc[2](Arg2: u32)
658 8: MoveLoc[4](Arg4: UnifiedAddress)
659 9: MoveLoc[5](Arg5: u32)
660 10: MoveLoc[9](loc0: Fill)
661 11: MoveLoc[8](Arg8: u64)
662 12: Pack[2](TradeDataV2)
663 13: Ret
664}
665
666public(friend) maker_funds_flow(Arg0: TradeResponse): S128 {
667B0:
668 0: ImmBorrowLoc[0](Arg0: TradeResponse)
669 1: ImmBorrowField[13](TradeResponse.maker_funds_flow: S128)
670 2: ReadRef
671 3: Ret
672}
673
674public(friend) taker_funds_flow(Arg0: TradeResponse): S128 {
675B0:
676 0: ImmBorrowLoc[0](Arg0: TradeResponse)
677 1: ImmBorrowField[14](TradeResponse.taker_funds_flow: S128)
678 2: ReadRef
679 3: Ret
680}
681
682public(friend) trade_fee(Arg0: TradeResponse): u128 {
683B0:
684 0: ImmBorrowLoc[0](Arg0: TradeResponse)
685 1: ImmBorrowField[15](TradeResponse.trade_fee: u128)
686 2: ReadRef
687 3: Ret
688}
689
690public(friend) gas_fee(Arg0: TradeResponse): u128 {
691B0:
692 0: ImmBorrowLoc[0](Arg0: TradeResponse)
693 1: ImmBorrowField[16](TradeResponse.gas_fee: u128)
694 2: ReadRef
695 3: Ret
696}
697
698public(friend) trade_type(): u8 {
699B0:
700 0: LdConst[0](u8: 1)
701 1: Ret
702}
703
704verify_order(Arg0: Position, Arg1: &mut Table<vector<u8>, OrderStatus>, Arg2: OrderV2, Arg3: vector<u8>, Arg4: UnifiedAddress, Arg5: Fill, Arg6: u64, Arg7: u64, Arg8: u128, Arg9: bool) {
705L10: loc0: bool
706L11: loc1: bool
707B0:
708 0: CopyLoc[7](Arg7: u64)
709 1: LdU64(0)
710 2: Eq
711 3: BrFalse(7)
712B1:
713 4: LdTrue
714 5: StLoc[10](loc0: bool)
715 6: Branch(11)
716B2:
717 7: CopyLoc[2](Arg2: OrderV2)
718 8: Call order::post_only(OrderV2): bool
719 9: Not
720 10: StLoc[10](loc0: bool)
721B3:
722 11: MoveLoc[10](loc0: bool)
723 12: BrFalse(14)
724B4:
725 13: Branch(18)
726B5:
727 14: MoveLoc[1](Arg1: &mut Table<vector<u8>, OrderStatus>)
728 15: Pop
729 16: LdU64(49)
730 17: Abort
731B6:
732 18: CopyLoc[7](Arg7: u64)
733 19: LdU64(1)
734 20: Eq
735 21: BrFalse(25)
736B7:
737 22: LdTrue
738 23: StLoc[11](loc1: bool)
739 24: Branch(29)
740B8:
741 25: CopyLoc[2](Arg2: OrderV2)
742 26: Call order::ioc(OrderV2): bool
743 27: Not
744 28: StLoc[11](loc1: bool)
745B9:
746 29: MoveLoc[11](loc1: bool)
747 30: BrFalse(32)
748B10:
749 31: Branch(36)
750B11:
751 32: MoveLoc[1](Arg1: &mut Table<vector<u8>, OrderStatus>)
752 33: Pop
753 34: LdU64(106)
754 35: Abort
755B12:
756 36: CopyLoc[1](Arg1: &mut Table<vector<u8>, OrderStatus>)
757 37: FreezeRef
758 38: CopyLoc[3](Arg3: vector<u8>)
759 39: CopyLoc[7](Arg7: u64)
760 40: Call order::verify_order_state(&Table<vector<u8>, OrderStatus>, vector<u8>, u64)
761 41: CopyLoc[2](Arg2: OrderV2)
762 42: Call order::expiration(OrderV2): u64
763 43: MoveLoc[6](Arg6: u64)
764 44: CopyLoc[7](Arg7: u64)
765 45: Call order::verify_order_expiry(u64, u64, u64)
766 46: MoveLoc[9](Arg9: bool)
767 47: Not
768 48: BrFalse(55)
769B13:
770 49: ImmBorrowLoc[0](Arg0: Position)
771 50: Call position::mro(&Position): u128
772 51: CopyLoc[2](Arg2: OrderV2)
773 52: Call order::leverage(OrderV2): u128
774 53: CopyLoc[7](Arg7: u64)
775 54: Call order::verify_order_leverage(u128, u128, u64)
776B14:
777 55: MoveLoc[1](Arg1: &mut Table<vector<u8>, OrderStatus>)
778 56: MoveLoc[2](Arg2: OrderV2)
779 57: MoveLoc[3](Arg3: vector<u8>)
780 58: ImmBorrowLoc[5](Arg5: Fill)
781 59: ImmBorrowField[2](Fill.price: u128)
782 60: ReadRef
783 61: ImmBorrowLoc[5](Arg5: Fill)
784 62: ImmBorrowField[1](Fill.quantity: u128)
785 63: ReadRef
786 64: ImmBorrowLoc[0](Arg0: Position)
787 65: Call position::is_long(&Position): bool
788 66: ImmBorrowLoc[0](Arg0: Position)
789 67: Call position::size(&Position): u128
790 68: MoveLoc[4](Arg4: UnifiedAddress)
791 69: MoveLoc[7](Arg7: u64)
792 70: MoveLoc[8](Arg8: u128)
793 71: Call order::verify_and_fill_order_qty(&mut Table<vector<u8>, OrderStatus>, OrderV2, vector<u8>, u128, u128, bool, u128, UnifiedAddress, u64, u128)
794 72: Ret
795}
796
797apply_isolated_margin(Arg0: TradeChecks, Arg1: &mut Position, Arg2: OrderV2, Arg3: Fill, Arg4: u128, Arg5: u64, Arg6: bool, Arg7: bool): IMResponse {
798L8: loc0: u128
799L9: loc1: u128
800L10: loc2: bool
801L11: loc3: bool
802L12: loc4: bool
803L13: loc5: u128
804L14: loc6: u128
805L15: loc7: S128
806L16: loc8: S128
807L17: loc9: bool
808L18: loc10: bool
809L19: loc11: u128
810L20: loc12: u128
811L21: loc13: u128
812L22: loc14: u128
813L23: loc15: u128
814L24: loc16: u128
815L25: loc17: S128
816L26: loc18: u128
817L27: loc19: u128
818L28: loc20: u128
819L29: loc21: u128
820B0:
821 0: ImmBorrowLoc[2](Arg2: OrderV2)
822 1: Call order::is_long(&OrderV2): bool
823 2: StLoc[17](loc9: bool)
824 3: CopyLoc[1](Arg1: &mut Position)
825 4: FreezeRef
826 5: Call position::oi_open(&Position): u128
827 6: StLoc[24](loc16: u128)
828 7: CopyLoc[1](Arg1: &mut Position)
829 8: FreezeRef
830 9: Call position::size(&Position): u128
831 10: StLoc[28](loc20: u128)
832 11: CopyLoc[1](Arg1: &mut Position)
833 12: FreezeRef
834 13: Call position::is_long(&Position): bool
835 14: StLoc[18](loc10: bool)
836 15: CopyLoc[1](Arg1: &mut Position)
837 16: FreezeRef
838 17: Call position::margin(&Position): u128
839 18: StLoc[19](loc11: u128)
840 19: CopyLoc[7](Arg7: bool)
841 20: BrFalse(24)
842B1:
843 21: LdU128(0)
844 22: StLoc[8](loc0: u128)
845 23: Branch(28)
846B2:
847 24: CopyLoc[2](Arg2: OrderV2)
848 25: Call order::leverage(OrderV2): u128
849 26: Call library::compute_mro(u128): u128
850 27: StLoc[8](loc0: u128)
851B3:
852 28: MoveLoc[8](loc0: u128)
853 29: StLoc[21](loc13: u128)
854 30: CopyLoc[1](Arg1: &mut Position)
855 31: FreezeRef
856 32: ImmBorrowLoc[3](Arg3: Fill)
857 33: ImmBorrowField[2](Fill.price: u128)
858 34: ReadRef
859 35: Call position::compute_pnl_per_unit(&Position, u128): S128
860 36: StLoc[25](loc17: S128)
861 37: CopyLoc[28](loc20: u128)
862 38: LdU128(0)
863 39: Eq
864 40: BrFalse(44)
865B4:
866 41: LdTrue
867 42: StLoc[10](loc2: bool)
868 43: Branch(48)
869B5:
870 44: CopyLoc[17](loc9: bool)
871 45: CopyLoc[18](loc10: bool)
872 46: Eq
873 47: StLoc[10](loc2: bool)
874B6:
875 48: MoveLoc[10](loc2: bool)
876 49: BrFalse(115)
877B7:
878 50: MoveLoc[7](Arg7: bool)
879 51: Not
880 52: BrFalse(54)
881B8:
882 53: Branch(58)
883B9:
884 54: MoveLoc[1](Arg1: &mut Position)
885 55: Pop
886 56: LdU64(118)
887 57: Abort
888B10:
889 58: ImmBorrowLoc[3](Arg3: Fill)
890 59: ImmBorrowField[2](Fill.price: u128)
891 60: ReadRef
892 61: CopyLoc[21](loc13: u128)
893 62: Call library::base_mul_up(u128, u128): u128
894 63: StLoc[20](loc12: u128)
895 64: ImmBorrowLoc[3](Arg3: Fill)
896 65: ImmBorrowField[1](Fill.quantity: u128)
897 66: ReadRef
898 67: CopyLoc[20](loc12: u128)
899 68: CopyLoc[4](Arg4: u128)
900 69: Add
901 70: Call library::base_mul_up(u128, u128): u128
902 71: LdTrue
903 72: Call s128::from(u128, bool): S128
904 73: StLoc[16](loc8: S128)
905 74: CopyLoc[1](Arg1: &mut Position)
906 75: MoveLoc[24](loc16: u128)
907 76: ImmBorrowLoc[3](Arg3: Fill)
908 77: ImmBorrowField[1](Fill.quantity: u128)
909 78: ReadRef
910 79: ImmBorrowLoc[3](Arg3: Fill)
911 80: ImmBorrowField[2](Fill.price: u128)
912 81: ReadRef
913 82: Call library::base_mul(u128, u128): u128
914 83: Add
915 84: Call position::set_oi_open(&mut Position, u128)
916 85: CopyLoc[1](Arg1: &mut Position)
917 86: MoveLoc[28](loc20: u128)
918 87: ImmBorrowLoc[3](Arg3: Fill)
919 88: ImmBorrowField[1](Fill.quantity: u128)
920 89: ReadRef
921 90: Add
922 91: Call position::set_size(&mut Position, u128)
923 92: CopyLoc[1](Arg1: &mut Position)
924 93: MoveLoc[19](loc11: u128)
925 94: ImmBorrowLoc[3](Arg3: Fill)
926 95: ImmBorrowField[1](Fill.quantity: u128)
927 96: ReadRef
928 97: MoveLoc[20](loc12: u128)
929 98: Call library::base_mul(u128, u128): u128
930 99: Add
931 100: Call position::set_margin(&mut Position, u128)
932 101: CopyLoc[1](Arg1: &mut Position)
933 102: MoveLoc[17](loc9: bool)
934 103: Call position::set_is_long(&mut Position, bool)
935 104: MoveLoc[0](Arg0: TradeChecks)
936 105: CopyLoc[21](loc13: u128)
937 106: CopyLoc[1](Arg1: &mut Position)
938 107: FreezeRef
939 108: Call position::oi_open(&Position): u128
940 109: MoveLoc[5](Arg5: u64)
941 110: MoveLoc[6](Arg6: bool)
942 111: Call evaluator::verify_oi_open_for_account(TradeChecks, u128, u128, u64, bool)
943 112: Call s128::zero(): S128
944 113: StLoc[25](loc17: S128)
945 114: Branch(340)
946B11:
947 115: MoveLoc[2](Arg2: OrderV2)
948 116: Call order::reduce_only(OrderV2): bool
949 117: BrFalse(121)
950B12:
951 118: LdTrue
952 119: StLoc[11](loc3: bool)
953 120: Branch(136)
954B13:
955 121: MoveLoc[17](loc9: bool)
956 122: CopyLoc[18](loc10: bool)
957 123: Neq
958 124: BrFalse(132)
959B14:
960 125: ImmBorrowLoc[3](Arg3: Fill)
961 126: ImmBorrowField[1](Fill.quantity: u128)
962 127: ReadRef
963 128: CopyLoc[28](loc20: u128)
964 129: Le
965 130: StLoc[12](loc4: bool)
966 131: Branch(134)
967B15:
968 132: LdFalse
969 133: StLoc[12](loc4: bool)
970B16:
971 134: MoveLoc[12](loc4: bool)
972 135: StLoc[11](loc3: bool)
973B17:
974 136: MoveLoc[11](loc3: bool)
975 137: BrFalse(227)
976B18:
977 138: CopyLoc[28](loc20: u128)
978 139: ImmBorrowLoc[3](Arg3: Fill)
979 140: ImmBorrowField[1](Fill.quantity: u128)
980 141: ReadRef
981 142: Sub
982 143: StLoc[22](loc14: u128)
983 144: CopyLoc[7](Arg7: bool)
984 145: Not
985 146: BrFalse(180)
986B19:
987 147: CopyLoc[19](loc11: u128)
988 148: CopyLoc[28](loc20: u128)
989 149: Call library::base_div(u128, u128): u128
990 150: StLoc[20](loc12: u128)
991 151: CopyLoc[25](loc17: S128)
992 152: MoveLoc[20](loc12: u128)
993 153: Call s128::add_u128(S128, u128): S128
994 154: StLoc[15](loc7: S128)
995 155: CopyLoc[15](loc7: S128)
996 156: LdU128(0)
997 157: Call s128::gte_u128(S128, u128): bool
998 158: BrFalse(160)
999B20:
1000 159: Branch(166)
1001B21:
1002 160: MoveLoc[1](Arg1: &mut Position)
1003 161: Pop
1004 162: MoveLoc[5](Arg5: u64)
1005 163: LdU64(46)
1006 164: Add
1007 165: Abort
1008B22:
1009 166: MoveLoc[15](loc7: S128)
1010 167: Call s128::positive_value(S128): u128
1011 168: StLoc[26](loc18: u128)
1012 169: CopyLoc[4](Arg4: u128)
1013 170: CopyLoc[26](loc18: u128)
1014 171: Gt
1015 172: BrFalse(176)
1016B23:
1017 173: MoveLoc[26](loc18: u128)
1018 174: StLoc[13](loc5: u128)
1019 175: Branch(178)
1020B24:
1021 176: MoveLoc[4](Arg4: u128)
1022 177: StLoc[13](loc5: u128)
1023B25:
1024 178: MoveLoc[13](loc5: u128)
1025 179: StLoc[4](Arg4: u128)
1026B26:
1027 180: CopyLoc[25](loc17: S128)
1028 181: Call s128::negate(S128): S128
1029 182: CopyLoc[4](Arg4: u128)
1030 183: Call s128::add_u128(S128, u128): S128
1031 184: ImmBorrowLoc[3](Arg3: Fill)
1032 185: ImmBorrowField[1](Fill.quantity: u128)
1033 186: ReadRef
1034 187: Call s128::mul_u128(S128, u128): S128
1035 188: CopyLoc[19](loc11: u128)
1036 189: ImmBorrowLoc[3](Arg3: Fill)
1037 190: ImmBorrowField[1](Fill.quantity: u128)
1038 191: ReadRef
1039 192: Mul
1040 193: CopyLoc[28](loc20: u128)
1041 194: Div
1042 195: Call s128::sub_u128(S128, u128): S128
1043 196: StLoc[16](loc8: S128)
1044 197: MoveLoc[7](Arg7: bool)
1045 198: Not
1046 199: BrFalse(203)
1047B27:
1048 200: MoveLoc[16](loc8: S128)
1049 201: Call s128::negative_number(S128): S128
1050 202: StLoc[16](loc8: S128)
1051B28:
1052 203: MoveLoc[25](loc17: S128)
1053 204: ImmBorrowLoc[3](Arg3: Fill)
1054 205: ImmBorrowField[1](Fill.quantity: u128)
1055 206: ReadRef
1056 207: Call s128::mul_u128(S128, u128): S128
1057 208: StLoc[25](loc17: S128)
1058 209: CopyLoc[1](Arg1: &mut Position)
1059 210: MoveLoc[19](loc11: u128)
1060 211: CopyLoc[22](loc14: u128)
1061 212: Mul
1062 213: CopyLoc[28](loc20: u128)
1063 214: Div
1064 215: Call position::set_margin(&mut Position, u128)
1065 216: CopyLoc[1](Arg1: &mut Position)
1066 217: MoveLoc[24](loc16: u128)
1067 218: CopyLoc[22](loc14: u128)
1068 219: Mul
1069 220: MoveLoc[28](loc20: u128)
1070 221: Div
1071 222: Call position::set_oi_open(&mut Position, u128)
1072 223: CopyLoc[1](Arg1: &mut Position)
1073 224: MoveLoc[22](loc14: u128)
1074 225: Call position::set_size(&mut Position, u128)
1075 226: Branch(340)
1076B29:
1077 227: MoveLoc[7](Arg7: bool)
1078 228: Not
1079 229: BrFalse(231)
1080B30:
1081 230: Branch(235)
1082B31:
1083 231: MoveLoc[1](Arg1: &mut Position)
1084 232: Pop
1085 233: LdU64(118)
1086 234: Abort
1087B32:
1088 235: ImmBorrowLoc[3](Arg3: Fill)
1089 236: ImmBorrowField[1](Fill.quantity: u128)
1090 237: ReadRef
1091 238: CopyLoc[28](loc20: u128)
1092 239: Sub
1093 240: StLoc[23](loc15: u128)
1094 241: CopyLoc[23](loc15: u128)
1095 242: ImmBorrowLoc[3](Arg3: Fill)
1096 243: ImmBorrowField[2](Fill.price: u128)
1097 244: ReadRef
1098 245: Call library::base_mul(u128, u128): u128
1099 246: StLoc[29](loc21: u128)
1100 247: CopyLoc[19](loc11: u128)
1101 248: CopyLoc[28](loc20: u128)
1102 249: Call library::base_div(u128, u128): u128
1103 250: StLoc[20](loc12: u128)
1104 251: CopyLoc[25](loc17: S128)
1105 252: MoveLoc[20](loc12: u128)
1106 253: Call s128::add_u128(S128, u128): S128
1107 254: StLoc[15](loc7: S128)
1108 255: CopyLoc[15](loc7: S128)
1109 256: LdU128(0)
1110 257: Call s128::gte_u128(S128, u128): bool
1111 258: BrFalse(260)
1112B33:
1113 259: Branch(266)
1114B34:
1115 260: MoveLoc[1](Arg1: &mut Position)
1116 261: Pop
1117 262: MoveLoc[5](Arg5: u64)
1118 263: LdU64(46)
1119 264: Add
1120 265: Abort
1121B35:
1122 266: MoveLoc[15](loc7: S128)
1123 267: Call s128::positive_value(S128): u128
1124 268: StLoc[27](loc19: u128)
1125 269: CopyLoc[4](Arg4: u128)
1126 270: CopyLoc[27](loc19: u128)
1127 271: Gt
1128 272: BrFalse(276)
1129B36:
1130 273: MoveLoc[27](loc19: u128)
1131 274: StLoc[9](loc1: u128)
1132 275: Branch(278)
1133B37:
1134 276: CopyLoc[4](Arg4: u128)
1135 277: StLoc[9](loc1: u128)
1136B38:
1137 278: MoveLoc[9](loc1: u128)
1138 279: StLoc[14](loc6: u128)
1139 280: CopyLoc[25](loc17: S128)
1140 281: Call s128::negate(S128): S128
1141 282: CopyLoc[14](loc6: u128)
1142 283: Call s128::add_u128(S128, u128): S128
1143 284: CopyLoc[28](loc20: u128)
1144 285: Call s128::mul_u128(S128, u128): S128
1145 286: MoveLoc[19](loc11: u128)
1146 287: Call s128::sub_u128(S128, u128): S128
1147 288: CopyLoc[23](loc15: u128)
1148 289: ImmBorrowLoc[3](Arg3: Fill)
1149 290: ImmBorrowField[2](Fill.price: u128)
1150 291: ReadRef
1151 292: CopyLoc[21](loc13: u128)
1152 293: Call library::base_mul_up(u128, u128): u128
1153 294: CopyLoc[4](Arg4: u128)
1154 295: Add
1155 296: Call library::base_mul_up(u128, u128): u128
1156 297: Call s128::add_u128(S128, u128): S128
1157 298: StLoc[16](loc8: S128)
1158 299: CopyLoc[28](loc20: u128)
1159 300: MoveLoc[14](loc6: u128)
1160 301: Call library::base_mul_up(u128, u128): u128
1161 302: CopyLoc[23](loc15: u128)
1162 303: MoveLoc[4](Arg4: u128)
1163 304: Call library::base_mul_up(u128, u128): u128
1164 305: Add
1165 306: ImmBorrowLoc[3](Arg3: Fill)
1166 307: ImmBorrowField[1](Fill.quantity: u128)
1167 308: ReadRef
1168 309: Call library::base_div_up(u128, u128): u128
1169 310: StLoc[4](Arg4: u128)
1170 311: MoveLoc[25](loc17: S128)
1171 312: MoveLoc[28](loc20: u128)
1172 313: Call s128::mul_u128(S128, u128): S128
1173 314: StLoc[25](loc17: S128)
1174 315: MoveLoc[0](Arg0: TradeChecks)
1175 316: CopyLoc[21](loc13: u128)
1176 317: CopyLoc[29](loc21: u128)
1177 318: MoveLoc[5](Arg5: u64)
1178 319: MoveLoc[6](Arg6: bool)
1179 320: Call evaluator::verify_oi_open_for_account(TradeChecks, u128, u128, u64, bool)
1180 321: CopyLoc[1](Arg1: &mut Position)
1181 322: CopyLoc[23](loc15: u128)
1182 323: Call position::set_size(&mut Position, u128)
1183 324: CopyLoc[1](Arg1: &mut Position)
1184 325: MoveLoc[29](loc21: u128)
1185 326: Call position::set_oi_open(&mut Position, u128)
1186 327: CopyLoc[1](Arg1: &mut Position)
1187 328: MoveLoc[23](loc15: u128)
1188 329: ImmBorrowLoc[3](Arg3: Fill)
1189 330: ImmBorrowField[2](Fill.price: u128)
1190 331: ReadRef
1191 332: CopyLoc[21](loc13: u128)
1192 333: Call library::base_mul(u128, u128): u128
1193 334: Call library::base_mul(u128, u128): u128
1194 335: Call position::set_margin(&mut Position, u128)
1195 336: CopyLoc[1](Arg1: &mut Position)
1196 337: MoveLoc[18](loc10: bool)
1197 338: Not
1198 339: Call position::set_is_long(&mut Position, bool)
1199B39:
1200 340: MoveLoc[1](Arg1: &mut Position)
1201 341: MoveLoc[21](loc13: u128)
1202 342: Call position::set_mro(&mut Position, u128)
1203 343: MoveLoc[16](loc8: S128)
1204 344: MoveLoc[25](loc17: S128)
1205 345: MoveLoc[4](Arg4: u128)
1206 346: ImmBorrowLoc[3](Arg3: Fill)
1207 347: ImmBorrowField[1](Fill.quantity: u128)
1208 348: ReadRef
1209 349: Call library::base_mul_up(u128, u128): u128
1210 350: Pack[4](IMResponse)
1211 351: Ret
1212}
1213
1214caculate_gas_fee(Arg0: &Table<vector<u8>, OrderStatus>, Arg1: vector<u8>, Arg2: u128, Arg3: u128): u128 {
1215B0:
1216 0: CopyLoc[3](Arg3: u128)
1217 1: LdU128(0)
1218 2: Eq
1219 3: BrFalse(8)
1220B1:
1221 4: MoveLoc[0](Arg0: &Table<vector<u8>, OrderStatus>)
1222 5: Pop
1223 6: LdU128(0)
1224 7: Ret
1225B2:
1226 8: MoveLoc[0](Arg0: &Table<vector<u8>, OrderStatus>)
1227 9: MoveLoc[1](Arg1: vector<u8>)
1228 10: Call table::borrow<vector<u8>, OrderStatus>(&Table<vector<u8>, OrderStatus>, vector<u8>): &OrderStatus
1229 11: Call order::get_filled_qty(&OrderStatus): u128
1230 12: MoveLoc[2](Arg2: u128)
1231 13: Eq
1232 14: BrFalse(17)
1233B3:
1234 15: MoveLoc[3](Arg3: u128)
1235 16: Ret
1236B4:
1237 17: LdU128(0)
1238 18: Ret
1239}
1240
1241Constants [
1242 0 => u8: 1
1243 1 => u8: 0
1244]
1245}
1246
0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/library.mvb238 lines
1// Move bytecode v7
2module 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001.library {
3use 0000000000000000000000000000000000000000000000000000000000000001::hash;
4
5struct VerificationResult has copy, drop {
6 is_verified: bool,
7 public_key: vector<u8>
8}
9
10public(friend) base_uint(): u128 {
11B0:
12 0: LdConst[0](u128: 1000..)
13 1: Ret
14}
15
16public(friend) half_base_uint(): u128 {
17B0:
18 0: LdConst[1](u128: 5000..)
19 1: Ret
20}
21
22public(friend) convert_to_usdc_base(Arg0: u128): u64 {
23B0:
24 0: MoveLoc[0](Arg0: u128)
25 1: LdU128(1000)
26 2: Div
27 3: CastU64
28 4: Ret
29}
30
31public(friend) base_mul(Arg0: u128, Arg1: u128): u128 {
32B0:
33 0: MoveLoc[0](Arg0: u128)
34 1: MoveLoc[1](Arg1: u128)
35 2: Mul
36 3: LdConst[0](u128: 1000..)
37 4: Div
38 5: Ret
39}
40
41public(friend) base_mul_up(Arg0: u128, Arg1: u128): u128 {
42B0:
43 0: MoveLoc[0](Arg0: u128)
44 1: MoveLoc[1](Arg1: u128)
45 2: Mul
46 3: LdConst[0](u128: 1000..)
47 4: Add
48 5: LdU128(1)
49 6: Sub
50 7: LdConst[0](u128: 1000..)
51 8: Div
52 9: Ret
53}
54
55public(friend) base_div(Arg0: u128, Arg1: u128): u128 {
56B0:
57 0: MoveLoc[0](Arg0: u128)
58 1: LdConst[0](u128: 1000..)
59 2: Mul
60 3: MoveLoc[1](Arg1: u128)
61 4: Div
62 5: Ret
63}
64
65public(friend) base_div_up(Arg0: u128, Arg1: u128): u128 {
66B0:
67 0: MoveLoc[0](Arg0: u128)
68 1: LdConst[0](u128: 1000..)
69 2: Mul
70 3: CopyLoc[1](Arg1: u128)
71 4: Add
72 5: LdU128(1)
73 6: Sub
74 7: MoveLoc[1](Arg1: u128)
75 8: Div
76 9: Ret
77}
78
79public(friend) ceil(Arg0: u128, Arg1: u128): u128 {
80B0:
81 0: MoveLoc[0](Arg0: u128)
82 1: CopyLoc[1](Arg1: u128)
83 2: Add
84 3: LdU128(1)
85 4: Sub
86 5: CopyLoc[1](Arg1: u128)
87 6: Div
88 7: MoveLoc[1](Arg1: u128)
89 8: Mul
90 9: Ret
91}
92
93public(friend) min(Arg0: u128, Arg1: u128): u128 {
94L2: loc0: u128
95B0:
96 0: CopyLoc[0](Arg0: u128)
97 1: CopyLoc[1](Arg1: u128)
98 2: Lt
99 3: BrFalse(7)
100B1:
101 4: MoveLoc[0](Arg0: u128)
102 5: StLoc[2](loc0: u128)
103 6: Branch(9)
104B2:
105 7: MoveLoc[1](Arg1: u128)
106 8: StLoc[2](loc0: u128)
107B3:
108 9: MoveLoc[2](loc0: u128)
109 10: Ret
110}
111
112public(friend) sub(Arg0: u128, Arg1: u128): u128 {
113L2: loc0: u128
114B0:
115 0: CopyLoc[0](Arg0: u128)
116 1: CopyLoc[1](Arg1: u128)
117 2: Gt
118 3: BrFalse(9)
119B1:
120 4: MoveLoc[0](Arg0: u128)
121 5: MoveLoc[1](Arg1: u128)
122 6: Sub
123 7: StLoc[2](loc0: u128)
124 8: Branch(11)
125B2:
126 9: LdU128(0)
127 10: StLoc[2](loc0: u128)
128B3:
129 11: MoveLoc[2](loc0: u128)
130 12: Ret
131}
132
133public(friend) round_down(Arg0: u128): u128 {
134B0:
135 0: MoveLoc[0](Arg0: u128)
136 1: Call base_uint(): u128
137 2: Div
138 3: Call base_uint(): u128
139 4: Mul
140 5: Ret
141}
142
143public(friend) round(Arg0: u128, Arg1: u128): u128 {
144B0:
145 0: MoveLoc[0](Arg0: u128)
146 1: CopyLoc[1](Arg1: u128)
147 2: LdU128(5)
148 3: Mul
149 4: LdU128(10)
150 5: Div
151 6: Add
152 7: StLoc[0](Arg0: u128)
153 8: CopyLoc[0](Arg0: u128)
154 9: MoveLoc[0](Arg0: u128)
155 10: MoveLoc[1](Arg1: u128)
156 11: Mod
157 12: Sub
158 13: Ret
159}
160
161public(friend) compute_mro(Arg0: u128): u128 {
162B0:
163 0: Call base_uint(): u128
164 1: MoveLoc[0](Arg0: u128)
165 2: Call base_div(u128, u128): u128
166 3: Ret
167}
168
169public(friend) convert_usdc_to_base_decimals(Arg0: u128): u128 {
170B0:
171 0: MoveLoc[0](Arg0: u128)
172 1: LdU128(1000)
173 2: Mul
174 3: Ret
175}
176
177public(friend) decimal_1e18_to_base(Arg0: u128): u128 {
178B0:
179 0: MoveLoc[0](Arg0: u128)
180 1: LdConst[0](u128: 1000..)
181 2: Div
182 3: Ret
183}
184
185public(friend) get_hash(Arg0: vector<u8>): vector<u8> {
186B0:
187 0: MoveLoc[0](Arg0: vector<u8>)
188 1: Call hash::sha2_256(vector<u8>): vector<u8>
189 2: Ret
190}
191
192public(friend) to_1x9_vec(Arg0: vector<u128>): vector<u128> {
193L1: loc0: u64
194L2: loc1: &u128
195L3: loc2: u64
196L4: loc3: vector<u128>
197B0:
198 0: ImmBorrowLoc[0](Arg0: vector<u128>)
199 1: VecLen(1)
200 2: StLoc[1](loc0: u64)
201 3: VecPack(1, 0)
202 4: StLoc[4](loc3: vector<u128>)
203 5: LdU64(0)
204 6: StLoc[3](loc2: u64)
205B1:
206 7: CopyLoc[3](loc2: u64)
207 8: CopyLoc[1](loc0: u64)
208 9: Lt
209 10: BrFalse(27)
210B2:
211 11: Branch(12)
212B3:
213 12: ImmBorrowLoc[0](Arg0: vector<u128>)
214 13: CopyLoc[3](loc2: u64)
215 14: VecImmBorrow(1)
216 15: StLoc[2](loc1: &u128)
217 16: MutBorrowLoc[4](loc3: vector<u128>)
218 17: MoveLoc[2](loc1: &u128)
219 18: ReadRef
220 19: LdConst[0](u128: 1000..)
221 20: Div
222 21: VecPushBack(1)
223 22: MoveLoc[3](loc2: u64)
224 23: LdU64(1)
225 24: Add
226 25: StLoc[3](loc2: u64)
227 26: Branch(7)
228B4:
229 27: MoveLoc[4](loc3: vector<u128>)
230 28: Ret
231}
232
233Constants [
234 0 => u128: 1000000000
235 1 => u128: 500000000
236]
237}
238
0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/order.mvb941 lines
1// Move bytecode v7
2module 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001.order {
3use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::library;
4use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::protocol;
5use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::sub_accounts;
6use 9041eddbe15edba576c8c0bd4237e07b19e2c17fb59b240658f96522261f10c4::payload;
7use 9041eddbe15edba576c8c0bd4237e07b19e2c17fb59b240658f96522261f10c4::unified_address;
8use 0000000000000000000000000000000000000000000000000000000000000002::event;
9use 0000000000000000000000000000000000000000000000000000000000000002::table;
10use 0000000000000000000000000000000000000000000000000000000000000002::tx_context;
11
12struct OrderFillEvent has copy, drop {
13 tx_index: u128,
14 order_hash: vector<u8>,
15 order: Order,
16 sig_maker: address,
17 fill_price: u128,
18 fill_qty: u128,
19 new_filled_quantity: u128
20}
21
22struct OrderCancelEvent has copy, drop {
23 tx_index: u128,
24 caller: address,
25 sig_maker: address,
26 perpetual: address,
27 order_hash: vector<u8>
28}
29
30struct OrderFlags has copy, drop {
31 ioc: bool,
32 post_only: bool,
33 reduce_only: bool,
34 is_long: bool,
35 orderbook_only: bool
36}
37
38struct Order has copy, drop {
39 market: address,
40 creator: address,
41 is_long: bool,
42 reduce_only: bool,
43 post_only: bool,
44 orderbook_only: bool,
45 ioc: bool,
46 flags: u8,
47 price: u128,
48 quantity: u128,
49 leverage: u128,
50 expiration: u64,
51 salt: u128
52}
53
54struct OrderV2 has copy, drop {
55 market: address,
56 creator: UnifiedAddress,
57 is_long: bool,
58 reduce_only: bool,
59 post_only: bool,
60 orderbook_only: bool,
61 ioc: bool,
62 flags: u8,
63 price: u128,
64 quantity: u128,
65 leverage: u128,
66 expiration: u64,
67 salt: u128
68}
69
70struct OrderStatus has store {
71 status: bool,
72 filled_qty: u128
73}
74
75entry cancel_order(Arg0: &ProtocolConfig, Arg1: &SubAccounts, Arg2: &mut TxIndexer, Arg3: &mut Table<vector<u8>, OrderStatus>, Arg4: address, Arg5: u8, Arg6: u128, Arg7: u128, Arg8: u128, Arg9: u64, Arg10: u128, Arg11: address, Arg12: vector<u8>, Arg13: vector<u8>, Arg14: vector<u8>, Arg15: &TxContext) {
76B0:
77 0: LdU64(999)
78 1: Abort
79}
80
81entry cancel_order_v2(Arg0: &ProtocolConfig, Arg1: &SubAccounts, Arg2: &mut TxIndexer, Arg3: &mut Table<vector<u8>, OrderStatus>, Arg4: address, Arg5: u8, Arg6: u128, Arg7: u128, Arg8: u128, Arg9: u64, Arg10: u128, Arg11: address, Arg12: &TxContext) {
82B0:
83 0: LdU64(999)
84 1: Abort
85}
86
87public(friend) cancel(Arg0: &mut Table<vector<u8>, OrderStatus>, Arg1: vector<u8>, Arg2: address, Arg3: address, Arg4: u128) {
88L5: loc0: address
89L6: loc1: address
90L7: loc2: vector<u8>
91L8: loc3: address
92L9: loc4: &mut OrderStatus
93B0:
94 0: CopyLoc[0](Arg0: &mut Table<vector<u8>, OrderStatus>)
95 1: CopyLoc[1](Arg1: vector<u8>)
96 2: Call create_order(&mut Table<vector<u8>, OrderStatus>, vector<u8>)
97 3: MoveLoc[0](Arg0: &mut Table<vector<u8>, OrderStatus>)
98 4: CopyLoc[1](Arg1: vector<u8>)
99 5: Call table::borrow_mut<vector<u8>, OrderStatus>(&mut Table<vector<u8>, OrderStatus>, vector<u8>): &mut OrderStatus
100 6: StLoc[9](loc4: &mut OrderStatus)
101 7: CopyLoc[9](loc4: &mut OrderStatus)
102 8: ImmBorrowField[0](OrderStatus.status: bool)
103 9: ReadRef
104 10: BrFalse(12)
105B1:
106 11: Branch(16)
107B2:
108 12: MoveLoc[9](loc4: &mut OrderStatus)
109 13: Pop
110 14: LdU64(28)
111 15: Abort
112B3:
113 16: LdFalse
114 17: MoveLoc[9](loc4: &mut OrderStatus)
115 18: MutBorrowField[0](OrderStatus.status: bool)
116 19: WriteRef
117 20: CopyLoc[3](Arg3: address)
118 21: StLoc[5](loc0: address)
119 22: MoveLoc[3](Arg3: address)
120 23: StLoc[6](loc1: address)
121 24: MoveLoc[1](Arg1: vector<u8>)
122 25: StLoc[7](loc2: vector<u8>)
123 26: MoveLoc[2](Arg2: address)
124 27: StLoc[8](loc3: address)
125 28: MoveLoc[4](Arg4: u128)
126 29: MoveLoc[5](loc0: address)
127 30: MoveLoc[6](loc1: address)
128 31: MoveLoc[8](loc3: address)
129 32: MoveLoc[7](loc2: vector<u8>)
130 33: Pack[1](OrderCancelEvent)
131 34: Call event::emit<OrderCancelEvent>(OrderCancelEvent)
132 35: Ret
133}
134
135public(friend) flag_orderbook_only(Arg0: u8): bool {
136B0:
137 0: MoveLoc[0](Arg0: u8)
138 1: LdU8(16)
139 2: BitAnd
140 3: LdU8(0)
141 4: Gt
142 5: Ret
143}
144
145public(friend) is_long(Arg0: &OrderV2): bool {
146B0:
147 0: MoveLoc[0](Arg0: &OrderV2)
148 1: ImmBorrowField[1](OrderV2.is_long: bool)
149 2: ReadRef
150 3: Ret
151}
152
153public(friend) creator(Arg0: OrderV2): UnifiedAddress {
154B0:
155 0: ImmBorrowLoc[0](Arg0: OrderV2)
156 1: ImmBorrowField[2](OrderV2.creator: UnifiedAddress)
157 2: ReadRef
158 3: Ret
159}
160
161public(friend) creator_identifier(Arg0: &OrderV2): address {
162B0:
163 0: MoveLoc[0](Arg0: &OrderV2)
164 1: ImmBorrowField[2](OrderV2.creator: UnifiedAddress)
165 2: Call unified_address::identifier(&UnifiedAddress): address
166 3: Ret
167}
168
169public(friend) to_json_bytes(Arg0: OrderV2, Arg1: u32): vector<u8> {
170L2: loc0: JsonBuilder
171B0:
172 0: Call payload::new_builder(): JsonBuilder
173 1: StLoc[2](loc0: JsonBuilder)
174 2: CopyLoc[1](Arg1: u32)
175 3: LdU32(2)
176 4: Eq
177 5: BrFalse(10)
178B1:
179 6: MutBorrowLoc[2](loc0: JsonBuilder)
180 7: LdConst[0](vector<u8>: "act..)
181 8: LdConst[1](vector<u8>: "Pla..)
182 9: Call payload::add_bytes(&mut JsonBuilder, vector<u8>, vector<u8>)
183B2:
184 10: MutBorrowLoc[2](loc0: JsonBuilder)
185 11: LdConst[2](vector<u8>: "mar..)
186 12: ImmBorrowLoc[0](Arg0: OrderV2)
187 13: ImmBorrowField[3](OrderV2.market: address)
188 14: ReadRef
189 15: Call payload::add_address(&mut JsonBuilder, vector<u8>, address)
190 16: CopyLoc[1](Arg1: u32)
191 17: LdU32(1)
192 18: Eq
193 19: BrFalse(34)
194B3:
195 20: ImmBorrowLoc[0](Arg0: OrderV2)
196 21: ImmBorrowField[2](OrderV2.creator: UnifiedAddress)
197 22: Call unified_address::is_sui(&UnifiedAddress): bool
198 23: BrFalse(25)
199B4:
200 24: Branch(27)
201B5:
202 25: LdU64(2100)
203 26: Abort
204B6:
205 27: MutBorrowLoc[2](loc0: JsonBuilder)
206 28: LdConst[3](vector<u8>: "cre..)
207 29: ImmBorrowLoc[0](Arg0: OrderV2)
208 30: ImmBorrowField[2](OrderV2.creator: UnifiedAddress)
209 31: Call unified_address::identifier(&UnifiedAddress): address
210 32: Call payload::add_address(&mut JsonBuilder, vector<u8>, address)
211 33: Branch(47)
212B7:
213 34: MoveLoc[1](Arg1: u32)
214 35: LdU32(2)
215 36: Eq
216 37: BrFalse(39)
217B8:
218 38: Branch(41)
219B9:
220 39: LdU64(2101)
221 40: Abort
222B10:
223 41: MutBorrowLoc[2](loc0: JsonBuilder)
224 42: LdConst[3](vector<u8>: "cre..)
225 43: ImmBorrowLoc[0](Arg0: OrderV2)
226 44: ImmBorrowField[2](OrderV2.creator: UnifiedAddress)
227 45: Call unified_address::display_bytes(&UnifiedAddress): vector<u8>
228 46: Call payload::add_bytes(&mut JsonBuilder, vector<u8>, vector<u8>)
229B11:
230 47: MutBorrowLoc[2](loc0: JsonBuilder)
231 48: LdConst[4](vector<u8>: "isL..)
232 49: ImmBorrowLoc[0](Arg0: OrderV2)
233 50: ImmBorrowField[1](OrderV2.is_long: bool)
234 51: ReadRef
235 52: Call payload::add_bool(&mut JsonBuilder, vector<u8>, bool)
236 53: MutBorrowLoc[2](loc0: JsonBuilder)
237 54: LdConst[5](vector<u8>: "red..)
238 55: ImmBorrowLoc[0](Arg0: OrderV2)
239 56: ImmBorrowField[4](OrderV2.reduce_only: bool)
240 57: ReadRef
241 58: Call payload::add_bool(&mut JsonBuilder, vector<u8>, bool)
242 59: MutBorrowLoc[2](loc0: JsonBuilder)
243 60: LdConst[6](vector<u8>: "pos..)
244 61: ImmBorrowLoc[0](Arg0: OrderV2)
245 62: ImmBorrowField[5](OrderV2.post_only: bool)
246 63: ReadRef
247 64: Call payload::add_bool(&mut JsonBuilder, vector<u8>, bool)
248 65: MutBorrowLoc[2](loc0: JsonBuilder)
249 66: LdConst[7](vector<u8>: "ord..)
250 67: ImmBorrowLoc[0](Arg0: OrderV2)
251 68: ImmBorrowField[6](OrderV2.orderbook_only: bool)
252 69: ReadRef
253 70: Call payload::add_bool(&mut JsonBuilder, vector<u8>, bool)
254 71: MutBorrowLoc[2](loc0: JsonBuilder)
255 72: LdConst[8](vector<u8>: "ioc..)
256 73: ImmBorrowLoc[0](Arg0: OrderV2)
257 74: ImmBorrowField[7](OrderV2.ioc: bool)
258 75: ReadRef
259 76: Call payload::add_bool(&mut JsonBuilder, vector<u8>, bool)
260 77: MutBorrowLoc[2](loc0: JsonBuilder)
261 78: LdConst[9](vector<u8>: "qua..)
262 79: ImmBorrowLoc[0](Arg0: OrderV2)
263 80: ImmBorrowField[8](OrderV2.quantity: u128)
264 81: ReadRef
265 82: Call payload::add_u128(&mut JsonBuilder, vector<u8>, u128)
266 83: MutBorrowLoc[2](loc0: JsonBuilder)
267 84: LdConst[10](vector<u8>: "pri..)
268 85: ImmBorrowLoc[0](Arg0: OrderV2)
269 86: ImmBorrowField[9](OrderV2.price: u128)
270 87: ReadRef
271 88: Call payload::add_u128(&mut JsonBuilder, vector<u8>, u128)
272 89: MutBorrowLoc[2](loc0: JsonBuilder)
273 90: LdConst[11](vector<u8>: "lev..)
274 91: ImmBorrowLoc[0](Arg0: OrderV2)
275 92: ImmBorrowField[10](OrderV2.leverage: u128)
276 93: ReadRef
277 94: Call payload::add_u128(&mut JsonBuilder, vector<u8>, u128)
278 95: MutBorrowLoc[2](loc0: JsonBuilder)
279 96: LdConst[12](vector<u8>: "exp..)
280 97: ImmBorrowLoc[0](Arg0: OrderV2)
281 98: ImmBorrowField[11](OrderV2.expiration: u64)
282 99: ReadRef
283 100: Call payload::add_u64(&mut JsonBuilder, vector<u8>, u64)
284 101: MutBorrowLoc[2](loc0: JsonBuilder)
285 102: LdConst[13](vector<u8>: "sal..)
286 103: ImmBorrowLoc[0](Arg0: OrderV2)
287 104: ImmBorrowField[12](OrderV2.salt: u128)
288 105: ReadRef
289 106: Call payload::add_u128(&mut JsonBuilder, vector<u8>, u128)
290 107: MutBorrowLoc[2](loc0: JsonBuilder)
291 108: LdConst[14](vector<u8>: "ord..)
292 109: ImmBorrowLoc[0](Arg0: OrderV2)
293 110: ImmBorrowField[13](OrderV2.flags: u8)
294 111: ReadRef
295 112: Call payload::add_u8(&mut JsonBuilder, vector<u8>, u8)
296 113: MoveLoc[2](loc0: JsonBuilder)
297 114: Call payload::build(JsonBuilder): vector<u8>
298 115: Ret
299}
300
301public(friend) market(Arg0: OrderV2): address {
302B0:
303 0: ImmBorrowLoc[0](Arg0: OrderV2)
304 1: ImmBorrowField[3](OrderV2.market: address)
305 2: ReadRef
306 3: Ret
307}
308
309public(friend) reduce_only(Arg0: OrderV2): bool {
310B0:
311 0: ImmBorrowLoc[0](Arg0: OrderV2)
312 1: ImmBorrowField[4](OrderV2.reduce_only: bool)
313 2: ReadRef
314 3: Ret
315}
316
317public(friend) post_only(Arg0: OrderV2): bool {
318B0:
319 0: ImmBorrowLoc[0](Arg0: OrderV2)
320 1: ImmBorrowField[5](OrderV2.post_only: bool)
321 2: ReadRef
322 3: Ret
323}
324
325public(friend) orderbook_only(Arg0: OrderV2): bool {
326B0:
327 0: ImmBorrowLoc[0](Arg0: OrderV2)
328 1: ImmBorrowField[6](OrderV2.orderbook_only: bool)
329 2: ReadRef
330 3: Ret
331}
332
333public(friend) ioc(Arg0: OrderV2): bool {
334B0:
335 0: ImmBorrowLoc[0](Arg0: OrderV2)
336 1: ImmBorrowField[7](OrderV2.ioc: bool)
337 2: ReadRef
338 3: Ret
339}
340
341public(friend) flags(Arg0: OrderV2): u8 {
342B0:
343 0: ImmBorrowLoc[0](Arg0: OrderV2)
344 1: ImmBorrowField[13](OrderV2.flags: u8)
345 2: ReadRef
346 3: Ret
347}
348
349public(friend) price(Arg0: OrderV2): u128 {
350B0:
351 0: ImmBorrowLoc[0](Arg0: OrderV2)
352 1: ImmBorrowField[9](OrderV2.price: u128)
353 2: ReadRef
354 3: Ret
355}
356
357public(friend) quantity(Arg0: OrderV2): u128 {
358B0:
359 0: ImmBorrowLoc[0](Arg0: OrderV2)
360 1: ImmBorrowField[8](OrderV2.quantity: u128)
361 2: ReadRef
362 3: Ret
363}
364
365public(friend) leverage(Arg0: OrderV2): u128 {
366B0:
367 0: ImmBorrowLoc[0](Arg0: OrderV2)
368 1: ImmBorrowField[10](OrderV2.leverage: u128)
369 2: ReadRef
370 3: Ret
371}
372
373public(friend) expiration(Arg0: OrderV2): u64 {
374B0:
375 0: ImmBorrowLoc[0](Arg0: OrderV2)
376 1: ImmBorrowField[11](OrderV2.expiration: u64)
377 2: ReadRef
378 3: Ret
379}
380
381public(friend) salt(Arg0: OrderV2): u128 {
382B0:
383 0: ImmBorrowLoc[0](Arg0: OrderV2)
384 1: ImmBorrowField[12](OrderV2.salt: u128)
385 2: ReadRef
386 3: Ret
387}
388
389public(friend) pack_order(Arg0: address, Arg1: u8, Arg2: u128, Arg3: u128, Arg4: u128, Arg5: UnifiedAddress, Arg6: u64, Arg7: u128): OrderV2 {
390L8: loc0: address
391L9: loc1: u128
392L10: loc2: u128
393L11: loc3: u64
394L12: loc4: u128
395L13: loc5: UnifiedAddress
396L14: loc6: bool
397L15: loc7: bool
398L16: loc8: bool
399L17: loc9: bool
400L18: loc10: bool
401L19: loc11: u8
402L20: loc12: u128
403L21: loc13: OrderFlags
404B0:
405 0: CopyLoc[1](Arg1: u8)
406 1: Call decode_order_flags(u8): OrderFlags
407 2: StLoc[21](loc13: OrderFlags)
408 3: MoveLoc[0](Arg0: address)
409 4: StLoc[8](loc0: address)
410 5: MoveLoc[5](Arg5: UnifiedAddress)
411 6: StLoc[13](loc5: UnifiedAddress)
412 7: ImmBorrowLoc[21](loc13: OrderFlags)
413 8: ImmBorrowField[14](OrderFlags.is_long: bool)
414 9: ReadRef
415 10: StLoc[14](loc6: bool)
416 11: ImmBorrowLoc[21](loc13: OrderFlags)
417 12: ImmBorrowField[15](OrderFlags.post_only: bool)
418 13: ReadRef
419 14: StLoc[15](loc7: bool)
420 15: ImmBorrowLoc[21](loc13: OrderFlags)
421 16: ImmBorrowField[16](OrderFlags.orderbook_only: bool)
422 17: ReadRef
423 18: StLoc[16](loc8: bool)
424 19: ImmBorrowLoc[21](loc13: OrderFlags)
425 20: ImmBorrowField[17](OrderFlags.reduce_only: bool)
426 21: ReadRef
427 22: StLoc[17](loc9: bool)
428 23: ImmBorrowLoc[21](loc13: OrderFlags)
429 24: ImmBorrowField[18](OrderFlags.ioc: bool)
430 25: ReadRef
431 26: StLoc[18](loc10: bool)
432 27: MoveLoc[1](Arg1: u8)
433 28: StLoc[19](loc11: u8)
434 29: MoveLoc[2](Arg2: u128)
435 30: StLoc[20](loc12: u128)
436 31: MoveLoc[3](Arg3: u128)
437 32: StLoc[9](loc1: u128)
438 33: MoveLoc[4](Arg4: u128)
439 34: StLoc[10](loc2: u128)
440 35: MoveLoc[6](Arg6: u64)
441 36: StLoc[11](loc3: u64)
442 37: MoveLoc[7](Arg7: u128)
443 38: StLoc[12](loc4: u128)
444 39: MoveLoc[8](loc0: address)
445 40: MoveLoc[13](loc5: UnifiedAddress)
446 41: MoveLoc[14](loc6: bool)
447 42: MoveLoc[17](loc9: bool)
448 43: MoveLoc[15](loc7: bool)
449 44: MoveLoc[16](loc8: bool)
450 45: MoveLoc[18](loc10: bool)
451 46: MoveLoc[19](loc11: u8)
452 47: MoveLoc[20](loc12: u128)
453 48: MoveLoc[9](loc1: u128)
454 49: MoveLoc[10](loc2: u128)
455 50: MoveLoc[11](loc3: u64)
456 51: MoveLoc[12](loc4: u128)
457 52: Pack[4](OrderV2)
458 53: Ret
459}
460
461public(friend) order_v2_to_order(Arg0: OrderV2): Order {
462L1: loc0: address
463L2: loc1: u128
464L3: loc2: u128
465L4: loc3: u64
466L5: loc4: u128
467L6: loc5: address
468L7: loc6: bool
469L8: loc7: bool
470L9: loc8: bool
471L10: loc9: bool
472L11: loc10: bool
473L12: loc11: u8
474L13: loc12: u128
475B0:
476 0: ImmBorrowLoc[0](Arg0: OrderV2)
477 1: ImmBorrowField[3](OrderV2.market: address)
478 2: ReadRef
479 3: StLoc[1](loc0: address)
480 4: ImmBorrowLoc[0](Arg0: OrderV2)
481 5: ImmBorrowField[2](OrderV2.creator: UnifiedAddress)
482 6: Call unified_address::identifier(&UnifiedAddress): address
483 7: StLoc[6](loc5: address)
484 8: ImmBorrowLoc[0](Arg0: OrderV2)
485 9: ImmBorrowField[1](OrderV2.is_long: bool)
486 10: ReadRef
487 11: StLoc[7](loc6: bool)
488 12: ImmBorrowLoc[0](Arg0: OrderV2)
489 13: ImmBorrowField[5](OrderV2.post_only: bool)
490 14: ReadRef
491 15: StLoc[8](loc7: bool)
492 16: ImmBorrowLoc[0](Arg0: OrderV2)
493 17: ImmBorrowField[6](OrderV2.orderbook_only: bool)
494 18: ReadRef
495 19: StLoc[9](loc8: bool)
496 20: ImmBorrowLoc[0](Arg0: OrderV2)
497 21: ImmBorrowField[4](OrderV2.reduce_only: bool)
498 22: ReadRef
499 23: StLoc[10](loc9: bool)
500 24: ImmBorrowLoc[0](Arg0: OrderV2)
501 25: ImmBorrowField[7](OrderV2.ioc: bool)
502 26: ReadRef
503 27: StLoc[11](loc10: bool)
504 28: ImmBorrowLoc[0](Arg0: OrderV2)
505 29: ImmBorrowField[13](OrderV2.flags: u8)
506 30: ReadRef
507 31: StLoc[12](loc11: u8)
508 32: ImmBorrowLoc[0](Arg0: OrderV2)
509 33: ImmBorrowField[9](OrderV2.price: u128)
510 34: ReadRef
511 35: StLoc[13](loc12: u128)
512 36: ImmBorrowLoc[0](Arg0: OrderV2)
513 37: ImmBorrowField[8](OrderV2.quantity: u128)
514 38: ReadRef
515 39: StLoc[2](loc1: u128)
516 40: ImmBorrowLoc[0](Arg0: OrderV2)
517 41: ImmBorrowField[10](OrderV2.leverage: u128)
518 42: ReadRef
519 43: StLoc[3](loc2: u128)
520 44: ImmBorrowLoc[0](Arg0: OrderV2)
521 45: ImmBorrowField[11](OrderV2.expiration: u64)
522 46: ReadRef
523 47: StLoc[4](loc3: u64)
524 48: ImmBorrowLoc[0](Arg0: OrderV2)
525 49: ImmBorrowField[12](OrderV2.salt: u128)
526 50: ReadRef
527 51: StLoc[5](loc4: u128)
528 52: MoveLoc[1](loc0: address)
529 53: MoveLoc[6](loc5: address)
530 54: MoveLoc[7](loc6: bool)
531 55: MoveLoc[10](loc9: bool)
532 56: MoveLoc[8](loc7: bool)
533 57: MoveLoc[9](loc8: bool)
534 58: MoveLoc[11](loc10: bool)
535 59: MoveLoc[12](loc11: u8)
536 60: MoveLoc[13](loc12: u128)
537 61: MoveLoc[2](loc1: u128)
538 62: MoveLoc[3](loc2: u128)
539 63: MoveLoc[4](loc3: u64)
540 64: MoveLoc[5](loc4: u128)
541 65: Pack[3](Order)
542 66: Ret
543}
544
545public(friend) to_1x9(Arg0: OrderV2): OrderV2 {
546L1: loc0: address
547L2: loc1: u128
548L3: loc2: u128
549L4: loc3: u64
550L5: loc4: u128
551L6: loc5: UnifiedAddress
552L7: loc6: bool
553L8: loc7: bool
554L9: loc8: bool
555L10: loc9: bool
556L11: loc10: bool
557L12: loc11: u8
558L13: loc12: u128
559B0:
560 0: ImmBorrowLoc[0](Arg0: OrderV2)
561 1: ImmBorrowField[3](OrderV2.market: address)
562 2: ReadRef
563 3: StLoc[1](loc0: address)
564 4: ImmBorrowLoc[0](Arg0: OrderV2)
565 5: ImmBorrowField[2](OrderV2.creator: UnifiedAddress)
566 6: ReadRef
567 7: StLoc[6](loc5: UnifiedAddress)
568 8: ImmBorrowLoc[0](Arg0: OrderV2)
569 9: ImmBorrowField[1](OrderV2.is_long: bool)
570 10: ReadRef
571 11: StLoc[7](loc6: bool)
572 12: ImmBorrowLoc[0](Arg0: OrderV2)
573 13: ImmBorrowField[5](OrderV2.post_only: bool)
574 14: ReadRef
575 15: StLoc[8](loc7: bool)
576 16: ImmBorrowLoc[0](Arg0: OrderV2)
577 17: ImmBorrowField[6](OrderV2.orderbook_only: bool)
578 18: ReadRef
579 19: StLoc[9](loc8: bool)
580 20: ImmBorrowLoc[0](Arg0: OrderV2)
581 21: ImmBorrowField[4](OrderV2.reduce_only: bool)
582 22: ReadRef
583 23: StLoc[10](loc9: bool)
584 24: ImmBorrowLoc[0](Arg0: OrderV2)
585 25: ImmBorrowField[7](OrderV2.ioc: bool)
586 26: ReadRef
587 27: StLoc[11](loc10: bool)
588 28: ImmBorrowLoc[0](Arg0: OrderV2)
589 29: ImmBorrowField[13](OrderV2.flags: u8)
590 30: ReadRef
591 31: StLoc[12](loc11: u8)
592 32: ImmBorrowLoc[0](Arg0: OrderV2)
593 33: ImmBorrowField[9](OrderV2.price: u128)
594 34: ReadRef
595 35: Call library::base_uint(): u128
596 36: Div
597 37: StLoc[13](loc12: u128)
598 38: ImmBorrowLoc[0](Arg0: OrderV2)
599 39: ImmBorrowField[8](OrderV2.quantity: u128)
600 40: ReadRef
601 41: Call library::base_uint(): u128
602 42: Div
603 43: StLoc[2](loc1: u128)
604 44: ImmBorrowLoc[0](Arg0: OrderV2)
605 45: ImmBorrowField[10](OrderV2.leverage: u128)
606 46: ReadRef
607 47: Call library::base_uint(): u128
608 48: Div
609 49: StLoc[3](loc2: u128)
610 50: ImmBorrowLoc[0](Arg0: OrderV2)
611 51: ImmBorrowField[11](OrderV2.expiration: u64)
612 52: ReadRef
613 53: StLoc[4](loc3: u64)
614 54: ImmBorrowLoc[0](Arg0: OrderV2)
615 55: ImmBorrowField[12](OrderV2.salt: u128)
616 56: ReadRef
617 57: StLoc[5](loc4: u128)
618 58: MoveLoc[1](loc0: address)
619 59: MoveLoc[6](loc5: UnifiedAddress)
620 60: MoveLoc[7](loc6: bool)
621 61: MoveLoc[10](loc9: bool)
622 62: MoveLoc[8](loc7: bool)
623 63: MoveLoc[9](loc8: bool)
624 64: MoveLoc[11](loc10: bool)
625 65: MoveLoc[12](loc11: u8)
626 66: MoveLoc[13](loc12: u128)
627 67: MoveLoc[2](loc1: u128)
628 68: MoveLoc[3](loc2: u128)
629 69: MoveLoc[4](loc3: u64)
630 70: MoveLoc[5](loc4: u128)
631 71: Pack[4](OrderV2)
632 72: Ret
633}
634
635public(friend) set_price(Arg0: &mut OrderV2, Arg1: u128) {
636B0:
637 0: MoveLoc[1](Arg1: u128)
638 1: MoveLoc[0](Arg0: &mut OrderV2)
639 2: MutBorrowField[9](OrderV2.price: u128)
640 3: WriteRef
641 4: Ret
642}
643
644public(friend) set_leverage(Arg0: &mut OrderV2, Arg1: u128) {
645B0:
646 0: MoveLoc[1](Arg1: u128)
647 1: MoveLoc[0](Arg0: &mut OrderV2)
648 2: MutBorrowField[10](OrderV2.leverage: u128)
649 3: WriteRef
650 4: Ret
651}
652
653public(friend) create_order(Arg0: &mut Table<vector<u8>, OrderStatus>, Arg1: vector<u8>) {
654B0:
655 0: CopyLoc[0](Arg0: &mut Table<vector<u8>, OrderStatus>)
656 1: FreezeRef
657 2: CopyLoc[1](Arg1: vector<u8>)
658 3: Call table::contains<vector<u8>, OrderStatus>(&Table<vector<u8>, OrderStatus>, vector<u8>): bool
659 4: Not
660 5: BrFalse(13)
661B1:
662 6: MoveLoc[0](Arg0: &mut Table<vector<u8>, OrderStatus>)
663 7: MoveLoc[1](Arg1: vector<u8>)
664 8: LdTrue
665 9: LdU128(0)
666 10: Pack[5](OrderStatus)
667 11: Call table::add<vector<u8>, OrderStatus>(&mut Table<vector<u8>, OrderStatus>, vector<u8>, OrderStatus)
668 12: Branch(15)
669B2:
670 13: MoveLoc[0](Arg0: &mut Table<vector<u8>, OrderStatus>)
671 14: Pop
672B3:
673 15: Ret
674}
675
676public(friend) verify_order_state(Arg0: &Table<vector<u8>, OrderStatus>, Arg1: vector<u8>, Arg2: u64) {
677B0:
678 0: MoveLoc[0](Arg0: &Table<vector<u8>, OrderStatus>)
679 1: MoveLoc[1](Arg1: vector<u8>)
680 2: Call table::borrow<vector<u8>, OrderStatus>(&Table<vector<u8>, OrderStatus>, vector<u8>): &OrderStatus
681 3: ImmBorrowField[0](OrderStatus.status: bool)
682 4: ReadRef
683 5: BrFalse(7)
684B1:
685 6: Branch(11)
686B2:
687 7: MoveLoc[2](Arg2: u64)
688 8: LdU64(28)
689 9: Add
690 10: Abort
691B3:
692 11: Ret
693}
694
695public(friend) verify_and_fill_order_qty(Arg0: &mut Table<vector<u8>, OrderStatus>, Arg1: OrderV2, Arg2: vector<u8>, Arg3: u128, Arg4: u128, Arg5: bool, Arg6: u128, Arg7: UnifiedAddress, Arg8: u64, Arg9: u128) {
696L10: loc0: bool
697L11: loc1: bool
698L12: loc2: &mut OrderStatus
699B0:
700 0: ImmBorrowLoc[1](Arg1: OrderV2)
701 1: ImmBorrowField[1](OrderV2.is_long: bool)
702 2: ReadRef
703 3: BrFalse(11)
704B1:
705 4: CopyLoc[3](Arg3: u128)
706 5: ImmBorrowLoc[1](Arg1: OrderV2)
707 6: ImmBorrowField[9](OrderV2.price: u128)
708 7: ReadRef
709 8: Le
710 9: StLoc[10](loc0: bool)
711 10: Branch(17)
712B2:
713 11: CopyLoc[3](Arg3: u128)
714 12: ImmBorrowLoc[1](Arg1: OrderV2)
715 13: ImmBorrowField[9](OrderV2.price: u128)
716 14: ReadRef
717 15: Ge
718 16: StLoc[10](loc0: bool)
719B3:
720 17: MoveLoc[10](loc0: bool)
721 18: BrFalse(20)
722B4:
723 19: Branch(26)
724B5:
725 20: MoveLoc[0](Arg0: &mut Table<vector<u8>, OrderStatus>)
726 21: Pop
727 22: MoveLoc[8](Arg8: u64)
728 23: LdU64(34)
729 24: Add
730 25: Abort
731B6:
732 26: ImmBorrowLoc[1](Arg1: OrderV2)
733 27: ImmBorrowField[4](OrderV2.reduce_only: bool)
734 28: ReadRef
735 29: BrFalse(52)
736B7:
737 30: ImmBorrowLoc[1](Arg1: OrderV2)
738 31: ImmBorrowField[1](OrderV2.is_long: bool)
739 32: ReadRef
740 33: MoveLoc[5](Arg5: bool)
741 34: Neq
742 35: BrFalse(41)
743B8:
744 36: CopyLoc[4](Arg4: u128)
745 37: MoveLoc[6](Arg6: u128)
746 38: Le
747 39: StLoc[11](loc1: bool)
748 40: Branch(43)
749B9:
750 41: LdFalse
751 42: StLoc[11](loc1: bool)
752B10:
753 43: MoveLoc[11](loc1: bool)
754 44: BrFalse(46)
755B11:
756 45: Branch(52)
757B12:
758 46: MoveLoc[0](Arg0: &mut Table<vector<u8>, OrderStatus>)
759 47: Pop
760 48: MoveLoc[8](Arg8: u64)
761 49: LdU64(38)
762 50: Add
763 51: Abort
764B13:
765 52: MoveLoc[0](Arg0: &mut Table<vector<u8>, OrderStatus>)
766 53: CopyLoc[2](Arg2: vector<u8>)
767 54: Call table::borrow_mut<vector<u8>, OrderStatus>(&mut Table<vector<u8>, OrderStatus>, vector<u8>): &mut OrderStatus
768 55: StLoc[12](loc2: &mut OrderStatus)
769 56: CopyLoc[12](loc2: &mut OrderStatus)
770 57: ImmBorrowField[19](OrderStatus.filled_qty: u128)
771 58: ReadRef
772 59: CopyLoc[4](Arg4: u128)
773 60: Add
774 61: CopyLoc[12](loc2: &mut OrderStatus)
775 62: MutBorrowField[19](OrderStatus.filled_qty: u128)
776 63: WriteRef
777 64: CopyLoc[12](loc2: &mut OrderStatus)
778 65: ImmBorrowField[19](OrderStatus.filled_qty: u128)
779 66: ReadRef
780 67: ImmBorrowLoc[1](Arg1: OrderV2)
781 68: ImmBorrowField[8](OrderV2.quantity: u128)
782 69: ReadRef
783 70: Le
784 71: BrFalse(73)
785B14:
786 72: Branch(79)
787B15:
788 73: MoveLoc[12](loc2: &mut OrderStatus)
789 74: Pop
790 75: MoveLoc[8](Arg8: u64)
791 76: LdU64(44)
792 77: Add
793 78: Abort
794B16:
795 79: MoveLoc[9](Arg9: u128)
796 80: MoveLoc[2](Arg2: vector<u8>)
797 81: MoveLoc[1](Arg1: OrderV2)
798 82: Call order_v2_to_order(OrderV2): Order
799 83: ImmBorrowLoc[7](Arg7: UnifiedAddress)
800 84: Call unified_address::identifier(&UnifiedAddress): address
801 85: MoveLoc[3](Arg3: u128)
802 86: MoveLoc[4](Arg4: u128)
803 87: MoveLoc[12](loc2: &mut OrderStatus)
804 88: ImmBorrowField[19](OrderStatus.filled_qty: u128)
805 89: ReadRef
806 90: Pack[0](OrderFillEvent)
807 91: Call event::emit<OrderFillEvent>(OrderFillEvent)
808 92: Ret
809}
810
811public(friend) verify_order_expiry(Arg0: u64, Arg1: u64, Arg2: u64) {
812L3: loc0: bool
813B0:
814 0: CopyLoc[0](Arg0: u64)
815 1: LdU64(0)
816 2: Eq
817 3: BrFalse(7)
818B1:
819 4: LdTrue
820 5: StLoc[3](loc0: bool)
821 6: Branch(11)
822B2:
823 7: MoveLoc[0](Arg0: u64)
824 8: MoveLoc[1](Arg1: u64)
825 9: Gt
826 10: StLoc[3](loc0: bool)
827B3:
828 11: MoveLoc[3](loc0: bool)
829 12: BrFalse(14)
830B4:
831 13: Branch(18)
832B5:
833 14: MoveLoc[2](Arg2: u64)
834 15: LdU64(32)
835 16: Add
836 17: Abort
837B6:
838 18: Ret
839}
840
841public(friend) verify_order_leverage(Arg0: u128, Arg1: u128, Arg2: u64) {
842L3: loc0: bool
843B0:
844 0: CopyLoc[1](Arg1: u128)
845 1: LdU128(0)
846 2: Gt
847 3: BrFalse(5)
848B1:
849 4: Branch(9)
850B2:
851 5: MoveLoc[2](Arg2: u64)
852 6: LdU64(42)
853 7: Add
854 8: Abort
855B3:
856 9: CopyLoc[0](Arg0: u128)
857 10: LdU128(0)
858 11: Eq
859 12: BrFalse(16)
860B4:
861 13: LdTrue
862 14: StLoc[3](loc0: bool)
863 15: Branch(21)
864B5:
865 16: MoveLoc[1](Arg1: u128)
866 17: Call library::compute_mro(u128): u128
867 18: MoveLoc[0](Arg0: u128)
868 19: Eq
869 20: StLoc[3](loc0: bool)
870B6:
871 21: MoveLoc[3](loc0: bool)
872 22: BrFalse(24)
873B7:
874 23: Branch(28)
875B8:
876 24: MoveLoc[2](Arg2: u64)
877 25: LdU64(40)
878 26: Add
879 27: Abort
880B9:
881 28: Ret
882}
883
884public(friend) get_filled_qty(Arg0: &OrderStatus): u128 {
885B0:
886 0: MoveLoc[0](Arg0: &OrderStatus)
887 1: ImmBorrowField[19](OrderStatus.filled_qty: u128)
888 2: ReadRef
889 3: Ret
890}
891
892decode_order_flags(Arg0: u8): OrderFlags {
893B0:
894 0: CopyLoc[0](Arg0: u8)
895 1: LdU8(1)
896 2: BitAnd
897 3: LdU8(0)
898 4: Gt
899 5: CopyLoc[0](Arg0: u8)
900 6: LdU8(2)
901 7: BitAnd
902 8: LdU8(0)
903 9: Gt
904 10: CopyLoc[0](Arg0: u8)
905 11: LdU8(4)
906 12: BitAnd
907 13: LdU8(0)
908 14: Gt
909 15: CopyLoc[0](Arg0: u8)
910 16: LdU8(8)
911 17: BitAnd
912 18: LdU8(0)
913 19: Gt
914 20: MoveLoc[0](Arg0: u8)
915 21: LdU8(16)
916 22: BitAnd
917 23: LdU8(0)
918 24: Gt
919 25: Pack[2](OrderFlags)
920 26: Ret
921}
922
923Constants [
924 0 => vector<u8>: "action" // interpreted as UTF8 string
925 1 => vector<u8>: "PlaceOrder" // interpreted as UTF8 string
926 2 => vector<u8>: "market" // interpreted as UTF8 string
927 3 => vector<u8>: "creator" // interpreted as UTF8 string
928 4 => vector<u8>: "isLong" // interpreted as UTF8 string
929 5 => vector<u8>: "reduceOnly" // interpreted as UTF8 string
930 6 => vector<u8>: "postOnly" // interpreted as UTF8 string
931 7 => vector<u8>: "orderbookOnly" // interpreted as UTF8 string
932 8 => vector<u8>: "ioc" // interpreted as UTF8 string
933 9 => vector<u8>: "quantity" // interpreted as UTF8 string
934 10 => vector<u8>: "price" // interpreted as UTF8 string
935 11 => vector<u8>: "leverage" // interpreted as UTF8 string
936 12 => vector<u8>: "expiration" // interpreted as UTF8 string
937 13 => vector<u8>: "salt" // interpreted as UTF8 string
938 14 => vector<u8>: "orderFlag" // interpreted as UTF8 string
939]
940}
941
0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/perpetual.mvb1429 lines
1// Move bytecode v7
2module 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001.perpetual {
3use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::bank;
4use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::evaluator;
5use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::funding_rate;
6use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::insurance_fund;
7use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::library;
8use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::position;
9use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::price_feed;
10use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::protocol;
11use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::roles;
12use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::sub_accounts;
13use 8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::price_info;
14use 0000000000000000000000000000000000000000000000000000000000000001::string;
15use 0000000000000000000000000000000000000000000000000000000000000002::clock;
16use 0000000000000000000000000000000000000000000000000000000000000002::event;
17use 0000000000000000000000000000000000000000000000000000000000000002::object;
18use 0000000000000000000000000000000000000000000000000000000000000002::table;
19use 0000000000000000000000000000000000000000000000000000000000000002::transfer;
20use 0000000000000000000000000000000000000000000000000000000000000002::tx_context;
21
22struct PerpetualCreationEvent has copy, drop {
23 id: ID,
24 name: String,
25 imr: u128,
26 mmr: u128,
27 maker_fee: u128,
28 taker_fee: u128,
29 fee_pool: address,
30 gas_pool: address,
31 start_time: u64,
32 price_identifier_id: vector<u8>,
33 checks: TradeChecks,
34 funding: FundingRate
35}
36
37struct FeePoolAccountUpdateEvent has copy, drop {
38 id: ID,
39 account: address
40}
41
42struct GasPoolAccountUpdateEvent has copy, drop {
43 id: ID,
44 account: address
45}
46
47struct DelistEvent has copy, drop {
48 id: ID,
49 delisting_price: u128
50}
51
52struct TradingPermissionStatusUpdateEvent has copy, drop {
53 status: bool
54}
55
56struct MMRUpdateEvent has copy, drop {
57 id: ID,
58 mmr: u128
59}
60
61struct IMRUpdateEvent has copy, drop {
62 id: ID,
63 imr: u128
64}
65
66struct SpecialFeeEvent has copy, drop {
67 perp: ID,
68 account: address,
69 status: bool,
70 maker_fee: u128,
71 taker_fee: u128
72}
73
74struct PriceOracleIdentifierUpdateEvent has copy, drop {
75 perp: ID,
76 identifier: vector<u8>
77}
78
79struct MakerFeeUpdateEvent has copy, drop {
80 perp: ID,
81 maker_fee: u128
82}
83
84struct TakerFeeUpdateEvent has copy, drop {
85 perp: ID,
86 taker_fee: u128
87}
88
89struct Perpetual has key {
90 id: UID,
91 name: String,
92 imr: u128,
93 mmr: u128,
94 maker_fee: u128,
95 taker_fee: u128,
96 insurance_fund: InsuranceFund,
97 fee_pool: address,
98 gas_pool: address,
99 delisted: bool,
100 delisting_price: u128,
101 is_trading_permitted: bool,
102 start_time: u64,
103 checks: TradeChecks,
104 positions: Table<address, Position>,
105 special_fee: Table<address, SpecialFee>,
106 price_oracle: u128,
107 funding: FundingRate,
108 price_identifier_id: vector<u8>
109}
110
111struct SpecialFee has copy, drop, store {
112 status: bool,
113 maker_fee: u128,
114 taker_fee: u128
115}
116
117public set_trading_permit(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Perpetual, Arg3: bool) {
118B0:
119 0: CopyLoc[0](Arg0: &ProtocolConfig)
120 1: Call protocol::check_basic(&ProtocolConfig)
121 2: MoveLoc[0](Arg0: &ProtocolConfig)
122 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
123 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
124 5: CopyLoc[3](Arg3: bool)
125 6: MoveLoc[2](Arg2: &mut Perpetual)
126 7: MutBorrowField[0](Perpetual.is_trading_permitted: bool)
127 8: WriteRef
128 9: MoveLoc[3](Arg3: bool)
129 10: Pack[4](TradingPermissionStatusUpdateEvent)
130 11: Call event::emit<TradingPermissionStatusUpdateEvent>(TradingPermissionStatusUpdateEvent)
131 12: Ret
132}
133
134public set_price_oracle_identifier(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Perpetual, Arg3: vector<u8>) {
135B0:
136 0: CopyLoc[0](Arg0: &ProtocolConfig)
137 1: Call protocol::check_basic(&ProtocolConfig)
138 2: MoveLoc[0](Arg0: &ProtocolConfig)
139 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
140 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
141 5: CopyLoc[3](Arg3: vector<u8>)
142 6: CopyLoc[2](Arg2: &mut Perpetual)
143 7: MutBorrowField[1](Perpetual.price_identifier_id: vector<u8>)
144 8: WriteRef
145 9: MoveLoc[2](Arg2: &mut Perpetual)
146 10: FreezeRef
147 11: Call id(&Perpetual): &UID
148 12: Call object::uid_to_inner(&UID): ID
149 13: MoveLoc[3](Arg3: vector<u8>)
150 14: Pack[8](PriceOracleIdentifierUpdateEvent)
151 15: Call event::emit<PriceOracleIdentifierUpdateEvent>(PriceOracleIdentifierUpdateEvent)
152 16: Ret
153}
154
155public set_fee_pool_address<Ty0>(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Bank<Ty0>, Arg3: &mut Perpetual, Arg4: address) {
156L5: loc0: ID
157B0:
158 0: CopyLoc[0](Arg0: &ProtocolConfig)
159 1: Call protocol::check_basic(&ProtocolConfig)
160 2: MoveLoc[0](Arg0: &ProtocolConfig)
161 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
162 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
163 5: CopyLoc[4](Arg4: address)
164 6: LdConst[2](address: 0x00..)
165 7: Neq
166 8: BrFalse(10)
167B1:
168 9: Branch(16)
169B2:
170 10: MoveLoc[3](Arg3: &mut Perpetual)
171 11: Pop
172 12: MoveLoc[2](Arg2: &mut Bank<Ty0>)
173 13: Pop
174 14: LdU64(105)
175 15: Abort
176B3:
177 16: CopyLoc[3](Arg3: &mut Perpetual)
178 17: FreezeRef
179 18: Call id(&Perpetual): &UID
180 19: Call object::uid_to_inner(&UID): ID
181 20: StLoc[5](loc0: ID)
182 21: CopyLoc[4](Arg4: address)
183 22: CopyLoc[3](Arg3: &mut Perpetual)
184 23: MutBorrowField[2](Perpetual.fee_pool: address)
185 24: WriteRef
186 25: MoveLoc[2](Arg2: &mut Bank<Ty0>)
187 26: MoveLoc[3](Arg3: &mut Perpetual)
188 27: ImmBorrowField[2](Perpetual.fee_pool: address)
189 28: ReadRef
190 29: Call bank::create_account_if_not_exist<Ty0>(&mut Bank<Ty0>, address)
191 30: MoveLoc[5](loc0: ID)
192 31: MoveLoc[4](Arg4: address)
193 32: Pack[1](FeePoolAccountUpdateEvent)
194 33: Call event::emit<FeePoolAccountUpdateEvent>(FeePoolAccountUpdateEvent)
195 34: Ret
196}
197
198public set_gas_pool_address<Ty0>(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Bank<Ty0>, Arg3: &mut Perpetual, Arg4: address) {
199L5: loc0: ID
200B0:
201 0: CopyLoc[0](Arg0: &ProtocolConfig)
202 1: Call protocol::check_basic(&ProtocolConfig)
203 2: MoveLoc[0](Arg0: &ProtocolConfig)
204 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
205 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
206 5: CopyLoc[4](Arg4: address)
207 6: LdConst[2](address: 0x00..)
208 7: Neq
209 8: BrFalse(10)
210B1:
211 9: Branch(16)
212B2:
213 10: MoveLoc[3](Arg3: &mut Perpetual)
214 11: Pop
215 12: MoveLoc[2](Arg2: &mut Bank<Ty0>)
216 13: Pop
217 14: LdU64(105)
218 15: Abort
219B3:
220 16: CopyLoc[3](Arg3: &mut Perpetual)
221 17: FreezeRef
222 18: Call id(&Perpetual): &UID
223 19: Call object::uid_to_inner(&UID): ID
224 20: StLoc[5](loc0: ID)
225 21: CopyLoc[4](Arg4: address)
226 22: CopyLoc[3](Arg3: &mut Perpetual)
227 23: MutBorrowField[3](Perpetual.gas_pool: address)
228 24: WriteRef
229 25: MoveLoc[2](Arg2: &mut Bank<Ty0>)
230 26: MoveLoc[3](Arg3: &mut Perpetual)
231 27: ImmBorrowField[3](Perpetual.gas_pool: address)
232 28: ReadRef
233 29: Call bank::create_account_if_not_exist<Ty0>(&mut Bank<Ty0>, address)
234 30: MoveLoc[5](loc0: ID)
235 31: MoveLoc[4](Arg4: address)
236 32: Pack[2](GasPoolAccountUpdateEvent)
237 33: Call event::emit<GasPoolAccountUpdateEvent>(GasPoolAccountUpdateEvent)
238 34: Ret
239}
240
241public set_insurance_active_pool_address<Ty0>(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Bank<Ty0>, Arg3: &mut Perpetual, Arg4: address) {
242B0:
243 0: CopyLoc[0](Arg0: &ProtocolConfig)
244 1: Call protocol::check_basic(&ProtocolConfig)
245 2: MoveLoc[0](Arg0: &ProtocolConfig)
246 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
247 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
248 5: MoveLoc[3](Arg3: &mut Perpetual)
249 6: MutBorrowField[4](Perpetual.insurance_fund: InsuranceFund)
250 7: CopyLoc[4](Arg4: address)
251 8: Call insurance_fund::set_active_account(&mut InsuranceFund, address)
252 9: MoveLoc[2](Arg2: &mut Bank<Ty0>)
253 10: MoveLoc[4](Arg4: address)
254 11: Call bank::create_account_if_not_exist<Ty0>(&mut Bank<Ty0>, address)
255 12: Ret
256}
257
258public set_insurance_security_pool_address<Ty0>(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Bank<Ty0>, Arg3: &mut Perpetual, Arg4: address) {
259B0:
260 0: CopyLoc[0](Arg0: &ProtocolConfig)
261 1: Call protocol::check_basic(&ProtocolConfig)
262 2: MoveLoc[0](Arg0: &ProtocolConfig)
263 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
264 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
265 5: MoveLoc[3](Arg3: &mut Perpetual)
266 6: MutBorrowField[4](Perpetual.insurance_fund: InsuranceFund)
267 7: CopyLoc[4](Arg4: address)
268 8: Call insurance_fund::set_security_account(&mut InsuranceFund, address)
269 9: MoveLoc[2](Arg2: &mut Bank<Ty0>)
270 10: MoveLoc[4](Arg4: address)
271 11: Call bank::create_account_if_not_exist<Ty0>(&mut Bank<Ty0>, address)
272 12: Ret
273}
274
275public transfer_insurance_fund_from_active_to_security_v2<Ty0>(Arg0: &Clock, Arg1: &ProtocolConfig, Arg2: &InsuranceOperatorCap, Arg3: &mut TxIndexer, Arg4: &mut Bank<Ty0>, Arg5: &Perpetual, Arg6: u128) {
276L7: loc0: u128
277B0:
278 0: CopyLoc[1](Arg1: &ProtocolConfig)
279 1: Call protocol::check_basic(&ProtocolConfig)
280 2: MoveLoc[1](Arg1: &ProtocolConfig)
281 3: MoveLoc[2](Arg2: &InsuranceOperatorCap)
282 4: Call roles::check_insurance_operator_validity(&ProtocolConfig, &InsuranceOperatorCap)
283 5: MoveLoc[3](Arg3: &mut TxIndexer)
284 6: Call sub_accounts::increment_tx_index(&mut TxIndexer): u128
285 7: StLoc[7](loc0: u128)
286 8: MoveLoc[5](Arg5: &Perpetual)
287 9: Call insurance_fund(&Perpetual): &InsuranceFund
288 10: MoveLoc[0](Arg0: &Clock)
289 11: MoveLoc[4](Arg4: &mut Bank<Ty0>)
290 12: MoveLoc[6](Arg6: u128)
291 13: Call library::decimal_1e18_to_base(u128): u128
292 14: MoveLoc[7](loc0: u128)
293 15: Call insurance_fund::transfer_from_active_to_security<Ty0>(&InsuranceFund, &Clock, &mut Bank<Ty0>, u128, u128)
294 16: Ret
295}
296
297public transfer_insurance_fund_from_active_to_security<Ty0>(Arg0: &Clock, Arg1: &ProtocolConfig, Arg2: &ExchangeManagerCap, Arg3: &mut TxIndexer, Arg4: &mut Bank<Ty0>, Arg5: &Perpetual, Arg6: u128) {
298B0:
299 0: LdU64(999)
300 1: Abort
301}
302
303public transfer_insurance_fund_from_security_to_active_v2<Ty0>(Arg0: &Clock, Arg1: &ProtocolConfig, Arg2: &InsuranceOperatorCap, Arg3: &mut TxIndexer, Arg4: &mut Bank<Ty0>, Arg5: &mut Perpetual, Arg6: u128) {
304L7: loc0: u128
305B0:
306 0: CopyLoc[1](Arg1: &ProtocolConfig)
307 1: Call protocol::check_basic(&ProtocolConfig)
308 2: MoveLoc[1](Arg1: &ProtocolConfig)
309 3: MoveLoc[2](Arg2: &InsuranceOperatorCap)
310 4: Call roles::check_insurance_operator_validity(&ProtocolConfig, &InsuranceOperatorCap)
311 5: MoveLoc[3](Arg3: &mut TxIndexer)
312 6: Call sub_accounts::increment_tx_index(&mut TxIndexer): u128
313 7: StLoc[7](loc0: u128)
314 8: MoveLoc[5](Arg5: &mut Perpetual)
315 9: Call insurance_fund_mut(&mut Perpetual): &mut InsuranceFund
316 10: MoveLoc[0](Arg0: &Clock)
317 11: MoveLoc[4](Arg4: &mut Bank<Ty0>)
318 12: MoveLoc[6](Arg6: u128)
319 13: Call library::decimal_1e18_to_base(u128): u128
320 14: MoveLoc[7](loc0: u128)
321 15: Call insurance_fund::transfer_from_security_to_active<Ty0>(&mut InsuranceFund, &Clock, &mut Bank<Ty0>, u128, u128)
322 16: Ret
323}
324
325public transfer_insurance_fund_from_security_to_active<Ty0>(Arg0: &Clock, Arg1: &ProtocolConfig, Arg2: &ExchangeManagerCap, Arg3: &mut TxIndexer, Arg4: &mut Bank<Ty0>, Arg5: &mut Perpetual, Arg6: u128) {
326B0:
327 0: LdU64(999)
328 1: Abort
329}
330
331public set_insurance_fund_transfer_amount_limit(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Perpetual, Arg3: u128) {
332B0:
333 0: CopyLoc[0](Arg0: &ProtocolConfig)
334 1: Call protocol::check_basic(&ProtocolConfig)
335 2: MoveLoc[0](Arg0: &ProtocolConfig)
336 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
337 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
338 5: MoveLoc[2](Arg2: &mut Perpetual)
339 6: Call insurance_fund_mut(&mut Perpetual): &mut InsuranceFund
340 7: MoveLoc[3](Arg3: u128)
341 8: Call library::decimal_1e18_to_base(u128): u128
342 9: Call insurance_fund::set_amount_limit(&mut InsuranceFund, u128)
343 10: Ret
344}
345
346public set_insurance_fund_transfer_interval(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Perpetual, Arg3: u64) {
347B0:
348 0: CopyLoc[0](Arg0: &ProtocolConfig)
349 1: Call protocol::check_basic(&ProtocolConfig)
350 2: MoveLoc[0](Arg0: &ProtocolConfig)
351 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
352 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
353 5: MoveLoc[2](Arg2: &mut Perpetual)
354 6: Call insurance_fund_mut(&mut Perpetual): &mut InsuranceFund
355 7: MoveLoc[3](Arg3: u64)
356 8: Call insurance_fund::set_transfer_interval(&mut InsuranceFund, u64)
357 9: Ret
358}
359
360public delist_perpetual(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Perpetual, Arg3: u128) {
361B0:
362 0: CopyLoc[0](Arg0: &ProtocolConfig)
363 1: Call protocol::check_basic(&ProtocolConfig)
364 2: MoveLoc[0](Arg0: &ProtocolConfig)
365 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
366 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
367 5: MoveLoc[3](Arg3: u128)
368 6: Call library::base_uint(): u128
369 7: Div
370 8: StLoc[3](Arg3: u128)
371 9: CopyLoc[2](Arg2: &mut Perpetual)
372 10: ImmBorrowField[5](Perpetual.delisted: bool)
373 11: ReadRef
374 12: Not
375 13: BrFalse(15)
376B1:
377 14: Branch(19)
378B2:
379 15: MoveLoc[2](Arg2: &mut Perpetual)
380 16: Pop
381 17: LdU64(60)
382 18: Abort
383B3:
384 19: CopyLoc[2](Arg2: &mut Perpetual)
385 20: ImmBorrowField[6](Perpetual.checks: TradeChecks)
386 21: ReadRef
387 22: CopyLoc[3](Arg3: u128)
388 23: Call evaluator::verify_price_checks(TradeChecks, u128)
389 24: LdTrue
390 25: CopyLoc[2](Arg2: &mut Perpetual)
391 26: MutBorrowField[5](Perpetual.delisted: bool)
392 27: WriteRef
393 28: CopyLoc[3](Arg3: u128)
394 29: CopyLoc[2](Arg2: &mut Perpetual)
395 30: MutBorrowField[7](Perpetual.delisting_price: u128)
396 31: WriteRef
397 32: MoveLoc[2](Arg2: &mut Perpetual)
398 33: FreezeRef
399 34: Call id(&Perpetual): &UID
400 35: Call object::uid_to_inner(&UID): ID
401 36: MoveLoc[3](Arg3: u128)
402 37: Pack[3](DelistEvent)
403 38: Call event::emit<DelistEvent>(DelistEvent)
404 39: Ret
405}
406
407public set_min_price(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Perpetual, Arg3: u128) {
408B0:
409 0: CopyLoc[0](Arg0: &ProtocolConfig)
410 1: Call protocol::check_basic(&ProtocolConfig)
411 2: MoveLoc[0](Arg0: &ProtocolConfig)
412 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
413 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
414 5: CopyLoc[2](Arg2: &mut Perpetual)
415 6: ImmBorrowField[8](Perpetual.id: UID)
416 7: Call object::uid_to_inner(&UID): ID
417 8: MoveLoc[2](Arg2: &mut Perpetual)
418 9: MutBorrowField[6](Perpetual.checks: TradeChecks)
419 10: MoveLoc[3](Arg3: u128)
420 11: Call library::base_uint(): u128
421 12: Div
422 13: Call evaluator::set_min_price(ID, &mut TradeChecks, u128)
423 14: Ret
424}
425
426public set_max_price(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Perpetual, Arg3: u128) {
427B0:
428 0: CopyLoc[0](Arg0: &ProtocolConfig)
429 1: Call protocol::check_basic(&ProtocolConfig)
430 2: MoveLoc[0](Arg0: &ProtocolConfig)
431 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
432 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
433 5: CopyLoc[2](Arg2: &mut Perpetual)
434 6: ImmBorrowField[8](Perpetual.id: UID)
435 7: Call object::uid_to_inner(&UID): ID
436 8: MoveLoc[2](Arg2: &mut Perpetual)
437 9: MutBorrowField[6](Perpetual.checks: TradeChecks)
438 10: MoveLoc[3](Arg3: u128)
439 11: Call library::base_uint(): u128
440 12: Div
441 13: Call evaluator::set_max_price(ID, &mut TradeChecks, u128)
442 14: Ret
443}
444
445public set_step_size(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Perpetual, Arg3: u128) {
446B0:
447 0: CopyLoc[0](Arg0: &ProtocolConfig)
448 1: Call protocol::check_basic(&ProtocolConfig)
449 2: MoveLoc[0](Arg0: &ProtocolConfig)
450 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
451 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
452 5: CopyLoc[2](Arg2: &mut Perpetual)
453 6: ImmBorrowField[8](Perpetual.id: UID)
454 7: Call object::uid_to_inner(&UID): ID
455 8: MoveLoc[2](Arg2: &mut Perpetual)
456 9: MutBorrowField[6](Perpetual.checks: TradeChecks)
457 10: MoveLoc[3](Arg3: u128)
458 11: Call library::base_uint(): u128
459 12: Div
460 13: Call evaluator::set_step_size(ID, &mut TradeChecks, u128)
461 14: Ret
462}
463
464public set_tick_size(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Perpetual, Arg3: u128) {
465B0:
466 0: CopyLoc[0](Arg0: &ProtocolConfig)
467 1: Call protocol::check_basic(&ProtocolConfig)
468 2: MoveLoc[0](Arg0: &ProtocolConfig)
469 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
470 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
471 5: CopyLoc[2](Arg2: &mut Perpetual)
472 6: ImmBorrowField[8](Perpetual.id: UID)
473 7: Call object::uid_to_inner(&UID): ID
474 8: MoveLoc[2](Arg2: &mut Perpetual)
475 9: MutBorrowField[6](Perpetual.checks: TradeChecks)
476 10: MoveLoc[3](Arg3: u128)
477 11: Call library::base_uint(): u128
478 12: Div
479 13: Call evaluator::set_tick_size(ID, &mut TradeChecks, u128)
480 14: Ret
481}
482
483public set_mtb_long(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Perpetual, Arg3: u128) {
484B0:
485 0: CopyLoc[0](Arg0: &ProtocolConfig)
486 1: Call protocol::check_basic(&ProtocolConfig)
487 2: MoveLoc[0](Arg0: &ProtocolConfig)
488 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
489 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
490 5: CopyLoc[2](Arg2: &mut Perpetual)
491 6: ImmBorrowField[8](Perpetual.id: UID)
492 7: Call object::uid_to_inner(&UID): ID
493 8: MoveLoc[2](Arg2: &mut Perpetual)
494 9: MutBorrowField[6](Perpetual.checks: TradeChecks)
495 10: MoveLoc[3](Arg3: u128)
496 11: Call library::base_uint(): u128
497 12: Div
498 13: Call evaluator::set_mtb_long(ID, &mut TradeChecks, u128)
499 14: Ret
500}
501
502public set_mtb_short(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Perpetual, Arg3: u128) {
503B0:
504 0: CopyLoc[0](Arg0: &ProtocolConfig)
505 1: Call protocol::check_basic(&ProtocolConfig)
506 2: MoveLoc[0](Arg0: &ProtocolConfig)
507 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
508 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
509 5: CopyLoc[2](Arg2: &mut Perpetual)
510 6: ImmBorrowField[8](Perpetual.id: UID)
511 7: Call object::uid_to_inner(&UID): ID
512 8: MoveLoc[2](Arg2: &mut Perpetual)
513 9: MutBorrowField[6](Perpetual.checks: TradeChecks)
514 10: MoveLoc[3](Arg3: u128)
515 11: Call library::base_uint(): u128
516 12: Div
517 13: Call evaluator::set_mtb_short(ID, &mut TradeChecks, u128)
518 14: Ret
519}
520
521public set_max_qty_limit(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Perpetual, Arg3: u128) {
522B0:
523 0: CopyLoc[0](Arg0: &ProtocolConfig)
524 1: Call protocol::check_basic(&ProtocolConfig)
525 2: MoveLoc[0](Arg0: &ProtocolConfig)
526 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
527 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
528 5: CopyLoc[2](Arg2: &mut Perpetual)
529 6: ImmBorrowField[8](Perpetual.id: UID)
530 7: Call object::uid_to_inner(&UID): ID
531 8: MoveLoc[2](Arg2: &mut Perpetual)
532 9: MutBorrowField[6](Perpetual.checks: TradeChecks)
533 10: MoveLoc[3](Arg3: u128)
534 11: Call library::base_uint(): u128
535 12: Div
536 13: Call evaluator::set_max_qty_limit(ID, &mut TradeChecks, u128)
537 14: Ret
538}
539
540public set_max_qty_market(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Perpetual, Arg3: u128) {
541B0:
542 0: CopyLoc[0](Arg0: &ProtocolConfig)
543 1: Call protocol::check_basic(&ProtocolConfig)
544 2: MoveLoc[0](Arg0: &ProtocolConfig)
545 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
546 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
547 5: CopyLoc[2](Arg2: &mut Perpetual)
548 6: ImmBorrowField[8](Perpetual.id: UID)
549 7: Call object::uid_to_inner(&UID): ID
550 8: MoveLoc[2](Arg2: &mut Perpetual)
551 9: MutBorrowField[6](Perpetual.checks: TradeChecks)
552 10: MoveLoc[3](Arg3: u128)
553 11: Call library::base_uint(): u128
554 12: Div
555 13: Call evaluator::set_max_qty_market(ID, &mut TradeChecks, u128)
556 14: Ret
557}
558
559public set_min_qty(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Perpetual, Arg3: u128) {
560B0:
561 0: CopyLoc[0](Arg0: &ProtocolConfig)
562 1: Call protocol::check_basic(&ProtocolConfig)
563 2: MoveLoc[0](Arg0: &ProtocolConfig)
564 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
565 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
566 5: CopyLoc[2](Arg2: &mut Perpetual)
567 6: ImmBorrowField[8](Perpetual.id: UID)
568 7: Call object::uid_to_inner(&UID): ID
569 8: MoveLoc[2](Arg2: &mut Perpetual)
570 9: MutBorrowField[6](Perpetual.checks: TradeChecks)
571 10: MoveLoc[3](Arg3: u128)
572 11: Call library::base_uint(): u128
573 12: Div
574 13: Call evaluator::set_min_qty(ID, &mut TradeChecks, u128)
575 14: Ret
576}
577
578public set_max_oi_open(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Perpetual, Arg3: vector<u128>) {
579L4: loc0: vector<u128>
580B0:
581 0: CopyLoc[0](Arg0: &ProtocolConfig)
582 1: Call protocol::check_basic(&ProtocolConfig)
583 2: MoveLoc[0](Arg0: &ProtocolConfig)
584 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
585 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
586 5: MoveLoc[3](Arg3: vector<u128>)
587 6: Call library::to_1x9_vec(vector<u128>): vector<u128>
588 7: StLoc[4](loc0: vector<u128>)
589 8: CopyLoc[2](Arg2: &mut Perpetual)
590 9: ImmBorrowField[8](Perpetual.id: UID)
591 10: Call object::uid_to_inner(&UID): ID
592 11: MoveLoc[2](Arg2: &mut Perpetual)
593 12: MutBorrowField[6](Perpetual.checks: TradeChecks)
594 13: MoveLoc[4](loc0: vector<u128>)
595 14: Call evaluator::set_max_oi_open(ID, &mut TradeChecks, vector<u128>)
596 15: Ret
597}
598
599public set_max_allowed_funding_rate(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Perpetual, Arg3: u128) {
600L4: loc0: ID
601B0:
602 0: CopyLoc[0](Arg0: &ProtocolConfig)
603 1: Call protocol::check_basic(&ProtocolConfig)
604 2: MoveLoc[0](Arg0: &ProtocolConfig)
605 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
606 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
607 5: CopyLoc[2](Arg2: &mut Perpetual)
608 6: FreezeRef
609 7: Call id(&Perpetual): &UID
610 8: Call object::uid_to_inner(&UID): ID
611 9: StLoc[4](loc0: ID)
612 10: MoveLoc[2](Arg2: &mut Perpetual)
613 11: MutBorrowField[9](Perpetual.funding: FundingRate)
614 12: MoveLoc[3](Arg3: u128)
615 13: Call library::base_uint(): u128
616 14: Div
617 15: MoveLoc[4](loc0: ID)
618 16: Call funding_rate::set_max_allowed_funding_rate(&mut FundingRate, u128, ID)
619 17: Ret
620}
621
622public set_funding_rate(Arg0: &ProtocolConfig, Arg1: &Clock, Arg2: &FundingRateCap, Arg3: &mut Perpetual, Arg4: u128, Arg5: bool, Arg6: &PriceInfoObject) {
623B0:
624 0: LdU64(999)
625 1: Abort
626}
627
628public set_funding_rate_v2(Arg0: &ProtocolConfig, Arg1: &Clock, Arg2: &FundingRateCap, Arg3: &mut Perpetual, Arg4: u128, Arg5: bool, Arg6: &PriceFeed) {
629L7: loc0: FundingIndex
630L8: loc1: ID
631B0:
632 0: CopyLoc[0](Arg0: &ProtocolConfig)
633 1: Call protocol::check_basic(&ProtocolConfig)
634 2: MoveLoc[0](Arg0: &ProtocolConfig)
635 3: MoveLoc[2](Arg2: &FundingRateCap)
636 4: Call roles::check_funding_rate_operator_validity(&ProtocolConfig, &FundingRateCap)
637 5: CopyLoc[3](Arg3: &mut Perpetual)
638 6: ImmBorrowField[5](Perpetual.delisted: bool)
639 7: ReadRef
640 8: Not
641 9: BrFalse(11)
642B1:
643 10: Branch(19)
644B2:
645 11: MoveLoc[6](Arg6: &PriceFeed)
646 12: Pop
647 13: MoveLoc[3](Arg3: &mut Perpetual)
648 14: Pop
649 15: MoveLoc[1](Arg1: &Clock)
650 16: Pop
651 17: LdU64(61)
652 18: Abort
653B3:
654 19: CopyLoc[3](Arg3: &mut Perpetual)
655 20: MoveLoc[6](Arg6: &PriceFeed)
656 21: CopyLoc[1](Arg1: &Clock)
657 22: Call update_oracle_price_v2(&mut Perpetual, &PriceFeed, &Clock)
658 23: CopyLoc[3](Arg3: &mut Perpetual)
659 24: ImmBorrowField[8](Perpetual.id: UID)
660 25: Call object::uid_to_inner(&UID): ID
661 26: StLoc[8](loc1: ID)
662 27: CopyLoc[1](Arg1: &Clock)
663 28: CopyLoc[3](Arg3: &mut Perpetual)
664 29: ImmBorrowField[9](Perpetual.funding: FundingRate)
665 30: ReadRef
666 31: CopyLoc[3](Arg3: &mut Perpetual)
667 32: FreezeRef
668 33: Call price_oracle(&Perpetual): u128
669 34: Call funding_rate::compute_new_global_index(&Clock, FundingRate, u128): FundingIndex
670 35: StLoc[7](loc0: FundingIndex)
671 36: CopyLoc[3](Arg3: &mut Perpetual)
672 37: MutBorrowField[9](Perpetual.funding: FundingRate)
673 38: MoveLoc[7](loc0: FundingIndex)
674 39: CopyLoc[8](loc1: ID)
675 40: Call funding_rate::set_global_index(&mut FundingRate, FundingIndex, ID)
676 41: MoveLoc[3](Arg3: &mut Perpetual)
677 42: MutBorrowField[9](Perpetual.funding: FundingRate)
678 43: MoveLoc[4](Arg4: u128)
679 44: Call library::base_uint(): u128
680 45: Div
681 46: MoveLoc[5](Arg5: bool)
682 47: MoveLoc[1](Arg1: &Clock)
683 48: Call clock::timestamp_ms(&Clock): u64
684 49: MoveLoc[8](loc1: ID)
685 50: Call funding_rate::set_funding_rate(&mut FundingRate, u128, bool, u64, ID)
686 51: Ret
687}
688
689public set_maintenance_margin_required(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Perpetual, Arg3: u128) {
690B0:
691 0: CopyLoc[0](Arg0: &ProtocolConfig)
692 1: Call protocol::check_basic(&ProtocolConfig)
693 2: MoveLoc[0](Arg0: &ProtocolConfig)
694 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
695 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
696 5: MoveLoc[3](Arg3: u128)
697 6: Call library::base_uint(): u128
698 7: Div
699 8: StLoc[3](Arg3: u128)
700 9: CopyLoc[3](Arg3: u128)
701 10: LdU128(0)
702 11: Gt
703 12: BrFalse(14)
704B1:
705 13: Branch(18)
706B2:
707 14: MoveLoc[2](Arg2: &mut Perpetual)
708 15: Pop
709 16: LdU64(300)
710 17: Abort
711B3:
712 18: CopyLoc[3](Arg3: u128)
713 19: CopyLoc[2](Arg2: &mut Perpetual)
714 20: ImmBorrowField[10](Perpetual.imr: u128)
715 21: ReadRef
716 22: Le
717 23: BrFalse(25)
718B4:
719 24: Branch(29)
720B5:
721 25: MoveLoc[2](Arg2: &mut Perpetual)
722 26: Pop
723 27: LdU64(301)
724 28: Abort
725B6:
726 29: CopyLoc[3](Arg3: u128)
727 30: CopyLoc[2](Arg2: &mut Perpetual)
728 31: MutBorrowField[11](Perpetual.mmr: u128)
729 32: WriteRef
730 33: MoveLoc[2](Arg2: &mut Perpetual)
731 34: FreezeRef
732 35: Call id(&Perpetual): &UID
733 36: Call object::uid_to_inner(&UID): ID
734 37: MoveLoc[3](Arg3: u128)
735 38: Pack[5](MMRUpdateEvent)
736 39: Call event::emit<MMRUpdateEvent>(MMRUpdateEvent)
737 40: Ret
738}
739
740public set_initial_margin_required(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Perpetual, Arg3: u128) {
741B0:
742 0: CopyLoc[0](Arg0: &ProtocolConfig)
743 1: Call protocol::check_basic(&ProtocolConfig)
744 2: MoveLoc[0](Arg0: &ProtocolConfig)
745 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
746 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
747 5: MoveLoc[3](Arg3: u128)
748 6: Call library::base_uint(): u128
749 7: Div
750 8: StLoc[3](Arg3: u128)
751 9: CopyLoc[3](Arg3: u128)
752 10: CopyLoc[2](Arg2: &mut Perpetual)
753 11: ImmBorrowField[11](Perpetual.mmr: u128)
754 12: ReadRef
755 13: Ge
756 14: BrFalse(16)
757B1:
758 15: Branch(20)
759B2:
760 16: MoveLoc[2](Arg2: &mut Perpetual)
761 17: Pop
762 18: LdU64(302)
763 19: Abort
764B3:
765 20: CopyLoc[3](Arg3: u128)
766 21: CopyLoc[2](Arg2: &mut Perpetual)
767 22: MutBorrowField[10](Perpetual.imr: u128)
768 23: WriteRef
769 24: MoveLoc[2](Arg2: &mut Perpetual)
770 25: FreezeRef
771 26: Call id(&Perpetual): &UID
772 27: Call object::uid_to_inner(&UID): ID
773 28: MoveLoc[3](Arg3: u128)
774 29: Pack[6](IMRUpdateEvent)
775 30: Call event::emit<IMRUpdateEvent>(IMRUpdateEvent)
776 31: Ret
777}
778
779public set_special_fee(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Perpetual, Arg3: address, Arg4: bool, Arg5: u128, Arg6: u128) {
780L7: loc0: &mut SpecialFee
781L8: loc1: SpecialFee
782B0:
783 0: CopyLoc[0](Arg0: &ProtocolConfig)
784 1: Call protocol::check_basic(&ProtocolConfig)
785 2: MoveLoc[0](Arg0: &ProtocolConfig)
786 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
787 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
788 5: CopyLoc[3](Arg3: address)
789 6: LdConst[2](address: 0x00..)
790 7: Neq
791 8: BrFalse(10)
792B1:
793 9: Branch(14)
794B2:
795 10: MoveLoc[2](Arg2: &mut Perpetual)
796 11: Pop
797 12: LdU64(105)
798 13: Abort
799B3:
800 14: CopyLoc[4](Arg4: bool)
801 15: MoveLoc[5](Arg5: u128)
802 16: Call library::base_uint(): u128
803 17: Div
804 18: MoveLoc[6](Arg6: u128)
805 19: Call library::base_uint(): u128
806 20: Div
807 21: Pack[12](SpecialFee)
808 22: StLoc[8](loc1: SpecialFee)
809 23: CopyLoc[2](Arg2: &mut Perpetual)
810 24: ImmBorrowField[12](Perpetual.special_fee: Table<address, SpecialFee>)
811 25: CopyLoc[3](Arg3: address)
812 26: Call table::contains<address, SpecialFee>(&Table<address, SpecialFee>, address): bool
813 27: BrFalse(37)
814B4:
815 28: CopyLoc[2](Arg2: &mut Perpetual)
816 29: MutBorrowField[12](Perpetual.special_fee: Table<address, SpecialFee>)
817 30: CopyLoc[3](Arg3: address)
818 31: Call table::borrow_mut<address, SpecialFee>(&mut Table<address, SpecialFee>, address): &mut SpecialFee
819 32: StLoc[7](loc0: &mut SpecialFee)
820 33: CopyLoc[8](loc1: SpecialFee)
821 34: MoveLoc[7](loc0: &mut SpecialFee)
822 35: WriteRef
823 36: Branch(42)
824B5:
825 37: CopyLoc[2](Arg2: &mut Perpetual)
826 38: MutBorrowField[12](Perpetual.special_fee: Table<address, SpecialFee>)
827 39: CopyLoc[3](Arg3: address)
828 40: CopyLoc[8](loc1: SpecialFee)
829 41: Call table::add<address, SpecialFee>(&mut Table<address, SpecialFee>, address, SpecialFee)
830B6:
831 42: MoveLoc[2](Arg2: &mut Perpetual)
832 43: FreezeRef
833 44: Call id(&Perpetual): &UID
834 45: Call object::uid_to_inner(&UID): ID
835 46: MoveLoc[3](Arg3: address)
836 47: MoveLoc[4](Arg4: bool)
837 48: ImmBorrowLoc[8](loc1: SpecialFee)
838 49: ImmBorrowField[13](SpecialFee.maker_fee: u128)
839 50: ReadRef
840 51: ImmBorrowLoc[8](loc1: SpecialFee)
841 52: ImmBorrowField[14](SpecialFee.taker_fee: u128)
842 53: ReadRef
843 54: Pack[7](SpecialFeeEvent)
844 55: Call event::emit<SpecialFeeEvent>(SpecialFeeEvent)
845 56: Ret
846}
847
848public remove_empty_positions(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &Clock, Arg3: &mut Perpetual, Arg4: vector<address>) {
849L5: loc0: u64
850B0:
851 0: CopyLoc[0](Arg0: &ProtocolConfig)
852 1: Call protocol::check_basic(&ProtocolConfig)
853 2: MoveLoc[0](Arg0: &ProtocolConfig)
854 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
855 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
856 5: MoveLoc[2](Arg2: &Clock)
857 6: Call clock::timestamp_ms(&Clock): u64
858 7: StLoc[5](loc0: u64)
859 8: MoveLoc[3](Arg3: &mut Perpetual)
860 9: Call positions(&mut Perpetual): &mut Table<address, Position>
861 10: MoveLoc[4](Arg4: vector<address>)
862 11: MoveLoc[5](loc0: u64)
863 12: Call position::remove_empty_positions(&mut Table<address, Position>, vector<address>, u64)
864 13: Ret
865}
866
867public set_maker_fee(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Perpetual, Arg3: u128) {
868L4: loc0: u128
869B0:
870 0: CopyLoc[0](Arg0: &ProtocolConfig)
871 1: Call protocol::check_basic(&ProtocolConfig)
872 2: MoveLoc[0](Arg0: &ProtocolConfig)
873 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
874 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
875 5: MoveLoc[3](Arg3: u128)
876 6: Call library::base_uint(): u128
877 7: Div
878 8: StLoc[4](loc0: u128)
879 9: CopyLoc[4](loc0: u128)
880 10: Call library::base_uint(): u128
881 11: Le
882 12: BrFalse(14)
883B1:
884 13: Branch(18)
885B2:
886 14: MoveLoc[2](Arg2: &mut Perpetual)
887 15: Pop
888 16: LdU64(99999)
889 17: Abort
890B3:
891 18: MoveLoc[4](loc0: u128)
892 19: CopyLoc[2](Arg2: &mut Perpetual)
893 20: MutBorrowField[15](Perpetual.maker_fee: u128)
894 21: WriteRef
895 22: CopyLoc[2](Arg2: &mut Perpetual)
896 23: FreezeRef
897 24: Call id(&Perpetual): &UID
898 25: Call object::uid_to_inner(&UID): ID
899 26: MoveLoc[2](Arg2: &mut Perpetual)
900 27: ImmBorrowField[15](Perpetual.maker_fee: u128)
901 28: ReadRef
902 29: Pack[9](MakerFeeUpdateEvent)
903 30: Call event::emit<MakerFeeUpdateEvent>(MakerFeeUpdateEvent)
904 31: Ret
905}
906
907public set_taker_fee(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut Perpetual, Arg3: u128) {
908L4: loc0: u128
909B0:
910 0: CopyLoc[0](Arg0: &ProtocolConfig)
911 1: Call protocol::check_basic(&ProtocolConfig)
912 2: MoveLoc[0](Arg0: &ProtocolConfig)
913 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
914 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
915 5: MoveLoc[3](Arg3: u128)
916 6: Call library::base_uint(): u128
917 7: Div
918 8: StLoc[4](loc0: u128)
919 9: CopyLoc[4](loc0: u128)
920 10: Call library::base_uint(): u128
921 11: Le
922 12: BrFalse(14)
923B1:
924 13: Branch(18)
925B2:
926 14: MoveLoc[2](Arg2: &mut Perpetual)
927 15: Pop
928 16: LdU64(99999)
929 17: Abort
930B3:
931 18: MoveLoc[4](loc0: u128)
932 19: CopyLoc[2](Arg2: &mut Perpetual)
933 20: MutBorrowField[16](Perpetual.taker_fee: u128)
934 21: WriteRef
935 22: CopyLoc[2](Arg2: &mut Perpetual)
936 23: FreezeRef
937 24: Call id(&Perpetual): &UID
938 25: Call object::uid_to_inner(&UID): ID
939 26: MoveLoc[2](Arg2: &mut Perpetual)
940 27: ImmBorrowField[16](Perpetual.taker_fee: u128)
941 28: ReadRef
942 29: Pack[10](TakerFeeUpdateEvent)
943 30: Call event::emit<TakerFeeUpdateEvent>(TakerFeeUpdateEvent)
944 31: Ret
945}
946
947public(friend) create(Arg0: vector<u8>, Arg1: u128, Arg2: u128, Arg3: u128, Arg4: u128, Arg5: address, Arg6: address, Arg7: address, Arg8: address, Arg9: u128, Arg10: u128, Arg11: u128, Arg12: u128, Arg13: u128, Arg14: u128, Arg15: u128, Arg16: u128, Arg17: u128, Arg18: u128, Arg19: u64, Arg20: vector<u128>, Arg21: vector<u8>, Arg22: u64, Arg23: u128, Arg24: &mut TxContext): ID {
948L25: loc0: TradeChecks
949L26: loc1: FundingRate
950L27: loc2: UID
951L28: loc3: InsuranceFund
952L29: loc4: Perpetual
953L30: loc5: ID
954L31: loc6: Table<address, Position>
955L32: loc7: Table<address, SpecialFee>
956B0:
957 0: CopyLoc[24](Arg24: &mut TxContext)
958 1: Call table::new<address, Position>(&mut TxContext): Table<address, Position>
959 2: StLoc[31](loc6: Table<address, Position>)
960 3: CopyLoc[24](Arg24: &mut TxContext)
961 4: Call table::new<address, SpecialFee>(&mut TxContext): Table<address, SpecialFee>
962 5: StLoc[32](loc7: Table<address, SpecialFee>)
963 6: MoveLoc[24](Arg24: &mut TxContext)
964 7: Call object::new(&mut TxContext): UID
965 8: StLoc[27](loc2: UID)
966 9: ImmBorrowLoc[27](loc2: UID)
967 10: Call object::uid_to_inner(&UID): ID
968 11: StLoc[30](loc5: ID)
969 12: CopyLoc[30](loc5: ID)
970 13: MoveLoc[5](Arg5: address)
971 14: MoveLoc[6](Arg6: address)
972 15: MoveLoc[22](Arg22: u64)
973 16: MoveLoc[23](Arg23: u128)
974 17: Call insurance_fund::create_insurance_fund(ID, address, address, u64, u128): InsuranceFund
975 18: StLoc[28](loc3: InsuranceFund)
976 19: MoveLoc[9](Arg9: u128)
977 20: MoveLoc[10](Arg10: u128)
978 21: MoveLoc[11](Arg11: u128)
979 22: MoveLoc[12](Arg12: u128)
980 23: MoveLoc[13](Arg13: u128)
981 24: MoveLoc[14](Arg14: u128)
982 25: MoveLoc[15](Arg15: u128)
983 26: MoveLoc[16](Arg16: u128)
984 27: MoveLoc[17](Arg17: u128)
985 28: MoveLoc[20](Arg20: vector<u128>)
986 29: Call evaluator::new_trade_checks(u128, u128, u128, u128, u128, u128, u128, u128, u128, vector<u128>): TradeChecks
987 30: StLoc[25](loc0: TradeChecks)
988 31: CopyLoc[19](Arg19: u64)
989 32: MoveLoc[18](Arg18: u128)
990 33: Call funding_rate::initialize(u64, u128): FundingRate
991 34: StLoc[26](loc1: FundingRate)
992 35: CopyLoc[2](Arg2: u128)
993 36: LdU128(0)
994 37: Gt
995 38: BrFalse(40)
996B1:
997 39: Branch(42)
998B2:
999 40: LdU64(300)
1000 41: Abort
1001B3:
1002 42: CopyLoc[2](Arg2: u128)
1003 43: CopyLoc[1](Arg1: u128)
1004 44: Le
1005 45: BrFalse(47)
1006B4:
1007 46: Branch(49)
1008B5:
1009 47: LdU64(301)
1010 48: Abort
1011B6:
1012 49: MoveLoc[27](loc2: UID)
1013 50: MoveLoc[0](Arg0: vector<u8>)
1014 51: Call string::utf8(vector<u8>): String
1015 52: CopyLoc[1](Arg1: u128)
1016 53: CopyLoc[2](Arg2: u128)
1017 54: CopyLoc[3](Arg3: u128)
1018 55: CopyLoc[4](Arg4: u128)
1019 56: MoveLoc[28](loc3: InsuranceFund)
1020 57: CopyLoc[7](Arg7: address)
1021 58: CopyLoc[8](Arg8: address)
1022 59: LdFalse
1023 60: LdU128(0)
1024 61: LdTrue
1025 62: CopyLoc[19](Arg19: u64)
1026 63: CopyLoc[25](loc0: TradeChecks)
1027 64: MoveLoc[31](loc6: Table<address, Position>)
1028 65: MoveLoc[32](loc7: Table<address, SpecialFee>)
1029 66: LdU128(0)
1030 67: CopyLoc[26](loc1: FundingRate)
1031 68: CopyLoc[21](Arg21: vector<u8>)
1032 69: Pack[11](Perpetual)
1033 70: StLoc[29](loc4: Perpetual)
1034 71: CopyLoc[30](loc5: ID)
1035 72: ImmBorrowLoc[29](loc4: Perpetual)
1036 73: ImmBorrowField[17](Perpetual.name: String)
1037 74: ReadRef
1038 75: MoveLoc[1](Arg1: u128)
1039 76: MoveLoc[2](Arg2: u128)
1040 77: MoveLoc[3](Arg3: u128)
1041 78: MoveLoc[4](Arg4: u128)
1042 79: MoveLoc[7](Arg7: address)
1043 80: MoveLoc[8](Arg8: address)
1044 81: MoveLoc[19](Arg19: u64)
1045 82: MoveLoc[21](Arg21: vector<u8>)
1046 83: MoveLoc[25](loc0: TradeChecks)
1047 84: MoveLoc[26](loc1: FundingRate)
1048 85: Pack[0](PerpetualCreationEvent)
1049 86: Call event::emit<PerpetualCreationEvent>(PerpetualCreationEvent)
1050 87: MoveLoc[29](loc4: Perpetual)
1051 88: Call transfer::share_object<Perpetual>(Perpetual)
1052 89: MoveLoc[30](loc5: ID)
1053 90: Ret
1054}
1055
1056public(friend) positions(Arg0: &mut Perpetual): &mut Table<address, Position> {
1057B0:
1058 0: MoveLoc[0](Arg0: &mut Perpetual)
1059 1: MutBorrowField[18](Perpetual.positions: Table<address, Position>)
1060 2: Ret
1061}
1062
1063public(friend) borrow_position(Arg0: &Perpetual, Arg1: address): &Position {
1064B0:
1065 0: MoveLoc[0](Arg0: &Perpetual)
1066 1: ImmBorrowField[18](Perpetual.positions: Table<address, Position>)
1067 2: MoveLoc[1](Arg1: address)
1068 3: Call table::borrow<address, Position>(&Table<address, Position>, address): &Position
1069 4: Ret
1070}
1071
1072public(friend) has_position(Arg0: &Perpetual, Arg1: address): bool {
1073B0:
1074 0: MoveLoc[0](Arg0: &Perpetual)
1075 1: ImmBorrowField[18](Perpetual.positions: Table<address, Position>)
1076 2: MoveLoc[1](Arg1: address)
1077 3: Call table::contains<address, Position>(&Table<address, Position>, address): bool
1078 4: Ret
1079}
1080
1081public(friend) id(Arg0: &Perpetual): &UID {
1082B0:
1083 0: MoveLoc[0](Arg0: &Perpetual)
1084 1: ImmBorrowField[8](Perpetual.id: UID)
1085 2: Ret
1086}
1087
1088public(friend) perp_address(Arg0: &Perpetual): address {
1089L1: loc0: ID
1090B0:
1091 0: MoveLoc[0](Arg0: &Perpetual)
1092 1: ImmBorrowField[8](Perpetual.id: UID)
1093 2: Call object::uid_to_inner(&UID): ID
1094 3: StLoc[1](loc0: ID)
1095 4: ImmBorrowLoc[1](loc0: ID)
1096 5: Call object::id_to_address(&ID): address
1097 6: Ret
1098}
1099
1100public(friend) name(Arg0: &Perpetual): &String {
1101B0:
1102 0: MoveLoc[0](Arg0: &Perpetual)
1103 1: ImmBorrowField[17](Perpetual.name: String)
1104 2: Ret
1105}
1106
1107public(friend) checks(Arg0: &Perpetual): TradeChecks {
1108B0:
1109 0: MoveLoc[0](Arg0: &Perpetual)
1110 1: ImmBorrowField[6](Perpetual.checks: TradeChecks)
1111 2: ReadRef
1112 3: Ret
1113}
1114
1115public(friend) imr(Arg0: &Perpetual): u128 {
1116B0:
1117 0: MoveLoc[0](Arg0: &Perpetual)
1118 1: ImmBorrowField[10](Perpetual.imr: u128)
1119 2: ReadRef
1120 3: Ret
1121}
1122
1123public(friend) mmr(Arg0: &Perpetual): u128 {
1124B0:
1125 0: MoveLoc[0](Arg0: &Perpetual)
1126 1: ImmBorrowField[11](Perpetual.mmr: u128)
1127 2: ReadRef
1128 3: Ret
1129}
1130
1131public(friend) maker_fee(Arg0: &Perpetual): u128 {
1132B0:
1133 0: MoveLoc[0](Arg0: &Perpetual)
1134 1: ImmBorrowField[15](Perpetual.maker_fee: u128)
1135 2: ReadRef
1136 3: Ret
1137}
1138
1139public(friend) taker_fee(Arg0: &Perpetual): u128 {
1140B0:
1141 0: MoveLoc[0](Arg0: &Perpetual)
1142 1: ImmBorrowField[16](Perpetual.taker_fee: u128)
1143 2: ReadRef
1144 3: Ret
1145}
1146
1147public(friend) funding_rate(Arg0: &Perpetual): FundingRate {
1148B0:
1149 0: MoveLoc[0](Arg0: &Perpetual)
1150 1: ImmBorrowField[9](Perpetual.funding: FundingRate)
1151 2: ReadRef
1152 3: Ret
1153}
1154
1155public(friend) funding_rate_mut(Arg0: &mut Perpetual): &mut FundingRate {
1156B0:
1157 0: MoveLoc[0](Arg0: &mut Perpetual)
1158 1: MutBorrowField[9](Perpetual.funding: FundingRate)
1159 2: Ret
1160}
1161
1162public(friend) insurance_fund(Arg0: &Perpetual): &InsuranceFund {
1163B0:
1164 0: MoveLoc[0](Arg0: &Perpetual)
1165 1: ImmBorrowField[4](Perpetual.insurance_fund: InsuranceFund)
1166 2: Ret
1167}
1168
1169public(friend) insurance_fund_mut(Arg0: &mut Perpetual): &mut InsuranceFund {
1170B0:
1171 0: MoveLoc[0](Arg0: &mut Perpetual)
1172 1: MutBorrowField[4](Perpetual.insurance_fund: InsuranceFund)
1173 2: Ret
1174}
1175
1176public(friend) insurance_active_pool(Arg0: &Perpetual): address {
1177B0:
1178 0: MoveLoc[0](Arg0: &Perpetual)
1179 1: ImmBorrowField[4](Perpetual.insurance_fund: InsuranceFund)
1180 2: Call insurance_fund::active_account(&InsuranceFund): address
1181 3: Ret
1182}
1183
1184public(friend) insurance_security_pool(Arg0: &Perpetual): address {
1185B0:
1186 0: MoveLoc[0](Arg0: &Perpetual)
1187 1: ImmBorrowField[4](Perpetual.insurance_fund: InsuranceFund)
1188 2: Call insurance_fund::security_account(&InsuranceFund): address
1189 3: Ret
1190}
1191
1192public(friend) fee_pool(Arg0: &Perpetual): address {
1193B0:
1194 0: MoveLoc[0](Arg0: &Perpetual)
1195 1: ImmBorrowField[2](Perpetual.fee_pool: address)
1196 2: ReadRef
1197 3: Ret
1198}
1199
1200public(friend) gas_pool(Arg0: &Perpetual): address {
1201B0:
1202 0: MoveLoc[0](Arg0: &Perpetual)
1203 1: ImmBorrowField[3](Perpetual.gas_pool: address)
1204 2: ReadRef
1205 3: Ret
1206}
1207
1208public(friend) price_oracle(Arg0: &Perpetual): u128 {
1209B0:
1210 0: MoveLoc[0](Arg0: &Perpetual)
1211 1: ImmBorrowField[19](Perpetual.price_oracle: u128)
1212 2: ReadRef
1213 3: Ret
1214}
1215
1216public(friend) global_index(Arg0: &Perpetual): FundingIndex {
1217B0:
1218 0: MoveLoc[0](Arg0: &Perpetual)
1219 1: ImmBorrowField[9](Perpetual.funding: FundingRate)
1220 2: ReadRef
1221 3: Call funding_rate::index(FundingRate): FundingIndex
1222 4: Ret
1223}
1224
1225public(friend) is_trading_permitted(Arg0: &Perpetual): bool {
1226B0:
1227 0: MoveLoc[0](Arg0: &Perpetual)
1228 1: ImmBorrowField[0](Perpetual.is_trading_permitted: bool)
1229 2: ReadRef
1230 3: Ret
1231}
1232
1233public(friend) delisted(Arg0: &Perpetual): bool {
1234B0:
1235 0: MoveLoc[0](Arg0: &Perpetual)
1236 1: ImmBorrowField[5](Perpetual.delisted: bool)
1237 2: ReadRef
1238 3: Ret
1239}
1240
1241public(friend) delisting_price(Arg0: &Perpetual): u128 {
1242B0:
1243 0: MoveLoc[0](Arg0: &Perpetual)
1244 1: ImmBorrowField[7](Perpetual.delisting_price: u128)
1245 2: ReadRef
1246 3: Ret
1247}
1248
1249public(friend) start_time(Arg0: &Perpetual): u64 {
1250B0:
1251 0: MoveLoc[0](Arg0: &Perpetual)
1252 1: ImmBorrowField[20](Perpetual.start_time: u64)
1253 2: ReadRef
1254 3: Ret
1255}
1256
1257public(friend) price_identifier(Arg0: &Perpetual): vector<u8> {
1258B0:
1259 0: MoveLoc[0](Arg0: &Perpetual)
1260 1: ImmBorrowField[1](Perpetual.price_identifier_id: vector<u8>)
1261 2: ReadRef
1262 3: Ret
1263}
1264
1265public(friend) get_fee(Arg0: &Perpetual, Arg1: address, Arg2: bool): u128 {
1266L3: loc0: &SpecialFee
1267B0:
1268 0: CopyLoc[0](Arg0: &Perpetual)
1269 1: ImmBorrowField[12](Perpetual.special_fee: Table<address, SpecialFee>)
1270 2: CopyLoc[1](Arg1: address)
1271 3: Call table::contains<address, SpecialFee>(&Table<address, SpecialFee>, address): bool
1272 4: BrFalse(28)
1273B1:
1274 5: CopyLoc[0](Arg0: &Perpetual)
1275 6: ImmBorrowField[12](Perpetual.special_fee: Table<address, SpecialFee>)
1276 7: MoveLoc[1](Arg1: address)
1277 8: Call table::borrow<address, SpecialFee>(&Table<address, SpecialFee>, address): &SpecialFee
1278 9: StLoc[3](loc0: &SpecialFee)
1279 10: CopyLoc[3](loc0: &SpecialFee)
1280 11: ImmBorrowField[21](SpecialFee.status: bool)
1281 12: ReadRef
1282 13: BrFalse(26)
1283B2:
1284 14: MoveLoc[0](Arg0: &Perpetual)
1285 15: Pop
1286 16: MoveLoc[2](Arg2: bool)
1287 17: BrFalse(22)
1288B3:
1289 18: MoveLoc[3](loc0: &SpecialFee)
1290 19: ImmBorrowField[13](SpecialFee.maker_fee: u128)
1291 20: ReadRef
1292 21: Ret
1293B4:
1294 22: MoveLoc[3](loc0: &SpecialFee)
1295 23: ImmBorrowField[14](SpecialFee.taker_fee: u128)
1296 24: ReadRef
1297 25: Ret
1298B5:
1299 26: MoveLoc[3](loc0: &SpecialFee)
1300 27: Pop
1301B6:
1302 28: MoveLoc[2](Arg2: bool)
1303 29: BrFalse(34)
1304B7:
1305 30: MoveLoc[0](Arg0: &Perpetual)
1306 31: ImmBorrowField[15](Perpetual.maker_fee: u128)
1307 32: ReadRef
1308 33: Ret
1309B8:
1310 34: MoveLoc[0](Arg0: &Perpetual)
1311 35: ImmBorrowField[16](Perpetual.taker_fee: u128)
1312 36: ReadRef
1313 37: Ret
1314}
1315
1316public(friend) update_oracle_price_v2(Arg0: &mut Perpetual, Arg1: &PriceFeed, Arg2: &Clock) {
1317L3: loc0: u64
1318L4: loc1: u64
1319L5: loc2: u64
1320L6: loc3: u128
1321L7: loc4: ID
1322L8: loc5: &PriceInfo
1323L9: loc6: u64
1324B0:
1325 0: CopyLoc[0](Arg0: &mut Perpetual)
1326 1: ImmBorrowField[8](Perpetual.id: UID)
1327 2: Call object::uid_to_inner(&UID): ID
1328 3: StLoc[7](loc4: ID)
1329 4: CopyLoc[1](Arg1: &PriceFeed)
1330 5: ImmBorrowLoc[7](loc4: ID)
1331 6: Call price_feed::contains(&PriceFeed, &ID): bool
1332 7: BrFalse(9)
1333B1:
1334 8: Branch(17)
1335B2:
1336 9: MoveLoc[1](Arg1: &PriceFeed)
1337 10: Pop
1338 11: MoveLoc[0](Arg0: &mut Perpetual)
1339 12: Pop
1340 13: MoveLoc[2](Arg2: &Clock)
1341 14: Pop
1342 15: LdU64(903)
1343 16: Abort
1344B3:
1345 17: MoveLoc[1](Arg1: &PriceFeed)
1346 18: ImmBorrowLoc[7](loc4: ID)
1347 19: Call price_feed::get_price_info(&PriceFeed, &ID): &PriceInfo
1348 20: StLoc[8](loc5: &PriceInfo)
1349 21: MoveLoc[2](Arg2: &Clock)
1350 22: Call clock::timestamp_ms(&Clock): u64
1351 23: StLoc[5](loc2: u64)
1352 24: CopyLoc[5](loc2: u64)
1353 25: LdConst[1](u64: 5000)
1354 26: Add
1355 27: StLoc[4](loc1: u64)
1356 28: CopyLoc[8](loc5: &PriceInfo)
1357 29: Call price_feed::price_info_timestamp(&PriceInfo): u64
1358 30: StLoc[9](loc6: u64)
1359 31: CopyLoc[9](loc6: u64)
1360 32: MoveLoc[4](loc1: u64)
1361 33: Le
1362 34: BrFalse(36)
1363B4:
1364 35: Branch(42)
1365B5:
1366 36: MoveLoc[8](loc5: &PriceInfo)
1367 37: Pop
1368 38: MoveLoc[0](Arg0: &mut Perpetual)
1369 39: Pop
1370 40: LdU64(912)
1371 41: Abort
1372B6:
1373 42: CopyLoc[9](loc6: u64)
1374 43: CopyLoc[5](loc2: u64)
1375 44: Gt
1376 45: BrFalse(49)
1377B7:
1378 46: LdU64(0)
1379 47: StLoc[3](loc0: u64)
1380 48: Branch(53)
1381B8:
1382 49: MoveLoc[5](loc2: u64)
1383 50: MoveLoc[9](loc6: u64)
1384 51: Sub
1385 52: StLoc[3](loc0: u64)
1386B9:
1387 53: MoveLoc[3](loc0: u64)
1388 54: LdConst[0](u64: 60000)
1389 55: Le
1390 56: BrFalse(58)
1391B10:
1392 57: Branch(64)
1393B11:
1394 58: MoveLoc[8](loc5: &PriceInfo)
1395 59: Pop
1396 60: MoveLoc[0](Arg0: &mut Perpetual)
1397 61: Pop
1398 62: LdU64(913)
1399 63: Abort
1400B12:
1401 64: MoveLoc[8](loc5: &PriceInfo)
1402 65: Call price_feed::price_info_price(&PriceInfo): u128
1403 66: StLoc[6](loc3: u128)
1404 67: CopyLoc[6](loc3: u128)
1405 68: LdU128(0)
1406 69: Gt
1407 70: BrFalse(72)
1408B13:
1409 71: Branch(76)
1410B14:
1411 72: MoveLoc[0](Arg0: &mut Perpetual)
1412 73: Pop
1413 74: LdU64(909)
1414 75: Abort
1415B15:
1416 76: MoveLoc[6](loc3: u128)
1417 77: MoveLoc[0](Arg0: &mut Perpetual)
1418 78: MutBorrowField[19](Perpetual.price_oracle: u128)
1419 79: WriteRef
1420 80: Ret
1421}
1422
1423Constants [
1424 0 => u64: 60000
1425 1 => u64: 5000
1426 2 => address: 0x0000000000000000000000000000000000000000000000000000000000000000
1427]
1428}
1429
0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/position.mvb691 lines
1// Move bytecode v7
2module 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001.position {
3use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::funding_rate;
4use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::library;
5use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::s128;
6use 0000000000000000000000000000000000000000000000000000000000000002::event;
7use 0000000000000000000000000000000000000000000000000000000000000002::object;
8use 0000000000000000000000000000000000000000000000000000000000000002::table;
9
10struct AccountPositionUpdateEvent has copy, drop {
11 tx_index: u128,
12 position: Position,
13 sender: address,
14 action: u8
15}
16
17struct PositionClosedEvent has copy, drop {
18 tx_index: u128,
19 perp_id: ID,
20 account: address,
21 amount: u128
22}
23
24struct Position has copy, drop, store {
25 user: address,
26 perp_id: ID,
27 is_long: bool,
28 size: u128,
29 margin: u128,
30 oi_open: u128,
31 mro: u128,
32 index: FundingIndex
33}
34
35public(friend) empty_position(Arg0: ID, Arg1: address): Position {
36B0:
37 0: MoveLoc[1](Arg1: address)
38 1: MoveLoc[0](Arg0: ID)
39 2: LdFalse
40 3: LdU128(0)
41 4: LdU128(0)
42 5: LdU128(0)
43 6: LdU128(0)
44 7: LdU64(0)
45 8: Call funding_rate::new_index(u64): FundingIndex
46 9: Pack[2](Position)
47 10: Ret
48}
49
50public(friend) is_long(Arg0: &Position): bool {
51B0:
52 0: MoveLoc[0](Arg0: &Position)
53 1: ImmBorrowField[0](Position.is_long: bool)
54 2: ReadRef
55 3: Ret
56}
57
58public(friend) size(Arg0: &Position): u128 {
59B0:
60 0: MoveLoc[0](Arg0: &Position)
61 1: ImmBorrowField[1](Position.size: u128)
62 2: ReadRef
63 3: Ret
64}
65
66public(friend) margin(Arg0: &Position): u128 {
67B0:
68 0: MoveLoc[0](Arg0: &Position)
69 1: ImmBorrowField[2](Position.margin: u128)
70 2: ReadRef
71 3: Ret
72}
73
74public(friend) oi_open(Arg0: &Position): u128 {
75B0:
76 0: MoveLoc[0](Arg0: &Position)
77 1: ImmBorrowField[3](Position.oi_open: u128)
78 2: ReadRef
79 3: Ret
80}
81
82public(friend) mro(Arg0: &Position): u128 {
83B0:
84 0: MoveLoc[0](Arg0: &Position)
85 1: ImmBorrowField[4](Position.mro: u128)
86 2: ReadRef
87 3: Ret
88}
89
90public(friend) user(Arg0: &Position): address {
91B0:
92 0: MoveLoc[0](Arg0: &Position)
93 1: ImmBorrowField[5](Position.user: address)
94 2: ReadRef
95 3: Ret
96}
97
98public(friend) index(Arg0: &Position): FundingIndex {
99B0:
100 0: MoveLoc[0](Arg0: &Position)
101 1: ImmBorrowField[6](Position.index: FundingIndex)
102 2: ReadRef
103 3: Ret
104}
105
106public(friend) set_mro(Arg0: &mut Position, Arg1: u128) {
107B0:
108 0: CopyLoc[0](Arg0: &mut Position)
109 1: ImmBorrowField[1](Position.size: u128)
110 2: ReadRef
111 3: LdU128(0)
112 4: Eq
113 5: BrFalse(11)
114B1:
115 6: LdU128(0)
116 7: MoveLoc[0](Arg0: &mut Position)
117 8: MutBorrowField[4](Position.mro: u128)
118 9: WriteRef
119 10: Branch(15)
120B2:
121 11: MoveLoc[1](Arg1: u128)
122 12: MoveLoc[0](Arg0: &mut Position)
123 13: MutBorrowField[4](Position.mro: u128)
124 14: WriteRef
125B3:
126 15: Ret
127}
128
129public(friend) set_oi_open(Arg0: &mut Position, Arg1: u128) {
130B0:
131 0: MoveLoc[1](Arg1: u128)
132 1: MoveLoc[0](Arg0: &mut Position)
133 2: MutBorrowField[3](Position.oi_open: u128)
134 3: WriteRef
135 4: Ret
136}
137
138public(friend) set_margin(Arg0: &mut Position, Arg1: u128) {
139B0:
140 0: MoveLoc[1](Arg1: u128)
141 1: MoveLoc[0](Arg0: &mut Position)
142 2: MutBorrowField[2](Position.margin: u128)
143 3: WriteRef
144 4: Ret
145}
146
147public(friend) set_size(Arg0: &mut Position, Arg1: u128) {
148B0:
149 0: CopyLoc[1](Arg1: u128)
150 1: CopyLoc[0](Arg0: &mut Position)
151 2: MutBorrowField[1](Position.size: u128)
152 3: WriteRef
153 4: MoveLoc[1](Arg1: u128)
154 5: LdU128(0)
155 6: Eq
156 7: BrFalse(15)
157B1:
158 8: CopyLoc[0](Arg0: &mut Position)
159 9: LdFalse
160 10: Call set_is_long(&mut Position, bool)
161 11: MoveLoc[0](Arg0: &mut Position)
162 12: LdU128(0)
163 13: Call set_mro(&mut Position, u128)
164 14: Branch(17)
165B2:
166 15: MoveLoc[0](Arg0: &mut Position)
167 16: Pop
168B3:
169 17: Ret
170}
171
172public(friend) set_is_long(Arg0: &mut Position, Arg1: bool) {
173B0:
174 0: MoveLoc[1](Arg1: bool)
175 1: MoveLoc[0](Arg0: &mut Position)
176 2: MutBorrowField[0](Position.is_long: bool)
177 3: WriteRef
178 4: Ret
179}
180
181public(friend) set_index(Arg0: &mut Position, Arg1: FundingIndex) {
182B0:
183 0: MoveLoc[1](Arg1: FundingIndex)
184 1: MoveLoc[0](Arg0: &mut Position)
185 2: MutBorrowField[6](Position.index: FundingIndex)
186 3: WriteRef
187 4: Ret
188}
189
190public(friend) compute_margin_ratio(Arg0: &Position, Arg1: u128): S128 {
191L2: loc0: S128
192L3: loc1: S128
193L4: loc2: u128
194B0:
195 0: Call s128::one(): S128
196 1: StLoc[3](loc1: S128)
197 2: CopyLoc[0](Arg0: &Position)
198 3: ImmBorrowField[1](Position.size: u128)
199 4: ReadRef
200 5: LdU128(0)
201 6: Eq
202 7: BrFalse(12)
203B1:
204 8: MoveLoc[0](Arg0: &Position)
205 9: Pop
206 10: MoveLoc[3](loc1: S128)
207 11: Ret
208B2:
209 12: MoveLoc[1](Arg1: u128)
210 13: CopyLoc[0](Arg0: &Position)
211 14: ImmBorrowField[1](Position.size: u128)
212 15: ReadRef
213 16: Call library::base_mul(u128, u128): u128
214 17: StLoc[4](loc2: u128)
215 18: CopyLoc[4](loc2: u128)
216 19: LdU128(0)
217 20: Eq
218 21: BrFalse(26)
219B3:
220 22: MoveLoc[0](Arg0: &Position)
221 23: Pop
222 24: Call s128::zero(): S128
223 25: Ret
224B4:
225 26: CopyLoc[0](Arg0: &Position)
226 27: ImmBorrowField[0](Position.is_long: bool)
227 28: ReadRef
228 29: BrFalse(45)
229B5:
230 30: CopyLoc[0](Arg0: &Position)
231 31: ImmBorrowField[3](Position.oi_open: u128)
232 32: ReadRef
233 33: MoveLoc[0](Arg0: &Position)
234 34: ImmBorrowField[2](Position.margin: u128)
235 35: ReadRef
236 36: Call s128::from_subtraction(u128, u128): S128
237 37: MoveLoc[4](loc2: u128)
238 38: Call s128::div_u128(S128, u128): S128
239 39: StLoc[2](loc0: S128)
240 40: MoveLoc[3](loc1: S128)
241 41: MoveLoc[2](loc0: S128)
242 42: Call s128::sub(S128, S128): S128
243 43: StLoc[3](loc1: S128)
244 44: Branch(57)
245B6:
246 45: CopyLoc[0](Arg0: &Position)
247 46: ImmBorrowField[3](Position.oi_open: u128)
248 47: ReadRef
249 48: MoveLoc[0](Arg0: &Position)
250 49: ImmBorrowField[2](Position.margin: u128)
251 50: ReadRef
252 51: Add
253 52: MoveLoc[4](loc2: u128)
254 53: Call library::base_div(u128, u128): u128
255 54: Call library::base_uint(): u128
256 55: Call s128::from_subtraction(u128, u128): S128
257 56: StLoc[3](loc1: S128)
258B7:
259 57: MoveLoc[3](loc1: S128)
260 58: Ret
261}
262
263public(friend) compute_average_entry_price(Arg0: &Position): u128 {
264L1: loc0: u128
265B0:
266 0: CopyLoc[0](Arg0: &Position)
267 1: ImmBorrowField[1](Position.size: u128)
268 2: ReadRef
269 3: LdU128(0)
270 4: Eq
271 5: BrFalse(11)
272B1:
273 6: MoveLoc[0](Arg0: &Position)
274 7: Pop
275 8: LdU128(0)
276 9: StLoc[1](loc0: u128)
277 10: Branch(19)
278B2:
279 11: CopyLoc[0](Arg0: &Position)
280 12: ImmBorrowField[3](Position.oi_open: u128)
281 13: ReadRef
282 14: MoveLoc[0](Arg0: &Position)
283 15: ImmBorrowField[1](Position.size: u128)
284 16: ReadRef
285 17: Call library::base_div(u128, u128): u128
286 18: StLoc[1](loc0: u128)
287B3:
288 19: MoveLoc[1](loc0: u128)
289 20: Ret
290}
291
292public(friend) create_position(Arg0: ID, Arg1: &mut Table<address, Position>, Arg2: address) {
293B0:
294 0: CopyLoc[1](Arg1: &mut Table<address, Position>)
295 1: FreezeRef
296 2: CopyLoc[2](Arg2: address)
297 3: Call table::contains<address, Position>(&Table<address, Position>, address): bool
298 4: Not
299 5: BrFalse(13)
300B1:
301 6: MoveLoc[1](Arg1: &mut Table<address, Position>)
302 7: CopyLoc[2](Arg2: address)
303 8: MoveLoc[0](Arg0: ID)
304 9: MoveLoc[2](Arg2: address)
305 10: Call empty_position(ID, address): Position
306 11: Call table::add<address, Position>(&mut Table<address, Position>, address, Position)
307 12: Branch(15)
308B2:
309 13: MoveLoc[1](Arg1: &mut Table<address, Position>)
310 14: Pop
311B3:
312 15: Ret
313}
314
315public(friend) remove_empty_positions(Arg0: &mut Table<address, Position>, Arg1: vector<address>, Arg2: u64) {
316L3: loc0: bool
317L4: loc1: address
318L5: loc2: u64
319L6: loc3: u64
320L7: loc4: &Position
321B0:
322 0: ImmBorrowLoc[1](Arg1: vector<address>)
323 1: VecLen(5)
324 2: LdU64(1000)
325 3: Le
326 4: BrFalse(6)
327B1:
328 5: Branch(10)
329B2:
330 6: MoveLoc[0](Arg0: &mut Table<address, Position>)
331 7: Pop
332 8: LdU64(99999)
333 9: Abort
334B3:
335 10: ImmBorrowLoc[1](Arg1: vector<address>)
336 11: VecLen(5)
337 12: StLoc[5](loc2: u64)
338 13: LdU64(0)
339 14: StLoc[6](loc3: u64)
340B4:
341 15: CopyLoc[6](loc3: u64)
342 16: CopyLoc[5](loc2: u64)
343 17: Lt
344 18: BrFalse(65)
345B5:
346 19: ImmBorrowLoc[1](Arg1: vector<address>)
347 20: CopyLoc[6](loc3: u64)
348 21: VecImmBorrow(5)
349 22: ReadRef
350 23: StLoc[4](loc1: address)
351 24: MoveLoc[6](loc3: u64)
352 25: LdU64(1)
353 26: Add
354 27: StLoc[6](loc3: u64)
355 28: CopyLoc[0](Arg0: &mut Table<address, Position>)
356 29: FreezeRef
357 30: CopyLoc[4](loc1: address)
358 31: Call table::contains<address, Position>(&Table<address, Position>, address): bool
359 32: BrFalse(15)
360B6:
361 33: CopyLoc[0](Arg0: &mut Table<address, Position>)
362 34: FreezeRef
363 35: CopyLoc[4](loc1: address)
364 36: Call table::borrow<address, Position>(&Table<address, Position>, address): &Position
365 37: StLoc[7](loc4: &Position)
366 38: CopyLoc[7](loc4: &Position)
367 39: ImmBorrowField[1](Position.size: u128)
368 40: ReadRef
369 41: LdU128(0)
370 42: Eq
371 43: BrFalse(54)
372B7:
373 44: CopyLoc[2](Arg2: u64)
374 45: MoveLoc[7](loc4: &Position)
375 46: ImmBorrowField[6](Position.index: FundingIndex)
376 47: ReadRef
377 48: Call funding_rate::index_timestamp(FundingIndex): u64
378 49: Sub
379 50: LdU64(604800000)
380 51: Gt
381 52: StLoc[3](loc0: bool)
382 53: Branch(58)
383B8:
384 54: MoveLoc[7](loc4: &Position)
385 55: Pop
386 56: LdFalse
387 57: StLoc[3](loc0: bool)
388B9:
389 58: MoveLoc[3](loc0: bool)
390 59: BrFalse(15)
391B10:
392 60: CopyLoc[0](Arg0: &mut Table<address, Position>)
393 61: MoveLoc[4](loc1: address)
394 62: Call table::remove<address, Position>(&mut Table<address, Position>, address): Position
395 63: Pop
396 64: Branch(15)
397B11:
398 65: MoveLoc[0](Arg0: &mut Table<address, Position>)
399 66: Pop
400 67: Ret
401}
402
403public(friend) emit_position_update_event(Arg0: Position, Arg1: address, Arg2: u8, Arg3: u128) {
404B0:
405 0: MoveLoc[3](Arg3: u128)
406 1: MoveLoc[0](Arg0: Position)
407 2: MoveLoc[1](Arg1: address)
408 3: MoveLoc[2](Arg2: u8)
409 4: Pack[0](AccountPositionUpdateEvent)
410 5: Call event::emit<AccountPositionUpdateEvent>(AccountPositionUpdateEvent)
411 6: Ret
412}
413
414public(friend) emit_position_closed_event(Arg0: ID, Arg1: address, Arg2: u128, Arg3: u128) {
415B0:
416 0: MoveLoc[3](Arg3: u128)
417 1: MoveLoc[0](Arg0: ID)
418 2: MoveLoc[1](Arg1: address)
419 3: MoveLoc[2](Arg2: u128)
420 4: Pack[1](PositionClosedEvent)
421 5: Call event::emit<PositionClosedEvent>(PositionClosedEvent)
422 6: Ret
423}
424
425public(friend) verify_collat_checks(Arg0: &Position, Arg1: &Position, Arg2: u128, Arg3: u128, Arg4: u128, Arg5: u8, Arg6: u64) {
426L7: loc0: bool
427L8: loc1: bool
428L9: loc2: bool
429L10: loc3: bool
430L11: loc4: S128
431L12: loc5: S128
432B0:
433 0: CopyLoc[0](Arg0: &Position)
434 1: CopyLoc[4](Arg4: u128)
435 2: Call compute_margin_ratio(&Position, u128): S128
436 3: StLoc[12](loc5: S128)
437 4: CopyLoc[1](Arg1: &Position)
438 5: MoveLoc[4](Arg4: u128)
439 6: Call compute_margin_ratio(&Position, u128): S128
440 7: StLoc[11](loc4: S128)
441 8: CopyLoc[11](loc4: S128)
442 9: MoveLoc[2](Arg2: u128)
443 10: Call s128::gte_u128(S128, u128): bool
444 11: BrFalse(17)
445B1:
446 12: MoveLoc[0](Arg0: &Position)
447 13: Pop
448 14: MoveLoc[1](Arg1: &Position)
449 15: Pop
450 16: Ret
451B2:
452 17: CopyLoc[1](Arg1: &Position)
453 18: ImmBorrowField[0](Position.is_long: bool)
454 19: ReadRef
455 20: CopyLoc[0](Arg0: &Position)
456 21: ImmBorrowField[0](Position.is_long: bool)
457 22: ReadRef
458 23: Eq
459 24: BrFalse(32)
460B3:
461 25: CopyLoc[0](Arg0: &Position)
462 26: ImmBorrowField[1](Position.size: u128)
463 27: ReadRef
464 28: LdU128(0)
465 29: Gt
466 30: StLoc[7](loc0: bool)
467 31: Branch(34)
468B4:
469 32: LdFalse
470 33: StLoc[7](loc0: bool)
471B5:
472 34: MoveLoc[7](loc0: bool)
473 35: BrFalse(37)
474B6:
475 36: Branch(45)
476B7:
477 37: MoveLoc[0](Arg0: &Position)
478 38: Pop
479 39: MoveLoc[1](Arg1: &Position)
480 40: Pop
481 41: LdU64(400)
482 42: MoveLoc[6](Arg6: u64)
483 43: Add
484 44: Abort
485B8:
486 45: CopyLoc[11](loc4: S128)
487 46: MoveLoc[12](loc5: S128)
488 47: Call s128::gte(S128, S128): bool
489 48: BrFalse(50)
490B9:
491 49: Branch(58)
492B10:
493 50: MoveLoc[0](Arg0: &Position)
494 51: Pop
495 52: MoveLoc[1](Arg1: &Position)
496 53: Pop
497 54: LdU64(402)
498 55: MoveLoc[6](Arg6: u64)
499 56: Add
500 57: Abort
501B11:
502 58: CopyLoc[11](loc4: S128)
503 59: MoveLoc[3](Arg3: u128)
504 60: Call s128::gt_u128(S128, u128): bool
505 61: BrFalse(69)
506B12:
507 62: MoveLoc[0](Arg0: &Position)
508 63: Pop
509 64: MoveLoc[1](Arg1: &Position)
510 65: Pop
511 66: LdTrue
512 67: StLoc[8](loc1: bool)
513 68: Branch(94)
514B13:
515 69: CopyLoc[0](Arg0: &Position)
516 70: ImmBorrowField[1](Position.size: u128)
517 71: ReadRef
518 72: CopyLoc[1](Arg1: &Position)
519 73: ImmBorrowField[1](Position.size: u128)
520 74: ReadRef
521 75: Ge
522 76: BrFalse(86)
523B14:
524 77: MoveLoc[0](Arg0: &Position)
525 78: ImmBorrowField[0](Position.is_long: bool)
526 79: ReadRef
527 80: MoveLoc[1](Arg1: &Position)
528 81: ImmBorrowField[0](Position.is_long: bool)
529 82: ReadRef
530 83: Eq
531 84: StLoc[9](loc2: bool)
532 85: Branch(92)
533B15:
534 86: MoveLoc[0](Arg0: &Position)
535 87: Pop
536 88: MoveLoc[1](Arg1: &Position)
537 89: Pop
538 90: LdFalse
539 91: StLoc[9](loc2: bool)
540B16:
541 92: MoveLoc[9](loc2: bool)
542 93: StLoc[8](loc1: bool)
543B17:
544 94: MoveLoc[8](loc1: bool)
545 95: BrFalse(97)
546B18:
547 96: Branch(101)
548B19:
549 97: LdU64(404)
550 98: MoveLoc[6](Arg6: u64)
551 99: Add
552 100: Abort
553B20:
554 101: MoveLoc[11](loc4: S128)
555 102: LdU128(0)
556 103: Call s128::gte_u128(S128, u128): bool
557 104: BrFalse(108)
558B21:
559 105: LdTrue
560 106: StLoc[10](loc3: bool)
561 107: Branch(119)
562B22:
563 108: CopyLoc[5](Arg5: u8)
564 109: LdU8(2)
565 110: Eq
566 111: BrFalse(115)
567B23:
568 112: LdTrue
569 113: StLoc[10](loc3: bool)
570 114: Branch(119)
571B24:
572 115: MoveLoc[5](Arg5: u8)
573 116: LdU8(3)
574 117: Eq
575 118: StLoc[10](loc3: bool)
576B25:
577 119: MoveLoc[10](loc3: bool)
578 120: BrFalse(122)
579B26:
580 121: Branch(126)
581B27:
582 122: LdU64(406)
583 123: MoveLoc[6](Arg6: u64)
584 124: Add
585 125: Abort
586B28:
587 126: Ret
588}
589
590public(friend) compute_pnl_per_unit(Arg0: &Position, Arg1: u128): S128 {
591L2: loc0: S128
592L3: loc1: u128
593B0:
594 0: CopyLoc[0](Arg0: &Position)
595 1: Call compute_average_entry_price(&Position): u128
596 2: StLoc[3](loc1: u128)
597 3: MoveLoc[0](Arg0: &Position)
598 4: ImmBorrowField[0](Position.is_long: bool)
599 5: ReadRef
600 6: BrFalse(12)
601B1:
602 7: MoveLoc[1](Arg1: u128)
603 8: MoveLoc[3](loc1: u128)
604 9: Call s128::from_subtraction(u128, u128): S128
605 10: StLoc[2](loc0: S128)
606 11: Branch(16)
607B2:
608 12: MoveLoc[3](loc1: u128)
609 13: MoveLoc[1](Arg1: u128)
610 14: Call s128::from_subtraction(u128, u128): S128
611 15: StLoc[2](loc0: S128)
612B3:
613 16: MoveLoc[2](loc0: S128)
614 17: Ret
615}
616
617public(friend) is_undercollat(Arg0: &Position, Arg1: u128, Arg2: u128): bool {
618B0:
619 0: MoveLoc[0](Arg0: &Position)
620 1: MoveLoc[1](Arg1: u128)
621 2: Call compute_margin_ratio(&Position, u128): S128
622 3: MoveLoc[2](Arg2: u128)
623 4: Call s128::lt_u128(S128, u128): bool
624 5: Ret
625}
626
627public(friend) compute_bankruptcy_price(Arg0: &Position): u128 {
628L1: loc0: u128
629B0:
630 0: CopyLoc[0](Arg0: &Position)
631 1: Call is_long(&Position): bool
632 2: BrFalse(13)
633B1:
634 3: CopyLoc[0](Arg0: &Position)
635 4: Call oi_open(&Position): u128
636 5: CopyLoc[0](Arg0: &Position)
637 6: Call margin(&Position): u128
638 7: Sub
639 8: MoveLoc[0](Arg0: &Position)
640 9: Call size(&Position): u128
641 10: Call library::base_div(u128, u128): u128
642 11: StLoc[1](loc0: u128)
643 12: Branch(22)
644B2:
645 13: CopyLoc[0](Arg0: &Position)
646 14: Call oi_open(&Position): u128
647 15: CopyLoc[0](Arg0: &Position)
648 16: Call margin(&Position): u128
649 17: Add
650 18: MoveLoc[0](Arg0: &Position)
651 19: Call size(&Position): u128
652 20: Call library::base_div(u128, u128): u128
653 21: StLoc[1](loc0: u128)
654B3:
655 22: MoveLoc[1](loc0: u128)
656 23: Ret
657}
658
659public(friend) compute_funding_fee_per_unit(Arg0: &Position, Arg1: FundingIndex): S128 {
660L2: loc0: S128
661B0:
662 0: CopyLoc[0](Arg0: &Position)
663 1: ImmBorrowField[0](Position.is_long: bool)
664 2: ReadRef
665 3: BrFalse(13)
666B1:
667 4: MoveLoc[0](Arg0: &Position)
668 5: ImmBorrowField[6](Position.index: FundingIndex)
669 6: ReadRef
670 7: Call funding_rate::index_value(FundingIndex): S128
671 8: MoveLoc[1](Arg1: FundingIndex)
672 9: Call funding_rate::index_value(FundingIndex): S128
673 10: Call s128::sub(S128, S128): S128
674 11: StLoc[2](loc0: S128)
675 12: Branch(21)
676B2:
677 13: MoveLoc[1](Arg1: FundingIndex)
678 14: Call funding_rate::index_value(FundingIndex): S128
679 15: MoveLoc[0](Arg0: &Position)
680 16: ImmBorrowField[6](Position.index: FundingIndex)
681 17: ReadRef
682 18: Call funding_rate::index_value(FundingIndex): S128
683 19: Call s128::sub(S128, S128): S128
684 20: StLoc[2](loc0: S128)
685B3:
686 21: MoveLoc[2](loc0: S128)
687 22: Ret
688}
689
690}
691
0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/price_feed.mvb413 lines
1// Move bytecode v7
2module 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001.price_feed {
3use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::library;
4use 9041eddbe15edba576c8c0bd4237e07b19e2c17fb59b240658f96522261f10c4::library as 0library;
5use 9041eddbe15edba576c8c0bd4237e07b19e2c17fb59b240658f96522261f10c4::unified_address;
6use 0000000000000000000000000000000000000000000000000000000000000002::bcs;
7use 0000000000000000000000000000000000000000000000000000000000000002::clock;
8use 0000000000000000000000000000000000000000000000000000000000000002::event;
9use 0000000000000000000000000000000000000000000000000000000000000002::object;
10use 0000000000000000000000000000000000000000000000000000000000000002::transfer;
11use 0000000000000000000000000000000000000000000000000000000000000002::tx_context;
12use 0000000000000000000000000000000000000000000000000000000000000002::vec_map;
13
14struct PriceInfo has copy, drop, store {
15 perp_id: ID,
16 price: u128,
17 timestamp: u64
18}
19
20struct PriceFeed has key {
21 id: UID,
22 feeder: address,
23 prices: VecMap<ID, PriceInfo>
24}
25
26struct PriceInfoUpdate has copy, drop {
27 perp_id: ID,
28 price: u128,
29 timestamp: u64
30}
31
32struct PriceFeedUpdateEvent has copy, drop {
33 updates: vector<PriceInfoUpdate>,
34 updated_count: u64
35}
36
37public(friend) initialize(Arg0: &mut TxContext) {
38B0:
39 0: MoveLoc[0](Arg0: &mut TxContext)
40 1: Call new_for_migration(&mut TxContext): PriceFeed
41 2: Call share_price_feed(PriceFeed)
42 3: Ret
43}
44
45public(friend) new_for_migration(Arg0: &mut TxContext): PriceFeed {
46B0:
47 0: MoveLoc[0](Arg0: &mut TxContext)
48 1: Call object::new(&mut TxContext): UID
49 2: LdConst[2](address: 0x00..)
50 3: Call vec_map::empty<ID, PriceInfo>(): VecMap<ID, PriceInfo>
51 4: Pack[1](PriceFeed)
52 5: Ret
53}
54
55public(friend) share_price_feed(Arg0: PriceFeed) {
56B0:
57 0: MoveLoc[0](Arg0: PriceFeed)
58 1: Call transfer::share_object<PriceFeed>(PriceFeed)
59 2: Ret
60}
61
62public(friend) insert_price_info(Arg0: &mut PriceFeed, Arg1: ID, Arg2: u128, Arg3: u64) {
63L4: loc0: PriceInfo
64B0:
65 0: CopyLoc[1](Arg1: ID)
66 1: MoveLoc[2](Arg2: u128)
67 2: MoveLoc[3](Arg3: u64)
68 3: Pack[0](PriceInfo)
69 4: StLoc[4](loc0: PriceInfo)
70 5: MoveLoc[0](Arg0: &mut PriceFeed)
71 6: MutBorrowField[0](PriceFeed.prices: VecMap<ID, PriceInfo>)
72 7: MoveLoc[1](Arg1: ID)
73 8: MoveLoc[4](loc0: PriceInfo)
74 9: Call vec_map::insert<ID, PriceInfo>(&mut VecMap<ID, PriceInfo>, ID, PriceInfo)
75 10: Ret
76}
77
78public(friend) set_feeder(Arg0: &mut PriceFeed, Arg1: address) {
79B0:
80 0: CopyLoc[1](Arg1: address)
81 1: LdConst[2](address: 0x00..)
82 2: Neq
83 3: BrFalse(5)
84B1:
85 4: Branch(9)
86B2:
87 5: MoveLoc[0](Arg0: &mut PriceFeed)
88 6: Pop
89 7: LdU64(105)
90 8: Abort
91B3:
92 9: MoveLoc[1](Arg1: address)
93 10: MoveLoc[0](Arg0: &mut PriceFeed)
94 11: MutBorrowField[1](PriceFeed.feeder: address)
95 12: WriteRef
96 13: Ret
97}
98
99public feeder(Arg0: &PriceFeed): address {
100B0:
101 0: MoveLoc[0](Arg0: &PriceFeed)
102 1: ImmBorrowField[1](PriceFeed.feeder: address)
103 2: ReadRef
104 3: Ret
105}
106
107public update_price_feed(Arg0: &mut PriceFeed, Arg1: &Clock, Arg2: vector<u8>, Arg3: vector<u8>, Arg4: vector<u8>) {
108L5: loc0: bool
109L6: loc1: vector<u8>
110L7: loc2: vector<u8>
111L8: loc3: vector<u8>
112L9: loc4: address
113L10: loc5: u8
114L11: loc6: UnifiedAddress
115B0:
116 0: CopyLoc[0](Arg0: &mut PriceFeed)
117 1: ImmBorrowField[1](PriceFeed.feeder: address)
118 2: ReadRef
119 3: StLoc[9](loc4: address)
120 4: CopyLoc[9](loc4: address)
121 5: LdConst[2](address: 0x00..)
122 6: Neq
123 7: BrFalse(9)
124B1:
125 8: Branch(15)
126B2:
127 9: MoveLoc[0](Arg0: &mut PriceFeed)
128 10: Pop
129 11: MoveLoc[1](Arg1: &Clock)
130 12: Pop
131 13: LdU64(910)
132 14: Abort
133B3:
134 15: ImmBorrowLoc[3](Arg3: vector<u8>)
135 16: Call 0library::signature_scheme(&vector<u8>): u8
136 17: StLoc[10](loc5: u8)
137 18: CopyLoc[10](loc5: u8)
138 19: Call 0library::scheme_secp256k1(): u8
139 20: Eq
140 21: BrFalse(25)
141B4:
142 22: LdTrue
143 23: StLoc[5](loc0: bool)
144 24: Branch(29)
145B5:
146 25: MoveLoc[10](loc5: u8)
147 26: Call 0library::scheme_ed25519(): u8
148 27: Eq
149 28: StLoc[5](loc0: bool)
150B6:
151 29: MoveLoc[5](loc0: bool)
152 30: BrFalse(32)
153B7:
154 31: Branch(38)
155B8:
156 32: MoveLoc[0](Arg0: &mut PriceFeed)
157 33: Pop
158 34: MoveLoc[1](Arg1: &Clock)
159 35: Pop
160 36: LdU64(908)
161 37: Abort
162B9:
163 38: MoveLoc[3](Arg3: vector<u8>)
164 39: StLoc[8](loc3: vector<u8>)
165 40: MoveLoc[4](Arg4: vector<u8>)
166 41: StLoc[7](loc2: vector<u8>)
167 42: CopyLoc[2](Arg2: vector<u8>)
168 43: StLoc[6](loc1: vector<u8>)
169 44: MoveLoc[8](loc3: vector<u8>)
170 45: MoveLoc[7](loc2: vector<u8>)
171 46: MoveLoc[6](loc1: vector<u8>)
172 47: LdU64(908)
173 48: Call 0library::recover_signer_address(vector<u8>, vector<u8>, vector<u8>, u64): UnifiedAddress
174 49: StLoc[11](loc6: UnifiedAddress)
175 50: ImmBorrowLoc[11](loc6: UnifiedAddress)
176 51: Call unified_address::identifier(&UnifiedAddress): address
177 52: MoveLoc[9](loc4: address)
178 53: Eq
179 54: BrFalse(56)
180B10:
181 55: Branch(62)
182B11:
183 56: MoveLoc[0](Arg0: &mut PriceFeed)
184 57: Pop
185 58: MoveLoc[1](Arg1: &Clock)
186 59: Pop
187 60: LdU64(908)
188 61: Abort
189B12:
190 62: MoveLoc[0](Arg0: &mut PriceFeed)
191 63: MoveLoc[1](Arg1: &Clock)
192 64: MoveLoc[2](Arg2: vector<u8>)
193 65: Call collect_price_updates(&mut PriceFeed, &Clock, vector<u8>): vector<PriceInfoUpdate>
194 66: Call emit_price_feed_update_event(vector<PriceInfoUpdate>)
195 67: Ret
196}
197
198emit_price_feed_update_event(Arg0: vector<PriceInfoUpdate>) {
199L1: loc0: u64
200B0:
201 0: ImmBorrowLoc[0](Arg0: vector<PriceInfoUpdate>)
202 1: VecLen(27)
203 2: StLoc[1](loc0: u64)
204 3: MoveLoc[0](Arg0: vector<PriceInfoUpdate>)
205 4: MoveLoc[1](loc0: u64)
206 5: Pack[3](PriceFeedUpdateEvent)
207 6: Call event::emit<PriceFeedUpdateEvent>(PriceFeedUpdateEvent)
208 7: Ret
209}
210
211collect_price_updates(Arg0: &mut PriceFeed, Arg1: &Clock, Arg2: vector<u8>): vector<PriceInfoUpdate> {
212L3: loc0: u64
213L4: loc1: u64
214L5: loc2: &ID
215L6: loc3: u64
216L7: loc4: u64
217L8: loc5: u64
218L9: loc6: ID
219L10: loc7: u128
220L11: loc8: &mut PriceInfo
221L12: loc9: BCS
222L13: loc10: u16
223L14: loc11: u64
224L15: loc12: vector<PriceInfoUpdate>
225B0:
226 0: MoveLoc[1](Arg1: &Clock)
227 1: Call clock::timestamp_ms(&Clock): u64
228 2: StLoc[8](loc5: u64)
229 3: CopyLoc[8](loc5: u64)
230 4: LdConst[1](u64: 5000)
231 5: Add
232 6: StLoc[4](loc1: u64)
233 7: MoveLoc[2](Arg2: vector<u8>)
234 8: Call bcs::new(vector<u8>): BCS
235 9: StLoc[12](loc9: BCS)
236 10: MutBorrowLoc[12](loc9: BCS)
237 11: Call bcs::peel_vec_length(&mut BCS): u64
238 12: StLoc[7](loc4: u64)
239 13: CopyLoc[7](loc4: u64)
240 14: LdU64(0)
241 15: Gt
242 16: BrFalse(18)
243B1:
244 17: Branch(22)
245B2:
246 18: MoveLoc[0](Arg0: &mut PriceFeed)
247 19: Pop
248 20: LdU64(909)
249 21: Abort
250B3:
251 22: VecPack(27, 0)
252 23: StLoc[15](loc12: vector<PriceInfoUpdate>)
253 24: LdU64(0)
254 25: StLoc[6](loc3: u64)
255B4:
256 26: CopyLoc[6](loc3: u64)
257 27: CopyLoc[7](loc4: u64)
258 28: Lt
259 29: BrFalse(120)
260B5:
261 30: MutBorrowLoc[12](loc9: BCS)
262 31: Call bcs::peel_address(&mut BCS): address
263 32: Call object::id_from_address(address): ID
264 33: StLoc[9](loc6: ID)
265 34: MutBorrowLoc[12](loc9: BCS)
266 35: Call bcs::peel_u128(&mut BCS): u128
267 36: Call library::base_uint(): u128
268 37: Div
269 38: StLoc[10](loc7: u128)
270 39: MutBorrowLoc[12](loc9: BCS)
271 40: Call bcs::peel_u64(&mut BCS): u64
272 41: StLoc[14](loc11: u64)
273 42: CopyLoc[14](loc11: u64)
274 43: CopyLoc[4](loc1: u64)
275 44: Le
276 45: BrFalse(47)
277B6:
278 46: Branch(51)
279B7:
280 47: MoveLoc[0](Arg0: &mut PriceFeed)
281 48: Pop
282 49: LdU64(912)
283 50: Abort
284B8:
285 51: CopyLoc[14](loc11: u64)
286 52: CopyLoc[8](loc5: u64)
287 53: Gt
288 54: BrFalse(58)
289B9:
290 55: LdU64(0)
291 56: StLoc[3](loc0: u64)
292 57: Branch(62)
293B10:
294 58: CopyLoc[8](loc5: u64)
295 59: CopyLoc[14](loc11: u64)
296 60: Sub
297 61: StLoc[3](loc0: u64)
298B11:
299 62: MoveLoc[3](loc0: u64)
300 63: LdConst[0](u64: 60000)
301 64: Le
302 65: BrFalse(67)
303B12:
304 66: Branch(71)
305B13:
306 67: MoveLoc[0](Arg0: &mut PriceFeed)
307 68: Pop
308 69: LdU64(913)
309 70: Abort
310B14:
311 71: MutBorrowLoc[12](loc9: BCS)
312 72: Call bcs::peel_u16(&mut BCS): u16
313 73: StLoc[13](loc10: u16)
314 74: CopyLoc[0](Arg0: &mut PriceFeed)
315 75: MutBorrowField[0](PriceFeed.prices: VecMap<ID, PriceInfo>)
316 76: MoveLoc[13](loc10: u16)
317 77: CastU64
318 78: Call vec_map::get_entry_by_idx_mut<ID, PriceInfo>(&mut VecMap<ID, PriceInfo>, u64): &ID * &mut PriceInfo
319 79: StLoc[11](loc8: &mut PriceInfo)
320 80: StLoc[5](loc2: &ID)
321 81: ImmBorrowLoc[9](loc6: ID)
322 82: MoveLoc[5](loc2: &ID)
323 83: Eq
324 84: BrFalse(86)
325B15:
326 85: Branch(92)
327B16:
328 86: MoveLoc[11](loc8: &mut PriceInfo)
329 87: Pop
330 88: MoveLoc[0](Arg0: &mut PriceFeed)
331 89: Pop
332 90: LdU64(914)
333 91: Abort
334B17:
335 92: CopyLoc[14](loc11: u64)
336 93: CopyLoc[11](loc8: &mut PriceInfo)
337 94: ImmBorrowField[2](PriceInfo.timestamp: u64)
338 95: ReadRef
339 96: Ge
340 97: BrFalse(113)
341B18:
342 98: CopyLoc[10](loc7: u128)
343 99: CopyLoc[11](loc8: &mut PriceInfo)
344 100: MutBorrowField[3](PriceInfo.price: u128)
345 101: WriteRef
346 102: CopyLoc[14](loc11: u64)
347 103: MoveLoc[11](loc8: &mut PriceInfo)
348 104: MutBorrowField[2](PriceInfo.timestamp: u64)
349 105: WriteRef
350 106: MutBorrowLoc[15](loc12: vector<PriceInfoUpdate>)
351 107: MoveLoc[9](loc6: ID)
352 108: MoveLoc[10](loc7: u128)
353 109: MoveLoc[14](loc11: u64)
354 110: Pack[2](PriceInfoUpdate)
355 111: VecPushBack(27)
356 112: Branch(115)
357B19:
358 113: MoveLoc[11](loc8: &mut PriceInfo)
359 114: Pop
360B20:
361 115: MoveLoc[6](loc3: u64)
362 116: LdU64(1)
363 117: Add
364 118: StLoc[6](loc3: u64)
365 119: Branch(26)
366B21:
367 120: MoveLoc[0](Arg0: &mut PriceFeed)
368 121: Pop
369 122: MoveLoc[15](loc12: vector<PriceInfoUpdate>)
370 123: Ret
371}
372
373public(friend) get_price_info(Arg0: &PriceFeed, Arg1: &ID): &PriceInfo {
374B0:
375 0: MoveLoc[0](Arg0: &PriceFeed)
376 1: ImmBorrowField[0](PriceFeed.prices: VecMap<ID, PriceInfo>)
377 2: MoveLoc[1](Arg1: &ID)
378 3: Call vec_map::get<ID, PriceInfo>(&VecMap<ID, PriceInfo>, &ID): &PriceInfo
379 4: Ret
380}
381
382public(friend) contains(Arg0: &PriceFeed, Arg1: &ID): bool {
383B0:
384 0: MoveLoc[0](Arg0: &PriceFeed)
385 1: ImmBorrowField[0](PriceFeed.prices: VecMap<ID, PriceInfo>)
386 2: MoveLoc[1](Arg1: &ID)
387 3: Call vec_map::contains<ID, PriceInfo>(&VecMap<ID, PriceInfo>, &ID): bool
388 4: Ret
389}
390
391public(friend) price_info_price(Arg0: &PriceInfo): u128 {
392B0:
393 0: MoveLoc[0](Arg0: &PriceInfo)
394 1: ImmBorrowField[3](PriceInfo.price: u128)
395 2: ReadRef
396 3: Ret
397}
398
399public(friend) price_info_timestamp(Arg0: &PriceInfo): u64 {
400B0:
401 0: MoveLoc[0](Arg0: &PriceInfo)
402 1: ImmBorrowField[2](PriceInfo.timestamp: u64)
403 2: ReadRef
404 3: Ret
405}
406
407Constants [
408 0 => u64: 60000
409 1 => u64: 5000
410 2 => address: 0x0000000000000000000000000000000000000000000000000000000000000000
411]
412}
413
0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/protocol.mvb653 lines
1// Move bytecode v7
2module 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001.protocol {
3use 0000000000000000000000000000000000000000000000000000000000000001::string;
4use 0000000000000000000000000000000000000000000000000000000000000002::dynamic_field;
5use 0000000000000000000000000000000000000000000000000000000000000002::object;
6use 0000000000000000000000000000000000000000000000000000000000000002::transfer;
7use 0000000000000000000000000000000000000000000000000000000000000002::tx_context;
8use 0000000000000000000000000000000000000000000000000000000000000002::vec_map;
9use 0000000000000000000000000000000000000000000000000000000000000002::vec_set;
10
11struct ProtocolConfig has key {
12 id: UID,
13 version: u64,
14 is_paused: bool,
15 manager_cap_id: ID,
16 deleveraging_cap_id: ID,
17 funding_rate_cap_id: ID,
18 settlement_cap_ids: VecSet<ID>,
19 maker_gas_fee: u128,
20 taker_gas_fee: u128,
21 privileged_addresses: VecSet<address>
22}
23
24struct PerpetualRegistry has store {
25 perpetuals: VecSet<ID>
26}
27
28struct GasConfig has store {
29 relayer: address,
30 gas_table: VecMap<String, u128>
31}
32
33struct SettlementOperatorAddresses has store {
34 addresses: VecSet<address>
35}
36
37public(friend) initialize(Arg0: ID, Arg1: ID, Arg2: ID, Arg3: ID, Arg4: &mut TxContext) {
38L5: loc0: ProtocolConfig
39B0:
40 0: MoveLoc[4](Arg4: &mut TxContext)
41 1: Call object::new(&mut TxContext): UID
42 2: LdConst[0](u64: 6)
43 3: LdFalse
44 4: MoveLoc[0](Arg0: ID)
45 5: MoveLoc[1](Arg1: ID)
46 6: MoveLoc[2](Arg2: ID)
47 7: Call vec_set::empty<ID>(): VecSet<ID>
48 8: LdU128(0)
49 9: LdU128(0)
50 10: Call vec_set::empty<address>(): VecSet<address>
51 11: Pack[0](ProtocolConfig)
52 12: StLoc[5](loc0: ProtocolConfig)
53 13: MutBorrowLoc[5](loc0: ProtocolConfig)
54 14: MoveLoc[3](Arg3: ID)
55 15: Call set_insurance_operator_cap_id(&mut ProtocolConfig, ID)
56 16: MutBorrowLoc[5](loc0: ProtocolConfig)
57 17: Call init_gas_config(&mut ProtocolConfig)
58 18: MoveLoc[5](loc0: ProtocolConfig)
59 19: Call transfer::share_object<ProtocolConfig>(ProtocolConfig)
60 20: Ret
61}
62
63public(friend) version(): u64 {
64B0:
65 0: LdConst[0](u64: 6)
66 1: Ret
67}
68
69public(friend) check_version(Arg0: &ProtocolConfig) {
70B0:
71 0: MoveLoc[0](Arg0: &ProtocolConfig)
72 1: ImmBorrowField[0](ProtocolConfig.version: u64)
73 2: ReadRef
74 3: LdConst[0](u64: 6)
75 4: Eq
76 5: BrFalse(7)
77B1:
78 6: Branch(9)
79B2:
80 7: LdU64(3000)
81 8: Abort
82B3:
83 9: Ret
84}
85
86public(friend) upgrade(Arg0: &mut ProtocolConfig) {
87B0:
88 0: CopyLoc[0](Arg0: &mut ProtocolConfig)
89 1: ImmBorrowField[0](ProtocolConfig.version: u64)
90 2: ReadRef
91 3: LdU64(1)
92 4: Add
93 5: LdConst[0](u64: 6)
94 6: Eq
95 7: BrFalse(9)
96B1:
97 8: Branch(13)
98B2:
99 9: MoveLoc[0](Arg0: &mut ProtocolConfig)
100 10: Pop
101 11: LdU64(3000)
102 12: Abort
103B3:
104 13: LdConst[0](u64: 6)
105 14: MoveLoc[0](Arg0: &mut ProtocolConfig)
106 15: MutBorrowField[0](ProtocolConfig.version: u64)
107 16: WriteRef
108 17: Ret
109}
110
111public(friend) check_basic(Arg0: &ProtocolConfig) {
112B0:
113 0: CopyLoc[0](Arg0: &ProtocolConfig)
114 1: Call check_version(&ProtocolConfig)
115 2: MoveLoc[0](Arg0: &ProtocolConfig)
116 3: Call check_is_normal(&ProtocolConfig)
117 4: Ret
118}
119
120public(friend) check_is_normal(Arg0: &ProtocolConfig) {
121B0:
122 0: MoveLoc[0](Arg0: &ProtocolConfig)
123 1: ImmBorrowField[1](ProtocolConfig.is_paused: bool)
124 2: ReadRef
125 3: Not
126 4: BrFalse(6)
127B1:
128 5: Branch(8)
129B2:
130 6: LdU64(100002)
131 7: Abort
132B3:
133 8: Ret
134}
135
136public(friend) is_paused(Arg0: &ProtocolConfig): bool {
137B0:
138 0: MoveLoc[0](Arg0: &ProtocolConfig)
139 1: ImmBorrowField[1](ProtocolConfig.is_paused: bool)
140 2: ReadRef
141 3: Ret
142}
143
144public(friend) manager_cap_id(Arg0: &ProtocolConfig): ID {
145B0:
146 0: MoveLoc[0](Arg0: &ProtocolConfig)
147 1: ImmBorrowField[2](ProtocolConfig.manager_cap_id: ID)
148 2: ReadRef
149 3: Ret
150}
151
152public(friend) deleveraging_cap_id(Arg0: &ProtocolConfig): ID {
153B0:
154 0: MoveLoc[0](Arg0: &ProtocolConfig)
155 1: ImmBorrowField[3](ProtocolConfig.deleveraging_cap_id: ID)
156 2: ReadRef
157 3: Ret
158}
159
160public(friend) funding_rate_cap_id(Arg0: &ProtocolConfig): ID {
161B0:
162 0: MoveLoc[0](Arg0: &ProtocolConfig)
163 1: ImmBorrowField[4](ProtocolConfig.funding_rate_cap_id: ID)
164 2: ReadRef
165 3: Ret
166}
167
168public(friend) settlement_cap_ids(Arg0: &ProtocolConfig): &VecSet<ID> {
169B0:
170 0: MoveLoc[0](Arg0: &ProtocolConfig)
171 1: ImmBorrowField[5](ProtocolConfig.settlement_cap_ids: VecSet<ID>)
172 2: Ret
173}
174
175public(friend) insurance_operator_cap_id(Arg0: &ProtocolConfig): ID {
176B0:
177 0: CopyLoc[0](Arg0: &ProtocolConfig)
178 1: ImmBorrowField[6](ProtocolConfig.id: UID)
179 2: LdConst[2](vector<u8>: "ins..)
180 3: Call dynamic_field::exists_<vector<u8>>(&UID, vector<u8>): bool
181 4: Not
182 5: BrFalse(10)
183B1:
184 6: MoveLoc[0](Arg0: &ProtocolConfig)
185 7: Pop
186 8: LdU64(119)
187 9: Abort
188B2:
189 10: MoveLoc[0](Arg0: &ProtocolConfig)
190 11: ImmBorrowField[6](ProtocolConfig.id: UID)
191 12: LdConst[2](vector<u8>: "ins..)
192 13: Call dynamic_field::borrow<vector<u8>, ID>(&UID, vector<u8>): &ID
193 14: ReadRef
194 15: Ret
195}
196
197public(friend) set_is_paused(Arg0: &mut ProtocolConfig, Arg1: bool) {
198B0:
199 0: MoveLoc[1](Arg1: bool)
200 1: MoveLoc[0](Arg0: &mut ProtocolConfig)
201 2: MutBorrowField[1](ProtocolConfig.is_paused: bool)
202 3: WriteRef
203 4: Ret
204}
205
206public(friend) set_manager_cap_id(Arg0: &mut ProtocolConfig, Arg1: ID) {
207B0:
208 0: MoveLoc[1](Arg1: ID)
209 1: MoveLoc[0](Arg0: &mut ProtocolConfig)
210 2: MutBorrowField[2](ProtocolConfig.manager_cap_id: ID)
211 3: WriteRef
212 4: Ret
213}
214
215public(friend) set_deleveraging_cap_id(Arg0: &mut ProtocolConfig, Arg1: ID) {
216B0:
217 0: MoveLoc[1](Arg1: ID)
218 1: MoveLoc[0](Arg0: &mut ProtocolConfig)
219 2: MutBorrowField[3](ProtocolConfig.deleveraging_cap_id: ID)
220 3: WriteRef
221 4: Ret
222}
223
224public(friend) set_funding_rate_cap_id(Arg0: &mut ProtocolConfig, Arg1: ID) {
225B0:
226 0: MoveLoc[1](Arg1: ID)
227 1: MoveLoc[0](Arg0: &mut ProtocolConfig)
228 2: MutBorrowField[4](ProtocolConfig.funding_rate_cap_id: ID)
229 3: WriteRef
230 4: Ret
231}
232
233public(friend) set_insurance_operator_cap_id(Arg0: &mut ProtocolConfig, Arg1: ID) {
234L2: loc0: &mut ID
235B0:
236 0: CopyLoc[0](Arg0: &mut ProtocolConfig)
237 1: ImmBorrowField[6](ProtocolConfig.id: UID)
238 2: LdConst[2](vector<u8>: "ins..)
239 3: Call dynamic_field::exists_<vector<u8>>(&UID, vector<u8>): bool
240 4: Not
241 5: BrFalse(12)
242B1:
243 6: MoveLoc[0](Arg0: &mut ProtocolConfig)
244 7: MutBorrowField[6](ProtocolConfig.id: UID)
245 8: LdConst[2](vector<u8>: "ins..)
246 9: MoveLoc[1](Arg1: ID)
247 10: Call dynamic_field::add<vector<u8>, ID>(&mut UID, vector<u8>, ID)
248 11: Branch(20)
249B2:
250 12: MoveLoc[0](Arg0: &mut ProtocolConfig)
251 13: MutBorrowField[6](ProtocolConfig.id: UID)
252 14: LdConst[2](vector<u8>: "ins..)
253 15: Call dynamic_field::borrow_mut<vector<u8>, ID>(&mut UID, vector<u8>): &mut ID
254 16: StLoc[2](loc0: &mut ID)
255 17: MoveLoc[1](Arg1: ID)
256 18: MoveLoc[2](loc0: &mut ID)
257 19: WriteRef
258B3:
259 20: Ret
260}
261
262public(friend) init_gas_config(Arg0: &mut ProtocolConfig) {
263B0:
264 0: CopyLoc[0](Arg0: &mut ProtocolConfig)
265 1: ImmBorrowField[6](ProtocolConfig.id: UID)
266 2: LdConst[3](vector<u8>: "gas..)
267 3: Call dynamic_field::exists_<vector<u8>>(&UID, vector<u8>): bool
268 4: Not
269 5: BrFalse(14)
270B1:
271 6: MoveLoc[0](Arg0: &mut ProtocolConfig)
272 7: MutBorrowField[6](ProtocolConfig.id: UID)
273 8: LdConst[3](vector<u8>: "gas..)
274 9: LdConst[5](address: 0x00..)
275 10: Call vec_map::empty<String, u128>(): VecMap<String, u128>
276 11: Pack[2](GasConfig)
277 12: Call dynamic_field::add<vector<u8>, GasConfig>(&mut UID, vector<u8>, GasConfig)
278 13: Branch(16)
279B2:
280 14: MoveLoc[0](Arg0: &mut ProtocolConfig)
281 15: Pop
282B3:
283 16: Ret
284}
285
286public(friend) set_gas_relayer(Arg0: &mut ProtocolConfig, Arg1: address) {
287L2: loc0: &mut GasConfig
288B0:
289 0: CopyLoc[0](Arg0: &mut ProtocolConfig)
290 1: Call init_gas_config(&mut ProtocolConfig)
291 2: MoveLoc[0](Arg0: &mut ProtocolConfig)
292 3: MutBorrowField[6](ProtocolConfig.id: UID)
293 4: LdConst[3](vector<u8>: "gas..)
294 5: Call dynamic_field::borrow_mut<vector<u8>, GasConfig>(&mut UID, vector<u8>): &mut GasConfig
295 6: StLoc[2](loc0: &mut GasConfig)
296 7: MoveLoc[1](Arg1: address)
297 8: MoveLoc[2](loc0: &mut GasConfig)
298 9: MutBorrowField[7](GasConfig.relayer: address)
299 10: WriteRef
300 11: Ret
301}
302
303public(friend) set_action_gas_fee(Arg0: &mut ProtocolConfig, Arg1: String, Arg2: u128) {
304L3: loc0: &mut GasConfig
305B0:
306 0: CopyLoc[0](Arg0: &mut ProtocolConfig)
307 1: Call init_gas_config(&mut ProtocolConfig)
308 2: MoveLoc[0](Arg0: &mut ProtocolConfig)
309 3: MutBorrowField[6](ProtocolConfig.id: UID)
310 4: LdConst[3](vector<u8>: "gas..)
311 5: Call dynamic_field::borrow_mut<vector<u8>, GasConfig>(&mut UID, vector<u8>): &mut GasConfig
312 6: StLoc[3](loc0: &mut GasConfig)
313 7: CopyLoc[3](loc0: &mut GasConfig)
314 8: ImmBorrowField[8](GasConfig.gas_table: VecMap<String, u128>)
315 9: ImmBorrowLoc[1](Arg1: String)
316 10: Call vec_map::contains<String, u128>(&VecMap<String, u128>, &String): bool
317 11: BrFalse(19)
318B1:
319 12: MoveLoc[2](Arg2: u128)
320 13: MoveLoc[3](loc0: &mut GasConfig)
321 14: MutBorrowField[8](GasConfig.gas_table: VecMap<String, u128>)
322 15: ImmBorrowLoc[1](Arg1: String)
323 16: Call vec_map::get_mut<String, u128>(&mut VecMap<String, u128>, &String): &mut u128
324 17: WriteRef
325 18: Branch(24)
326B2:
327 19: MoveLoc[3](loc0: &mut GasConfig)
328 20: MutBorrowField[8](GasConfig.gas_table: VecMap<String, u128>)
329 21: MoveLoc[1](Arg1: String)
330 22: MoveLoc[2](Arg2: u128)
331 23: Call vec_map::insert<String, u128>(&mut VecMap<String, u128>, String, u128)
332B3:
333 24: Ret
334}
335
336public(friend) gas_relayer(Arg0: &ProtocolConfig): address {
337B0:
338 0: CopyLoc[0](Arg0: &ProtocolConfig)
339 1: ImmBorrowField[6](ProtocolConfig.id: UID)
340 2: LdConst[3](vector<u8>: "gas..)
341 3: Call dynamic_field::exists_<vector<u8>>(&UID, vector<u8>): bool
342 4: Not
343 5: BrFalse(10)
344B1:
345 6: MoveLoc[0](Arg0: &ProtocolConfig)
346 7: Pop
347 8: LdConst[5](address: 0x00..)
348 9: Ret
349B2:
350 10: MoveLoc[0](Arg0: &ProtocolConfig)
351 11: ImmBorrowField[6](ProtocolConfig.id: UID)
352 12: LdConst[3](vector<u8>: "gas..)
353 13: Call dynamic_field::borrow<vector<u8>, GasConfig>(&UID, vector<u8>): &GasConfig
354 14: ImmBorrowField[7](GasConfig.relayer: address)
355 15: ReadRef
356 16: Ret
357}
358
359public get_action_gas_fee(Arg0: &ProtocolConfig, Arg1: String, Arg2: &TxContext): u128 {
360L3: loc0: bool
361L4: loc1: &GasConfig
362B0:
363 0: CopyLoc[0](Arg0: &ProtocolConfig)
364 1: ImmBorrowField[6](ProtocolConfig.id: UID)
365 2: LdConst[3](vector<u8>: "gas..)
366 3: Call dynamic_field::exists_<vector<u8>>(&UID, vector<u8>): bool
367 4: Not
368 5: BrFalse(12)
369B1:
370 6: MoveLoc[2](Arg2: &TxContext)
371 7: Pop
372 8: MoveLoc[0](Arg0: &ProtocolConfig)
373 9: Pop
374 10: LdU128(0)
375 11: Ret
376B2:
377 12: MoveLoc[0](Arg0: &ProtocolConfig)
378 13: ImmBorrowField[6](ProtocolConfig.id: UID)
379 14: LdConst[3](vector<u8>: "gas..)
380 15: Call dynamic_field::borrow<vector<u8>, GasConfig>(&UID, vector<u8>): &GasConfig
381 16: StLoc[4](loc1: &GasConfig)
382 17: MoveLoc[2](Arg2: &TxContext)
383 18: Call tx_context::sender(&TxContext): address
384 19: CopyLoc[4](loc1: &GasConfig)
385 20: ImmBorrowField[7](GasConfig.relayer: address)
386 21: ReadRef
387 22: Neq
388 23: BrFalse(27)
389B3:
390 24: LdTrue
391 25: StLoc[3](loc0: bool)
392 26: Branch(33)
393B4:
394 27: CopyLoc[4](loc1: &GasConfig)
395 28: ImmBorrowField[8](GasConfig.gas_table: VecMap<String, u128>)
396 29: ImmBorrowLoc[1](Arg1: String)
397 30: Call vec_map::contains<String, u128>(&VecMap<String, u128>, &String): bool
398 31: Not
399 32: StLoc[3](loc0: bool)
400B5:
401 33: MoveLoc[3](loc0: bool)
402 34: BrFalse(39)
403B6:
404 35: MoveLoc[4](loc1: &GasConfig)
405 36: Pop
406 37: LdU128(0)
407 38: Ret
408B7:
409 39: MoveLoc[4](loc1: &GasConfig)
410 40: ImmBorrowField[8](GasConfig.gas_table: VecMap<String, u128>)
411 41: ImmBorrowLoc[1](Arg1: String)
412 42: Call vec_map::get<String, u128>(&VecMap<String, u128>, &String): &u128
413 43: ReadRef
414 44: Ret
415}
416
417public(friend) configured_action_gas_fee(Arg0: &ProtocolConfig, Arg1: String): u128 {
418L2: loc0: &GasConfig
419B0:
420 0: CopyLoc[0](Arg0: &ProtocolConfig)
421 1: ImmBorrowField[6](ProtocolConfig.id: UID)
422 2: LdConst[3](vector<u8>: "gas..)
423 3: Call dynamic_field::exists_<vector<u8>>(&UID, vector<u8>): bool
424 4: Not
425 5: BrFalse(10)
426B1:
427 6: MoveLoc[0](Arg0: &ProtocolConfig)
428 7: Pop
429 8: LdU128(0)
430 9: Ret
431B2:
432 10: MoveLoc[0](Arg0: &ProtocolConfig)
433 11: ImmBorrowField[6](ProtocolConfig.id: UID)
434 12: LdConst[3](vector<u8>: "gas..)
435 13: Call dynamic_field::borrow<vector<u8>, GasConfig>(&UID, vector<u8>): &GasConfig
436 14: StLoc[2](loc0: &GasConfig)
437 15: CopyLoc[2](loc0: &GasConfig)
438 16: ImmBorrowField[8](GasConfig.gas_table: VecMap<String, u128>)
439 17: ImmBorrowLoc[1](Arg1: String)
440 18: Call vec_map::contains<String, u128>(&VecMap<String, u128>, &String): bool
441 19: Not
442 20: BrFalse(25)
443B3:
444 21: MoveLoc[2](loc0: &GasConfig)
445 22: Pop
446 23: LdU128(0)
447 24: Ret
448B4:
449 25: MoveLoc[2](loc0: &GasConfig)
450 26: ImmBorrowField[8](GasConfig.gas_table: VecMap<String, u128>)
451 27: ImmBorrowLoc[1](Arg1: String)
452 28: Call vec_map::get<String, u128>(&VecMap<String, u128>, &String): &u128
453 29: ReadRef
454 30: Ret
455}
456
457public(friend) clear_settlement_cap_ids(Arg0: &mut ProtocolConfig) {
458B0:
459 0: Call vec_set::empty<ID>(): VecSet<ID>
460 1: MoveLoc[0](Arg0: &mut ProtocolConfig)
461 2: MutBorrowField[5](ProtocolConfig.settlement_cap_ids: VecSet<ID>)
462 3: WriteRef
463 4: Ret
464}
465
466public(friend) init_settlement_operator_addresses(Arg0: &mut ProtocolConfig) {
467B0:
468 0: CopyLoc[0](Arg0: &mut ProtocolConfig)
469 1: ImmBorrowField[6](ProtocolConfig.id: UID)
470 2: LdConst[4](vector<u8>: "set..)
471 3: Call dynamic_field::exists_<vector<u8>>(&UID, vector<u8>): bool
472 4: Not
473 5: BrFalse(13)
474B1:
475 6: MoveLoc[0](Arg0: &mut ProtocolConfig)
476 7: MutBorrowField[6](ProtocolConfig.id: UID)
477 8: LdConst[4](vector<u8>: "set..)
478 9: Call vec_set::empty<address>(): VecSet<address>
479 10: Pack[3](SettlementOperatorAddresses)
480 11: Call dynamic_field::add<vector<u8>, SettlementOperatorAddresses>(&mut UID, vector<u8>, SettlementOperatorAddresses)
481 12: Branch(15)
482B2:
483 13: MoveLoc[0](Arg0: &mut ProtocolConfig)
484 14: Pop
485B3:
486 15: Ret
487}
488
489public(friend) settlement_operator_address_exists(Arg0: &ProtocolConfig, Arg1: address): bool {
490B0:
491 0: CopyLoc[0](Arg0: &ProtocolConfig)
492 1: ImmBorrowField[6](ProtocolConfig.id: UID)
493 2: LdConst[4](vector<u8>: "set..)
494 3: Call dynamic_field::exists_<vector<u8>>(&UID, vector<u8>): bool
495 4: Not
496 5: BrFalse(10)
497B1:
498 6: MoveLoc[0](Arg0: &ProtocolConfig)
499 7: Pop
500 8: LdFalse
501 9: Ret
502B2:
503 10: MoveLoc[0](Arg0: &ProtocolConfig)
504 11: ImmBorrowField[6](ProtocolConfig.id: UID)
505 12: LdConst[4](vector<u8>: "set..)
506 13: Call dynamic_field::borrow<vector<u8>, SettlementOperatorAddresses>(&UID, vector<u8>): &SettlementOperatorAddresses
507 14: ImmBorrowField[9](SettlementOperatorAddresses.addresses: VecSet<address>)
508 15: ImmBorrowLoc[1](Arg1: address)
509 16: Call vec_set::contains<address>(&VecSet<address>, &address): bool
510 17: Ret
511}
512
513public(friend) add_settlement_operator_address(Arg0: &mut ProtocolConfig, Arg1: address) {
514B0:
515 0: CopyLoc[0](Arg0: &mut ProtocolConfig)
516 1: Call init_settlement_operator_addresses(&mut ProtocolConfig)
517 2: MoveLoc[0](Arg0: &mut ProtocolConfig)
518 3: MutBorrowField[6](ProtocolConfig.id: UID)
519 4: LdConst[4](vector<u8>: "set..)
520 5: Call dynamic_field::borrow_mut<vector<u8>, SettlementOperatorAddresses>(&mut UID, vector<u8>): &mut SettlementOperatorAddresses
521 6: MutBorrowField[9](SettlementOperatorAddresses.addresses: VecSet<address>)
522 7: MoveLoc[1](Arg1: address)
523 8: Call vec_set::insert<address>(&mut VecSet<address>, address)
524 9: Ret
525}
526
527public(friend) remove_settlement_operator_address(Arg0: &mut ProtocolConfig, Arg1: address) {
528B0:
529 0: CopyLoc[0](Arg0: &mut ProtocolConfig)
530 1: ImmBorrowField[6](ProtocolConfig.id: UID)
531 2: LdConst[4](vector<u8>: "set..)
532 3: Call dynamic_field::exists_<vector<u8>>(&UID, vector<u8>): bool
533 4: Not
534 5: BrFalse(10)
535B1:
536 6: MoveLoc[0](Arg0: &mut ProtocolConfig)
537 7: Pop
538 8: LdU64(112)
539 9: Abort
540B2:
541 10: MoveLoc[0](Arg0: &mut ProtocolConfig)
542 11: MutBorrowField[6](ProtocolConfig.id: UID)
543 12: LdConst[4](vector<u8>: "set..)
544 13: Call dynamic_field::borrow_mut<vector<u8>, SettlementOperatorAddresses>(&mut UID, vector<u8>): &mut SettlementOperatorAddresses
545 14: MutBorrowField[9](SettlementOperatorAddresses.addresses: VecSet<address>)
546 15: ImmBorrowLoc[1](Arg1: address)
547 16: Call vec_set::remove<address>(&mut VecSet<address>, &address)
548 17: Ret
549}
550
551public(friend) maker_gas_fee(Arg0: &ProtocolConfig): u128 {
552B0:
553 0: MoveLoc[0](Arg0: &ProtocolConfig)
554 1: ImmBorrowField[10](ProtocolConfig.maker_gas_fee: u128)
555 2: ReadRef
556 3: Ret
557}
558
559public(friend) set_maker_gas_fee(Arg0: &mut ProtocolConfig, Arg1: u128) {
560B0:
561 0: MoveLoc[1](Arg1: u128)
562 1: MoveLoc[0](Arg0: &mut ProtocolConfig)
563 2: MutBorrowField[10](ProtocolConfig.maker_gas_fee: u128)
564 3: WriteRef
565 4: Ret
566}
567
568public(friend) taker_gas_fee(Arg0: &ProtocolConfig): u128 {
569B0:
570 0: MoveLoc[0](Arg0: &ProtocolConfig)
571 1: ImmBorrowField[11](ProtocolConfig.taker_gas_fee: u128)
572 2: ReadRef
573 3: Ret
574}
575
576public(friend) set_taker_gas_fee(Arg0: &mut ProtocolConfig, Arg1: u128) {
577B0:
578 0: MoveLoc[1](Arg1: u128)
579 1: MoveLoc[0](Arg0: &mut ProtocolConfig)
580 2: MutBorrowField[11](ProtocolConfig.taker_gas_fee: u128)
581 3: WriteRef
582 4: Ret
583}
584
585public(friend) privileged_addresses(Arg0: &ProtocolConfig): &VecSet<address> {
586B0:
587 0: MoveLoc[0](Arg0: &ProtocolConfig)
588 1: ImmBorrowField[12](ProtocolConfig.privileged_addresses: VecSet<address>)
589 2: Ret
590}
591
592public(friend) privileged_addresses_mut(Arg0: &mut ProtocolConfig): &mut VecSet<address> {
593B0:
594 0: MoveLoc[0](Arg0: &mut ProtocolConfig)
595 1: MutBorrowField[12](ProtocolConfig.privileged_addresses: VecSet<address>)
596 2: Ret
597}
598
599public(friend) register_perpetual(Arg0: &mut ProtocolConfig, Arg1: ID) {
600B0:
601 0: CopyLoc[0](Arg0: &mut ProtocolConfig)
602 1: ImmBorrowField[6](ProtocolConfig.id: UID)
603 2: LdConst[1](vector<u8>: "per..)
604 3: Call dynamic_field::exists_<vector<u8>>(&UID, vector<u8>): bool
605 4: Not
606 5: BrFalse(12)
607B1:
608 6: CopyLoc[0](Arg0: &mut ProtocolConfig)
609 7: MutBorrowField[6](ProtocolConfig.id: UID)
610 8: LdConst[1](vector<u8>: "per..)
611 9: Call vec_set::empty<ID>(): VecSet<ID>
612 10: Pack[1](PerpetualRegistry)
613 11: Call dynamic_field::add<vector<u8>, PerpetualRegistry>(&mut UID, vector<u8>, PerpetualRegistry)
614B2:
615 12: MoveLoc[0](Arg0: &mut ProtocolConfig)
616 13: MutBorrowField[6](ProtocolConfig.id: UID)
617 14: LdConst[1](vector<u8>: "per..)
618 15: Call dynamic_field::borrow_mut<vector<u8>, PerpetualRegistry>(&mut UID, vector<u8>): &mut PerpetualRegistry
619 16: MutBorrowField[13](PerpetualRegistry.perpetuals: VecSet<ID>)
620 17: MoveLoc[1](Arg1: ID)
621 18: Call vec_set::insert<ID>(&mut VecSet<ID>, ID)
622 19: Ret
623}
624
625public(friend) perpetual_registry_exists(Arg0: &ProtocolConfig): bool {
626B0:
627 0: MoveLoc[0](Arg0: &ProtocolConfig)
628 1: ImmBorrowField[6](ProtocolConfig.id: UID)
629 2: LdConst[1](vector<u8>: "per..)
630 3: Call dynamic_field::exists_<vector<u8>>(&UID, vector<u8>): bool
631 4: Ret
632}
633
634public(friend) borrow_perpetual_ids(Arg0: &ProtocolConfig): &VecSet<ID> {
635B0:
636 0: MoveLoc[0](Arg0: &ProtocolConfig)
637 1: ImmBorrowField[6](ProtocolConfig.id: UID)
638 2: LdConst[1](vector<u8>: "per..)
639 3: Call dynamic_field::borrow<vector<u8>, PerpetualRegistry>(&UID, vector<u8>): &PerpetualRegistry
640 4: ImmBorrowField[13](PerpetualRegistry.perpetuals: VecSet<ID>)
641 5: Ret
642}
643
644Constants [
645 0 => u64: 6
646 1 => vector<u8>: "perpetual_registry" // interpreted as UTF8 string
647 2 => vector<u8>: "insurance_operator" // interpreted as UTF8 string
648 3 => vector<u8>: "gas_config" // interpreted as UTF8 string
649 4 => vector<u8>: "settlement_operator_addresses" // interpreted as UTF8 string
650 5 => address: 0x0000000000000000000000000000000000000000000000000000000000000000
651]
652}
653
0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/roles.mvb823 lines
1// Move bytecode v7
2module 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001.roles {
3use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::library;
4use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::price_feed;
5use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::protocol;
6use 0000000000000000000000000000000000000000000000000000000000000001::string;
7use 0000000000000000000000000000000000000000000000000000000000000002::event;
8use 0000000000000000000000000000000000000000000000000000000000000002::object;
9use 0000000000000000000000000000000000000000000000000000000000000002::transfer;
10use 0000000000000000000000000000000000000000000000000000000000000002::tx_context;
11use 0000000000000000000000000000000000000000000000000000000000000002::vec_set;
12
13struct ExchangeAdminUpdateEvent has copy, drop {
14 account: address
15}
16
17struct ExchangeAdminPauseEvent has copy, drop {
18 admin: address
19}
20
21struct ExchangeAdminResumeEvent has copy, drop {
22 admin: address
23}
24
25struct ExchangeManagerUpdateEvent has copy, drop {
26 id: ID,
27 account: address
28}
29
30struct SettlementOperatorCreationEvent has copy, drop {
31 id: ID,
32 account: address
33}
34
35struct SettlementOperatorRemovalEvent has copy, drop {
36 id: ID
37}
38
39struct SettlementOperatorAddressAddedEvent has copy, drop {
40 account: address
41}
42
43struct SettlementOperatorAddressRemovedEvent has copy, drop {
44 account: address
45}
46
47struct DelevergingOperatorUpdateEvent has copy, drop {
48 id: ID,
49 account: address
50}
51
52struct FundingRateOperatorUpdateEvent has copy, drop {
53 id: ID,
54 account: address
55}
56
57struct InsuranceOperatorUpdateEvent has copy, drop {
58 id: ID,
59 account: address
60}
61
62struct ExchangeAdminCap has key {
63 id: UID
64}
65
66struct ExchangeManagerCap has key {
67 id: UID
68}
69
70struct SettlementCap has key {
71 id: UID
72}
73
74struct DeleveragingCap has key {
75 id: UID
76}
77
78struct FundingRateCap has key {
79 id: UID
80}
81
82struct InsuranceOperatorCap has key {
83 id: UID
84}
85
86entry upgrade(Arg0: &ExchangeAdminCap, Arg1: &mut ProtocolConfig) {
87B0:
88 0: MoveLoc[1](Arg1: &mut ProtocolConfig)
89 1: Call protocol::upgrade(&mut ProtocolConfig)
90 2: Ret
91}
92
93entry pause(Arg0: &ExchangeAdminCap, Arg1: &mut ProtocolConfig, Arg2: &TxContext) {
94B0:
95 0: CopyLoc[1](Arg1: &mut ProtocolConfig)
96 1: FreezeRef
97 2: Call protocol::check_version(&ProtocolConfig)
98 3: CopyLoc[1](Arg1: &mut ProtocolConfig)
99 4: FreezeRef
100 5: Call protocol::is_paused(&ProtocolConfig): bool
101 6: Not
102 7: BrFalse(9)
103B1:
104 8: Branch(15)
105B2:
106 9: MoveLoc[2](Arg2: &TxContext)
107 10: Pop
108 11: MoveLoc[1](Arg1: &mut ProtocolConfig)
109 12: Pop
110 13: LdU64(100000)
111 14: Abort
112B3:
113 15: MoveLoc[1](Arg1: &mut ProtocolConfig)
114 16: LdTrue
115 17: Call protocol::set_is_paused(&mut ProtocolConfig, bool)
116 18: MoveLoc[2](Arg2: &TxContext)
117 19: Call tx_context::sender(&TxContext): address
118 20: Pack[1](ExchangeAdminPauseEvent)
119 21: Call event::emit<ExchangeAdminPauseEvent>(ExchangeAdminPauseEvent)
120 22: Ret
121}
122
123entry resume(Arg0: &ExchangeAdminCap, Arg1: &mut ProtocolConfig, Arg2: &TxContext) {
124B0:
125 0: CopyLoc[1](Arg1: &mut ProtocolConfig)
126 1: FreezeRef
127 2: Call protocol::check_version(&ProtocolConfig)
128 3: CopyLoc[1](Arg1: &mut ProtocolConfig)
129 4: FreezeRef
130 5: Call protocol::is_paused(&ProtocolConfig): bool
131 6: BrFalse(8)
132B1:
133 7: Branch(14)
134B2:
135 8: MoveLoc[2](Arg2: &TxContext)
136 9: Pop
137 10: MoveLoc[1](Arg1: &mut ProtocolConfig)
138 11: Pop
139 12: LdU64(100001)
140 13: Abort
141B3:
142 14: MoveLoc[1](Arg1: &mut ProtocolConfig)
143 15: LdFalse
144 16: Call protocol::set_is_paused(&mut ProtocolConfig, bool)
145 17: MoveLoc[2](Arg2: &TxContext)
146 18: Call tx_context::sender(&TxContext): address
147 19: Pack[2](ExchangeAdminResumeEvent)
148 20: Call event::emit<ExchangeAdminResumeEvent>(ExchangeAdminResumeEvent)
149 21: Ret
150}
151
152entry set_exchange_admin(Arg0: ExchangeAdminCap, Arg1: address, Arg2: &TxContext) {
153B0:
154 0: CopyLoc[1](Arg1: address)
155 1: LdConst[1](address: 0x00..)
156 2: Neq
157 3: BrFalse(5)
158B1:
159 4: Branch(9)
160B2:
161 5: MoveLoc[2](Arg2: &TxContext)
162 6: Pop
163 7: LdU64(105)
164 8: Abort
165B3:
166 9: CopyLoc[1](Arg1: address)
167 10: MoveLoc[2](Arg2: &TxContext)
168 11: Call tx_context::sender(&TxContext): address
169 12: Neq
170 13: BrFalse(15)
171B4:
172 14: Branch(17)
173B5:
174 15: LdU64(900)
175 16: Abort
176B6:
177 17: MoveLoc[0](Arg0: ExchangeAdminCap)
178 18: CopyLoc[1](Arg1: address)
179 19: Call transfer::transfer<ExchangeAdminCap>(ExchangeAdminCap, address)
180 20: MoveLoc[1](Arg1: address)
181 21: Pack[0](ExchangeAdminUpdateEvent)
182 22: Call event::emit<ExchangeAdminUpdateEvent>(ExchangeAdminUpdateEvent)
183 23: Ret
184}
185
186entry set_exchange_manager(Arg0: &ExchangeAdminCap, Arg1: &mut ProtocolConfig, Arg2: address, Arg3: &mut TxContext) {
187B0:
188 0: CopyLoc[1](Arg1: &mut ProtocolConfig)
189 1: FreezeRef
190 2: Call protocol::check_basic(&ProtocolConfig)
191 3: CopyLoc[2](Arg2: address)
192 4: LdConst[1](address: 0x00..)
193 5: Neq
194 6: BrFalse(8)
195B1:
196 7: Branch(14)
197B2:
198 8: MoveLoc[3](Arg3: &mut TxContext)
199 9: Pop
200 10: MoveLoc[1](Arg1: &mut ProtocolConfig)
201 11: Pop
202 12: LdU64(105)
203 13: Abort
204B3:
205 14: MoveLoc[1](Arg1: &mut ProtocolConfig)
206 15: MoveLoc[2](Arg2: address)
207 16: MoveLoc[3](Arg3: &mut TxContext)
208 17: Call create_exchange_manager_cap(address, &mut TxContext): ID
209 18: Call protocol::set_manager_cap_id(&mut ProtocolConfig, ID)
210 19: Ret
211}
212
213entry set_deleveraging_operator(Arg0: &ExchangeAdminCap, Arg1: &mut ProtocolConfig, Arg2: address, Arg3: &mut TxContext) {
214B0:
215 0: CopyLoc[1](Arg1: &mut ProtocolConfig)
216 1: FreezeRef
217 2: Call protocol::check_basic(&ProtocolConfig)
218 3: CopyLoc[2](Arg2: address)
219 4: LdConst[1](address: 0x00..)
220 5: Neq
221 6: BrFalse(8)
222B1:
223 7: Branch(14)
224B2:
225 8: MoveLoc[3](Arg3: &mut TxContext)
226 9: Pop
227 10: MoveLoc[1](Arg1: &mut ProtocolConfig)
228 11: Pop
229 12: LdU64(105)
230 13: Abort
231B3:
232 14: MoveLoc[1](Arg1: &mut ProtocolConfig)
233 15: MoveLoc[2](Arg2: address)
234 16: MoveLoc[3](Arg3: &mut TxContext)
235 17: Call create_deleveraging_cap(address, &mut TxContext): ID
236 18: Call protocol::set_deleveraging_cap_id(&mut ProtocolConfig, ID)
237 19: Ret
238}
239
240entry set_funding_rate_operator(Arg0: &ExchangeAdminCap, Arg1: &mut ProtocolConfig, Arg2: address, Arg3: &mut TxContext) {
241B0:
242 0: CopyLoc[1](Arg1: &mut ProtocolConfig)
243 1: FreezeRef
244 2: Call protocol::check_basic(&ProtocolConfig)
245 3: CopyLoc[2](Arg2: address)
246 4: LdConst[1](address: 0x00..)
247 5: Neq
248 6: BrFalse(8)
249B1:
250 7: Branch(14)
251B2:
252 8: MoveLoc[3](Arg3: &mut TxContext)
253 9: Pop
254 10: MoveLoc[1](Arg1: &mut ProtocolConfig)
255 11: Pop
256 12: LdU64(105)
257 13: Abort
258B3:
259 14: MoveLoc[1](Arg1: &mut ProtocolConfig)
260 15: MoveLoc[2](Arg2: address)
261 16: MoveLoc[3](Arg3: &mut TxContext)
262 17: Call create_funding_rate_cap(address, &mut TxContext): ID
263 18: Call protocol::set_funding_rate_cap_id(&mut ProtocolConfig, ID)
264 19: Ret
265}
266
267entry set_insurance_operator(Arg0: &ExchangeAdminCap, Arg1: &mut ProtocolConfig, Arg2: address, Arg3: &mut TxContext) {
268B0:
269 0: CopyLoc[1](Arg1: &mut ProtocolConfig)
270 1: FreezeRef
271 2: Call protocol::check_basic(&ProtocolConfig)
272 3: CopyLoc[2](Arg2: address)
273 4: LdConst[1](address: 0x00..)
274 5: Neq
275 6: BrFalse(8)
276B1:
277 7: Branch(14)
278B2:
279 8: MoveLoc[3](Arg3: &mut TxContext)
280 9: Pop
281 10: MoveLoc[1](Arg1: &mut ProtocolConfig)
282 11: Pop
283 12: LdU64(105)
284 13: Abort
285B3:
286 14: MoveLoc[1](Arg1: &mut ProtocolConfig)
287 15: MoveLoc[2](Arg2: address)
288 16: MoveLoc[3](Arg3: &mut TxContext)
289 17: Call create_insurance_operator_cap(address, &mut TxContext): ID
290 18: Call protocol::set_insurance_operator_cap_id(&mut ProtocolConfig, ID)
291 19: Ret
292}
293
294entry create_settlement_operator(Arg0: &ExchangeAdminCap, Arg1: &mut ProtocolConfig, Arg2: address, Arg3: &mut TxContext) {
295B0:
296 0: LdU64(999)
297 1: Abort
298}
299
300public remove_settlement_operator(Arg0: &ExchangeAdminCap, Arg1: &mut ProtocolConfig, Arg2: ID) {
301B0:
302 0: LdU64(999)
303 1: Abort
304}
305
306entry add_settlement_operator_address(Arg0: &ExchangeAdminCap, Arg1: &mut ProtocolConfig, Arg2: address) {
307B0:
308 0: CopyLoc[1](Arg1: &mut ProtocolConfig)
309 1: FreezeRef
310 2: Call protocol::check_basic(&ProtocolConfig)
311 3: CopyLoc[2](Arg2: address)
312 4: LdConst[1](address: 0x00..)
313 5: Neq
314 6: BrFalse(8)
315B1:
316 7: Branch(12)
317B2:
318 8: MoveLoc[1](Arg1: &mut ProtocolConfig)
319 9: Pop
320 10: LdU64(105)
321 11: Abort
322B3:
323 12: MoveLoc[1](Arg1: &mut ProtocolConfig)
324 13: CopyLoc[2](Arg2: address)
325 14: Call protocol::add_settlement_operator_address(&mut ProtocolConfig, address)
326 15: MoveLoc[2](Arg2: address)
327 16: Pack[6](SettlementOperatorAddressAddedEvent)
328 17: Call event::emit<SettlementOperatorAddressAddedEvent>(SettlementOperatorAddressAddedEvent)
329 18: Ret
330}
331
332entry remove_settlement_operator_address(Arg0: &ExchangeManagerCap, Arg1: &mut ProtocolConfig, Arg2: address) {
333B0:
334 0: CopyLoc[1](Arg1: &mut ProtocolConfig)
335 1: FreezeRef
336 2: Call protocol::check_basic(&ProtocolConfig)
337 3: CopyLoc[1](Arg1: &mut ProtocolConfig)
338 4: FreezeRef
339 5: MoveLoc[0](Arg0: &ExchangeManagerCap)
340 6: Call check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
341 7: MoveLoc[1](Arg1: &mut ProtocolConfig)
342 8: CopyLoc[2](Arg2: address)
343 9: Call protocol::remove_settlement_operator_address(&mut ProtocolConfig, address)
344 10: MoveLoc[2](Arg2: address)
345 11: Pack[7](SettlementOperatorAddressRemovedEvent)
346 12: Call event::emit<SettlementOperatorAddressRemovedEvent>(SettlementOperatorAddressRemovedEvent)
347 13: Ret
348}
349
350entry set_maker_gas_fee(Arg0: &ExchangeManagerCap, Arg1: &mut ProtocolConfig, Arg2: u128) {
351B0:
352 0: CopyLoc[1](Arg1: &mut ProtocolConfig)
353 1: FreezeRef
354 2: Call protocol::check_basic(&ProtocolConfig)
355 3: CopyLoc[1](Arg1: &mut ProtocolConfig)
356 4: FreezeRef
357 5: MoveLoc[0](Arg0: &ExchangeManagerCap)
358 6: Call check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
359 7: MoveLoc[2](Arg2: u128)
360 8: Call library::base_uint(): u128
361 9: Div
362 10: StLoc[2](Arg2: u128)
363 11: MoveLoc[1](Arg1: &mut ProtocolConfig)
364 12: MoveLoc[2](Arg2: u128)
365 13: Call protocol::set_maker_gas_fee(&mut ProtocolConfig, u128)
366 14: Ret
367}
368
369entry set_taker_gas_fee(Arg0: &ExchangeManagerCap, Arg1: &mut ProtocolConfig, Arg2: u128) {
370B0:
371 0: CopyLoc[1](Arg1: &mut ProtocolConfig)
372 1: FreezeRef
373 2: Call protocol::check_basic(&ProtocolConfig)
374 3: CopyLoc[1](Arg1: &mut ProtocolConfig)
375 4: FreezeRef
376 5: MoveLoc[0](Arg0: &ExchangeManagerCap)
377 6: Call check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
378 7: MoveLoc[2](Arg2: u128)
379 8: Call library::base_uint(): u128
380 9: Div
381 10: StLoc[2](Arg2: u128)
382 11: MoveLoc[1](Arg1: &mut ProtocolConfig)
383 12: MoveLoc[2](Arg2: u128)
384 13: Call protocol::set_taker_gas_fee(&mut ProtocolConfig, u128)
385 14: Ret
386}
387
388public(friend) set_gas_relayer(Arg0: &ExchangeManagerCap, Arg1: &mut ProtocolConfig, Arg2: address) {
389B0:
390 0: CopyLoc[1](Arg1: &mut ProtocolConfig)
391 1: FreezeRef
392 2: Call protocol::check_basic(&ProtocolConfig)
393 3: CopyLoc[1](Arg1: &mut ProtocolConfig)
394 4: FreezeRef
395 5: MoveLoc[0](Arg0: &ExchangeManagerCap)
396 6: Call check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
397 7: CopyLoc[2](Arg2: address)
398 8: LdConst[1](address: 0x00..)
399 9: Neq
400 10: BrFalse(12)
401B1:
402 11: Branch(16)
403B2:
404 12: MoveLoc[1](Arg1: &mut ProtocolConfig)
405 13: Pop
406 14: LdU64(105)
407 15: Abort
408B3:
409 16: MoveLoc[1](Arg1: &mut ProtocolConfig)
410 17: MoveLoc[2](Arg2: address)
411 18: Call protocol::set_gas_relayer(&mut ProtocolConfig, address)
412 19: Ret
413}
414
415entry set_action_gas_fee(Arg0: &ExchangeManagerCap, Arg1: &mut ProtocolConfig, Arg2: String, Arg3: u128) {
416B0:
417 0: CopyLoc[1](Arg1: &mut ProtocolConfig)
418 1: FreezeRef
419 2: Call protocol::check_basic(&ProtocolConfig)
420 3: CopyLoc[1](Arg1: &mut ProtocolConfig)
421 4: FreezeRef
422 5: MoveLoc[0](Arg0: &ExchangeManagerCap)
423 6: Call check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
424 7: MoveLoc[3](Arg3: u128)
425 8: Call library::base_uint(): u128
426 9: Div
427 10: StLoc[3](Arg3: u128)
428 11: CopyLoc[3](Arg3: u128)
429 12: LdConst[0](u128: 5000..)
430 13: Le
431 14: BrFalse(16)
432B1:
433 15: Branch(20)
434B2:
435 16: MoveLoc[1](Arg1: &mut ProtocolConfig)
436 17: Pop
437 18: LdU64(3001)
438 19: Abort
439B3:
440 20: MoveLoc[1](Arg1: &mut ProtocolConfig)
441 21: MoveLoc[2](Arg2: String)
442 22: MoveLoc[3](Arg3: u128)
443 23: Call protocol::set_action_gas_fee(&mut ProtocolConfig, String, u128)
444 24: Ret
445}
446
447entry set_price_feeder(Arg0: &ExchangeManagerCap, Arg1: &ProtocolConfig, Arg2: &mut PriceFeed, Arg3: address) {
448B0:
449 0: CopyLoc[1](Arg1: &ProtocolConfig)
450 1: Call protocol::check_basic(&ProtocolConfig)
451 2: MoveLoc[1](Arg1: &ProtocolConfig)
452 3: MoveLoc[0](Arg0: &ExchangeManagerCap)
453 4: Call check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
454 5: CopyLoc[3](Arg3: address)
455 6: LdConst[1](address: 0x00..)
456 7: Neq
457 8: BrFalse(10)
458B1:
459 9: Branch(14)
460B2:
461 10: MoveLoc[2](Arg2: &mut PriceFeed)
462 11: Pop
463 12: LdU64(105)
464 13: Abort
465B3:
466 14: MoveLoc[2](Arg2: &mut PriceFeed)
467 15: MoveLoc[3](Arg3: address)
468 16: Call price_feed::set_feeder(&mut PriceFeed, address)
469 17: Ret
470}
471
472entry add_privileged_addresses(Arg0: &ExchangeManagerCap, Arg1: &mut ProtocolConfig, Arg2: vector<address>) {
473L3: loc0: address
474L4: loc1: u64
475L5: loc2: u64
476L6: loc3: &mut VecSet<address>
477B0:
478 0: CopyLoc[1](Arg1: &mut ProtocolConfig)
479 1: FreezeRef
480 2: Call protocol::check_basic(&ProtocolConfig)
481 3: CopyLoc[1](Arg1: &mut ProtocolConfig)
482 4: FreezeRef
483 5: MoveLoc[0](Arg0: &ExchangeManagerCap)
484 6: Call check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
485 7: ImmBorrowLoc[2](Arg2: vector<address>)
486 8: VecLen(26)
487 9: StLoc[5](loc2: u64)
488 10: CopyLoc[5](loc2: u64)
489 11: LdU64(0)
490 12: Gt
491 13: BrFalse(15)
492B1:
493 14: Branch(19)
494B2:
495 15: MoveLoc[1](Arg1: &mut ProtocolConfig)
496 16: Pop
497 17: LdU64(109)
498 18: Abort
499B3:
500 19: LdU64(0)
501 20: StLoc[4](loc1: u64)
502 21: MoveLoc[1](Arg1: &mut ProtocolConfig)
503 22: Call protocol::privileged_addresses_mut(&mut ProtocolConfig): &mut VecSet<address>
504 23: StLoc[6](loc3: &mut VecSet<address>)
505B4:
506 24: CopyLoc[4](loc1: u64)
507 25: CopyLoc[5](loc2: u64)
508 26: Lt
509 27: BrFalse(41)
510B5:
511 28: ImmBorrowLoc[2](Arg2: vector<address>)
512 29: CopyLoc[4](loc1: u64)
513 30: VecImmBorrow(26)
514 31: ReadRef
515 32: StLoc[3](loc0: address)
516 33: CopyLoc[6](loc3: &mut VecSet<address>)
517 34: MoveLoc[3](loc0: address)
518 35: Call vec_set::insert<address>(&mut VecSet<address>, address)
519 36: MoveLoc[4](loc1: u64)
520 37: LdU64(1)
521 38: Add
522 39: StLoc[4](loc1: u64)
523 40: Branch(24)
524B6:
525 41: MoveLoc[6](loc3: &mut VecSet<address>)
526 42: Pop
527 43: Ret
528}
529
530entry remove_privileged_addresses(Arg0: &ExchangeManagerCap, Arg1: &mut ProtocolConfig, Arg2: vector<address>) {
531L3: loc0: &address
532L4: loc1: u64
533L5: loc2: u64
534L6: loc3: &mut VecSet<address>
535B0:
536 0: CopyLoc[1](Arg1: &mut ProtocolConfig)
537 1: FreezeRef
538 2: Call protocol::check_basic(&ProtocolConfig)
539 3: CopyLoc[1](Arg1: &mut ProtocolConfig)
540 4: FreezeRef
541 5: MoveLoc[0](Arg0: &ExchangeManagerCap)
542 6: Call check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
543 7: ImmBorrowLoc[2](Arg2: vector<address>)
544 8: VecLen(26)
545 9: StLoc[5](loc2: u64)
546 10: CopyLoc[5](loc2: u64)
547 11: LdU64(0)
548 12: Gt
549 13: BrFalse(15)
550B1:
551 14: Branch(19)
552B2:
553 15: MoveLoc[1](Arg1: &mut ProtocolConfig)
554 16: Pop
555 17: LdU64(109)
556 18: Abort
557B3:
558 19: LdU64(0)
559 20: StLoc[4](loc1: u64)
560 21: MoveLoc[1](Arg1: &mut ProtocolConfig)
561 22: Call protocol::privileged_addresses_mut(&mut ProtocolConfig): &mut VecSet<address>
562 23: StLoc[6](loc3: &mut VecSet<address>)
563B4:
564 24: CopyLoc[4](loc1: u64)
565 25: CopyLoc[5](loc2: u64)
566 26: Lt
567 27: BrFalse(40)
568B5:
569 28: ImmBorrowLoc[2](Arg2: vector<address>)
570 29: CopyLoc[4](loc1: u64)
571 30: VecImmBorrow(26)
572 31: StLoc[3](loc0: &address)
573 32: CopyLoc[6](loc3: &mut VecSet<address>)
574 33: MoveLoc[3](loc0: &address)
575 34: Call vec_set::remove<address>(&mut VecSet<address>, &address)
576 35: MoveLoc[4](loc1: u64)
577 36: LdU64(1)
578 37: Add
579 38: StLoc[4](loc1: u64)
580 39: Branch(24)
581B6:
582 40: MoveLoc[6](loc3: &mut VecSet<address>)
583 41: Pop
584 42: Ret
585}
586
587public(friend) initialize(Arg0: &mut TxContext): ID * ID * ID * ID {
588L1: loc0: ID
589L2: loc1: ID
590L3: loc2: ID
591L4: loc3: ID
592B0:
593 0: CopyLoc[0](Arg0: &mut TxContext)
594 1: Call create_exchange_admin_cap(&mut TxContext)
595 2: CopyLoc[0](Arg0: &mut TxContext)
596 3: FreezeRef
597 4: Call tx_context::sender(&TxContext): address
598 5: CopyLoc[0](Arg0: &mut TxContext)
599 6: Call create_exchange_manager_cap(address, &mut TxContext): ID
600 7: StLoc[4](loc3: ID)
601 8: CopyLoc[0](Arg0: &mut TxContext)
602 9: FreezeRef
603 10: Call tx_context::sender(&TxContext): address
604 11: CopyLoc[0](Arg0: &mut TxContext)
605 12: Call create_deleveraging_cap(address, &mut TxContext): ID
606 13: StLoc[1](loc0: ID)
607 14: CopyLoc[0](Arg0: &mut TxContext)
608 15: FreezeRef
609 16: Call tx_context::sender(&TxContext): address
610 17: CopyLoc[0](Arg0: &mut TxContext)
611 18: Call create_funding_rate_cap(address, &mut TxContext): ID
612 19: StLoc[2](loc1: ID)
613 20: CopyLoc[0](Arg0: &mut TxContext)
614 21: FreezeRef
615 22: Call tx_context::sender(&TxContext): address
616 23: MoveLoc[0](Arg0: &mut TxContext)
617 24: Call create_insurance_operator_cap(address, &mut TxContext): ID
618 25: StLoc[3](loc2: ID)
619 26: MoveLoc[4](loc3: ID)
620 27: MoveLoc[1](loc0: ID)
621 28: MoveLoc[2](loc1: ID)
622 29: MoveLoc[3](loc2: ID)
623 30: Ret
624}
625
626public(friend) check_manager_validity(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap) {
627B0:
628 0: MoveLoc[0](Arg0: &ProtocolConfig)
629 1: Call protocol::manager_cap_id(&ProtocolConfig): ID
630 2: MoveLoc[1](Arg1: &ExchangeManagerCap)
631 3: ImmBorrowField[0](ExchangeManagerCap.id: UID)
632 4: Call object::uid_to_inner(&UID): ID
633 5: Eq
634 6: BrFalse(8)
635B1:
636 7: Branch(10)
637B2:
638 8: LdU64(111)
639 9: Abort
640B3:
641 10: Ret
642}
643
644public(friend) check_deleveraging_operator_validity(Arg0: &ProtocolConfig, Arg1: &DeleveragingCap) {
645B0:
646 0: MoveLoc[0](Arg0: &ProtocolConfig)
647 1: Call protocol::deleveraging_cap_id(&ProtocolConfig): ID
648 2: MoveLoc[1](Arg1: &DeleveragingCap)
649 3: ImmBorrowField[1](DeleveragingCap.id: UID)
650 4: Call object::uid_to_inner(&UID): ID
651 5: Eq
652 6: BrFalse(8)
653B1:
654 7: Branch(10)
655B2:
656 8: LdU64(113)
657 9: Abort
658B3:
659 10: Ret
660}
661
662public(friend) check_funding_rate_operator_validity(Arg0: &ProtocolConfig, Arg1: &FundingRateCap) {
663B0:
664 0: MoveLoc[0](Arg0: &ProtocolConfig)
665 1: Call protocol::funding_rate_cap_id(&ProtocolConfig): ID
666 2: MoveLoc[1](Arg1: &FundingRateCap)
667 3: ImmBorrowField[2](FundingRateCap.id: UID)
668 4: Call object::uid_to_inner(&UID): ID
669 5: Eq
670 6: BrFalse(8)
671B1:
672 7: Branch(10)
673B2:
674 8: LdU64(101)
675 9: Abort
676B3:
677 10: Ret
678}
679
680public(friend) check_settlement_sender_validity(Arg0: &ProtocolConfig, Arg1: address) {
681B0:
682 0: MoveLoc[0](Arg0: &ProtocolConfig)
683 1: MoveLoc[1](Arg1: address)
684 2: Call protocol::settlement_operator_address_exists(&ProtocolConfig, address): bool
685 3: BrFalse(5)
686B1:
687 4: Branch(7)
688B2:
689 5: LdU64(110)
690 6: Abort
691B3:
692 7: Ret
693}
694
695public(friend) check_insurance_operator_validity(Arg0: &ProtocolConfig, Arg1: &InsuranceOperatorCap) {
696B0:
697 0: MoveLoc[0](Arg0: &ProtocolConfig)
698 1: Call protocol::insurance_operator_cap_id(&ProtocolConfig): ID
699 2: MoveLoc[1](Arg1: &InsuranceOperatorCap)
700 3: ImmBorrowField[3](InsuranceOperatorCap.id: UID)
701 4: Call object::uid_to_inner(&UID): ID
702 5: Eq
703 6: BrFalse(8)
704B1:
705 7: Branch(10)
706B2:
707 8: LdU64(119)
708 9: Abort
709B3:
710 10: Ret
711}
712
713create_exchange_admin_cap(Arg0: &mut TxContext) {
714B0:
715 0: CopyLoc[0](Arg0: &mut TxContext)
716 1: Call object::new(&mut TxContext): UID
717 2: Pack[11](ExchangeAdminCap)
718 3: CopyLoc[0](Arg0: &mut TxContext)
719 4: FreezeRef
720 5: Call tx_context::sender(&TxContext): address
721 6: Call transfer::transfer<ExchangeAdminCap>(ExchangeAdminCap, address)
722 7: MoveLoc[0](Arg0: &mut TxContext)
723 8: FreezeRef
724 9: Call tx_context::sender(&TxContext): address
725 10: Pack[0](ExchangeAdminUpdateEvent)
726 11: Call event::emit<ExchangeAdminUpdateEvent>(ExchangeAdminUpdateEvent)
727 12: Ret
728}
729
730create_exchange_manager_cap(Arg0: address, Arg1: &mut TxContext): ID {
731L2: loc0: UID
732L3: loc1: ID
733B0:
734 0: MoveLoc[1](Arg1: &mut TxContext)
735 1: Call object::new(&mut TxContext): UID
736 2: StLoc[2](loc0: UID)
737 3: ImmBorrowLoc[2](loc0: UID)
738 4: Call object::uid_to_inner(&UID): ID
739 5: StLoc[3](loc1: ID)
740 6: MoveLoc[2](loc0: UID)
741 7: Pack[12](ExchangeManagerCap)
742 8: CopyLoc[0](Arg0: address)
743 9: Call transfer::transfer<ExchangeManagerCap>(ExchangeManagerCap, address)
744 10: CopyLoc[3](loc1: ID)
745 11: MoveLoc[0](Arg0: address)
746 12: Pack[3](ExchangeManagerUpdateEvent)
747 13: Call event::emit<ExchangeManagerUpdateEvent>(ExchangeManagerUpdateEvent)
748 14: MoveLoc[3](loc1: ID)
749 15: Ret
750}
751
752create_deleveraging_cap(Arg0: address, Arg1: &mut TxContext): ID {
753L2: loc0: ID
754L3: loc1: UID
755B0:
756 0: MoveLoc[1](Arg1: &mut TxContext)
757 1: Call object::new(&mut TxContext): UID
758 2: StLoc[3](loc1: UID)
759 3: ImmBorrowLoc[3](loc1: UID)
760 4: Call object::uid_to_inner(&UID): ID
761 5: StLoc[2](loc0: ID)
762 6: MoveLoc[3](loc1: UID)
763 7: Pack[14](DeleveragingCap)
764 8: CopyLoc[0](Arg0: address)
765 9: Call transfer::transfer<DeleveragingCap>(DeleveragingCap, address)
766 10: CopyLoc[2](loc0: ID)
767 11: MoveLoc[0](Arg0: address)
768 12: Pack[8](DelevergingOperatorUpdateEvent)
769 13: Call event::emit<DelevergingOperatorUpdateEvent>(DelevergingOperatorUpdateEvent)
770 14: MoveLoc[2](loc0: ID)
771 15: Ret
772}
773
774create_funding_rate_cap(Arg0: address, Arg1: &mut TxContext): ID {
775L2: loc0: ID
776L3: loc1: UID
777B0:
778 0: MoveLoc[1](Arg1: &mut TxContext)
779 1: Call object::new(&mut TxContext): UID
780 2: StLoc[3](loc1: UID)
781 3: ImmBorrowLoc[3](loc1: UID)
782 4: Call object::uid_to_inner(&UID): ID
783 5: StLoc[2](loc0: ID)
784 6: MoveLoc[3](loc1: UID)
785 7: Pack[15](FundingRateCap)
786 8: CopyLoc[0](Arg0: address)
787 9: Call transfer::transfer<FundingRateCap>(FundingRateCap, address)
788 10: CopyLoc[2](loc0: ID)
789 11: MoveLoc[0](Arg0: address)
790 12: Pack[9](FundingRateOperatorUpdateEvent)
791 13: Call event::emit<FundingRateOperatorUpdateEvent>(FundingRateOperatorUpdateEvent)
792 14: MoveLoc[2](loc0: ID)
793 15: Ret
794}
795
796public(friend) create_insurance_operator_cap(Arg0: address, Arg1: &mut TxContext): ID {
797L2: loc0: UID
798L3: loc1: ID
799B0:
800 0: MoveLoc[1](Arg1: &mut TxContext)
801 1: Call object::new(&mut TxContext): UID
802 2: StLoc[2](loc0: UID)
803 3: ImmBorrowLoc[2](loc0: UID)
804 4: Call object::uid_to_inner(&UID): ID
805 5: StLoc[3](loc1: ID)
806 6: MoveLoc[2](loc0: UID)
807 7: Pack[16](InsuranceOperatorCap)
808 8: CopyLoc[0](Arg0: address)
809 9: Call transfer::transfer<InsuranceOperatorCap>(InsuranceOperatorCap, address)
810 10: CopyLoc[3](loc1: ID)
811 11: MoveLoc[0](Arg0: address)
812 12: Pack[10](InsuranceOperatorUpdateEvent)
813 13: Call event::emit<InsuranceOperatorUpdateEvent>(InsuranceOperatorUpdateEvent)
814 14: MoveLoc[3](loc1: ID)
815 15: Ret
816}
817
818Constants [
819 0 => u128: 500000000
820 1 => address: 0x0000000000000000000000000000000000000000000000000000000000000000
821]
822}
823
0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/s128.mvb688 lines
1// Move bytecode v7
2module 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001.s128 {
3use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::library;
4
5struct S128 has copy, drop, store {
6 value: u128,
7 sign: bool
8}
9
10public(friend) zero(): S128 {
11B0:
12 0: LdU128(0)
13 1: LdTrue
14 2: Pack[0](S128)
15 3: Ret
16}
17
18public(friend) from(Arg0: u128, Arg1: bool): S128 {
19L2: loc0: S128
20B0:
21 0: MoveLoc[0](Arg0: u128)
22 1: MoveLoc[1](Arg1: bool)
23 2: Pack[0](S128)
24 3: StLoc[2](loc0: S128)
25 4: MutBorrowLoc[2](loc0: S128)
26 5: Call normalize_zero(&mut S128)
27 6: MoveLoc[2](loc0: S128)
28 7: Ret
29}
30
31public(friend) one(): S128 {
32B0:
33 0: Call library::base_uint(): u128
34 1: LdTrue
35 2: Pack[0](S128)
36 3: Ret
37}
38
39public(friend) add_u128(Arg0: S128, Arg1: u128): S128 {
40L2: loc0: bool
41L3: loc1: u128
42B0:
43 0: ImmBorrowLoc[0](Arg0: S128)
44 1: ImmBorrowField[0](S128.value: u128)
45 2: ReadRef
46 3: StLoc[3](loc1: u128)
47 4: ImmBorrowLoc[0](Arg0: S128)
48 5: ImmBorrowField[1](S128.sign: bool)
49 6: ReadRef
50 7: StLoc[2](loc0: bool)
51 8: CopyLoc[2](loc0: bool)
52 9: LdTrue
53 10: Eq
54 11: BrFalse(17)
55B1:
56 12: MoveLoc[3](loc1: u128)
57 13: MoveLoc[1](Arg1: u128)
58 14: Add
59 15: StLoc[3](loc1: u128)
60 16: Branch(32)
61B2:
62 17: CopyLoc[3](loc1: u128)
63 18: CopyLoc[1](Arg1: u128)
64 19: Gt
65 20: BrFalse(26)
66B3:
67 21: MoveLoc[3](loc1: u128)
68 22: MoveLoc[1](Arg1: u128)
69 23: Sub
70 24: StLoc[3](loc1: u128)
71 25: Branch(32)
72B4:
73 26: MoveLoc[1](Arg1: u128)
74 27: MoveLoc[3](loc1: u128)
75 28: Sub
76 29: StLoc[3](loc1: u128)
77 30: LdTrue
78 31: StLoc[2](loc0: bool)
79B5:
80 32: MoveLoc[3](loc1: u128)
81 33: MoveLoc[2](loc0: bool)
82 34: Call from(u128, bool): S128
83 35: Ret
84}
85
86public(friend) sub_u128(Arg0: S128, Arg1: u128): S128 {
87L2: loc0: bool
88L3: loc1: u128
89B0:
90 0: ImmBorrowLoc[0](Arg0: S128)
91 1: ImmBorrowField[0](S128.value: u128)
92 2: ReadRef
93 3: StLoc[3](loc1: u128)
94 4: ImmBorrowLoc[0](Arg0: S128)
95 5: ImmBorrowField[1](S128.sign: bool)
96 6: ReadRef
97 7: StLoc[2](loc0: bool)
98 8: CopyLoc[2](loc0: bool)
99 9: LdFalse
100 10: Eq
101 11: BrFalse(17)
102B1:
103 12: MoveLoc[3](loc1: u128)
104 13: MoveLoc[1](Arg1: u128)
105 14: Add
106 15: StLoc[3](loc1: u128)
107 16: Branch(32)
108B2:
109 17: CopyLoc[3](loc1: u128)
110 18: CopyLoc[1](Arg1: u128)
111 19: Gt
112 20: BrFalse(26)
113B3:
114 21: MoveLoc[3](loc1: u128)
115 22: MoveLoc[1](Arg1: u128)
116 23: Sub
117 24: StLoc[3](loc1: u128)
118 25: Branch(32)
119B4:
120 26: MoveLoc[1](Arg1: u128)
121 27: MoveLoc[3](loc1: u128)
122 28: Sub
123 29: StLoc[3](loc1: u128)
124 30: LdFalse
125 31: StLoc[2](loc0: bool)
126B5:
127 32: MoveLoc[3](loc1: u128)
128 33: MoveLoc[2](loc0: bool)
129 34: Call from(u128, bool): S128
130 35: Ret
131}
132
133public(friend) mul_u128(Arg0: S128, Arg1: u128): S128 {
134B0:
135 0: ImmBorrowLoc[0](Arg0: S128)
136 1: ImmBorrowField[0](S128.value: u128)
137 2: ReadRef
138 3: MoveLoc[1](Arg1: u128)
139 4: Call library::base_mul(u128, u128): u128
140 5: ImmBorrowLoc[0](Arg0: S128)
141 6: ImmBorrowField[1](S128.sign: bool)
142 7: ReadRef
143 8: Call from(u128, bool): S128
144 9: Ret
145}
146
147public(friend) mul_u128_up(Arg0: S128, Arg1: u128): S128 {
148B0:
149 0: ImmBorrowLoc[0](Arg0: S128)
150 1: ImmBorrowField[0](S128.value: u128)
151 2: ReadRef
152 3: MoveLoc[1](Arg1: u128)
153 4: Call library::base_mul_up(u128, u128): u128
154 5: ImmBorrowLoc[0](Arg0: S128)
155 6: ImmBorrowField[1](S128.sign: bool)
156 7: ReadRef
157 8: Call from(u128, bool): S128
158 9: Ret
159}
160
161public(friend) div_u128(Arg0: S128, Arg1: u128): S128 {
162B0:
163 0: ImmBorrowLoc[0](Arg0: S128)
164 1: ImmBorrowField[0](S128.value: u128)
165 2: ReadRef
166 3: MoveLoc[1](Arg1: u128)
167 4: Call library::base_div(u128, u128): u128
168 5: ImmBorrowLoc[0](Arg0: S128)
169 6: ImmBorrowField[1](S128.sign: bool)
170 7: ReadRef
171 8: Call from(u128, bool): S128
172 9: Ret
173}
174
175public(friend) negate(Arg0: S128): S128 {
176B0:
177 0: ImmBorrowLoc[0](Arg0: S128)
178 1: ImmBorrowField[0](S128.value: u128)
179 2: ReadRef
180 3: ImmBorrowLoc[0](Arg0: S128)
181 4: ImmBorrowField[1](S128.sign: bool)
182 5: ReadRef
183 6: Not
184 7: Call from(u128, bool): S128
185 8: Ret
186}
187
188public(friend) add(Arg0: S128, Arg1: S128): S128 {
189L2: loc0: bool
190L3: loc1: u128
191B0:
192 0: ImmBorrowLoc[0](Arg0: S128)
193 1: ImmBorrowField[1](S128.sign: bool)
194 2: ReadRef
195 3: ImmBorrowLoc[1](Arg1: S128)
196 4: ImmBorrowField[1](S128.sign: bool)
197 5: ReadRef
198 6: Eq
199 7: BrFalse(21)
200B1:
201 8: ImmBorrowLoc[0](Arg0: S128)
202 9: ImmBorrowField[0](S128.value: u128)
203 10: ReadRef
204 11: ImmBorrowLoc[1](Arg1: S128)
205 12: ImmBorrowField[0](S128.value: u128)
206 13: ReadRef
207 14: Add
208 15: StLoc[3](loc1: u128)
209 16: ImmBorrowLoc[0](Arg0: S128)
210 17: ImmBorrowField[1](S128.sign: bool)
211 18: ReadRef
212 19: StLoc[2](loc0: bool)
213 20: Branch(54)
214B2:
215 21: ImmBorrowLoc[0](Arg0: S128)
216 22: ImmBorrowField[0](S128.value: u128)
217 23: ReadRef
218 24: ImmBorrowLoc[1](Arg1: S128)
219 25: ImmBorrowField[0](S128.value: u128)
220 26: ReadRef
221 27: Ge
222 28: BrFalse(42)
223B3:
224 29: ImmBorrowLoc[0](Arg0: S128)
225 30: ImmBorrowField[0](S128.value: u128)
226 31: ReadRef
227 32: ImmBorrowLoc[1](Arg1: S128)
228 33: ImmBorrowField[0](S128.value: u128)
229 34: ReadRef
230 35: Sub
231 36: StLoc[3](loc1: u128)
232 37: ImmBorrowLoc[0](Arg0: S128)
233 38: ImmBorrowField[1](S128.sign: bool)
234 39: ReadRef
235 40: StLoc[2](loc0: bool)
236 41: Branch(54)
237B4:
238 42: ImmBorrowLoc[1](Arg1: S128)
239 43: ImmBorrowField[0](S128.value: u128)
240 44: ReadRef
241 45: ImmBorrowLoc[0](Arg0: S128)
242 46: ImmBorrowField[0](S128.value: u128)
243 47: ReadRef
244 48: Sub
245 49: StLoc[3](loc1: u128)
246 50: ImmBorrowLoc[1](Arg1: S128)
247 51: ImmBorrowField[1](S128.sign: bool)
248 52: ReadRef
249 53: StLoc[2](loc0: bool)
250B5:
251 54: MoveLoc[3](loc1: u128)
252 55: MoveLoc[2](loc0: bool)
253 56: Call from(u128, bool): S128
254 57: Ret
255}
256
257public(friend) sub(Arg0: S128, Arg1: S128): S128 {
258L2: loc0: bool
259L3: loc1: u128
260B0:
261 0: ImmBorrowLoc[1](Arg1: S128)
262 1: ImmBorrowField[1](S128.sign: bool)
263 2: ReadRef
264 3: Not
265 4: MutBorrowLoc[1](Arg1: S128)
266 5: MutBorrowField[1](S128.sign: bool)
267 6: WriteRef
268 7: ImmBorrowLoc[0](Arg0: S128)
269 8: ImmBorrowField[1](S128.sign: bool)
270 9: ReadRef
271 10: ImmBorrowLoc[1](Arg1: S128)
272 11: ImmBorrowField[1](S128.sign: bool)
273 12: ReadRef
274 13: Eq
275 14: BrFalse(28)
276B1:
277 15: ImmBorrowLoc[0](Arg0: S128)
278 16: ImmBorrowField[0](S128.value: u128)
279 17: ReadRef
280 18: ImmBorrowLoc[1](Arg1: S128)
281 19: ImmBorrowField[0](S128.value: u128)
282 20: ReadRef
283 21: Add
284 22: StLoc[3](loc1: u128)
285 23: ImmBorrowLoc[0](Arg0: S128)
286 24: ImmBorrowField[1](S128.sign: bool)
287 25: ReadRef
288 26: StLoc[2](loc0: bool)
289 27: Branch(61)
290B2:
291 28: ImmBorrowLoc[0](Arg0: S128)
292 29: ImmBorrowField[0](S128.value: u128)
293 30: ReadRef
294 31: ImmBorrowLoc[1](Arg1: S128)
295 32: ImmBorrowField[0](S128.value: u128)
296 33: ReadRef
297 34: Ge
298 35: BrFalse(49)
299B3:
300 36: ImmBorrowLoc[0](Arg0: S128)
301 37: ImmBorrowField[0](S128.value: u128)
302 38: ReadRef
303 39: ImmBorrowLoc[1](Arg1: S128)
304 40: ImmBorrowField[0](S128.value: u128)
305 41: ReadRef
306 42: Sub
307 43: StLoc[3](loc1: u128)
308 44: ImmBorrowLoc[0](Arg0: S128)
309 45: ImmBorrowField[1](S128.sign: bool)
310 46: ReadRef
311 47: StLoc[2](loc0: bool)
312 48: Branch(61)
313B4:
314 49: ImmBorrowLoc[1](Arg1: S128)
315 50: ImmBorrowField[0](S128.value: u128)
316 51: ReadRef
317 52: ImmBorrowLoc[0](Arg0: S128)
318 53: ImmBorrowField[0](S128.value: u128)
319 54: ReadRef
320 55: Sub
321 56: StLoc[3](loc1: u128)
322 57: ImmBorrowLoc[1](Arg1: S128)
323 58: ImmBorrowField[1](S128.sign: bool)
324 59: ReadRef
325 60: StLoc[2](loc0: bool)
326B5:
327 61: MoveLoc[3](loc1: u128)
328 62: MoveLoc[2](loc0: bool)
329 63: Call from(u128, bool): S128
330 64: Ret
331}
332
333public(friend) gte_u128(Arg0: S128, Arg1: u128): bool {
334L2: loc0: bool
335B0:
336 0: ImmBorrowLoc[0](Arg0: S128)
337 1: ImmBorrowField[1](S128.sign: bool)
338 2: ReadRef
339 3: Not
340 4: BrFalse(8)
341B1:
342 5: LdFalse
343 6: StLoc[2](loc0: bool)
344 7: Branch(14)
345B2:
346 8: ImmBorrowLoc[0](Arg0: S128)
347 9: ImmBorrowField[0](S128.value: u128)
348 10: ReadRef
349 11: MoveLoc[1](Arg1: u128)
350 12: Ge
351 13: StLoc[2](loc0: bool)
352B3:
353 14: MoveLoc[2](loc0: bool)
354 15: Ret
355}
356
357public(friend) gt_u128(Arg0: S128, Arg1: u128): bool {
358L2: loc0: bool
359B0:
360 0: ImmBorrowLoc[0](Arg0: S128)
361 1: ImmBorrowField[1](S128.sign: bool)
362 2: ReadRef
363 3: Not
364 4: BrFalse(8)
365B1:
366 5: LdFalse
367 6: StLoc[2](loc0: bool)
368 7: Branch(14)
369B2:
370 8: ImmBorrowLoc[0](Arg0: S128)
371 9: ImmBorrowField[0](S128.value: u128)
372 10: ReadRef
373 11: MoveLoc[1](Arg1: u128)
374 12: Gt
375 13: StLoc[2](loc0: bool)
376B3:
377 14: MoveLoc[2](loc0: bool)
378 15: Ret
379}
380
381public(friend) lt_u128(Arg0: S128, Arg1: u128): bool {
382L2: loc0: bool
383B0:
384 0: ImmBorrowLoc[0](Arg0: S128)
385 1: ImmBorrowField[1](S128.sign: bool)
386 2: ReadRef
387 3: Not
388 4: BrFalse(8)
389B1:
390 5: LdTrue
391 6: StLoc[2](loc0: bool)
392 7: Branch(14)
393B2:
394 8: ImmBorrowLoc[0](Arg0: S128)
395 9: ImmBorrowField[0](S128.value: u128)
396 10: ReadRef
397 11: MoveLoc[1](Arg1: u128)
398 12: Lt
399 13: StLoc[2](loc0: bool)
400B3:
401 14: MoveLoc[2](loc0: bool)
402 15: Ret
403}
404
405public(friend) lte_u128(Arg0: S128, Arg1: u128): bool {
406L2: loc0: bool
407B0:
408 0: ImmBorrowLoc[0](Arg0: S128)
409 1: ImmBorrowField[1](S128.sign: bool)
410 2: ReadRef
411 3: Not
412 4: BrFalse(8)
413B1:
414 5: LdTrue
415 6: StLoc[2](loc0: bool)
416 7: Branch(14)
417B2:
418 8: ImmBorrowLoc[0](Arg0: S128)
419 9: ImmBorrowField[0](S128.value: u128)
420 10: ReadRef
421 11: MoveLoc[1](Arg1: u128)
422 12: Le
423 13: StLoc[2](loc0: bool)
424B3:
425 14: MoveLoc[2](loc0: bool)
426 15: Ret
427}
428
429public(friend) gte(Arg0: S128, Arg1: S128): bool {
430L2: loc0: bool
431L3: loc1: bool
432B0:
433 0: ImmBorrowLoc[0](Arg0: S128)
434 1: ImmBorrowField[1](S128.sign: bool)
435 2: ReadRef
436 3: BrFalse(9)
437B1:
438 4: ImmBorrowLoc[1](Arg1: S128)
439 5: ImmBorrowField[1](S128.sign: bool)
440 6: ReadRef
441 7: StLoc[2](loc0: bool)
442 8: Branch(11)
443B2:
444 9: LdFalse
445 10: StLoc[2](loc0: bool)
446B3:
447 11: MoveLoc[2](loc0: bool)
448 12: BrFalse(21)
449B4:
450 13: ImmBorrowLoc[0](Arg0: S128)
451 14: ImmBorrowField[0](S128.value: u128)
452 15: ReadRef
453 16: ImmBorrowLoc[1](Arg1: S128)
454 17: ImmBorrowField[0](S128.value: u128)
455 18: ReadRef
456 19: Ge
457 20: Ret
458B5:
459 21: ImmBorrowLoc[0](Arg0: S128)
460 22: ImmBorrowField[1](S128.sign: bool)
461 23: ReadRef
462 24: Not
463 25: BrFalse(32)
464B6:
465 26: ImmBorrowLoc[1](Arg1: S128)
466 27: ImmBorrowField[1](S128.sign: bool)
467 28: ReadRef
468 29: Not
469 30: StLoc[3](loc1: bool)
470 31: Branch(34)
471B7:
472 32: LdFalse
473 33: StLoc[3](loc1: bool)
474B8:
475 34: MoveLoc[3](loc1: bool)
476 35: BrFalse(44)
477B9:
478 36: ImmBorrowLoc[0](Arg0: S128)
479 37: ImmBorrowField[0](S128.value: u128)
480 38: ReadRef
481 39: ImmBorrowLoc[1](Arg1: S128)
482 40: ImmBorrowField[0](S128.value: u128)
483 41: ReadRef
484 42: Le
485 43: Ret
486B10:
487 44: ImmBorrowLoc[0](Arg0: S128)
488 45: ImmBorrowField[1](S128.sign: bool)
489 46: ReadRef
490 47: Ret
491}
492
493public(friend) gt(Arg0: S128, Arg1: S128): bool {
494L2: loc0: bool
495L3: loc1: bool
496B0:
497 0: ImmBorrowLoc[0](Arg0: S128)
498 1: ImmBorrowField[1](S128.sign: bool)
499 2: ReadRef
500 3: BrFalse(9)
501B1:
502 4: ImmBorrowLoc[1](Arg1: S128)
503 5: ImmBorrowField[1](S128.sign: bool)
504 6: ReadRef
505 7: StLoc[2](loc0: bool)
506 8: Branch(11)
507B2:
508 9: LdFalse
509 10: StLoc[2](loc0: bool)
510B3:
511 11: MoveLoc[2](loc0: bool)
512 12: BrFalse(21)
513B4:
514 13: ImmBorrowLoc[0](Arg0: S128)
515 14: ImmBorrowField[0](S128.value: u128)
516 15: ReadRef
517 16: ImmBorrowLoc[1](Arg1: S128)
518 17: ImmBorrowField[0](S128.value: u128)
519 18: ReadRef
520 19: Gt
521 20: Ret
522B5:
523 21: ImmBorrowLoc[0](Arg0: S128)
524 22: ImmBorrowField[1](S128.sign: bool)
525 23: ReadRef
526 24: Not
527 25: BrFalse(32)
528B6:
529 26: ImmBorrowLoc[1](Arg1: S128)
530 27: ImmBorrowField[1](S128.sign: bool)
531 28: ReadRef
532 29: Not
533 30: StLoc[3](loc1: bool)
534 31: Branch(34)
535B7:
536 32: LdFalse
537 33: StLoc[3](loc1: bool)
538B8:
539 34: MoveLoc[3](loc1: bool)
540 35: BrFalse(44)
541B9:
542 36: ImmBorrowLoc[0](Arg0: S128)
543 37: ImmBorrowField[0](S128.value: u128)
544 38: ReadRef
545 39: ImmBorrowLoc[1](Arg1: S128)
546 40: ImmBorrowField[0](S128.value: u128)
547 41: ReadRef
548 42: Lt
549 43: Ret
550B10:
551 44: ImmBorrowLoc[0](Arg0: S128)
552 45: ImmBorrowField[1](S128.sign: bool)
553 46: ReadRef
554 47: Ret
555}
556
557public(friend) from_subtraction(Arg0: u128, Arg1: u128): S128 {
558L2: loc0: S128
559B0:
560 0: CopyLoc[0](Arg0: u128)
561 1: CopyLoc[1](Arg1: u128)
562 2: Ge
563 3: BrFalse(11)
564B1:
565 4: MoveLoc[0](Arg0: u128)
566 5: MoveLoc[1](Arg1: u128)
567 6: Sub
568 7: LdTrue
569 8: Pack[0](S128)
570 9: StLoc[2](loc0: S128)
571 10: Branch(17)
572B2:
573 11: MoveLoc[1](Arg1: u128)
574 12: MoveLoc[0](Arg0: u128)
575 13: Sub
576 14: LdFalse
577 15: Pack[0](S128)
578 16: StLoc[2](loc0: S128)
579B3:
580 17: MoveLoc[2](loc0: S128)
581 18: Ret
582}
583
584public(friend) value(Arg0: S128): u128 {
585B0:
586 0: ImmBorrowLoc[0](Arg0: S128)
587 1: ImmBorrowField[0](S128.value: u128)
588 2: ReadRef
589 3: Ret
590}
591
592public(friend) sign(Arg0: S128): bool {
593B0:
594 0: ImmBorrowLoc[0](Arg0: S128)
595 1: ImmBorrowField[1](S128.sign: bool)
596 2: ReadRef
597 3: Ret
598}
599
600public(friend) positive_value(Arg0: S128): u128 {
601L1: loc0: u128
602B0:
603 0: ImmBorrowLoc[0](Arg0: S128)
604 1: ImmBorrowField[1](S128.sign: bool)
605 2: ReadRef
606 3: Not
607 4: BrFalse(8)
608B1:
609 5: LdU128(0)
610 6: StLoc[1](loc0: u128)
611 7: Branch(12)
612B2:
613 8: ImmBorrowLoc[0](Arg0: S128)
614 9: ImmBorrowField[0](S128.value: u128)
615 10: ReadRef
616 11: StLoc[1](loc0: u128)
617B3:
618 12: MoveLoc[1](loc0: u128)
619 13: Ret
620}
621
622public(friend) positive_number(Arg0: S128): S128 {
623L1: loc0: S128
624B0:
625 0: ImmBorrowLoc[0](Arg0: S128)
626 1: ImmBorrowField[1](S128.sign: bool)
627 2: ReadRef
628 3: Not
629 4: BrFalse(10)
630B1:
631 5: LdU128(0)
632 6: LdTrue
633 7: Pack[0](S128)
634 8: StLoc[1](loc0: S128)
635 9: Branch(12)
636B2:
637 10: MoveLoc[0](Arg0: S128)
638 11: StLoc[1](loc0: S128)
639B3:
640 12: MoveLoc[1](loc0: S128)
641 13: Ret
642}
643
644public(friend) negative_number(Arg0: S128): S128 {
645L1: loc0: S128
646B0:
647 0: ImmBorrowLoc[0](Arg0: S128)
648 1: ImmBorrowField[1](S128.sign: bool)
649 2: ReadRef
650 3: Not
651 4: BrFalse(8)
652B1:
653 5: MoveLoc[0](Arg0: S128)
654 6: StLoc[1](loc0: S128)
655 7: Branch(12)
656B2:
657 8: LdU128(0)
658 9: LdTrue
659 10: Pack[0](S128)
660 11: StLoc[1](loc0: S128)
661B3:
662 12: MoveLoc[1](loc0: S128)
663 13: Ret
664}
665
666normalize_zero(Arg0: &mut S128) {
667B0:
668 0: CopyLoc[0](Arg0: &mut S128)
669 1: ImmBorrowField[0](S128.value: u128)
670 2: ReadRef
671 3: LdU128(0)
672 4: Eq
673 5: BrFalse(11)
674B1:
675 6: LdTrue
676 7: MoveLoc[0](Arg0: &mut S128)
677 8: MutBorrowField[1](S128.sign: bool)
678 9: WriteRef
679 10: Branch(13)
680B2:
681 11: MoveLoc[0](Arg0: &mut S128)
682 12: Pop
683B3:
684 13: Ret
685}
686
687}
688
0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/settlement.mvb280 lines
1// Move bytecode v7
2module 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001.settlement {
3use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::bank;
4use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::library;
5use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::position;
6use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::s128;
7
8public(friend) trade_margin_settlement<Ty0>(Arg0: &mut Bank<Ty0>, Arg1: address, Arg2: address, Arg3: address, Arg4: S128, Arg5: S128, Arg6: u128) {
9B0:
10 0: CopyLoc[0](Arg0: &mut Bank<Ty0>)
11 1: FreezeRef
12 2: CopyLoc[2](Arg2: address)
13 3: Call bank::exists_account<Ty0>(&Bank<Ty0>, address): bool
14 4: BrFalse(6)
15B1:
16 5: Branch(10)
17B2:
18 6: MoveLoc[0](Arg0: &mut Bank<Ty0>)
19 7: Pop
20 8: LdU64(605)
21 9: Abort
22B3:
23 10: CopyLoc[0](Arg0: &mut Bank<Ty0>)
24 11: FreezeRef
25 12: CopyLoc[3](Arg3: address)
26 13: Call bank::exists_account<Ty0>(&Bank<Ty0>, address): bool
27 14: BrFalse(16)
28B4:
29 15: Branch(20)
30B5:
31 16: MoveLoc[0](Arg0: &mut Bank<Ty0>)
32 17: Pop
33 18: LdU64(605)
34 19: Abort
35B6:
36 20: CopyLoc[4](Arg4: S128)
37 21: LdU128(0)
38 22: Call s128::gte_u128(S128, u128): bool
39 23: BrFalse(39)
40B7:
41 24: CopyLoc[0](Arg0: &mut Bank<Ty0>)
42 25: CopyLoc[1](Arg1: address)
43 26: MoveLoc[2](Arg2: address)
44 27: MoveLoc[4](Arg4: S128)
45 28: LdU64(0)
46 29: CopyLoc[6](Arg6: u128)
47 30: Call transfer_based_on_fundsflow<Ty0>(&mut Bank<Ty0>, address, address, S128, u64, u128)
48 31: MoveLoc[0](Arg0: &mut Bank<Ty0>)
49 32: MoveLoc[1](Arg1: address)
50 33: MoveLoc[3](Arg3: address)
51 34: MoveLoc[5](Arg5: S128)
52 35: LdU64(1)
53 36: MoveLoc[6](Arg6: u128)
54 37: Call transfer_based_on_fundsflow<Ty0>(&mut Bank<Ty0>, address, address, S128, u64, u128)
55 38: Branch(53)
56B8:
57 39: CopyLoc[0](Arg0: &mut Bank<Ty0>)
58 40: CopyLoc[1](Arg1: address)
59 41: MoveLoc[3](Arg3: address)
60 42: MoveLoc[5](Arg5: S128)
61 43: LdU64(1)
62 44: CopyLoc[6](Arg6: u128)
63 45: Call transfer_based_on_fundsflow<Ty0>(&mut Bank<Ty0>, address, address, S128, u64, u128)
64 46: MoveLoc[0](Arg0: &mut Bank<Ty0>)
65 47: MoveLoc[1](Arg1: address)
66 48: MoveLoc[2](Arg2: address)
67 49: MoveLoc[4](Arg4: S128)
68 50: LdU64(0)
69 51: MoveLoc[6](Arg6: u128)
70 52: Call transfer_based_on_fundsflow<Ty0>(&mut Bank<Ty0>, address, address, S128, u64, u128)
71B9:
72 53: Ret
73}
74
75public(friend) get_margin_left(Arg0: &Position, Arg1: u128, Arg2: u128): u128 {
76L3: loc0: u128
77L4: loc1: u128
78L5: loc2: u128
79L6: loc3: u128
80B0:
81 0: CopyLoc[0](Arg0: &Position)
82 1: Call position::compute_average_entry_price(&Position): u128
83 2: StLoc[6](loc3: u128)
84 3: CopyLoc[0](Arg0: &Position)
85 4: Call position::margin(&Position): u128
86 5: StLoc[3](loc0: u128)
87 6: CopyLoc[0](Arg0: &Position)
88 7: Call position::oi_open(&Position): u128
89 8: StLoc[5](loc2: u128)
90 9: MoveLoc[0](Arg0: &Position)
91 10: Call position::is_long(&Position): bool
92 11: BrFalse(23)
93B1:
94 12: MoveLoc[3](loc0: u128)
95 13: CopyLoc[5](loc2: u128)
96 14: MoveLoc[1](Arg1: u128)
97 15: Mul
98 16: MoveLoc[6](loc3: u128)
99 17: Div
100 18: Add
101 19: MoveLoc[5](loc2: u128)
102 20: Call library::sub(u128, u128): u128
103 21: StLoc[4](loc1: u128)
104 22: Branch(33)
105B2:
106 23: MoveLoc[3](loc0: u128)
107 24: CopyLoc[5](loc2: u128)
108 25: Add
109 26: MoveLoc[5](loc2: u128)
110 27: MoveLoc[1](Arg1: u128)
111 28: Mul
112 29: MoveLoc[6](loc3: u128)
113 30: Div
114 31: Call library::sub(u128, u128): u128
115 32: StLoc[4](loc1: u128)
116B3:
117 33: MoveLoc[4](loc1: u128)
118 34: MoveLoc[2](Arg2: u128)
119 35: Call library::min(u128, u128): u128
120 36: Ret
121}
122
123public(friend) get_target_margin(Arg0: &Position, Arg1: u128, Arg2: u128): u128 {
124L3: loc0: u128
125L4: loc1: u128
126L5: loc2: u128
127L6: loc3: u128
128B0:
129 0: CopyLoc[0](Arg0: &Position)
130 1: Call position::oi_open(&Position): u128
131 2: StLoc[4](loc1: u128)
132 3: CopyLoc[0](Arg0: &Position)
133 4: Call position::size(&Position): u128
134 5: MoveLoc[2](Arg2: u128)
135 6: Call library::base_mul(u128, u128): u128
136 7: StLoc[3](loc0: u128)
137 8: CopyLoc[3](loc0: u128)
138 9: MoveLoc[1](Arg1: u128)
139 10: Call library::base_div(u128, u128): u128
140 11: StLoc[6](loc3: u128)
141 12: MoveLoc[0](Arg0: &Position)
142 13: Call position::is_long(&Position): bool
143 14: BrFalse(22)
144B1:
145 15: MoveLoc[6](loc3: u128)
146 16: MoveLoc[4](loc1: u128)
147 17: Add
148 18: MoveLoc[3](loc0: u128)
149 19: Call library::sub(u128, u128): u128
150 20: StLoc[5](loc2: u128)
151 21: Branch(28)
152B2:
153 22: MoveLoc[6](loc3: u128)
154 23: MoveLoc[3](loc0: u128)
155 24: Add
156 25: MoveLoc[4](loc1: u128)
157 26: Call library::sub(u128, u128): u128
158 27: StLoc[5](loc2: u128)
159B3:
160 28: MoveLoc[5](loc2: u128)
161 29: Ret
162}
163
164public(friend) get_max_removeable_margin(Arg0: Position, Arg1: u128): u128 {
165L2: loc0: u128
166L3: loc1: u128
167L4: loc2: u128
168L5: loc3: u128
169L6: loc4: u128
170L7: loc5: u128
171L8: loc6: u128
172L9: loc7: u128
173L10: loc8: u128
174B0:
175 0: ImmBorrowLoc[0](Arg0: Position)
176 1: Call position::mro(&Position): u128
177 2: StLoc[6](loc4: u128)
178 3: ImmBorrowLoc[0](Arg0: Position)
179 4: Call position::margin(&Position): u128
180 5: StLoc[2](loc0: u128)
181 6: ImmBorrowLoc[0](Arg0: Position)
182 7: Call position::oi_open(&Position): u128
183 8: StLoc[8](loc6: u128)
184 9: ImmBorrowLoc[0](Arg0: Position)
185 10: Call position::size(&Position): u128
186 11: MoveLoc[1](Arg1: u128)
187 12: Call library::base_mul(u128, u128): u128
188 13: StLoc[7](loc5: u128)
189 14: ImmBorrowLoc[0](Arg0: Position)
190 15: Call position::is_long(&Position): bool
191 16: BrFalse(35)
192B1:
193 17: Call library::base_uint(): u128
194 18: MoveLoc[6](loc4: u128)
195 19: Sub
196 20: StLoc[4](loc2: u128)
197 21: MoveLoc[7](loc5: u128)
198 22: MoveLoc[4](loc2: u128)
199 23: Call library::base_mul(u128, u128): u128
200 24: StLoc[9](loc7: u128)
201 25: CopyLoc[2](loc0: u128)
202 26: MoveLoc[2](loc0: u128)
203 27: MoveLoc[8](loc6: u128)
204 28: Call s128::from_subtraction(u128, u128): S128
205 29: MoveLoc[9](loc7: u128)
206 30: Call s128::add_u128(S128, u128): S128
207 31: Call s128::positive_value(S128): u128
208 32: Call library::min(u128, u128): u128
209 33: StLoc[3](loc1: u128)
210 34: Branch(51)
211B2:
212 35: Call library::base_uint(): u128
213 36: MoveLoc[6](loc4: u128)
214 37: Add
215 38: StLoc[5](loc3: u128)
216 39: MoveLoc[7](loc5: u128)
217 40: MoveLoc[5](loc3: u128)
218 41: Call library::base_mul(u128, u128): u128
219 42: StLoc[10](loc8: u128)
220 43: CopyLoc[2](loc0: u128)
221 44: MoveLoc[2](loc0: u128)
222 45: MoveLoc[8](loc6: u128)
223 46: Add
224 47: MoveLoc[10](loc8: u128)
225 48: Call library::sub(u128, u128): u128
226 49: Call library::min(u128, u128): u128
227 50: StLoc[3](loc1: u128)
228B3:
229 51: MoveLoc[3](loc1: u128)
230 52: Ret
231}
232
233transfer_based_on_fundsflow<Ty0>(Arg0: &mut Bank<Ty0>, Arg1: address, Arg2: address, Arg3: S128, Arg4: u64, Arg5: u128) {
234L6: loc0: address
235L7: loc1: u64
236L8: loc2: address
237B0:
238 0: CopyLoc[3](Arg3: S128)
239 1: Call s128::value(S128): u128
240 2: LdU128(0)
241 3: Eq
242 4: BrFalse(8)
243B1:
244 5: MoveLoc[0](Arg0: &mut Bank<Ty0>)
245 6: Pop
246 7: Ret
247B2:
248 8: CopyLoc[3](Arg3: S128)
249 9: LdU128(0)
250 10: Call s128::gt_u128(S128, u128): bool
251 11: BrFalse(19)
252B3:
253 12: MoveLoc[2](Arg2: address)
254 13: StLoc[8](loc2: address)
255 14: MoveLoc[1](Arg1: address)
256 15: StLoc[6](loc0: address)
257 16: MoveLoc[4](Arg4: u64)
258 17: StLoc[7](loc1: u64)
259 18: Branch(25)
260B4:
261 19: MoveLoc[1](Arg1: address)
262 20: StLoc[8](loc2: address)
263 21: MoveLoc[2](Arg2: address)
264 22: StLoc[6](loc0: address)
265 23: LdU64(2)
266 24: StLoc[7](loc1: u64)
267B5:
268 25: MoveLoc[0](Arg0: &mut Bank<Ty0>)
269 26: MoveLoc[8](loc2: address)
270 27: MoveLoc[6](loc0: address)
271 28: MoveLoc[3](Arg3: S128)
272 29: Call s128::value(S128): u128
273 30: MoveLoc[7](loc1: u64)
274 31: MoveLoc[5](Arg5: u128)
275 32: Call bank::transfer<Ty0>(&mut Bank<Ty0>, address, address, u128, u64, u128)
276 33: Ret
277}
278
279}
280
0xa5b1b7a4cc8a765b422f41b8cfbc43553574f5731abdfa038df8d3cce09efec9/bytecode/sub_accounts.mvb401 lines
1// Move bytecode v7
2module 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001.sub_accounts {
3use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::library;
4use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::protocol;
5use 978fed071cca22dd26bec3cf4a5d5a00ab10f39cb8c659bbfdfbec4397241001::roles;
6use 9041eddbe15edba576c8c0bd4237e07b19e2c17fb59b240658f96522261f10c4::payload;
7use 9041eddbe15edba576c8c0bd4237e07b19e2c17fb59b240658f96522261f10c4::signature;
8use 9041eddbe15edba576c8c0bd4237e07b19e2c17fb59b240658f96522261f10c4::unified_address;
9use 0000000000000000000000000000000000000000000000000000000000000002::clock;
10use 0000000000000000000000000000000000000000000000000000000000000002::event;
11use 0000000000000000000000000000000000000000000000000000000000000002::object;
12use 0000000000000000000000000000000000000000000000000000000000000002::table;
13use 0000000000000000000000000000000000000000000000000000000000000002::transfer;
14use 0000000000000000000000000000000000000000000000000000000000000002::tx_context;
15use 0000000000000000000000000000000000000000000000000000000000000002::vec_set;
16
17struct SubAccountUpdateEvent has copy, drop {
18 account: address,
19 sub_account: address,
20 status: bool
21}
22
23struct TxIndexerCreationEvent has copy, drop {
24 id: ID
25}
26
27struct SubAccounts has key {
28 id: UID,
29 map: Table<address, VecSet<address>>
30}
31
32struct TxIndexer has key {
33 id: UID,
34 counter: u128,
35 map: Table<vector<u8>, bool>
36}
37
38entry create_tx_indexer(Arg0: &ProtocolConfig, Arg1: &ExchangeManagerCap, Arg2: &mut TxContext) {
39L3: loc0: TxIndexer
40B0:
41 0: CopyLoc[0](Arg0: &ProtocolConfig)
42 1: Call protocol::check_basic(&ProtocolConfig)
43 2: MoveLoc[0](Arg0: &ProtocolConfig)
44 3: MoveLoc[1](Arg1: &ExchangeManagerCap)
45 4: Call roles::check_manager_validity(&ProtocolConfig, &ExchangeManagerCap)
46 5: CopyLoc[2](Arg2: &mut TxContext)
47 6: Call object::new(&mut TxContext): UID
48 7: LdU128(0)
49 8: MoveLoc[2](Arg2: &mut TxContext)
50 9: Call table::new<vector<u8>, bool>(&mut TxContext): Table<vector<u8>, bool>
51 10: Pack[3](TxIndexer)
52 11: StLoc[3](loc0: TxIndexer)
53 12: ImmBorrowLoc[3](loc0: TxIndexer)
54 13: ImmBorrowField[0](TxIndexer.id: UID)
55 14: Call object::uid_to_inner(&UID): ID
56 15: Pack[1](TxIndexerCreationEvent)
57 16: Call event::emit<TxIndexerCreationEvent>(TxIndexerCreationEvent)
58 17: MoveLoc[3](loc0: TxIndexer)
59 18: Call transfer::share_object<TxIndexer>(TxIndexer)
60 19: Ret
61}
62
63entry set_sub_account(Arg0: &ProtocolConfig, Arg1: &mut SubAccounts, Arg2: address, Arg3: bool, Arg4: &TxContext) {
64L5: loc0: address
65B0:
66 0: MoveLoc[0](Arg0: &ProtocolConfig)
67 1: Call protocol::check_basic(&ProtocolConfig)
68 2: MoveLoc[4](Arg4: &TxContext)
69 3: Call tx_context::sender(&TxContext): address
70 4: StLoc[5](loc0: address)
71 5: MoveLoc[1](Arg1: &mut SubAccounts)
72 6: MoveLoc[5](loc0: address)
73 7: MoveLoc[2](Arg2: address)
74 8: MoveLoc[3](Arg3: bool)
75 9: Call set_sub_account_internal(&mut SubAccounts, address, address, bool)
76 10: Ret
77}
78
79entry set_sub_account_v2(Arg0: &ProtocolConfig, Arg1: &mut SubAccounts, Arg2: &mut TxIndexer, Arg3: &Clock, Arg4: vector<u8>, Arg5: vector<u8>, Arg6: bool, Arg7: u128, Arg8: u64, Arg9: vector<u8>, Arg10: vector<u8>) {
80L11: loc0: u64
81L12: loc1: &Clock
82L13: loc2: vector<u8>
83L14: loc3: vector<u8>
84L15: loc4: vector<u8>
85L16: loc5: vector<address>
86L17: loc6: &UnifiedAddress
87L18: loc7: vector<u8>
88L19: loc8: UnifiedAddress
89L20: loc9: UnifiedAddress
90B0:
91 0: MoveLoc[0](Arg0: &ProtocolConfig)
92 1: Call protocol::check_basic(&ProtocolConfig)
93 2: MoveLoc[4](Arg4: vector<u8>)
94 3: Call unified_address::from_tagged_bytes(vector<u8>): UnifiedAddress
95 4: StLoc[20](loc9: UnifiedAddress)
96 5: MoveLoc[5](Arg5: vector<u8>)
97 6: Call unified_address::from_tagged_bytes(vector<u8>): UnifiedAddress
98 7: StLoc[19](loc8: UnifiedAddress)
99 8: MoveLoc[3](Arg3: &Clock)
100 9: StLoc[12](loc1: &Clock)
101 10: CopyLoc[8](Arg8: u64)
102 11: StLoc[11](loc0: u64)
103 12: MoveLoc[12](loc1: &Clock)
104 13: MoveLoc[11](loc0: u64)
105 14: LdU64(34)
106 15: Call signature::assert_signed_payload_fresh(&Clock, u64, u64)
107 16: CopyLoc[20](loc9: UnifiedAddress)
108 17: CopyLoc[19](loc8: UnifiedAddress)
109 18: CopyLoc[6](Arg6: bool)
110 19: MoveLoc[7](Arg7: u128)
111 20: MoveLoc[8](Arg8: u64)
112 21: Call payload::set_sub_account(UnifiedAddress, UnifiedAddress, bool, u128, u64): vector<u8>
113 22: StLoc[18](loc7: vector<u8>)
114 23: ImmBorrowLoc[20](loc9: UnifiedAddress)
115 24: StLoc[17](loc6: &UnifiedAddress)
116 25: VecPack(24, 0)
117 26: StLoc[16](loc5: vector<address>)
118 27: CopyLoc[18](loc7: vector<u8>)
119 28: StLoc[15](loc4: vector<u8>)
120 29: MoveLoc[9](Arg9: vector<u8>)
121 30: StLoc[14](loc3: vector<u8>)
122 31: MoveLoc[10](Arg10: vector<u8>)
123 32: StLoc[13](loc2: vector<u8>)
124 33: MoveLoc[17](loc6: &UnifiedAddress)
125 34: MoveLoc[16](loc5: vector<address>)
126 35: MoveLoc[15](loc4: vector<u8>)
127 36: MoveLoc[14](loc3: vector<u8>)
128 37: MoveLoc[13](loc2: vector<u8>)
129 38: LdU64(52)
130 39: Call signature::verify_user_signature(&UnifiedAddress, vector<address>, vector<u8>, vector<u8>, vector<u8>, u64): UnifiedAddress
131 40: Pop
132 41: MoveLoc[2](Arg2: &mut TxIndexer)
133 42: MoveLoc[18](loc7: vector<u8>)
134 43: Call library::get_hash(vector<u8>): vector<u8>
135 44: Call validate_unique_tx(&mut TxIndexer, vector<u8>): u128
136 45: Pop
137 46: MoveLoc[1](Arg1: &mut SubAccounts)
138 47: ImmBorrowLoc[20](loc9: UnifiedAddress)
139 48: Call unified_address::identifier(&UnifiedAddress): address
140 49: ImmBorrowLoc[19](loc8: UnifiedAddress)
141 50: Call unified_address::identifier(&UnifiedAddress): address
142 51: MoveLoc[6](Arg6: bool)
143 52: Call set_sub_account_internal(&mut SubAccounts, address, address, bool)
144 53: Ret
145}
146
147public(friend) assert_signed_action_sender_authorized(Arg0: &ProtocolConfig, Arg1: &SubAccounts, Arg2: &UnifiedAddress, Arg3: &TxContext) {
148L4: loc0: bool
149L5: loc1: address
150L6: loc2: address
151B0:
152 0: MoveLoc[3](Arg3: &TxContext)
153 1: Call tx_context::sender(&TxContext): address
154 2: StLoc[5](loc1: address)
155 3: MoveLoc[2](Arg2: &UnifiedAddress)
156 4: Call unified_address::identifier(&UnifiedAddress): address
157 5: StLoc[6](loc2: address)
158 6: CopyLoc[5](loc1: address)
159 7: MoveLoc[0](Arg0: &ProtocolConfig)
160 8: Call protocol::gas_relayer(&ProtocolConfig): address
161 9: Eq
162 10: BrFalse(16)
163B1:
164 11: MoveLoc[1](Arg1: &SubAccounts)
165 12: Pop
166 13: LdTrue
167 14: StLoc[4](loc0: bool)
168 15: Branch(30)
169B2:
170 16: CopyLoc[5](loc1: address)
171 17: CopyLoc[6](loc2: address)
172 18: Eq
173 19: BrFalse(25)
174B3:
175 20: MoveLoc[1](Arg1: &SubAccounts)
176 21: Pop
177 22: LdTrue
178 23: StLoc[4](loc0: bool)
179 24: Branch(30)
180B4:
181 25: MoveLoc[1](Arg1: &SubAccounts)
182 26: MoveLoc[6](loc2: address)
183 27: MoveLoc[5](loc1: address)
184 28: Call is_sub_account(&SubAccounts, address, address): bool
185 29: StLoc[4](loc0: bool)
186B5:
187 30: MoveLoc[4](loc0: bool)
188 31: BrFalse(33)
189B6:
190 32: Branch(35)
191B7:
192 33: LdU64(920)
193 34: Abort
194B8:
195 35: Ret
196}
197
198public(friend) set_sub_account_internal(Arg0: &mut SubAccounts, Arg1: address, Arg2: address, Arg3: bool) {
199L4: loc0: &mut Table<address, VecSet<address>>
200L5: loc1: &mut VecSet<address>
201B0:
202 0: CopyLoc[2](Arg2: address)
203 1: LdConst[0](address: 0x00..)
204 2: Neq
205 3: BrFalse(5)
206B1:
207 4: Branch(9)
208B2:
209 5: MoveLoc[0](Arg0: &mut SubAccounts)
210 6: Pop
211 7: LdU64(105)
212 8: Abort
213B3:
214 9: MoveLoc[0](Arg0: &mut SubAccounts)
215 10: MutBorrowField[1](SubAccounts.map: Table<address, VecSet<address>>)
216 11: StLoc[4](loc0: &mut Table<address, VecSet<address>>)
217 12: CopyLoc[4](loc0: &mut Table<address, VecSet<address>>)
218 13: FreezeRef
219 14: CopyLoc[1](Arg1: address)
220 15: Call table::contains<address, VecSet<address>>(&Table<address, VecSet<address>>, address): bool
221 16: Not
222 17: BrFalse(22)
223B4:
224 18: CopyLoc[4](loc0: &mut Table<address, VecSet<address>>)
225 19: CopyLoc[1](Arg1: address)
226 20: Call vec_set::empty<address>(): VecSet<address>
227 21: Call table::add<address, VecSet<address>>(&mut Table<address, VecSet<address>>, address, VecSet<address>)
228B5:
229 22: MoveLoc[4](loc0: &mut Table<address, VecSet<address>>)
230 23: CopyLoc[1](Arg1: address)
231 24: Call table::borrow_mut<address, VecSet<address>>(&mut Table<address, VecSet<address>>, address): &mut VecSet<address>
232 25: StLoc[5](loc1: &mut VecSet<address>)
233 26: CopyLoc[3](Arg3: bool)
234 27: BrFalse(41)
235B6:
236 28: CopyLoc[5](loc1: &mut VecSet<address>)
237 29: FreezeRef
238 30: ImmBorrowLoc[2](Arg2: address)
239 31: Call vec_set::contains<address>(&VecSet<address>, &address): bool
240 32: Not
241 33: BrFalse(38)
242B7:
243 34: MoveLoc[5](loc1: &mut VecSet<address>)
244 35: CopyLoc[2](Arg2: address)
245 36: Call vec_set::insert<address>(&mut VecSet<address>, address)
246 37: Branch(52)
247B8:
248 38: MoveLoc[5](loc1: &mut VecSet<address>)
249 39: Pop
250 40: Branch(52)
251B9:
252 41: CopyLoc[5](loc1: &mut VecSet<address>)
253 42: FreezeRef
254 43: ImmBorrowLoc[2](Arg2: address)
255 44: Call vec_set::contains<address>(&VecSet<address>, &address): bool
256 45: BrFalse(50)
257B10:
258 46: MoveLoc[5](loc1: &mut VecSet<address>)
259 47: ImmBorrowLoc[2](Arg2: address)
260 48: Call vec_set::remove<address>(&mut VecSet<address>, &address)
261 49: Branch(52)
262B11:
263 50: MoveLoc[5](loc1: &mut VecSet<address>)
264 51: Pop
265B12:
266 52: MoveLoc[1](Arg1: address)
267 53: MoveLoc[2](Arg2: address)
268 54: MoveLoc[3](Arg3: bool)
269 55: Pack[0](SubAccountUpdateEvent)
270 56: Call event::emit<SubAccountUpdateEvent>(SubAccountUpdateEvent)
271 57: Ret
272}
273
274public(friend) initialize(Arg0: &mut TxContext) {
275B0:
276 0: CopyLoc[0](Arg0: &mut TxContext)
277 1: Call object::new(&mut TxContext): UID
278 2: CopyLoc[0](Arg0: &mut TxContext)
279 3: Call table::new<address, VecSet<address>>(&mut TxContext): Table<address, VecSet<address>>
280 4: Pack[2](SubAccounts)
281 5: Call transfer::share_object<SubAccounts>(SubAccounts)
282 6: CopyLoc[0](Arg0: &mut TxContext)
283 7: Call object::new(&mut TxContext): UID
284 8: LdU128(0)
285 9: MoveLoc[0](Arg0: &mut TxContext)
286 10: Call table::new<vector<u8>, bool>(&mut TxContext): Table<vector<u8>, bool>
287 11: Pack[3](TxIndexer)
288 12: Call transfer::share_object<TxIndexer>(TxIndexer)
289 13: Ret
290}
291
292public(friend) validate_unique_tx(Arg0: &mut TxIndexer, Arg1: vector<u8>): u128 {
293B0:
294 0: CopyLoc[0](Arg0: &mut TxIndexer)
295 1: ImmBorrowField[2](TxIndexer.map: Table<vector<u8>, bool>)
296 2: CopyLoc[1](Arg1: vector<u8>)
297 3: Call table::contains<vector<u8>, bool>(&Table<vector<u8>, bool>, vector<u8>): bool
298 4: Not
299 5: BrFalse(7)
300B1:
301 6: Branch(11)
302B2:
303 7: MoveLoc[0](Arg0: &mut TxIndexer)
304 8: Pop
305 9: LdU64(906)
306 10: Abort
307B3:
308 11: CopyLoc[0](Arg0: &mut TxIndexer)
309 12: MutBorrowField[2](TxIndexer.map: Table<vector<u8>, bool>)
310 13: MoveLoc[1](Arg1: vector<u8>)
311 14: LdTrue
312 15: Call table::add<vector<u8>, bool>(&mut Table<vector<u8>, bool>, vector<u8>, bool)
313 16: CopyLoc[0](Arg0: &mut TxIndexer)
314 17: ImmBorrowField[3](TxIndexer.counter: u128)
315 18: ReadRef
316 19: LdU128(1)
317 20: Add
318 21: CopyLoc[0](Arg0: &mut TxIndexer)
319 22: MutBorrowField[3](TxIndexer.counter: u128)
320 23: WriteRef
321 24: MoveLoc[0](Arg0: &mut TxIndexer)
322 25: ImmBorrowField[3](TxIndexer.counter: u128)
323 26: ReadRef
324 27: Ret
325}
326
327public(friend) increment_tx_index(Arg0: &mut TxIndexer): u128 {
328B0:
329 0: CopyLoc[0](Arg0: &mut TxIndexer)
330 1: ImmBorrowField[3](TxIndexer.counter: u128)
331 2: ReadRef
332 3: LdU128(1)
333 4: Add
334 5: CopyLoc[0](Arg0: &mut TxIndexer)
335 6: MutBorrowField[3](TxIndexer.counter: u128)
336 7: WriteRef
337 8: MoveLoc[0](Arg0: &mut TxIndexer)
338 9: ImmBorrowField[3](TxIndexer.counter: u128)
339 10: ReadRef
340 11: Ret
341}
342
343public(friend) is_sub_account(Arg0: &SubAccounts, Arg1: address, Arg2: address): bool {
344L3: loc0: &Table<address, VecSet<address>>
345B0:
346 0: MoveLoc[0](Arg0: &SubAccounts)
347 1: ImmBorrowField[1](SubAccounts.map: Table<address, VecSet<address>>)
348 2: StLoc[3](loc0: &Table<address, VecSet<address>>)
349 3: CopyLoc[3](loc0: &Table<address, VecSet<address>>)
350 4: CopyLoc[1](Arg1: address)
351 5: Call table::contains<address, VecSet<address>>(&Table<address, VecSet<address>>, address): bool
352 6: Not
353 7: BrFalse(12)
354B1:
355 8: MoveLoc[3](loc0: &Table<address, VecSet<address>>)
356 9: Pop
357 10: LdFalse
358 11: Ret
359B2:
360 12: MoveLoc[3](loc0: &Table<address, VecSet<address>>)
361 13: MoveLoc[1](Arg1: address)
362 14: Call table::borrow<address, VecSet<address>>(&Table<address, VecSet<address>>, address): &VecSet<address>
363 15: ImmBorrowLoc[2](Arg2: address)
364 16: Call vec_set::contains<address>(&VecSet<address>, &address): bool
365 17: Ret
366}
367
368public(friend) get_all_sub_accounts(Arg0: &SubAccounts, Arg1: address): vector<address> {
369L2: loc0: vector<address>
370L3: loc1: &Table<address, VecSet<address>>
371B0:
372 0: MoveLoc[0](Arg0: &SubAccounts)
373 1: ImmBorrowField[1](SubAccounts.map: Table<address, VecSet<address>>)
374 2: StLoc[3](loc1: &Table<address, VecSet<address>>)
375 3: CopyLoc[3](loc1: &Table<address, VecSet<address>>)
376 4: CopyLoc[1](Arg1: address)
377 5: Call table::contains<address, VecSet<address>>(&Table<address, VecSet<address>>, address): bool
378 6: BrFalse(14)
379B1:
380 7: MoveLoc[3](loc1: &Table<address, VecSet<address>>)
381 8: MoveLoc[1](Arg1: address)
382 9: Call table::borrow<address, VecSet<address>>(&Table<address, VecSet<address>>, address): &VecSet<address>
383 10: Call vec_set::keys<address>(&VecSet<address>): &vector<address>
384 11: ReadRef
385 12: StLoc[2](loc0: vector<address>)
386 13: Branch(18)
387B2:
388 14: MoveLoc[3](loc1: &Table<address, VecSet<address>>)
389 15: Pop
390 16: VecPack(24, 0)
391 17: StLoc[2](loc0: vector<address>)
392B3:
393 18: MoveLoc[2](loc0: vector<address>)
394 19: Ret
395}
396
397Constants [
398 0 => address: 0x0000000000000000000000000000000000000000000000000000000000000000
399]
400}
401
This is a circuit, not a contract. It declares no ABI and no storage layout, so there is no interface list and no slot mapping to show. The source above is the whole of what it publishes.
Deployments
This code is deployed at one address. Any other address running the same bytecode would appear here too, already verified.