Skip to content

Commit 6504385

Browse files
committed
make WOUSD inherit from WOETH
1 parent 19854fa commit 6504385

File tree

7 files changed

+33
-62
lines changed

7 files changed

+33
-62
lines changed

contracts/contracts/mocks/MockLimitedWrappedOusd.sol

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ import { WrappedOusd } from "../token/WrappedOusd.sol";
55
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
66

77
contract MockLimitedWrappedOusd is WrappedOusd {
8-
constructor(
9-
ERC20 underlying_,
10-
string memory name_,
11-
string memory symbol_
12-
) WrappedOusd(underlying_, name_, symbol_) {}
8+
constructor(ERC20 underlying_) WrappedOusd(underlying_) {}
139

1410
function maxDeposit(address)
1511
public

contracts/contracts/token/WOETHBase.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-License-Identifier: MIT
1+
// SPDX-License-Identifier: BUSL-1.1
22
pragma solidity ^0.8.0;
33

44
import { WOETH } from "./WOETH.sol";

contracts/contracts/token/WOSonic.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-License-Identifier: MIT
1+
// SPDX-License-Identifier: BUSL-1.1
22
pragma solidity ^0.8.0;
33

44
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,23 @@
1-
// SPDX-License-Identifier: MIT
1+
// SPDX-License-Identifier: BUSL-1.1
22
pragma solidity ^0.8.0;
33

4-
import { ERC4626 } from "../../lib/openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol";
54
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
65
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
7-
import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
8-
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
96

10-
import { Governable } from "../governance/Governable.sol";
11-
import { Initializable } from "../utils/Initializable.sol";
12-
import { OUSD } from "./OUSD.sol";
7+
import { WOETH } from "./WOETH.sol";
138

14-
contract WrappedOusd is ERC4626, Governable, Initializable {
15-
using SafeERC20 for IERC20;
16-
17-
constructor(
18-
ERC20 underlying_,
19-
string memory name_,
20-
string memory symbol_
21-
) ERC20(name_, symbol_) ERC4626(underlying_) Governable() {}
22-
23-
/**
24-
* @notice Enable OUSD rebasing for this contract
25-
*/
26-
function initialize() external onlyGovernor initializer {
27-
OUSD(address(asset())).rebaseOptIn();
28-
}
9+
/**
10+
* @title Wrapped OUSD Token Contract
11+
* @author Origin Protocol Inc
12+
*/
13+
contract WrappedOusd is WOETH {
14+
constructor(ERC20 underlying_) WOETH(underlying_) {}
2915

3016
function name()
3117
public
3218
view
33-
override(ERC20, IERC20Metadata)
19+
virtual
20+
override(WOETH)
3421
returns (string memory)
3522
{
3623
return "Wrapped OUSD";
@@ -39,23 +26,10 @@ contract WrappedOusd is ERC4626, Governable, Initializable {
3926
function symbol()
4027
public
4128
view
42-
override(ERC20, IERC20Metadata)
29+
virtual
30+
override(WOETH)
4331
returns (string memory)
4432
{
4533
return "WOUSD";
4634
}
47-
48-
/**
49-
* @notice Transfer token to governor. Intended for recovering tokens stuck in
50-
* contract, i.e. mistaken sends. Cannot transfer OUSD
51-
* @param asset_ Address for the asset
52-
* @param amount_ Amount of the asset to transfer
53-
*/
54-
function transferToken(address asset_, uint256 amount_)
55-
external
56-
onlyGovernor
57-
{
58-
require(asset_ != address(asset()), "Cannot collect OUSD");
59-
IERC20(asset_).safeTransfer(governor(), amount_);
60-
}
6135
}

contracts/deploy/deployActions.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,8 +1222,6 @@ const deployWOusd = async () => {
12221222
const ousd = await ethers.getContract("OUSDProxy");
12231223
const dWrappedOusdImpl = await deployWithConfirmation("WrappedOusd", [
12241224
ousd.address,
1225-
"Wrapped OUSD IMPL",
1226-
"WOUSD IMPL",
12271225
]);
12281226
await deployWithConfirmation("WrappedOUSDProxy");
12291227
const wousdProxy = await ethers.getContract("WrappedOUSDProxy");

contracts/test/token/woeth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe("WOETH", function () {
4040
const increaseOETHSupplyAndRebase = async (wethAmount) => {
4141
await weth.connect(josh).deposit({ value: wethAmount });
4242
await weth.connect(josh).transfer(oethVault.address, wethAmount);
43-
await oethVault.connect(josh).rebase();
43+
await oethVault.rebase();
4444
};
4545

4646
describe("General functionality", async () => {

contracts/test/token/wousd.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ describe("WOUSD", function () {
77
if (isFork) {
88
this.timeout(0);
99
}
10-
1110
let ousd, wousd, vault, usds, matt, josh, governor;
1211

1312
beforeEach(async () => {
@@ -20,46 +19,54 @@ describe("WOUSD", function () {
2019
josh = fixture.josh;
2120
governor = fixture.governor;
2221

23-
// Josh wraps 50
22+
/* Matt and Josh start out with 100 OUSD
23+
* Josh wraps 50 OUSD to WOETH
24+
*/
2425
await ousd.connect(josh).approve(wousd.address, ousdUnits("1000"));
2526
await wousd.connect(josh).deposit(ousdUnits("50"), josh.address);
2627
// Matt gives money to wOUSD, which counts as yield and changes the effective price of WOUSD
28+
2729
// 1 WOUSD will be worth 2 OUSD
28-
await ousd.connect(matt).transfer(wousd.address, ousdUnits("50"));
30+
await increaseOUSDSupplyAndRebase(await ousd.totalSupply());
2931
});
3032

33+
const increaseOUSDSupplyAndRebase = async (usdsAmount) => {
34+
await usds.connect(matt).transfer(vault.address, usdsAmount);
35+
await vault.rebase();
36+
};
37+
3138
describe("Funds in, Funds out", async () => {
3239
it("should deposit at the correct ratio", async () => {
3340
await wousd.connect(josh).deposit(ousdUnits("50"), josh.address);
3441
await expect(josh).to.have.a.balanceOf("75", wousd);
35-
await expect(josh).to.have.a.balanceOf("0", ousd);
42+
await expect(josh).to.have.a.balanceOf("50", ousd);
3643
});
3744
it("should withdraw at the correct ratio", async () => {
3845
await wousd
3946
.connect(josh)
4047
.withdraw(ousdUnits("50"), josh.address, josh.address);
4148
await expect(josh).to.have.a.balanceOf("25", wousd);
42-
await expect(josh).to.have.a.balanceOf("100", ousd);
49+
await expect(josh).to.have.a.balanceOf("150", ousd);
4350
});
4451
it("should mint at the correct ratio", async () => {
4552
await wousd.connect(josh).mint(ousdUnits("25"), josh.address);
4653
await expect(josh).to.have.a.balanceOf("75", wousd);
47-
await expect(josh).to.have.a.balanceOf("0", ousd);
54+
await expect(josh).to.have.a.balanceOf("50", ousd);
4855
});
4956
it("should redeem at the correct ratio", async () => {
5057
await expect(josh).to.have.a.balanceOf("50", wousd);
5158
await wousd
5259
.connect(josh)
5360
.redeem(ousdUnits("50"), josh.address, josh.address);
5461
await expect(josh).to.have.a.balanceOf("0", wousd);
55-
await expect(josh).to.have.a.balanceOf("150", ousd);
62+
await expect(josh).to.have.a.balanceOf("200", ousd);
5663
});
5764
});
5865

5966
describe("Collects Rebase", async () => {
6067
it("should increase with an OUSD rebase", async () => {
6168
await expect(wousd).to.have.approxBalanceOf("100", ousd);
62-
await usds.connect(josh).transfer(vault.address, usdsUnits("100"));
69+
await usds.connect(josh).transfer(vault.address, usdsUnits("200"));
6370
await vault.rebase();
6471
await expect(wousd).to.have.approxBalanceOf("150", ousd);
6572
});
@@ -85,7 +92,7 @@ describe("WOUSD", function () {
8592
it("should not allow a governor to collect OUSD", async () => {
8693
await expect(
8794
wousd.connect(governor).transferToken(ousd.address, ousdUnits("2"))
88-
).to.be.revertedWith("Cannot collect OUSD");
95+
).to.be.revertedWith("Cannot collect core asset");
8996
});
9097
it("should not allow a non governor to recover tokens ", async () => {
9198
await expect(
@@ -99,11 +106,7 @@ describe("WOUSD", function () {
99106
// Do upgrade
100107
const cWrappedOUSDProxy = await ethers.getContract("WrappedOUSDProxy");
101108
const factory = await ethers.getContractFactory("MockLimitedWrappedOusd");
102-
const dNewImpl = await factory.deploy(
103-
ousd.address,
104-
"WOUSD",
105-
"Wrapped OUSD"
106-
);
109+
const dNewImpl = await factory.deploy(ousd.address);
107110
await cWrappedOUSDProxy.connect(governor).upgradeTo(dNewImpl.address);
108111

109112
// Test basics

0 commit comments

Comments
 (0)