Skip to content

Commit

Permalink
Merge pull request #296 from Midas-Protocol/feat/more-beefy4626-assets
Browse files Browse the repository at this point in the history
testing different cake LP tokens with the BeefyERC4626
  • Loading branch information
vminkov authored Jul 1, 2022
2 parents be12ca5 + 7d8c326 commit c834e06
Show file tree
Hide file tree
Showing 15 changed files with 263 additions and 240 deletions.
2 changes: 1 addition & 1 deletion contracts/compound/strategies/BeefyERC4626.sol
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ contract BeefyERC4626 is MidasERC4626 {

// takes as argument the internal ERC4626 shares to redeem
// returns the external BeefyVault shares to withdraw
function convertToBeefyVaultShares(uint256 shares) public returns (uint256) {
function convertToBeefyVaultShares(uint256 shares) public view returns (uint256) {
uint256 supply = totalSupply;
return supply == 0 ? shares : shares.mulDivUp(beefyVault.balanceOf(address(this)), supply);
}
Expand Down
1 change: 0 additions & 1 deletion contracts/compound/strategies/MidasERC4626.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ abstract contract MidasERC4626 is ERC4626, Ownable, Pausable {
address receiver,
address owner
) public override returns (uint256 assets) {
uint256 supply = totalSupply;
if (msg.sender != owner) {
uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals.

Expand Down
10 changes: 4 additions & 6 deletions contracts/test/AlpacaERC4626Test.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,8 @@ contract AlpacaERC4626Test is BaseTest {
assertEq(alpacaERC4626.balanceOf(address(this)), erc4626BalBefore - expectedErc4626SharesNeeded, "!erc4626 supply");

// Test that the ERC4626 holds the expected amount of beefy shares
assertEq(
mockVault.balanceOf(address(alpacaERC4626)),
beefyShares - expectedBeefySharesNeeded,
assertTrue(
diff(mockVault.balanceOf(address(alpacaERC4626)), beefyShares - expectedBeefySharesNeeded) <= 1,
"!beefy share balance"
);

Expand Down Expand Up @@ -281,9 +280,8 @@ contract AlpacaERC4626Test is BaseTest {
assertEq(alpacaERC4626.balanceOf(address(1)), erc4626BalBefore - expectedErc4626SharesNeeded, "!erc4626 supply");

// Test that the ERC4626 holds the expected amount of beefy shares
assertEq(
mockVault.balanceOf(address(alpacaERC4626)),
beefyShares - expectedBeefySharesNeeded,
assertTrue(
diff(mockVault.balanceOf(address(alpacaERC4626)), beefyShares - expectedBeefySharesNeeded) <= 1,
"!beefy share balance"
);

Expand Down
Loading

0 comments on commit c834e06

Please sign in to comment.