Skip to content

Commit

Permalink
fix: cofnlicts
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-manuel committed Jun 13, 2024
2 parents 2e60593 + b61f683 commit 14fdf08
Show file tree
Hide file tree
Showing 5 changed files with 512 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/PSM3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ contract PSM3 is IPSM3 {

// NOTE: Assumption is made that asset2 is the yield-bearing counterpart of asset0 and asset1.
// Examples: asset0 = USDC, asset1 = DAI, asset2 = sDAI
IERC20 public immutable asset0;
IERC20 public immutable asset1;
IERC20 public immutable asset2;
IERC20 public override immutable asset0;
IERC20 public override immutable asset1;
IERC20 public override immutable asset2;

address public immutable rateProvider;
address public override immutable rateProvider;

uint256 public totalShares;
uint256 public override totalShares;

mapping(address user => uint256 shares) public shares;
mapping(address user => uint256 shares) public override shares;

constructor(address asset0_, address asset1_, address asset2_, address rateProvider_) {
require(asset0_ != address(0), "PSM3/invalid-asset0");
Expand Down
57 changes: 57 additions & 0 deletions test/Constructor.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.13;

import "forge-std/Test.sol";

import { PSM3 } from "../src/PSM3.sol";

import { PSMTestBase } from "test/PSMTestBase.sol";

contract PSMConstructorTests is PSMTestBase {

function test_constructor_invalidAsset0() public {
vm.expectRevert("PSM3/invalid-asset0");
new PSM3(address(0), address(usdc), address(sDai), address(rateProvider));
}

function test_constructor_invalidAsset1() public {
vm.expectRevert("PSM3/invalid-asset1");
new PSM3(address(dai), address(0), address(sDai), address(rateProvider));
}

function test_constructor_invalidAsset2() public {
vm.expectRevert("PSM3/invalid-asset2");
new PSM3(address(dai), address(usdc), address(0), address(rateProvider));
}

function test_constructor_invalidRateProvider() public {
vm.expectRevert("PSM3/invalid-rateProvider");
new PSM3(address(dai), address(usdc), address(sDai), address(0));
}

function test_constructor_asset0Asset1Match() public {
vm.expectRevert("PSM3/asset0-asset1-same");
new PSM3(address(dai), address(dai), address(sDai), address(rateProvider));
}

function test_constructor_asset0Asset2Match() public {
vm.expectRevert("PSM3/asset0-asset2-same");
new PSM3(address(dai), address(usdc), address(dai), address(rateProvider));
}

function test_constructor_asset1Asset2Match() public {
vm.expectRevert("PSM3/asset1-asset2-same");
new PSM3(address(dai), address(usdc), address(usdc), address(rateProvider));
}

function test_constructor() public {
// Deploy new PSM to get test coverage
psm = new PSM3(address(dai), address(usdc), address(sDai), address(rateProvider));

assertEq(address(psm.asset0()), address(dai));
assertEq(address(psm.asset1()), address(usdc));
assertEq(address(psm.asset2()), address(sDai));
assertEq(address(psm.rateProvider()), address(rateProvider));
}

}
Loading

0 comments on commit 14fdf08

Please sign in to comment.