-
Notifications
You must be signed in to change notification settings - Fork 2
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
Combine StablePool traits into one #30
Conversation
helpers/stable_swap_math/mod.rs
Outdated
/// Compute the amount of LP tokens to mint after a deposit | ||
/// return <lp_amount_to_mint, lp_fees_part> | ||
/// Given `deposit_amounts` user want deposit, calculates how many lpt | ||
/// is required to be burnt. |
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.
minted, not burned? (also use plural? (are))
helpers/stable_swap_math/mod.rs
Outdated
/// return <lp_amount_to_burn, lp_fees_part> | ||
/// all amounts are in c_amount (comparable amount) | ||
/// Given `withdraw_amounts` user want get, calculates how many lpt | ||
/// is required to be burnt |
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.
are, not is?
amm/contracts/stable_pool/lib.rs
Outdated
/// NOTE: | ||
/// If the pool contains a token with rate oracle, this function makes | ||
/// a cross-contract call to the `RateProvider` contract if the cached rate is expired. | ||
/// This means that the gas cost of the contract methods that use this function may change, |
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.
'vary' instead of 'change'? Feels like a better fitting word 😛
amm/traits/stable_pool.rs
Outdated
amounts: Vec<u128>, | ||
) -> Result<(u128, u128), StablePoolError>; | ||
|
||
/// Calculate ideal deposit amounts required | ||
/// Estimate ideal deposit amounts required |
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.
I would stay with 'Calculate' here and below. 'Estimate' suggests some randomness 😛. I suppose that 'Estimate' here was supposed to account for precision errors. I think 'Calculate' is still a good word, even in presence of precision errors.
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.
LGTM, but I've got a few remarks:
- I don't understand the purpose of merging
StablePool
withStablePoolView
. I've got nothing against it, but I would like to understand the reason (if there's any) - You made all getters to use immutable reference, which required you to remove rate updates from them. It makes sense to have an immutable getter, but consider a scenario when the contract is not used for a long long time for whatever reason. Someone uses a getter to for instance get the mint liquidity for given amounts (they are consideing putting in the liquidity, but want to estimate lpt first). Then they will get very outdated results. Pls consider getting back to
mut
in these getters which use rates. If you disagree, we can discuss that.
The reason was purely cosmetic. Imho it simplifies the contract.
The getters still use updated rates for calculations. The difference is that now the getters don't update the cached rates in the contract. |
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.
Right, sorry, didn't notice that 😉
This PR combines
StablePool
andStablePoolView
into one trait. It also introduces a few less significant changes:&mut self