Skip to content
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

Fixes on flashFee #14

Merged
merged 5 commits into from
Aug 9, 2023
Merged

Fixes on flashFee #14

merged 5 commits into from
Aug 9, 2023

Conversation

alcueca
Copy link
Owner

@alcueca alcueca commented Aug 8, 2023

  • flashFee returns type(uint256).max on lack of liquidity
  • flashFee returns on unsupported assets (only managed for ERC3156Wrapper and Uniswap)

 - flashFee returns on unsupported assets (partial)
src/BaseWrapper.sol Outdated Show resolved Hide resolved
Comment on lines +28 to +29
function maxFlashLoan(address asset) external view returns (uint256) {
return _maxFlashLoan(asset);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not making it public instead?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since calling a public from the same contract is an external CALL, I have the habit of using only internal and external, which also serves to segregate functionality and UX very clearly.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Afaik That's not true, a call to a public function uses a JUMP when called from the same contract, unless you prepend this, in that case it would use a CALL.

Public functions have no extra overhead over internal ones

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe things have changed in some recent version of solidity, and I didn't realize. Do you want to fix this through the wrappers, or to let it be?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I knew it, if you call an internal from the same contract is a JUMP, a public would be a CALL, and for an external you have to prepend this. and it will be a CALL as well.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afaik that was never the case, the problem in older versions of solidity was that public functions couldn't use calldata params so they could be more expensive when calling as internal... there's an easy way to verify what I say, if it uses a JUMP, msg.sender wouldn't change, if it's a CALL, then msg.sender would be address(this), I'm 99.99999e18 sure that it's the former.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still, I like the separation and I'm not so keen on a refactor. Do you mind if we keep it as it is?

@alcueca alcueca merged commit b34d05c into main Aug 9, 2023
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants