Skip to content

Commit

Permalink
Oz version upgrade (#120)
Browse files Browse the repository at this point in the history
* upgraded oz to v5.0

* pulled latest changes from main

* added upgarder role

* fix: typo
  • Loading branch information
Krishnakumarskr authored Oct 4, 2024
1 parent 7aadefb commit 9713cfc
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
[submodule "packages/contracts/lib/openzeppelin-contracts-upgradeable"]
path = packages/contracts/lib/openzeppelin-contracts-upgradeable
url = https://github.com/openzeppelin/openzeppelin-contracts-upgradeable
baranch = release-v4.9
branch = release-v5.0
2 changes: 1 addition & 1 deletion packages/contracts/lib/openzeppelin-contracts-upgradeable
2 changes: 2 additions & 0 deletions packages/contracts/resource/ci.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ owner = "0xD79Be36f61fce3B8EF2FBF22b13B2b9a68eE15A2"
operator = "0xaD3C004eE1f942BFDA2DA0D2DAaC94d6aC012F75"
# devops custodian (wallet 3) - public address, okay to share
custodian = "0x8561845F6a9511cD8e2daCae77A961e718A77cF6"
# devops upgrader (wallet 4) - public address, okay to share
upgrader = "0xaD3C004eE1f942BFDA2DA0D2DAaC94d6aC012F75"

[evm.contracts.liquid_continuous_multi_token_vault]
# rate in basis points, e.g. 10% = 1000 bps
Expand Down
2 changes: 2 additions & 0 deletions packages/contracts/resource/local.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ owner = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
operator = "0x70997970C51812dc3A010C7d01b50e0d17dc79C8"
# Dev/Anvil Wallet, Account[2]
custodian = "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC"
# Dev/Anvil Wallet, Account[3]
upgrader = "0x90F79bf6EB2c4f870365E785982E1f101E93b906"

[evm.contracts.liquid_continuous_multi_token_vault]
# rate in basis points, e.g. 10% = 1000 bps
Expand Down
2 changes: 2 additions & 0 deletions packages/contracts/resource/testnet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ owner = "0xD79Be36f61fce3B8EF2FBF22b13B2b9a68eE15A2"
operator = "0xaD3C004eE1f942BFDA2DA0D2DAaC94d6aC012F75"
# devops custodian (wallet 3) - public address, okay to share
custodian = "0x8561845F6a9511cD8e2daCae77A961e718A77cF6"
# devops upgrader (wallet 4) - public address, okay to share
upgrader = "0xaD3C004eE1f942BFDA2DA0D2DAaC94d6aC012F75"

[evm.contracts.liquid_continuous_multi_token_vault]
# rate in basis points, e.g. 10% = 1000 bps
Expand Down
3 changes: 3 additions & 0 deletions packages/contracts/script/DeployLiquidMultiTokenVault.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ contract DeployLiquidMultiTokenVault is TomlConfig {

address private owner;
address private operator;
address private upgrader;

constructor() {
tomlConfig = loadTomlConfiguration();

owner = tomlConfig.readAddress(".evm.address.owner");
operator = tomlConfig.readAddress(".evm.address.operator");
upgrader = tomlConfig.readAddress(".evm.address.upgrader");
}

function run() public returns (LiquidContinuousMultiTokenVault vault) {
Expand Down Expand Up @@ -112,6 +114,7 @@ contract DeployLiquidMultiTokenVault is TomlConfig {
LiquidContinuousMultiTokenVault.VaultParams memory vaultParams = LiquidContinuousMultiTokenVault.VaultParams({
contractOwner: contractOwner,
contractOperator: operator,
contractUpgrader: upgrader,
asset: asset,
yieldStrategy: yieldStrategy,
redeemOptimizer: redeemOptimizer,
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts/src/token/ERC1155/IMultiTokenVault.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import { IERC1155Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol";
import { IERC1155 } from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";

/**
* @title IMultiTokenVault
Expand All @@ -10,7 +10,7 @@ import { IERC1155Upgradeable } from "@openzeppelin/contracts-upgradeable/token/E
* - Users redeem ERC1155 share tokens, and the vault returns the corresponding amount of ERC20 assets.
* - Each deposit period has its own ERC1155 share token, allowing for time-based calculations, e.g. for returns.
*/
interface IMultiTokenVault is IERC1155Upgradeable {
interface IMultiTokenVault is IERC1155 {
/// @notice The event is being emitted once user deposits.
event Deposit(
address indexed sender, address indexed receiver, uint256 depositPeriod, uint256 assets, uint256 shares
Expand Down
39 changes: 16 additions & 23 deletions packages/contracts/src/token/ERC1155/MultiTokenVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ pragma solidity ^0.8.23;
import { IMultiTokenVault } from "@credbull/token/ERC1155/IMultiTokenVault.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { IERC165Upgradeable } from "@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol";
import { IERC1155Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol";
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import { IERC1155 } from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import { ERC1155Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol";
import { ERC1155SupplyUpgradeable } from
"@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155SupplyUpgradeable.sol";
import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
import { ERC1155PausableUpgradeable } from
"@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155PausableUpgradeable.sol";
import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
Expand Down Expand Up @@ -254,7 +254,7 @@ abstract contract MultiTokenVault is
public
view
virtual
override(IERC165Upgradeable, ERC1155Upgradeable)
override(IERC165, ERC1155Upgradeable)
returns (bool)
{
return interfaceId == type(IMultiTokenVault).interfaceId || super.supportsInterface(interfaceId);
Expand Down Expand Up @@ -311,22 +311,19 @@ abstract contract MultiTokenVault is
emit Withdraw(caller, receiver, owner, depositPeriod, assets, shares);
}

function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual override(ERC1155SupplyUpgradeable, ERC1155PausableUpgradeable) {
super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
function _update(address from, address to, uint256[] memory ids, uint256[] memory values)
internal
virtual
override(ERC1155SupplyUpgradeable, ERC1155PausableUpgradeable)
{
super._update(from, to, ids, values);
}

function balanceOf(address account, uint256 id)
public
view
virtual
override(ERC1155Upgradeable, IERC1155Upgradeable)
override(ERC1155Upgradeable, IERC1155)
returns (uint256)
{
return super.balanceOf(account, id);
Expand All @@ -336,7 +333,7 @@ abstract contract MultiTokenVault is
public
view
virtual
override(ERC1155Upgradeable, IERC1155Upgradeable)
override(ERC1155Upgradeable, IERC1155)
returns (uint256[] memory)
{
return super.balanceOfBatch(accounts, ids);
Expand All @@ -346,24 +343,20 @@ abstract contract MultiTokenVault is
public
view
virtual
override(ERC1155Upgradeable, IERC1155Upgradeable)
override(ERC1155Upgradeable, IERC1155)
returns (bool)
{
return super.isApprovedForAll(account, operator);
}

function setApprovalForAll(address operator, bool approved)
public
virtual
override(ERC1155Upgradeable, IERC1155Upgradeable)
{
function setApprovalForAll(address operator, bool approved) public virtual override(ERC1155Upgradeable, IERC1155) {
super.setApprovalForAll(operator, approved);
}

function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes memory data)
public
virtual
override(ERC1155Upgradeable, IERC1155Upgradeable)
override(ERC1155Upgradeable, IERC1155)
{
super.safeTransferFrom(from, to, id, amount, data);
}
Expand All @@ -374,7 +367,7 @@ abstract contract MultiTokenVault is
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) public virtual override(ERC1155Upgradeable, IERC1155Upgradeable) {
) public virtual override(ERC1155Upgradeable, IERC1155) {
super.safeBatchTransferFrom(from, to, ids, amounts, data);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ contract LiquidContinuousMultiTokenVault is
struct VaultParams {
address contractOwner;
address contractOperator;
address contractUpgrader;
IERC20Metadata asset;
IYieldStrategy yieldStrategy;
IRedeemOptimizer redeemOptimizer;
Expand Down Expand Up @@ -85,7 +86,7 @@ contract LiquidContinuousMultiTokenVault is

_grantRole(DEFAULT_ADMIN_ROLE, vaultParams.contractOwner);
_grantRole(OPERATOR_ROLE, vaultParams.contractOperator);
_grantRole(UPGRADER_ROLE, vaultParams.contractOperator);
_grantRole(UPGRADER_ROLE, vaultParams.contractUpgrader);

yieldStrategy = vaultParams.yieldStrategy;
redeemOptimizer = vaultParams.redeemOptimizer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ contract LiquidContinuousMultiTokenVaultTest is IMultiTokenVaultTestBase {
//Upgrade contract
LiquidContinuousMultiTokenVaultMockV2 mockVaultV2 = new LiquidContinuousMultiTokenVaultMockV2();

vm.prank(_vaultParams.contractOperator);
mockVault.upgradeTo(address(mockVaultV2));
vm.prank(_vaultParams.contractUpgrader);
mockVault.upgradeToAndCall(address(mockVaultV2), "");

assertEq("2.0.0", mockVaultV2.version(), "version should be 2.0.0");

Expand Down

0 comments on commit 9713cfc

Please sign in to comment.