-
Notifications
You must be signed in to change notification settings - Fork 78
feat: audit follow up #1218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat: audit follow up #1218
Conversation
Signed-off-by: Faisal Usmani <faisal.of.usmani@gmail.com>
Signed-off-by: Faisal Usmani <faisal.of.usmani@gmail.com>
Signed-off-by: Faisal Usmani <faisal.of.usmani@gmail.com>
…isal/perp-destination-dex
Signed-off-by: Faisal Usmani <faisal.of.usmani@gmail.com>
Signed-off-by: Faisal Usmani <faisal.of.usmani@gmail.com>
Signed-off-by: Faisal Usmani <faisal.of.usmani@gmail.com>
Signed-off-by: Faisal Usmani <faisal.of.usmani@gmail.com>
Signed-off-by: Faisal Usmani <faisal.of.usmani@gmail.com>
Signed-off-by: Faisal Usmani <faisal.of.usmani@gmail.com>
* plan out the code Signed-off-by: Ihor Farion <ihor@umaproject.org> * dst side impl Signed-off-by: Ihor Farion <ihor@umaproject.org> * remove redundant var Signed-off-by: Ihor Farion <ihor@umaproject.org> * add account creation mode to encoded / decoded data Signed-off-by: Ihor Farion <ihor@umaproject.org> * fix tests and build Signed-off-by: Ihor Farion <ihor@umaproject.org> --------- Signed-off-by: Ihor Farion <ihor@umaproject.org>
Signed-off-by: Ihor Farion <ihor@umaproject.org>
| uint64 accountActivationFeeCore; | ||
| if (!userAccountExists) { | ||
| if (params.accountCreationMode == AccountCreationMode.Standard) { | ||
| if (!HyperCoreLib.coreUserExists(params.finalRecipient)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why repeated call and userAccountExists=false in this branch already
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, great call, thank you!
For standard mode, I just copied the existing logic and didn't update it based on the new outter if I added. Fixed in 2e5bb7e
| bool userAccountExists = HyperCoreLib.coreUserExists(params.finalRecipient); | ||
| if (!userAccountExists) { | ||
| if (params.accountCreationMode == AccountCreationMode.Standard) { | ||
| if (!HyperCoreLib.coreUserExists(params.finalRecipient)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
userAccountExists=false in this branch already
Signed-off-by: Faisal Usmani <faisal.of.usmani@gmail.com>
Signed-off-by: Faisal Usmani <faisal.of.usmani@gmail.com>
Signed-off-by: Ihor Farion <ihor@umaproject.org>
Signed-off-by: Ihor Farion <ihor@umaproject.org>
Signed-off-by: Ihor Farion <ihor@umaproject.org>
| bool userAccountExists = HyperCoreLib.coreUserExists(params.finalRecipient); | ||
| if (!userAccountExists) { | ||
| if (params.accountCreationMode == AccountCreationMode.Standard) { | ||
| if (params.maxBpsToSponsor > 0) { | ||
| revert AccountNotActivatedError(params.finalRecipient); | ||
| } else { | ||
| emit AccountNotActivated(params.quoteNonce, params.finalRecipient); | ||
| params.finalToken = initialToken; | ||
| _fallbackHyperEVMFlow(params); | ||
| return; | ||
| } | ||
| } else { | ||
| // In the FromUserFunds logic for the swap flow, we only allow account creation if the final token is | ||
| // usable for it. Finilazing the swap flow should handle account creation automatically when doing the | ||
| // final transfer of tokens to the user | ||
| if (!finalCoreTokenInfo.canBeUsedForAccountActivation) { | ||
| emit AccountNotActivated(params.quoteNonce, params.finalRecipient); | ||
| params.finalToken = initialToken; | ||
| _fallbackHyperEVMFlow(params); | ||
| return; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also this could be simplified to something like:
if (!HyperCoreLib.coreUserExists(params.finalRecipient)) {
bool isStandard = params.accountCreationMode == AccountCreationMode.Standard;
if (isStandard && params.maxBpsToSponsor > 0) {
revert AccountNotActivatedError(params.finalRecipient);
}
// Fall back unless FromUserFunds mode with an eligible activation token
if (isStandard || !finalCoreTokenInfo.canBeUsedForAccountActivation) {
emit AccountNotActivated(params.quoteNonce, params.finalRecipient);
params.finalToken = initialToken;
_fallbackHyperEVMFlow(params);
return;
}
}
| if (!coreTokenInfo.canBeUsedForAccountActivation) { | ||
| _fallbackHyperEVMFlow(params); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to emit the AccountNotActivated event here?
If so, we could probably simplify this in a similar way to my other comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added events in 2c97a95
Looking into simplification
Signed-off-by: Ihor Farion <ihor@umaproject.org>
Signed-off-by: Ihor Farion <ihor@umaproject.org>
Signed-off-by: Ihor Farion <ihor@umaproject.org>
Signed-off-by: Ihor Farion <ihor@umaproject.org>
Added support for:
-> PERP, not just-> SPOT