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

Aerodrome OETH AMO #2019

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open

Aerodrome OETH AMO #2019

wants to merge 35 commits into from

Conversation

PraneshASP
Copy link
Contributor

@PraneshASP PraneshASP commented Apr 15, 2024

If you made a contract change, make sure to complete the checklist below before merging it in master.

Refer to our documentation for more details about contract security best practices.

Contract change checklist:

  • Code reviewed by 2 reviewers.
  • Copy & paste code review security checklist below this checklist.
  • Unit tests pass
  • Slither tests pass with no warning
  • Echidna tests pass if PR includes changes to OUSD contract (not automated, run manually on local)

Notion resources:

Copy link

github-actions bot commented Apr 15, 2024

Warnings
⚠️ 👀 This PR needs at least 2 reviewers

Generated by 🚫 dangerJS against 5afa21c

@PraneshASP PraneshASP marked this pull request as ready for review April 19, 2024 05:35
@PraneshASP PraneshASP self-assigned this Apr 29, 2024
@DanielVF DanielVF added the contracts Works related to contracts label May 8, 2024
* @param r2 The reserve of OETH.
* @return The calculated constant K.
*/
function getK(uint256 r1, uint256 r2) internal pure returns (uint256) {
Copy link
Member

Choose a reason for hiding this comment

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

Since this is an internal function, it should get an underscore.


function _lpWithdraw(uint256 _lpTokensAmount) internal {
// Claim remaining rwards before withdrawing LP Tokens
aeroGaugeAddress.getReward(address(this));
Copy link
Member

Choose a reason for hiding this comment

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

Do we lose these reward tokens if we don't withdraw them? If not, it might just make things easier to not withdraw them until they are ready to be passed on. Less gas, and less things that could go wrong during a withdraw.

* the pool's balance is not worsened.
* Withdrawals are proportional so doesn't change the pools asset balance.
*/
modifier improvePoolBalance() {
Copy link
Member

@DanielVF DanielVF May 8, 2024

Choose a reason for hiding this comment

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

This method should check the pool's balances before the action that the modifier wraps, then compare them again after.

This way we check that things got better during the action.

If I'm reading this correctly, this only compares the balances/ratios after the action has taken place, which means it will not be able to compare the before and after to see if the difference is better?

What is this modifier currently trying to do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is this modifier currently trying to do?

This modifier is used to make sure after rebalancing, the pool ratio doesn't skew more than the allowed threshold. As long as the ratio remains within threshold, we should be good. It helps avoid errors from the strategist while rebalancing the pool. This also gives the strategist the flexibility to rebalance the pool as per the market conditions.

This way we check that things got better during the action.

To validate that we should define what we mean by "better" for the pool. Does it mean the pool should be closer to 50:50 ratio or should it be unbalanced till the safest point.

* 10 digits. This way we move the decimal point by 36 places when doing the calculation
* and again by 36 places when we are done with it.
*/
uint256 k = (1e36 * IERC20(address(lpTokenAddress)).totalSupply()) /
Copy link
Member

Choose a reason for hiding this comment

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

Might want to avoid calling this 'k' because it's a very different thing than the AMM's k, which is also calculated elsewhere in the code.

poolWETHBalance;
// prettier-ignore
// slither-disable-next-line divide-before-multiply
uint256 diff = (_wethAmount + 1) * k;
Copy link
Member

Choose a reason for hiding this comment

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

This calculation currently calculates a ratio, then uses that ratio to calculate the end result. This is slightly lossy in doing two calculations with rounding errors, which requires the extra high intermediate precision.

Would this be much simpler and less if we just move the (_wethAmount+1) to be directly multiplied by the totalSupply in the first step?

Something like:

(_wethAmount+1) * totalSupply / poolWETHBalance ?

uint256 _amountIn,
uint256 _minAmountOut,
address _tokenIn,
address _recipient
Copy link
Member

Choose a reason for hiding this comment

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

The strategist should not be able to steal tokens from the strategy / vault. We should probably remove the _recipient option here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we remove the _recipient, where should the swapped weth sent? Will it be held in the AMO contract?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contracts Works related to contracts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants