Skip to content
This repository has been archived by the owner on Jan 16, 2022. It is now read-only.

Commit

Permalink
rename to v1
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeyrf committed Jun 3, 2021
1 parent 1e4d913 commit fbb22c4
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import "@openzeppelin/contracts/access/Ownable.sol";
import "./interfaces/IMirinFactory.sol";
import "./interfaces/IMirinOracle.sol";

import "./OverlayMirinMarket.sol";
import "./OverlayV1MirinMarket.sol";
import "./OverlayToken.sol";

contract OverlayMirinFactory is Ownable {
contract OverlayV1MirinFactory is Ownable {

uint16 public constant MIN_FEE = 1; // 0.01%
uint16 public constant MAX_FEE = 100; // 1.00%
Expand Down Expand Up @@ -83,10 +83,10 @@ contract OverlayMirinFactory is Ownable {
uint112 fundingKNumerator,
uint112 fundingKDenominator,
uint256 amountIn
) external onlyOwner returns (OverlayMirinMarket marketContract) {
) external onlyOwner returns (OverlayV1MirinMarket marketContract) {
require(IMirinFactory(mirinFactory).isPool(mirinPool), "OverlayV1: !MirinPool");
require(IMirinOracle(mirinPool).pricePointsLength() > 1, "OverlayV1: !MirinInitialized");
marketContract = new OverlayMirinMarket(
marketContract = new OverlayV1MirinMarket(
ovl,
mirinPool,
isPrice0,
Expand Down Expand Up @@ -132,13 +132,13 @@ contract OverlayMirinFactory is Ownable {

/// @notice Calls the update function on a market
function updateMarket(address market, address rewardsTo) external {
OverlayMirinMarket(market).update(rewardsTo);
OverlayV1MirinMarket(market).update(rewardsTo);
}

/// @notice Mass calls update functions on all markets
function massUpdateMarkets(address rewardsTo) external {
for (uint256 i=0; i < allMarkets.length; ++i) {
OverlayMirinMarket(allMarkets[i]).update(rewardsTo);
OverlayV1MirinMarket(allMarkets[i]).update(rewardsTo);
}
}

Expand All @@ -152,7 +152,7 @@ contract OverlayMirinFactory is Ownable {
uint112 fundingKNumerator,
uint112 fundingKDenominator
) external onlyOwner {
OverlayMirinMarket(market).adjustParams(
OverlayV1MirinMarket(market).adjustParams(
updatePeriod,
leverageMax,
marginAdjustment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ pragma solidity ^0.8.2;

import "./libraries/FixedPoint.sol";
import "./interfaces/IMirinOracle.sol";
import "./market/OverlayMarket.sol";
import "./market/OverlayV1Market.sol";

contract OverlayMirinMarket is OverlayMarket {
contract OverlayV1MirinMarket is OverlayV1Market {
using FixedPoint for FixedPoint.uq112x112;
using FixedPoint for FixedPoint.uq144x112;

Expand All @@ -29,8 +29,8 @@ contract OverlayMirinMarket is OverlayMarket {
uint112 _fundingKNumerator,
uint112 _fundingKDenominator,
uint256 _amountIn
) OverlayMarket(
"https://metadata.overlay.exchange/mirin/{id}.json",
) OverlayV1Market(
"https://metadata.overlay.exchange/v1/mirin/{id}.json",
_ovl,
_updatePeriod,
_leverageMax,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;

interface IOverlayFactory {
interface IOverlayV1Factory {
function isMarket(address) external view returns (bool);
function getGlobalParams() external view returns (uint16, uint16, uint16, uint16, address, uint8, uint8, uint8, address);
function updateMarket(address, address) external;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.2;
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "../libraries/Position.sol";

interface IOverlayMarket is IERC1155 {
interface IOverlayV1Market is IERC1155 {
event Build(address indexed sender, uint256 positionId, uint256 oi, uint256 debt);
event Unwind(address indexed sender, uint256 positionId, uint256 oi, uint256 debt);
event Update(address indexed sender, address indexed rewarded, uint256 reward);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;

contract OverlayFees {
contract OverlayV1Fees {
// outstanding cumulative fees to be forwarded on update
uint256 public fees;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;

import "../interfaces/IOverlayFactory.sol";
import "../interfaces/IOverlayV1Factory.sol";

contract OverlayGovernance {
contract OverlayV1Governance {
// ovl erc20 token
address public immutable ovl;
// OverlayFactory address
Expand All @@ -29,7 +29,7 @@ contract OverlayGovernance {
}

modifier enabled() {
require(IOverlayFactory(factory).isMarket(address(this)), "OverlayV1: !enabled");
require(IOverlayV1Factory(factory).isMarket(address(this)), "OverlayV1: !enabled");
_;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ pragma solidity ^0.8.2;
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

import "../libraries/Position.sol";
import "../interfaces/IOverlayFactory.sol";
import "../interfaces/IOverlayV1Factory.sol";

import "./OverlayGovernance.sol";
import "./OverlayFees.sol";
import "./OverlayOpenInterest.sol";
import "./OverlayPosition.sol";
import "./OverlayV1Governance.sol";
import "./OverlayV1Fees.sol";
import "./OverlayV1OI.sol";
import "./OverlayV1Position.sol";
import "../OverlayToken.sol";

contract OverlayMarket is OverlayPosition, OverlayGovernance, OverlayOpenInterest, OverlayFees {
contract OverlayV1Market is OverlayV1Position, OverlayV1Governance, OverlayV1OI, OverlayV1Fees {
using Position for Position.Info;
using SafeERC20 for OverlayToken;

Expand Down Expand Up @@ -43,7 +43,7 @@ contract OverlayMarket is OverlayPosition, OverlayGovernance, OverlayOpenInteres
uint144 _oiCap,
uint112 _fundingKNumerator,
uint112 _fundingKDenominator
) OverlayPosition(_uri) OverlayGovernance(
) OverlayV1Position(_uri) OverlayV1Governance(
_ovl,
_updatePeriod,
_leverageMax,
Expand All @@ -68,7 +68,7 @@ contract OverlayMarket is OverlayPosition, OverlayGovernance, OverlayOpenInteres
uint256 feeResolution,
address feeTo,
,,,
) = IOverlayFactory(factory).getGlobalParams();
) = IOverlayV1Factory(factory).getGlobalParams();
(
uint256 amountToBurn,
uint256 amountToForward,
Expand Down Expand Up @@ -106,7 +106,7 @@ contract OverlayMarket is OverlayPosition, OverlayGovernance, OverlayOpenInteres
uint256 oi = collateralAmount * leverage;

// adjust for fees
(uint256 fee,,, uint256 feeResolution,,,,,) = IOverlayFactory(factory).getGlobalParams();
(uint256 fee,,, uint256 feeResolution,,,,,) = IOverlayV1Factory(factory).getGlobalParams();
(uint256 oiAdjusted, uint256 feeAmount) = adjustForFees(oi, fee, feeResolution);
uint256 collateralAmountAdjusted = oiAdjusted / leverage;
uint256 debtAdjusted = oiAdjusted - collateralAmountAdjusted;
Expand Down Expand Up @@ -179,7 +179,7 @@ contract OverlayMarket is OverlayPosition, OverlayGovernance, OverlayOpenInteres

// adjust for fees
// TODO: think through edge case of underwater position ... and fee adjustments ...
(uint256 _fee,,, uint256 _feeResolution,,,,,) = IOverlayFactory(factory).getGlobalParams();
(uint256 _fee,,, uint256 _feeResolution,,,,,) = IOverlayV1Factory(factory).getGlobalParams();
(uint256 _notionalAdjusted, uint256 _feeAmount) = adjustForFees(_notional, _fee, _feeResolution);
valueAdjusted = _notionalAdjusted > _debt ? _notionalAdjusted - _debt : 0; // floor in case underwater, and protocol loses out on any maintenance margin
feeAmount = _feeAmount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.2;

import "../libraries/Position.sol";

contract OverlayOpenInterest {
contract OverlayV1OI {
using FixedPoint for FixedPoint.uq112x112;
using FixedPoint for FixedPoint.uq144x112;
using Position for Position.Info;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ pragma solidity ^0.8.2;
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";

import "../libraries/Position.sol";
import "./OverlayPricePoint.sol";
import "./OverlayV1PricePoint.sol";

contract OverlayPosition is ERC1155, OverlayPricePoint {
contract OverlayV1Position is ERC1155, OverlayV1PricePoint {
using Position for Position.Info;

// array of pos attributes; id is index in array
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;

contract OverlayPricePoint {
contract OverlayV1PricePoint {
// current index pointer for the upcoming price fetch on update
uint256 public pricePointCurrentIndex;
// mapping from price point index to realized historical prices
Expand Down
6 changes: 3 additions & 3 deletions tests/markets/common/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def price_points_after(token):
@pytest.fixture(
scope="module",
params=[
("OverlayMirinFactory", [15, 5000, 100, ETH_ADDRESS, 60, 50, ETH_ADDRESS],
"OverlayMirinMarket", [True, 4, 24, 100, 100, OI_CAP*10**TOKEN_DECIMALS, 1, 8, AMOUNT_IN*10**TOKEN_DECIMALS],
("OverlayV1MirinFactory", [15, 5000, 100, ETH_ADDRESS, 60, 50, ETH_ADDRESS],
"OverlayV1MirinMarket", [True, 4, 24, 100, 100, OI_CAP*10**TOKEN_DECIMALS, 1, 8, AMOUNT_IN*10**TOKEN_DECIMALS],
"MirinFactoryMock", [],
"IMirinOracle"),
])
Expand Down Expand Up @@ -136,7 +136,7 @@ def factory(create_factory):

@pytest.fixture(
scope="module",
params=["IOverlayMarket"])
params=["IOverlayV1Market"])
def market(factory, request):
addr = factory.allMarkets(0)
market = getattr(interface, request.param)(addr)
Expand Down
2 changes: 1 addition & 1 deletion tests/markets/common/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_market_is_enabled(factory, market):

def test_market_erc1155(market):
match = re.fullmatch(
r"https://metadata.overlay.exchange/(\w+)/{id}.json",
r"https://metadata.overlay.exchange/v1/(\w+)/{id}.json",
market.uri(0),
)
assert match is not None

0 comments on commit fbb22c4

Please sign in to comment.