Skip to content
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

Wrapped OUSD #957

Merged
merged 13 commits into from
Apr 11, 2022
23 changes: 23 additions & 0 deletions contracts/contracts/mocks/MockLimitedWrappedOusd.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { WrappedOusd } from "../token/WrappedOusd.sol";
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract MockLimitedWrappedOusd is WrappedOusd {
constructor(
ERC20 underlying_,
string memory name_,
string memory symbol_
) WrappedOusd(underlying_, name_, symbol_) {}

function maxDeposit(address)
public
view
virtual
override
returns (uint256)
{
return 1e18;
}
}
32 changes: 31 additions & 1 deletion contracts/test/token/wousd.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { defaultFixture } = require("../_fixture");

const { ousdUnits, daiUnits, isFork, loadFixture } = require("../helpers");

describe("WOUSD", function () {
describe.only("WOUSD", function () {
DanielVF marked this conversation as resolved.
Show resolved Hide resolved
if (isFork) {
this.timeout(0);
}
Expand Down Expand Up @@ -93,4 +93,34 @@ describe("WOUSD", function () {
).to.be.revertedWith("Caller is not the Governor");
});
});

describe("WOUSD upgrade", async () => {
it("should be upgradable", async () => {
// Do upgrade
const cWrappedOUSDProxy = await ethers.getContract("WrappedOUSDProxy");
const factory = await ethers.getContractFactory("MockLimitedWrappedOusd");
const dNewImpl = await factory.deploy(
ousd.address,
"WOUSD",
"Wrapped OUSD"
);
await cWrappedOUSDProxy.connect(governor).upgradeTo(dNewImpl.address);

// Test basics
expect(await wousd.decimals()).to.eq(18);
expect(await wousd.name()).to.eq("Wrapped OUSD");
expect(await wousd.symbol()).to.eq("WOUSD");

// Test previous balance
await expect(wousd).to.have.a.balanceOf("100", ousd);
await expect(josh).to.have.a.balanceOf("50", wousd);
await expect(matt).to.have.a.balanceOf("0", wousd);

// Upgraded contract will only allow deposits of up to 1 OUSD
await wousd.connect(josh).deposit(ousdUnits("1"), josh.address);
await expect(
wousd.connect(josh).deposit(ousdUnits("25"), josh.address)
).to.be.revertedWith("ERC4626: deposit more then max");
});
});
});