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

Amount and shares as input #248

Merged
merged 16 commits into from
Aug 10, 2023
Merged

Amount and shares as input #248

merged 16 commits into from
Aug 10, 2023

Conversation

MathisGD
Copy link
Contributor

@MathisGD MathisGD commented Aug 8, 2023

No description provided.

src/Blue.sol Outdated Show resolved Hide resolved
Copy link
Contributor

@MerlinEgalite MerlinEgalite left a comment

Choose a reason for hiding this comment

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

I'm not a real fan of this solution as it complexifies integrator's understanding

@Rubilmax
Copy link
Collaborator

Rubilmax commented Aug 9, 2023

Come on, a simple NATSPEC and everyone understands that you either need to provide amount or shares ; I understand there are people that don't understand Solidity well but they still succeeded in integrating Aave and Compound, while these 2 protocols are not simple nor do they have simple interfaces (How are cTokens and aTokens simple? remember interestRateMode and referralCode?)

Even with this change, Blue is still the simplest protocol to integrate

@MerlinEgalite
Copy link
Contributor

Come on, a simple NATSPEC and everyone understands that you either need to provide amount or shares ; I understand there are people that don't understand Solidity well but they still succeeded in integrating Aave and Compound, while these 2 protocols are not simple nor do they have simple interfaces (How are cTokens and aTokens simple? remember interestRateMode and referralCode?)

Even with this change, Blue is still the simplest protocol to integrate

Ok but which one I choose? Why? In which configuration should I use amount instead of shares? Those are questions that you now need to ask yourself when integrating Blue while you did not before. This is not easing integration for sure.

@Rubilmax
Copy link
Collaborator

Rubilmax commented Aug 9, 2023

We could have the following NATSPECs:

/// @notice Supplies the given amount of assets or shares to the given market on behalf of `onBehalf`,
///         optionally calling back the caller's `onBlueSupply` function with the given bytes of data.
/// @dev Either `amount` or `shares` should be zero.
///      Most usecases should rely on `amount` as an input so the caller
///      is guaranteed to have `amount` tokens pulled from their balance,
///      but the possibility to mint a specific amount of shares is given
///      for full compatibility and precision.

Copy link
Contributor

@Jean-Grimal Jean-Grimal left a comment

Choose a reason for hiding this comment

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

Also thought about this solution yesterday, but actually it looks very weird tbh

@pakim249CAL
Copy link
Contributor

IMO only the amount/share check looks weird, which is resolved well by @makcandrov 's solution.

@MerlinEgalite
Copy link
Contributor

MerlinEgalite commented Aug 9, 2023

We could have the following NATSPECs:

/// @notice Supplies the given amount of assets or shares to the given market on behalf of `onBehalf`,
///         optionally calling back the caller's `onBlueSupply` function with the given bytes of data.
/// @dev Either `amount` or `shares` should be zero.
///      Most usecases should rely on `amount` as an input so the caller
///      is guaranteed to have `amount` tokens pulled from their balance,
///      but the possibility to mint a specific amount of shares is given
///      for full compatibility and precision.

I'm still not convinced by this. The integrator still needs to reflect more. What's the upside of this solution?

@MathisGD MathisGD self-assigned this Aug 9, 2023
@Rubilmax
Copy link
Collaborator

Rubilmax commented Aug 9, 2023

What's the upside of this solution?

We are sure it fits any usecase

Copy link
Contributor

@julien-devatom julien-devatom left a comment

Choose a reason for hiding this comment

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

The most permissive interface. Finally, I find interdependency between arguments not so bad. This is easy to do or verify.
For integrators, you can still provide a library with 2 different interfaces, supplyShares & supplyAmount, but the primitive permits both.

src/Blue.sol Outdated Show resolved Hide resolved
@Jean-Grimal
Copy link
Contributor

Another solution could be to replace the input uint256 shares by bool max, and just do a check on this bool to know if the user wants to withdraw/repay max or not
In the end it is very close to #246 with an additional argument, but without the type(uint256).max @MathisGD hates so much.

Jean-Grimal
Jean-Grimal previously approved these changes Aug 9, 2023
@MathisGD MathisGD linked an issue Aug 9, 2023 that may be closed by this pull request
@MathisGD MathisGD requested review from a team, Rubilmax, MerlinEgalite, pakim249CAL and Jean-Grimal and removed request for a team August 9, 2023 20:56
@MathisGD MathisGD dismissed stale reviews from MerlinEgalite, Rubilmax, and makcandrov via 091f320 August 10, 2023 10:16
makcandrov
makcandrov previously approved these changes Aug 10, 2023
pakim249CAL
pakim249CAL previously approved these changes Aug 10, 2023
src/libraries/ErrorsLib.sol Outdated Show resolved Hide resolved
@MathisGD MathisGD dismissed stale reviews from pakim249CAL and makcandrov via a0c118a August 10, 2023 10:21
src/libraries/UtilsLib.sol Show resolved Hide resolved
src/libraries/Errors.sol Show resolved Hide resolved
@MathisGD MathisGD mentioned this pull request Aug 10, 2023
@MathisGD MathisGD merged commit b04316d into main Aug 10, 2023
@MathisGD MathisGD deleted the feat/amount-and-shares-as-input branch August 10, 2023 11:39
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.

Reconsider the share input choice
9 participants