Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Sherlock 99 #67

Merged
merged 3 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 7 additions & 15 deletions contracts/RedemptionVaultWithBUIDL.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import {SafeERC20Upgradeable as SafeERC20} from "@openzeppelin/contracts-upgrade
import "./RedemptionVault.sol";

import "./interfaces/buidl/IRedemption.sol";
import "./interfaces/buidl/ILiquiditySource.sol";
import "./interfaces/buidl/ISettlement.sol";
import "./libraries/DecimalsCorrectionLibrary.sol";

/**
Expand All @@ -22,12 +20,6 @@ contract RedemptionVaultWIthBUIDL is RedemptionVault {

IRedemption public buidlRedemption;

IERC20 public buidl;

ILiquiditySource public buidlLiquiditySource;

ISettlement public buidlSettlement;

uint256[50] private __gap;

/**
Expand Down Expand Up @@ -68,9 +60,6 @@ contract RedemptionVaultWIthBUIDL is RedemptionVault {
);
_validateAddress(_buidlRedemption, false);
buidlRedemption = IRedemption(_buidlRedemption);
buidlSettlement = ISettlement(buidlRedemption.settlement());
buidlLiquiditySource = ILiquiditySource(buidlRedemption.liquidity());
buidl = IERC20(buidlRedemption.asset());
}

/**
Expand All @@ -97,7 +86,7 @@ contract RedemptionVaultWIthBUIDL is RedemptionVault {
{
address user = msg.sender;

tokenOut = buidlLiquiditySource.token();
tokenOut = buidlRedemption.liquidity();

(
uint256 feeAmount,
Expand Down Expand Up @@ -170,8 +159,11 @@ contract RedemptionVaultWIthBUIDL is RedemptionVault {
if (contractBalanceTokenOut >= amountTokenOut) return;

uint256 buidlToRedeem = amountTokenOut - contractBalanceTokenOut;

buidl.safeIncreaseAllowance(address(buidlRedemption), buidlToRedeem);
buidlRedemption.redeem(buidlToRedeem);
IRedemption _buidlRedemption = buidlRedemption;
IERC20(_buidlRedemption.asset()).safeIncreaseAllowance(
address(buidlRedemption),
buidlToRedeem
);
_buidlRedemption.redeem(buidlToRedeem);
}
}
44 changes: 0 additions & 44 deletions contracts/interfaces/buidl/ILiquiditySource.sol

This file was deleted.

30 changes: 0 additions & 30 deletions contracts/interfaces/buidl/ISettlement.sol

This file was deleted.

16 changes: 0 additions & 16 deletions contracts/mocks/LiquiditySourceTest.sol

This file was deleted.

22 changes: 5 additions & 17 deletions contracts/mocks/RedemptionTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ pragma solidity 0.8.9;

import {IERC20Upgradeable as IERC20} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "../interfaces/buidl/IRedemption.sol";
import "../interfaces/buidl/ILiquiditySource.sol";
import "../interfaces/buidl/ISettlement.sol";

import "hardhat/console.sol";

Expand All @@ -13,25 +11,15 @@ contract RedemptionTest is IRedemption {

address public liquidity;

address public settlement;

constructor(
address _asset,
address _liquidity,
address _settlement
) {
constructor(address _asset, address _liquidity) {
asset = _asset;
liquidity = _liquidity;
settlement = _settlement;
}

function settlement() external view returns (address) {}

function redeem(uint256 amount) external {
IERC20(asset).transferFrom(
msg.sender,
ISettlement(settlement).recipient(),
amount
);
address token = ILiquiditySource(liquidity).token();
IERC20(token).transfer(msg.sender, amount);
IERC20(asset).transferFrom(msg.sender, address(this), amount);
IERC20(liquidity).transfer(msg.sender, amount);
}
}
12 changes: 0 additions & 12 deletions contracts/mocks/SettlementTest.sol

This file was deleted.

5 changes: 0 additions & 5 deletions test/RedemptionVaultWithBUIDL.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ describe('RedemptionVaultWithBUIDL', function () {
it('deployment', async () => {
const {
redemptionVaultWithBUIDL,
liquiditySource,
buidlRedemption,
mTBILL,
tokensReceiver,
Expand Down Expand Up @@ -96,10 +95,6 @@ describe('RedemptionVaultWithBUIDL', function () {
ethers.constants.AddressZero,
);

expect(await redemptionVaultWithBUIDL.buidlLiquiditySource()).eq(
liquiditySource.address,
);

expect(await redemptionVaultWithBUIDL.buidlRedemption()).eq(
buidlRedemption.address,
);
Expand Down
16 changes: 2 additions & 14 deletions test/common/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,10 @@ import {
// eslint-disable-next-line camelcase
WithSanctionsListTester__factory,
// eslint-disable-next-line camelcase
LiquiditySourceTest__factory,
// eslint-disable-next-line camelcase
RedemptionTest__factory,
// eslint-disable-next-line camelcase
RedemptionVaultWithBUIDLTest__factory,
// eslint-disable-next-line camelcase
SettlementTest__factory,
// eslint-disable-next-line camelcase
MBasisRedemptionVaultWithSwapperTest__factory,
} from '../../typechain-types';

Expand Down Expand Up @@ -705,17 +701,11 @@ export const defaultDeploy = async () => {

const buidl = await new ERC20Mock__factory(owner).deploy(8);

const liquiditySource = await new LiquiditySourceTest__factory(owner).deploy(
stableCoins.usdc.address,
);
const settlement = await new SettlementTest__factory(owner).deploy(
regularAccounts[5].address,
);
const buidlRedemption = await new RedemptionTest__factory(owner).deploy(
buidl.address,
liquiditySource.address,
settlement.address,
stableCoins.usdc.address,
);

await stableCoins.usdc.mint(buidlRedemption.address, parseUnits('1000000'));

const redemptionVaultWithBUIDL =
Expand Down Expand Up @@ -938,10 +928,8 @@ export const defaultDeploy = async () => {
mockedSanctionsList,
requestRedeemer,
buidl,
liquiditySource,
buidlRedemption,
redemptionVaultWithBUIDL,
settlement,
mBasisRedemptionVaultWithSwapper,
mBASISToUsdDataFeed,
mockedAggregatorMBASIS,
Expand Down
Loading