Skip to content

Commit de39ee1

Browse files
authored
fix(NotionalTradeModule): audit adjustments
fix(NotionalTradeModule): audit adjustments
2 parents ca55b0e + bf8bf35 commit de39ee1

27 files changed

+2363
-1624
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<p align="center">
2-
<a href="https://circleci.com/gh/SetProtocol/set-protocol-v2/tree/master">
3-
<img src="https://img.shields.io/circleci/project/github/SetProtocol/set-protocol-v2/master.svg" />
2+
<a href="https://circleci.com/gh/IndexCoop/index-protocol/tree/master">
3+
<img src="https://img.shields.io/circleci/project/github/IndexCoop/index-protocol/master.svg" />
44
</a>
5-
<a href='https://coveralls.io/github/SetProtocol/set-protocol-v2?branch=master'><img src='https://coveralls.io/repos/github/SetProtocol/set-protocol-v2/badge.svg?branch=master&amp;t=4pzROZ' alt='Coverage Status' /></a>
5+
<a href='https://coveralls.io/github/IndexCoop/index-protocol?branch=master'><img src='https://coveralls.io/repos/github/IndexCoop/index-protocol/badge.svg?branch=master' alt='Coverage Status' /></a>
66
</p>
77

88
# Set Protocol V2 Contract Repository
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// SPDX-License-Identifier: agpl-3.0
2+
pragma solidity 0.6.10;
3+
4+
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
5+
6+
interface IERC20Metadata is IERC20 {
7+
function name() external view returns (string memory);
8+
9+
function symbol() external view returns (string memory);
10+
11+
function decimals() external view returns (uint8);
12+
}
13+

contracts/interfaces/IWrappedFCash.sol

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
pragma solidity 0.6.10;
33
pragma experimental "ABIEncoderV2";
44

5-
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
5+
import "./IERC20Metadata.sol";
66

77
/// @notice Different types of internal tokens
88
/// - UnderlyingToken: underlying asset for a cToken (except for Ether)
@@ -65,4 +65,7 @@ interface IWrappedfCash {
6565
}
6666

6767

68-
interface IWrappedfCashComplete is IWrappedfCash, IERC20 {}
68+
interface IWrappedfCashComplete is IWrappedfCash, IERC20Metadata {
69+
/// @notice Returns the maturity of the underlying fCash instance
70+
function getMaturity() external view returns (uint40);
71+
}

contracts/interfaces/external/INotionalProxy.sol

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// SPDX-License-Identifier: GPL-3.0-only
2+
pragma solidity 0.6.10;
3+
pragma experimental "ABIEncoderV2";
4+
5+
/// @dev Market object as represented in memory
6+
struct MarketParameters {
7+
bytes32 storageSlot;
8+
uint256 maturity;
9+
// Total amount of fCash available for purchase in the market.
10+
int256 totalfCash;
11+
// Total amount of cash available for purchase in the market.
12+
int256 totalAssetCash;
13+
// Total amount of liquidity tokens (representing a claim on liquidity) in the market.
14+
int256 totalLiquidity;
15+
// This is the previous annualized interest rate in RATE_PRECISION that the market traded
16+
// at. This is used to calculate the rate anchor to smooth interest rates over time.
17+
uint256 lastImpliedRate;
18+
// Time lagged version of lastImpliedRate, used to value fCash assets at market rates while
19+
// remaining resistent to flash loan attacks.
20+
uint256 oracleRate;
21+
// This is the timestamp of the previous trade
22+
uint256 previousTradeTime;
23+
}
24+
25+
26+
interface INotionalV2 {
27+
function getfCashLendFromDeposit(
28+
uint16 currencyId,
29+
uint256 depositAmountExternal,
30+
uint256 maturity,
31+
uint32 minLendRate,
32+
uint256 blockTime,
33+
bool useUnderlying
34+
) external view returns (
35+
uint88 fCashAmount,
36+
uint8 marketIndex,
37+
bytes32 encodedTrade
38+
);
39+
40+
function getfCashBorrowFromPrincipal(
41+
uint16 currencyId,
42+
uint256 borrowedAmountExternal,
43+
uint256 maturity,
44+
uint32 maxBorrowRate,
45+
uint256 blockTime,
46+
bool useUnderlying
47+
) external view returns (
48+
uint88 fCashDebt,
49+
uint8 marketIndex,
50+
bytes32 encodedTrade
51+
);
52+
53+
}
54+
55+
interface INotionalV2Complete is INotionalV2 {
56+
function getCurrencyId(address tokenAddress) external view returns (uint16 currencyId);
57+
58+
function getActiveMarkets(uint16 currencyId) external view returns (MarketParameters[] memory);
59+
60+
function updateAssetRate(uint16 currencyId, address rateOracle) external;
61+
62+
function upgradeTo(address newAddress) external;
63+
64+
function owner() external view returns(address);
65+
}
66+

