Skip to content

Commit

Permalink
[Fix] pUSD comments 2 (#108)
Browse files Browse the repository at this point in the history
* remove BASE from componenttoken, change IVault contract to IBoringVault

* vm.skip(true) and return REQUEST_ID

* add _BASE back to componenttoken, change it's visibility, remove from AggregateToken
  • Loading branch information
ungaro committed Dec 12, 2024
1 parent 7e7a27f commit 5439b51
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 35 deletions.
8 changes: 4 additions & 4 deletions nest/script/UpgradepUSD.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,20 @@ contract UpgradePUSD is Script, Test {
console2.log("Vault:", currentVault);
console2.log("Total Supply:", currentTotalSupply);
} else {
vm.assume(true);
vm.skip(true);
isConnected = false;
}
} catch {
console2.log("No implementation found - skipping");
vm.assume(true);
vm.skip(true);
isConnected = false;
}
}

function testSimulateUpgrade() public {
// Deploy new implementation in test environment
if (!isConnected) {
vm.assume(true);
vm.skip(true);
} else {
vm.startPrank(ADMIN_ADDRESS);

Expand All @@ -85,7 +85,7 @@ contract UpgradePUSD is Script, Test {

function run() external {
if (!isConnected) {
vm.assume(true);
vm.skip(true);
} else {
vm.startBroadcast(ADMIN_ADDRESS);

Expand Down
2 changes: 0 additions & 2 deletions nest/src/AggregateToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ contract AggregateToken is ComponentToken, IAggregateToken, ERC1155Holder {

// Constants

// Base that is used to divide all price inputs in order to represent e.g. 1.000001 as 1000001e12
uint256 private constant _BASE = 1e18;
/// @notice Role for the price updater of the AggregateToken
bytes32 public constant PRICE_UPDATER_ROLE = keccak256("PRICE_UPDATER_ROLE");

Expand Down
6 changes: 3 additions & 3 deletions nest/src/ComponentToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ abstract contract ComponentToken is
// Constants

/// @notice All ComponentToken requests are fungible and all have ID = 0
uint256 private constant REQUEST_ID = 0;
uint256 internal constant REQUEST_ID = 0;
/// @notice Role for the admin of the ComponentToken
bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
/// @notice Role for the upgrader of the ComponentToken
bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");
/// @notice Base that is used to divide all price inputs in order to represent e.g. 1.000001 as 1000001e12
uint256 private constant _BASE = 1e18;

uint256 internal constant _BASE = 1e18;
// Events

/**
Expand Down
2 changes: 1 addition & 1 deletion nest/src/interfaces/IBoringVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.25;
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";

interface IVault is IERC20, IERC20Metadata {
interface IBoringVault is IERC20, IERC20Metadata {

/**
* @notice Deposits assets into the vault in exchange for shares
Expand Down
12 changes: 6 additions & 6 deletions nest/src/interfaces/ILens.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.25;

import { IAccountantWithRateProviders } from "./IAccountantWithRateProviders.sol";

import { IVault } from "./IBoringVault.sol";
import { IBoringVault } from "./IBoringVault.sol";
import { ITeller } from "./ITeller.sol";

import { IERC20 } from "@openzeppelin/contracts/interfaces/IERC20.sol";
Expand All @@ -14,22 +14,22 @@ interface ILens {
error InvalidVault();

function totalAssets(
IVault vault,
IBoringVault vault,
IAccountantWithRateProviders accountant
) external view returns (IERC20 asset, uint256 assets);

function previewDeposit(
IERC20 depositAsset,
uint256 depositAmount,
IVault vault,
IBoringVault vault,
IAccountantWithRateProviders accountant
) external view returns (uint256 shares);

function balanceOf(address account, IVault vault) external view returns (uint256 shares);
function balanceOf(address account, IBoringVault vault) external view returns (uint256 shares);

function balanceOfInAssets(
address account,
IVault vault,
IBoringVault vault,
IAccountantWithRateProviders accountant
) external view returns (uint256 assets);

Expand All @@ -41,7 +41,7 @@ interface ILens {
address account,
IERC20 depositAsset,
uint256 depositAmount,
IVault vault,
IBoringVault vault,
ITeller teller
) external view returns (bool);

Expand Down
19 changes: 7 additions & 12 deletions nest/src/mocks/MockLens.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.25;

import { IAccountantWithRateProviders } from "../interfaces/IAccountantWithRateProviders.sol";

import { IVault } from "../interfaces/IBoringVault.sol";
import { IBoringVault } from "../interfaces/IBoringVault.sol";
import { ILens } from "../interfaces/ILens.sol";
import { ITeller } from "../interfaces/ITeller.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
Expand All @@ -20,7 +20,7 @@ contract MockLens is ILens {
mapping(address => mapping(address => uint256)) private vaultBalances;

function totalAssets(
IVault vault,
IBoringVault vault,
IAccountantWithRateProviders accountant
) external view override returns (IERC20 asset, uint256 assets) {
uint256 totalSupply = vault.totalSupply();
Expand All @@ -31,7 +31,7 @@ contract MockLens is ILens {
function previewDeposit(
IERC20 depositAsset,
uint256 depositAmount,
IVault vault,
IBoringVault vault,
IAccountantWithRateProviders accountant
) external view override returns (uint256 shares) {
// Check if we have a preset value
Expand All @@ -44,12 +44,7 @@ contract MockLens is ILens {
try vault.decimals() returns (uint8 shareDecimals) {
return depositAmount.mulDivDown(10 ** shareDecimals, rate);
} catch {
// Explicitly revert with InvalidVault error
bytes4 selector = bytes4(keccak256("InvalidVault()"));
assembly {
mstore(0, selector)
revert(0, 4)
}
revert InvalidVault();
}
}

Expand All @@ -65,7 +60,7 @@ contract MockLens is ILens {
balances[account] = balance;
}

function balanceOf(address account, IVault vault) external view override returns (uint256) {
function balanceOf(address account, IBoringVault vault) external view override returns (uint256) {
// First check if we have a preset balance
if (balances[account] != 0) {
return balances[account];
Expand All @@ -76,7 +71,7 @@ contract MockLens is ILens {

function balanceOfInAssets(
address account,
IVault vault,
IBoringVault vault,
IAccountantWithRateProviders accountant
) external view override returns (uint256 assets) {
uint256 shares = vault.balanceOf(account);
Expand All @@ -96,7 +91,7 @@ contract MockLens is ILens {
address account,
IERC20 depositAsset,
uint256 depositAmount,
IVault vault,
IBoringVault vault,
ITeller teller
) external view override returns (bool) {
if (depositAsset.balanceOf(account) < depositAmount) {
Expand Down
4 changes: 2 additions & 2 deletions nest/src/mocks/MockVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.s
import { ERC721Holder } from "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
import { Auth, Authority } from "@solmate/auth/Auth.sol";

import { IVault } from "../interfaces/IBoringVault.sol";
import { IBoringVault } from "../interfaces/IBoringVault.sol";

contract MockVault is ERC20, Auth, ERC721Holder, ERC1155Holder, IVault {
contract MockVault is ERC20, Auth, ERC721Holder, ERC1155Holder, IBoringVault {

using SafeERC20 for IERC20;

Expand Down
10 changes: 5 additions & 5 deletions nest/src/token/BoringVaultAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { FixedPointMathLib } from "@solmate/utils/FixedPointMathLib.sol";

import { IAccountantWithRateProviders } from "../interfaces/IAccountantWithRateProviders.sol";
import { IAtomicQueue } from "../interfaces/IAtomicQueue.sol";
import { IVault } from "../interfaces/IBoringVault.sol";
import { IBoringVault } from "../interfaces/IBoringVault.sol";
import { IComponentToken } from "../interfaces/IComponentToken.sol";
import { ILens } from "../interfaces/ILens.sol";
import { ITeller } from "../interfaces/ITeller.sol";
Expand Down Expand Up @@ -55,7 +55,7 @@ abstract contract BoringVaultAdapter is

struct BoringVault {
ITeller teller;
IVault vault;
IBoringVault vault;
IAtomicQueue atomicQueue;
ILens lens;
IAccountantWithRateProviders accountant;
Expand Down Expand Up @@ -131,7 +131,7 @@ abstract contract BoringVaultAdapter is

BoringVaultAdapterStorage storage $ = _getBoringVaultAdapterStorage();
$.boringVault.teller = ITeller(teller_);
$.boringVault.vault = IVault(vault_);
$.boringVault.vault = IBoringVault(vault_);
$.boringVault.atomicQueue = IAtomicQueue(atomicQueue_);
$.boringVault.lens = ILens(lens_);
$.boringVault.accountant = IAccountantWithRateProviders(accountant_);
Expand Down Expand Up @@ -172,7 +172,7 @@ abstract contract BoringVaultAdapter is
// Increment version
$.version += 1;
$.boringVault.teller = ITeller(teller_);
$.boringVault.vault = IVault(vault_);
$.boringVault.vault = IBoringVault(vault_);
$.boringVault.atomicQueue = IAtomicQueue(atomicQueue_);
$.boringVault.lens = ILens(lens_);
$.boringVault.accountant = IAccountantWithRateProviders(accountant_);
Expand Down Expand Up @@ -325,7 +325,7 @@ abstract contract BoringVaultAdapter is
IAtomicQueue queue = _getBoringVaultAdapterStorage().boringVault.atomicQueue;
queue.updateAtomicRequest(IERC20(address(this)), IERC20(asset()), request);

return 0; // ComponentToken's standard REQUEST_ID
return REQUEST_ID;
}

/**
Expand Down

0 comments on commit 5439b51

Please sign in to comment.