@@ -238,7 +238,7 @@ contract HyperCoreFlowExecutor is AccessControlUpgradeable, AuthorizedFundedFlow
238238 * @param token The token used to fund the account activation
239239 * @param amountCore The amount paid for activation (in Core token units)
240240 */
241- event AccountActivatedFromUserBalance (
241+ event AccountActivatedFromUserFunds (
242242 bytes32 indexed quoteNonce ,
243243 address indexed user ,
244244 address indexed token ,
@@ -520,26 +520,25 @@ contract HyperCoreFlowExecutor is AccessControlUpgradeable, AuthorizedFundedFlow
520520 MainStorage storage $ = _getMainStorage ();
521521 CoreTokenInfo memory coreTokenInfo = $.coreTokenInfos[finalToken];
522522
523- bool userAccountExists = HyperCoreLib.coreUserExists (params.finalRecipient);
524523 uint64 accountActivationFeeCore;
525- if (! userAccountExists) {
526- if (params.accountCreationMode == AccountCreationMode.Standard) {
527- if (params.maxBpsToSponsor > 0 ) {
528- revert AccountNotActivatedError (params.finalRecipient);
529- } else {
530- emit AccountNotActivated (params.quoteNonce, params.finalRecipient);
531- _fallbackHyperEVMFlow (params);
532- return ;
533- }
534- } else {
535- // Notice. If the amount is too small to be able to activate an account, the funds will land there, but
536- // the account won't show up as active until an eligible transfer activates it
537- if (! coreTokenInfo.canBeUsedForAccountActivation) {
538- _fallbackHyperEVMFlow (params);
539- return ;
540- }
541- accountActivationFeeCore = coreTokenInfo.accountActivationFeeCore;
524+ if (! HyperCoreLib.coreUserExists (params.finalRecipient)) {
525+ bool isStandard = params.accountCreationMode == AccountCreationMode.Standard;
526+
527+ // Standard, sponsored
528+ if (isStandard && params.maxBpsToSponsor > 0 ) {
529+ revert AccountNotActivatedError (params.finalRecipient);
542530 }
531+
532+ // Standard, non-sponsored OR
533+ // FromUserAccount AND token can't be used for account activation
534+ if (isStandard || ! coreTokenInfo.canBeUsedForAccountActivation) {
535+ emit AccountNotActivated (params.quoteNonce, params.finalRecipient);
536+ _fallbackHyperEVMFlow (params);
537+ return ;
538+ }
539+
540+ // FromUserAccount AND token can be used for account activation
541+ accountActivationFeeCore = coreTokenInfo.accountActivationFeeCore;
543542 }
544543
545544 uint256 amountToSponsor;
@@ -605,7 +604,7 @@ contract HyperCoreFlowExecutor is AccessControlUpgradeable, AuthorizedFundedFlow
605604 );
606605
607606 if (accountActivationFeeCore > 0 ) {
608- emit AccountActivatedFromUserBalance (
607+ emit AccountActivatedFromUserFunds (
609608 params.quoteNonce,
610609 params.finalRecipient,
611610 finalToken,
@@ -638,27 +637,21 @@ contract HyperCoreFlowExecutor is AccessControlUpgradeable, AuthorizedFundedFlow
638637 CoreTokenInfo memory finalCoreTokenInfo = $.coreTokenInfos[params.finalToken];
639638 FinalTokenInfo memory finalTokenInfo = _getExistingFinalTokenInfo (params.finalToken);
640639
641- bool userAccountExists = HyperCoreLib.coreUserExists (params.finalRecipient);
642- if (! userAccountExists) {
643- if (params.accountCreationMode == AccountCreationMode.Standard) {
644- if (params.maxBpsToSponsor > 0 ) {
645- revert AccountNotActivatedError (params.finalRecipient);
646- } else {
647- emit AccountNotActivated (params.quoteNonce, params.finalRecipient);
648- params.finalToken = initialToken;
649- _fallbackHyperEVMFlow (params);
650- return ;
651- }
652- } else {
653- // In the FromUserFunds logic for the swap flow, we only allow account creation if the final token is
654- // usable for it. Finilazing the swap flow should handle account creation automatically when doing the
655- // final transfer of tokens to the user
656- if (! finalCoreTokenInfo.canBeUsedForAccountActivation) {
657- emit AccountNotActivated (params.quoteNonce, params.finalRecipient);
658- params.finalToken = initialToken;
659- _fallbackHyperEVMFlow (params);
660- return ;
661- }
640+ if (! HyperCoreLib.coreUserExists (params.finalRecipient)) {
641+ bool isStandard = params.accountCreationMode == AccountCreationMode.Standard;
642+
643+ // Standard, sponsored
644+ if (isStandard && params.maxBpsToSponsor > 0 ) {
645+ revert AccountNotActivatedError (params.finalRecipient);
646+ }
647+
648+ // Standard, non-sponsored OR
649+ // FromUserFunds AND final token can't be used for account creation
650+ if (isStandard || ! finalCoreTokenInfo.canBeUsedForAccountActivation) {
651+ emit AccountNotActivated (params.quoteNonce, params.finalRecipient);
652+ params.finalToken = initialToken;
653+ _fallbackHyperEVMFlow (params);
654+ return ;
662655 }
663656 }
664657
@@ -869,7 +862,7 @@ contract HyperCoreFlowExecutor is AccessControlUpgradeable, AuthorizedFundedFlow
869862 if (swap.finalToken != finalToken) revert WrongSwapFinalizationToken (quoteNonce);
870863
871864 uint64 accountActivationFee;
872- // User account can be absent if our AccountCreationMode is `FromUserBalance `. We need to adjust our transfer amount to user based on this
865+ // User account can be absent if our AccountCreationMode is `FromUserFunds `. We need to adjust our transfer amount to user based on this
873866 if (! HyperCoreLib.coreUserExists (swap.finalRecipient)) {
874867 // This is enforced by `_initiateSwapFlow`. If the setting changed, this revert can trigger. Requires manual resolution (creating an account)
875868 if (! finalCoreTokenInfo.canBeUsedForAccountActivation) revert TokenNotEligibleForActivation ();
@@ -909,12 +902,7 @@ contract HyperCoreFlowExecutor is AccessControlUpgradeable, AuthorizedFundedFlow
909902 );
910903
911904 if (accountActivationFee > 0 ) {
912- emit AccountActivatedFromUserBalance (
913- quoteNonce,
914- swap.finalRecipient,
915- swap.finalToken,
916- accountActivationFee
917- );
905+ emit AccountActivatedFromUserFunds (quoteNonce, swap.finalRecipient, swap.finalToken, accountActivationFee);
918906 }
919907
920908 emit SwapFlowFinalized (quoteNonce, swap.finalRecipient, swap.finalToken, amountToTransfer, additionalToSendEVM);
0 commit comments