contracts/mocks/NotionalV2Mock.sol

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// SPDX-License-Identifier: GPL-3.0-only
2+
pragma solidity 0.6.10;
3+
pragma experimental "ABIEncoderV2";
4+
5+
import { INotionalV2 } from "../interfaces/external/INotionalV2.sol";
6+
7+
8+
contract NotionalV2Mock is INotionalV2 {
9+
uint88 fCashEstimation;
10+
11+
function setFCashEstimation(uint88 _fCashEstimation) public {
12+
fCashEstimation = _fCashEstimation;
13+
}
14+
15+
function getfCashLendFromDeposit(
16+
uint16 currencyId,
17+
uint256 depositAmountExternal,
18+
uint256 maturity,
19+
uint32 minLendRate,
20+
uint256 blockTime,
21+
bool useUnderlying
22+
) external view override returns (
23+
uint88 fCashAmount,
24+
uint8 marketIndex,
25+
bytes32 encodedTrade
26+
) {
27+
fCashAmount = fCashEstimation;
28+
}
29+
30+
function getfCashBorrowFromPrincipal(
31+
uint16 currencyId,
32+
uint256 borrowedAmountExternal,
33+
uint256 maturity,
34+
uint32 maxBorrowRate,
35+
uint256 blockTime,
36+
bool useUnderlying
37+
) external view override returns (
38+
uint88 fCashDebt,
39+
uint8 marketIndex,
40+
bytes32 encodedTrade
41+
) {
42+
fCashDebt = fCashEstimation;
43+
}
44+
}
45+

contracts/mocks/WrappedfCashMock.sol

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ contract WrappedfCashMock is ERC20, IWrappedfCash {
3636
IERC20 private assetToken;
3737
int256 private assetPrecision;
3838
TokenType private tokenType;
39+
bool private isEth;
3940

4041
IERC20 private weth;
4142

@@ -46,10 +47,11 @@ contract WrappedfCashMock is ERC20, IWrappedfCash {
4647

4748
address internal constant ETH_ADDRESS = address(0);
4849

49-
constructor (IERC20 _assetToken, IERC20 _underlyingToken, IERC20 _weth) public ERC20("FCashMock", "FCM") {
50+
constructor (IERC20 _assetToken, IERC20 _underlyingToken, IERC20 _weth, bool _isEth) public ERC20("FCashMock", "FCM") {
5051
assetToken = _assetToken;
5152
underlyingToken = _underlyingToken;
5253
weth = _weth;
54+
isEth = _isEth;
5355
}
5456

5557
function initialize(uint16 _currencyId, uint40 _maturity) external override {
@@ -162,13 +164,13 @@ contract WrappedfCashMock is ERC20, IWrappedfCash {
162164
revertDecodedID = _revertDecodedID;
163165
}
164166

165-
function getToken(bool useUnderlying) public view override returns (IERC20 token, bool isETH) {
167+
function getToken(bool useUnderlying) public view override returns (IERC20 token, bool _isEth) {
166168
if (useUnderlying) {
167169
(token, /* */) = getUnderlyingToken();
170+
_isEth = isEth;
168171
} else {
169172
(token, /* */, /* */) = getAssetToken();
170173
}
171-
isETH = address(token) == ETH_ADDRESS;
172174
}
173175

174176

contracts/protocol/integration/wrap/notional/WrappedfCash.sol

Lines changed: 0 additions & 10 deletions
This file was deleted.

contracts/protocol/integration/wrap/notional/WrappedfCashFactory.sol

Lines changed: 0 additions & 8 deletions
This file was deleted.

contracts/protocol/integration/wrap/notional/nBeaconProxy.sol

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)