-
Notifications
You must be signed in to change notification settings - Fork 84
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
Balancer fork tests #1727
Merged
sparrowDom
merged 6 commits into
sparrowDom/balancer-sfrxETH-stETH-rETH
from
nicka/balancer-withdraw-tests
Aug 2, 2023
Merged
Balancer fork tests #1727
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8363490
Added large withdraw tests for Balancer strategy
naddison36 9a61790
fix test log
naddison36 36326d3
Balancer withdraw to handle close to BPT limit
naddison36 4b6b06d
Small change to Balancer withdraw fork test
naddison36 633564b
add some comments
sparrowDom 7c9f7d4
change implementation
sparrowDom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ pragma solidity ^0.8.0; | |
* @title OETH Base Balancer Abstract Strategy | ||
* @author Origin Protocol Inc | ||
*/ | ||
|
||
import "@openzeppelin/contracts/utils/math/Math.sol"; | ||
import { BaseBalancerStrategy } from "./BaseBalancerStrategy.sol"; | ||
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; | ||
import { IRateProvider } from "../../interfaces/balancer/IRateProvider.sol"; | ||
|
@@ -78,8 +80,14 @@ abstract contract BaseAuraStrategy is BaseBalancerStrategy { | |
* @param numBPTTokens Number of Balancer Pool Tokens (BPT) to withdraw | ||
*/ | ||
function _lpWithdraw(uint256 numBPTTokens) internal virtual override { | ||
// Get all the strategy's BPTs in Aura | ||
// maxRedeem is implemented as balanceOf(address) in Aura | ||
uint256 maxBPTTokens = IERC4626(auraRewardPoolAddress).maxRedeem( | ||
address(this) | ||
); | ||
|
||
IRewardStaking(auraRewardPoolAddress).withdrawAndUnwrap( | ||
numBPTTokens, | ||
Math.min(numBPTTokens, maxBPTTokens), | ||
true // also claim reward tokens | ||
); | ||
} | ||
|
@@ -89,7 +97,9 @@ abstract contract BaseAuraStrategy is BaseBalancerStrategy { | |
* the Aura rewards pool to this strategy contract. | ||
*/ | ||
function _lpWithdrawAll() internal virtual override { | ||
uint256 bptBalance = IERC4626(auraRewardPoolAddress).balanceOf( | ||
// Get all the strategy's BPTs in Aura | ||
// maxRedeem is implemented as balanceOf(address) in Aura | ||
uint256 bptBalance = IERC4626(auraRewardPoolAddress).maxRedeem( | ||
address(this) | ||
); | ||
|
||
|
@@ -123,7 +133,8 @@ abstract contract BaseAuraStrategy is BaseBalancerStrategy { | |
{ | ||
balancerPoolTokens = | ||
IERC20(platformAddress).balanceOf(address(this)) + | ||
IERC4626(auraRewardPoolAddress).balanceOf(address(this)); | ||
// maxRedeem is implemented as balanceOf(address) in Aura | ||
IERC4626(auraRewardPoolAddress).maxRedeem(address(this)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good point, also good to know that these things are implementation wise equivalent: |
||
} | ||
|
||
function _approveBase() internal virtual override { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 do understand rationale for this, to make it more resilient, but I don't think it is an ok change. I think the caller of this function would expect for AURA to withdraw
numBPTTokens
or fail if it unable to withdraw all.