@@ -177,11 +177,25 @@ contract IExchange
177
177
178
178
/// @dev Submit an onchain request to create a new account for msg.sender or
179
179
/// update its existing account by replacing its trading public key.
180
+ /// The total fee in ETH that the user needs to pay is:
181
+ /// depositFee +
182
+ /// (isAccountNew ? accountCreationFee : 0) +
183
+ /// (isAccountUpdated ? accountUpdateFee : 0)
184
+ /// If the user sends too much ETH the surplus is immediatly sent back.
185
+ ///
186
+ /// Note that after such an operation, it will take the operator some
187
+ /// time (no more than MAX_AGE_REQUEST_UNTIL_FORCED) to process the request
188
+ /// and create or update the offchain account.
189
+ ///
190
+ /// Calling this method with a different trading public key will effectively
191
+ /// cancel all existing orders within MAX_AGE_REQUEST_UNTIL_FORCED.
192
+ ///
180
193
/// @param pubKeyX The first part of the account's trading EdDSA public key
181
194
/// @param pubKeyY The second part of the account's trading EdDSA public key.
182
195
/// Note that pubkeyX and pubKeyY cannot be both `1`.
183
196
/// @return accountID The account's ID
184
197
/// @return isAccountNew True if this account is newly created, false if the account existed
198
+ /// @return isAccountUpdated True if this account was updated, false otherwise
185
199
function createOrUpdateAccount (
186
200
uint pubKeyX ,
187
201
uint pubKeyY
@@ -190,7 +204,8 @@ contract IExchange
190
204
payable
191
205
returns (
192
206
uint24 accountID ,
193
- bool isAccountNew
207
+ bool isAccountNew ,
208
+ bool isAccountUpdated
194
209
);
195
210
196
211
// -- Balances --
@@ -560,10 +575,16 @@ contract IExchange
560
575
);
561
576
562
577
/// @dev Deposit Ether or ERC20 tokens to the sender's account.
563
- /// This function will create a new account if such no account exists
578
+ /// This function will create a new account if no account exists
564
579
/// for msg.sender, or update the existing account with the given trading
565
580
/// public key when the account exists.
566
581
///
582
+ /// The total fee in ETH that the user needs to pay is:
583
+ /// depositFee +
584
+ /// (isAccountNew ? accountCreationFee : 0) +
585
+ /// (isAccountUpdated ? accountUpdateFee : 0)
586
+ /// If the user sends too much ETH the surplus is immediatly sent back.
587
+ ///
567
588
/// Note that after such an operation, it will take the operator some
568
589
/// time (no more than MAX_AGE_REQUEST_UNTIL_FORCED) to process the request
569
590
/// and create the deposit to the offchain account.
@@ -577,6 +598,7 @@ contract IExchange
577
598
/// @param amount The amount of tokens to deposit
578
599
/// @return accountID The id of the account
579
600
/// @return isAccountNew True if this account is newly created, false if the account existed
601
+ /// @return isAccountUpdated True if this account was updated, false otherwise
580
602
function updateAccountAndDeposit (
581
603
uint pubKeyX ,
582
604
uint pubKeyY ,
@@ -587,15 +609,19 @@ contract IExchange
587
609
payable
588
610
returns (
589
611
uint24 accountID ,
590
- bool isAccountNew
612
+ bool isAccountNew ,
613
+ bool isAccountUpdated
591
614
);
592
615
593
616
/// @dev Deposit Ether or ERC20 tokens to the sender's account.
594
617
///
618
+ /// The total fee in ETH that the user needs to pay is 'depositFee'.
619
+ /// If the user sends too much ETH the surplus is immediatly sent back.
620
+ ///
595
621
/// Note that after such an operation, it will take the operator some
596
622
/// time (no more than MAX_AGE_REQUEST_UNTIL_FORCED) to process the request
597
623
/// and create the deposit to the offchain account.
598
- ////
624
+ ///
599
625
/// Warning: the DEX UI should warn their users not to deposit more than 2^96 - 1
600
626
/// tokens in total. If that happens, the user may lose token.
601
627
/// This token balance upper limit, however, is large enought for most scenarios.
@@ -611,6 +637,9 @@ contract IExchange
611
637
612
638
/// @dev Deposit Ether or ERC20 tokens to a recipient account.
613
639
///
640
+ /// The total fee in ETH that the user needs to pay is 'depositFee'.
641
+ /// If the user sends too much ETH the surplus is immediatly sent back.
642
+ ///
614
643
/// Note that after such an operation, it will take the operator some
615
644
/// time (no more than MAX_AGE_REQUEST_UNTIL_FORCED) to process the request
616
645
/// and create the deposit to the offchain account.
@@ -664,15 +693,19 @@ contract IExchange
664
693
uint32 timestamp
665
694
);
666
695
667
- // Set the large value for amount to withdraw the complete balance
668
696
/// @dev Submit an onchain request to withdraw Ether or ERC20 tokens. To withdraw
669
697
/// all the balance, use a very large number for `amount`.
670
698
///
699
+ /// Only the owner of the account can request a withdrawal.
700
+ ///
701
+ /// The total fee in ETH that the user needs to pay is 'withdrawalFee'.
702
+ /// If the user sends too much ETH the surplus is immediatly sent back.
703
+ ///
671
704
/// Note that after such an operation, it will take the operator some
672
705
/// time (no more than MAX_AGE_REQUEST_UNTIL_FORCED) to process the request
673
706
/// and create the deposit to the offchain account.
674
707
///
675
- /// @param tokenAddress The adderss of the token, use `0x0` for Ether.
708
+ /// @param tokenAddress The address of the token, use `0x0` for Ether.
676
709
/// @param amount The amount of tokens to deposit
677
710
function withdraw (
678
711
address tokenAddress ,
@@ -681,6 +714,22 @@ contract IExchange
681
714
external
682
715
payable ;
683
716
717
+ /// @dev Submit an onchain request to withdraw Ether or ERC20 tokens from the
718
+ /// protocol fees account. The complete balance is always withdrawn.
719
+ ///
720
+ /// Anyone can request a withdrawal of the protocol fees.
721
+ ///
722
+ /// Note that after such an operation, it will take the operator some
723
+ /// time (no more than MAX_AGE_REQUEST_UNTIL_FORCED) to process the request
724
+ /// and create the deposit to the offchain account.
725
+ ///
726
+ /// @param tokenAddress The address of the token, use `0x0` for Ether.
727
+ function withdrawProtocolFees (
728
+ address tokenAddress
729
+ )
730
+ external
731
+ payable ;
732
+
684
733
/// @dev Allows an account owner to withdraw his funds using the balances stored
685
734
/// in the merkle tree. The funds will be sent to the owner of the acount.
686
735
///
0 commit comments