Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ yarn test

## Testnets

There is a testnet deployment on Kovan. It rebases hourly using real market data.

- ERC-20 Token: [0x3E0437898a5667a4769B1Ca5A34aAB1ae7E81377](https://kovan.etherscan.io/token/0x3E0437898a5667a4769B1Ca5A34aAB1ae7E81377)
- Supply Policy: [0xBB4617d26E704Ac0568E1cbf5232990a8b7846A4](https://kovan.etherscan.io/address/0xBB4617d26E704Ac0568E1cbf5232990a8b7846A4)
- Orchestrator: [0xdAcA62767840febA20Ae103d8B5BF923517FA3b9](https://kovan.etherscan.io/address/0xdAcA62767840febA20Ae103d8B5BF923517FA3b9)
- Market Oracle: [0xFC344AF21d647f4244B5F098203A178BF26c51Dc](https://kovan.etherscan.io/address/0xFC344AF21d647f4244B5F098203A178BF26c51Dc)
- CPI Oracle: [0xCedc17B394051d0E222797588f3e5ECe5023FB4A](https://kovan.etherscan.io/address/0xCedc17B394051d0E222797588f3e5ECe5023FB4A)
- WAMPL: [0xd012092d13e5a4aa7a9032335b380c62fc707232](https://kovan.etherscan.io/address/0xd012092d13e5a4aa7a9032335b380c62fc707232)
There is a testnet deployment on Goerli. It rebases hourly using real market data.

- ERC-20 Token: [0x08c5b39F000705ebeC8427C1d64D6262392944EE](https://goerli.etherscan.io/token/0x08c5b39F000705ebeC8427C1d64D6262392944EE)
- Supply Policy: [0x047b82a5D79d9DF62dE4f34CbaBa83F71848a6BF](https://goerli.etherscan.io/address/0x047b82a5D79d9DF62dE4f34CbaBa83F71848a6BF)
- Orchestrator: [0x0ec93391752ef1A06AA2b83D15c3a5814651C891](https://goerli.etherscan.io/address/0x0ec93391752ef1A06AA2b83D15c3a5814651C891)
- Market Oracle: [0xd4F96E4aC4B4f4E2359734a89b5484196298B69D](https://goerli.etherscan.io/address/0xd4F96E4aC4B4f4E2359734a89b5484196298B69D)
- CPI Oracle: [0x53c75D13a07AA02615Cb43e942829862C963D9bf](https://goerli.etherscan.io/address/0x53c75D13a07AA02615Cb43e942829862C963D9bf)
- Admin: [0x02C32fB5498e89a8750cc9Bd66382a681665c3a3](https://goerli.etherscan.io/address/0x02C32fB5498e89a8750cc9Bd66382a681665c3a3)
- WAMPL: [0x3b624861a14979537DE1B88F9565F41a7fc45FBf](https://goerli.etherscan.io/address/0x3b624861a14979537DE1B88F9565F41a7fc45FBf)

## Contribute

Expand Down
32 changes: 16 additions & 16 deletions contracts/MedianOracle.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
pragma solidity 0.4.24;

import {SafeMath} from "openzeppelin-solidity/contracts/math/SafeMath.sol";
import {Ownable} from "openzeppelin-solidity/contracts/ownership/Ownable.sol";
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.4;

import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "./lib/Select.sol";

interface IOracle {
Expand All @@ -15,9 +14,7 @@ interface IOracle {
* @notice Provides a value onchain that's aggregated from a whitelisted set of
* providers.
*/
contract MedianOracle is Ownable, IOracle {
using SafeMath for uint256;

contract MedianOracle is OwnableUpgradeable, IOracle {
struct Report {
uint256 timestamp;
uint256 payload;
Expand Down Expand Up @@ -51,23 +48,26 @@ contract MedianOracle is Ownable, IOracle {
uint256 private constant MAX_REPORT_EXPIRATION_TIME = 520 weeks;

/**
* @notice Contract state initialization.
*
* @param reportExpirationTimeSec_ The number of seconds after which the
* report is deemed expired.
* @param reportDelaySec_ The number of seconds since reporting that has to
* pass before a report is usable
* @param minimumProviders_ The minimum number of providers with valid
* reports to consider the aggregate report valid.
*/
constructor(
function init(
uint256 reportExpirationTimeSec_,
uint256 reportDelaySec_,
uint256 minimumProviders_
) public {
) public initializer {
require(reportExpirationTimeSec_ <= MAX_REPORT_EXPIRATION_TIME);
require(minimumProviders_ > 0);
reportExpirationTimeSec = reportExpirationTimeSec_;
reportDelaySec = reportDelaySec_;
minimumProviders = minimumProviders_;
__Ownable_init();
}

/**
Expand Down Expand Up @@ -114,12 +114,12 @@ contract MedianOracle is Ownable, IOracle {
uint8 index_past = 1 - index_recent;

// Check that the push is not too soon after the last one.
require(timestamps[index_recent].add(reportDelaySec) <= now);
require(timestamps[index_recent] + reportDelaySec <= block.timestamp);

reports[index_past].timestamp = now;
reports[index_past].timestamp = block.timestamp;
reports[index_past].payload = payload;

emit ProviderReportPushed(providerAddress, payload, now);
emit ProviderReportPushed(providerAddress, payload, block.timestamp);
}

/**
Expand All @@ -138,12 +138,12 @@ contract MedianOracle is Ownable, IOracle {
* @return AggregatedValue: Median of providers reported values.
* valid: Boolean indicating an aggregated value was computed successfully.
*/
function getData() external returns (uint256, bool) {
function getData() external override returns (uint256, bool) {
uint256 reportsCount = providers.length;
uint256[] memory validReports = new uint256[](reportsCount);
uint256 size = 0;
uint256 minValidTimestamp = now.sub(reportExpirationTimeSec);
uint256 maxValidTimestamp = now.sub(reportDelaySec);
uint256 minValidTimestamp = block.timestamp - reportExpirationTimeSec;
uint256 maxValidTimestamp = block.timestamp - reportDelaySec;

for (uint256 i = 0; i < reportsCount; i++) {
address providerAddress = providers[i];
Expand Down Expand Up @@ -207,7 +207,7 @@ contract MedianOracle is Ownable, IOracle {
if (i + 1 != providers.length) {
providers[i] = providers[providers.length - 1];
}
providers.length--;
providers.pop();
emit ProviderRemoved(provider);
break;
}
Expand Down
11 changes: 7 additions & 4 deletions contracts/Orchestrator.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
pragma solidity 0.7.6;
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.4;

import "./_external/Ownable.sol";

import "./UFragmentsPolicy.sol";
interface IUFragmentsPolicy {
function rebase() external;
}

/**
* @title Orchestrator
Expand All @@ -19,14 +22,14 @@ contract Orchestrator is Ownable {
// Stable ordering is not guaranteed.
Transaction[] public transactions;

UFragmentsPolicy public policy;
IUFragmentsPolicy public policy;

/**
* @param policy_ Address of the UFragments policy.
*/
constructor(address policy_) public {
Ownable.initialize(msg.sender);
policy = UFragmentsPolicy(policy_);
policy = IUFragmentsPolicy(policy_);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion contracts/UFragments.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pragma solidity 0.7.6;
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.4;

import "./_external/SafeMath.sol";
import "./_external/Ownable.sol";
Expand Down
7 changes: 4 additions & 3 deletions contracts/UFragmentsPolicy.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pragma solidity 0.7.6;
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.4;

import "./_external/SafeMath.sol";
import "./_external/Ownable.sol";
Expand Down Expand Up @@ -354,8 +355,8 @@ contract UFragmentsPolicy is Ownable {
}

/**
* To maintain abi backward compatibility
*/
* To maintain abi backward compatibility
*/
function rebaseLag() public pure returns (uint256) {
return 1;
}
Expand Down
35 changes: 19 additions & 16 deletions contracts/WAMPL.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity 0.8.4;

import {IERC20} from "openzeppelin-contracts-4.4.1/contracts/token/ERC20/IERC20.sol";
import {IERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
// solhint-disable-next-line max-line-length
import {SafeERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import {ERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";

import {SafeERC20} from "openzeppelin-contracts-4.4.1/contracts/token/ERC20/utils/SafeERC20.sol";
import {ERC20} from "openzeppelin-contracts-4.4.1/contracts/token/ERC20/ERC20.sol";
// solhint-disable-next-line max-line-length
import {ERC20Permit} from "openzeppelin-contracts-4.4.1/contracts/token/ERC20/extensions/draft-ERC20Permit.sol";
import {ERC20PermitUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol";

/**
* @title WAMPL (Wrapped AMPL).
Expand All @@ -26,8 +26,8 @@ import {ERC20Permit} from "openzeppelin-contracts-4.4.1/contracts/token/ERC20/ex
*
* We call wAMPL the "wrapper" token and AMPL the "underlying" or "wrapped" token.
*/
contract WAMPL is ERC20, ERC20Permit {
using SafeERC20 for IERC20;
contract WAMPL is ERC20Upgradeable, ERC20PermitUpgradeable {
Copy link

@moodmosaic moodmosaic May 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aalavandhan, what was the motivation to make this (and others, e.g. MedianOracle) upgradeable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to use both the upgradable and non-upgradable versions of the openzeppelin contracts as dependencies, as effectively they are the same except how the storage layout is organized.

Ultimately weather or not its upgradable (ie sits behind a proxy) depends on how its deployed.

AMPL and the policy we use deployProxy https://github.com/ampleforth/ampleforth-contracts/blob/master/scripts/deploy.ts#L52

For wampl, median oracle and others we use deployContract https://github.com/ampleforth/ampleforth-contracts/blob/master/scripts/deploy.ts#L201

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the proxy-based upgradeability system, no constructors can be used, though. So you end up with this:

constructor(address ampl) {
    _ampl = ampl;
 }

function init(string memory name_, string memory symbol_) public initializer {
    __ERC20_init(name_, symbol_);
    __ERC20Permit_init(name_);

but what you really need is this (since it's not really upgradable) which is both idiomatic and beautiful

constructor(
    address ampl,
    string memory name_,
    string memory symbol_
) ERC20(name_, symbol_) ERC20Permit(name_) {
    _ampl = ampl;

Some of the bugs I've seen, originate from the fact that we (sometimes myself included) tend to program in a language vs into a language.

It's just that using openzeppelin/contracts-upgradeable for non-upgradable contracts makes things more implicit, but we've seen in the past that usually explicit is better than implicit (and simple is better than complex).

So why not just use both, at the end:

   "dependencies": {
+    "@openzeppelin/contracts": "^4.7.3",
     "@openzeppelin/contracts-upgradeable": "^4.7.3"
   },

And if there are strong reasons for keeping things as-is, perhaps it'd be nice to see some slither checks.


Absolutely love the project and your work, hope my comment didn't scare you! ❤️ 🍻

Copy link

@moodmosaic moodmosaic May 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So why not just use both, at the end:

   "dependencies": {
+    "@openzeppelin/contracts": "^4.7.3",
     "@openzeppelin/contracts-upgradeable": "^4.7.3"
   },

Or, perhaps, since a potential V2 version of the contracts might be non-upgradable, why not just remove contracts-upgradeable entirely on master. I gave this a shot and it looks pretty clean, and all tests are passing:

diff --git a/contracts/MedianOracle.sol b/contracts/MedianOracle.sol
index c201c8a..ce62860 100644
--- a/contracts/MedianOracle.sol
+++ b/contracts/MedianOracle.sol
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-3.0-or-later
 pragma solidity 0.8.4;
 
-import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
+import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
 import "./lib/Select.sol";
 
 interface IOracle {
@@ -14,7 +14,7 @@ interface IOracle {
  * @notice Provides a value onchain that's aggregated from a whitelisted set of
  *         providers.
  */
-contract MedianOracle is OwnableUpgradeable, IOracle {
+contract MedianOracle is Ownable, IOracle {
     struct Report {
         uint256 timestamp;
         uint256 payload;
@@ -57,17 +57,16 @@ contract MedianOracle is OwnableUpgradeable, IOracle {
      * @param minimumProviders_ The minimum number of providers with valid
      *                          reports to consider the aggregate report valid.
      */
-    function init(
+    constructor(
         uint256 reportExpirationTimeSec_,
         uint256 reportDelaySec_,
         uint256 minimumProviders_
-    ) public initializer {
+    ) public {
         require(reportExpirationTimeSec_ <= MAX_REPORT_EXPIRATION_TIME);
         require(minimumProviders_ > 0);
         reportExpirationTimeSec = reportExpirationTimeSec_;
         reportDelaySec = reportDelaySec_;
         minimumProviders = minimumProviders_;
-        __Ownable_init();
     }
 
     /**
diff --git a/contracts/WAMPL.sol b/contracts/WAMPL.sol
index dc412f1..2023856 100644
--- a/contracts/WAMPL.sol
+++ b/contracts/WAMPL.sol
@@ -1,13 +1,12 @@
 // SPDX-License-Identifier: GPL-3.0-or-later
+
 pragma solidity 0.8.4;
 
-import {IERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
+import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
-import {SafeERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
+import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
-import {ERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
+import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
-import {ERC20PermitUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol";
+import {ERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol";
 
 /**
  * @title WAMPL (Wrapped AMPL).
@@ -26,8 +25,8 @@ import {ERC20PermitUpgradeable} from "@openzeppelin/contracts-upgradeable/token/
  *
  *      We call wAMPL the "wrapper" token and AMPL the "underlying" or "wrapped" token.
  */
-contract WAMPL is ERC20Upgradeable, ERC20PermitUpgradeable {
-    using SafeERC20Upgradeable for IERC20Upgradeable;
+contract WAMPL is ERC20, ERC20Permit {
+    using SafeERC20 for IERC20;
 
     //--------------------------------------------------------------------------
     // Constants
@@ -43,18 +42,15 @@ contract WAMPL is ERC20Upgradeable, ERC20PermitUpgradeable {
 
     //--------------------------------------------------------------------------
 
     /// @notice Contract constructor.
     /// @param ampl The AMPL ERC20 token address.
-    constructor(address ampl) {
-        _ampl = ampl;
-    }
-
-    /// @notice Contract state initialization.
     /// @param name_ The wAMPL ERC20 name.
     /// @param symbol_ The wAMPL ERC20 symbol.
-    function init(string memory name_, string memory symbol_) public initializer {
-        __ERC20_init(name_, symbol_);
-        __ERC20Permit_init(name_);
+    constructor(
+        address ampl,
+        string memory name_,
+        string memory symbol_
+    ) ERC20(name_, symbol_) ERC20Permit(name_) {
+        _ampl = ampl;
     }
 
     //--------------------------------------------------------------------------
@@ -237,7 +233,7 @@ contract WAMPL is ERC20Upgradeable, ERC20PermitUpgradeable {
         uint256 amples,
         uint256 wamples
     ) private {
-        IERC20Upgradeable(_ampl).safeTransferFrom(from, address(this), amples);
+        IERC20(_ampl).safeTransferFrom(from, address(this), amples);
 
         _mint(to, wamples);
     }
@@ -255,13 +251,13 @@ contract WAMPL is ERC20Upgradeable, ERC20PermitUpgradeable {
     ) private {
         _burn(from, wamples);
 
-        IERC20Upgradeable(_ampl).safeTransfer(to, amples);
+        IERC20(_ampl).safeTransfer(to, amples);
     }
 
     /// @dev Queries the current total supply of AMPL.
     /// @return The current AMPL supply.
     function _queryAMPLSupply() private view returns (uint256) {
-        return IERC20Upgradeable(_ampl).totalSupply();
+        return IERC20(_ampl).totalSupply();
     }
 
     //--------------------------------------------------------------------------
diff --git a/package.json b/package.json
index 32d611c..865af40 100644
--- a/package.json
+++ b/package.json
@@ -30,7 +30,7 @@
     "lint"
   ],
   "dependencies": {
-    "@openzeppelin/contracts-upgradeable": "^4.7.3"
+    "@openzeppelin/contracts": "^4.7.3"
   },
   "devDependencies": {
     "@ethersproject/abi": "^5.6.4",
diff --git a/test/unit/MedianOracle.ts b/test/unit/MedianOracle.ts
index ee2eb02..19636f6 100644
--- a/test/unit/MedianOracle.ts
+++ b/test/unit/MedianOracle.ts
@@ -22,8 +22,7 @@ async function setupContractsAndAccounts() {
   C = accounts[3]
   D = accounts[4]
   factory = await ethers.getContractFactory('MedianOracle')
-  oracle = await factory.deploy()
-  await oracle.init(60, 10, 1)
+  oracle = await factory.deploy(60, 10, 1)
   await oracle.deployed()
 }
 
diff --git a/test/unit/WAMPL.ts b/test/unit/WAMPL.ts
index b78bf97..0d7cf8d 100644
--- a/test/unit/WAMPL.ts
+++ b/test/unit/WAMPL.ts
@@ -46,8 +46,8 @@ async function setupContracts() {
   await ampl.setMonetaryPolicy(deployerAddress)
 
   const wAMPLFactory = await ethers.getContractFactory('WAMPL')
-  wAMPL = await wAMPLFactory.connect(deployer).deploy(ampl.address)
-  await wAMPL.init(NAME, SYMBOL)
+  wAMPL = await wAMPLFactory.connect(deployer).deploy(ampl.address, NAME, SYMBOL)
 }
 
 describe('WAMPL', () => {
diff --git a/yarn.lock b/yarn.lock
index 2016367..0bdcdaa 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -798,10 +798,10 @@
     "@types/sinon-chai" "^3.2.3"
     "@types/web3" "1.0.19"
 
-"@openzeppelin/contracts-upgradeable@^4.7.3":
-  version "4.7.3"
-  resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-4.7.3.tgz#f1d606e2827d409053f3e908ba4eb8adb1dd6995"
-  integrity sha512-+wuegAMaLcZnLCJIvrVUDzA9z/Wp93f0Dla/4jJvIhijRrPabjQbZe6fWiECLaJyfn5ci9fqf9vTw3xpQOad2A==
+"@openzeppelin/contracts@^4.7.3":
+  version "4.8.3"
+  resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.8.3.tgz#cbef3146bfc570849405f59cba18235da95a252a"
+  integrity sha512-bQHV8R9Me8IaJoJ2vPG4rXcL7seB7YVuskr4f+f5RyOStSZetwzkWtoqDMl5erkBJy0lDRUnIR2WIkPiC0GJlg==
 
 "@openzeppelin/hardhat-upgrades@^1.19.0":
   version "1.21.0"

using SafeERC20Upgradeable for IERC20Upgradeable;

//--------------------------------------------------------------------------
// Constants
Expand All @@ -43,15 +43,18 @@ contract WAMPL is ERC20, ERC20Permit {

//--------------------------------------------------------------------------

/// @notice Contract constructor.
/// @param ampl The AMPL ERC20 token address.
constructor(address ampl) {
_ampl = ampl;
}

/// @notice Contract state initialization.
/// @param name_ The wAMPL ERC20 name.
/// @param symbol_ The wAMPL ERC20 symbol.
constructor(
address ampl,
string memory name_,
string memory symbol_
) ERC20(name_, symbol_) ERC20Permit(name_) {
_ampl = ampl;
function init(string memory name_, string memory symbol_) public initializer {
__ERC20_init(name_, symbol_);
__ERC20Permit_init(name_);
}

//--------------------------------------------------------------------------
Expand Down Expand Up @@ -234,7 +237,7 @@ contract WAMPL is ERC20, ERC20Permit {
uint256 amples,
uint256 wamples
) private {
IERC20(_ampl).safeTransferFrom(from, address(this), amples);
IERC20Upgradeable(_ampl).safeTransferFrom(from, address(this), amples);

_mint(to, wamples);
}
Expand All @@ -252,13 +255,13 @@ contract WAMPL is ERC20, ERC20Permit {
) private {
_burn(from, wamples);

IERC20(_ampl).safeTransfer(to, amples);
IERC20Upgradeable(_ampl).safeTransfer(to, amples);
}

/// @dev Queries the current total supply of AMPL.
/// @return The current AMPL supply.
function _queryAMPLSupply() private view returns (uint256) {
return IERC20(_ampl).totalSupply();
return IERC20Upgradeable(_ampl).totalSupply();
}

//--------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion contracts/_external/ERC20Detailed.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.7.6;
pragma solidity 0.8.4;

import "./Initializable.sol";
import "./IERC20.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/_external/IERC20.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.7.6;
pragma solidity 0.8.4;

/**
* @title ERC20 interface
Expand Down
2 changes: 1 addition & 1 deletion contracts/_external/Initializable.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.7.6;
pragma solidity 0.8.4;

/**
* @title Initializable
Expand Down
2 changes: 1 addition & 1 deletion contracts/_external/Ownable.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.7.6;
pragma solidity 0.8.4;

import "./Initializable.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/_external/SafeMath.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.7.6;
pragma solidity 0.8.4;

/**
* @title SafeMath
Expand Down
2 changes: 0 additions & 2 deletions contracts/interfaces/IAMPL.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// pragma solidity ^0.4.24;

// Public interface definition for the AMPL - ERC20 token on Ethereum (the base-chain)
interface IAMPL {
// ERC20
Expand Down
2 changes: 0 additions & 2 deletions contracts/interfaces/IAmpleforth.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// pragma solidity ^0.4.24;

// Public interface definition for the Ampleforth supply policy on Ethereum (the base-chain)
interface IAmpleforth {
function epoch() external view returns (uint256);
Expand Down
2 changes: 0 additions & 2 deletions contracts/interfaces/IOrchestrator.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// pragma solidity ^0.4.24;

// Public interface definition for the Ampleforth Orchestrator on Ethereum (the base-chain)
interface IOrchestrator {
function rebase() external;
Expand Down
3 changes: 2 additions & 1 deletion contracts/lib/SafeMathInt.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

pragma solidity 0.7.6;
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.4;

/**
* @title SafeMathInt
Expand Down
10 changes: 4 additions & 6 deletions contracts/lib/Select.sol
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
pragma solidity ^0.4.24;
import {SafeMath} from "openzeppelin-solidity/contracts/math/SafeMath.sol";
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.4;

/**
* @title Select
* @dev Median Selection Library
*/
library Select {
using SafeMath for uint256;

/**
* @dev Sorts the input array up to the denoted size, and returns the median.
* @param array Input array to compute its median.
* @param size Number of elements in array to compute the median for.
* @return Median of array.
*/
function computeMedian(uint256[] array, uint256 size) internal pure returns (uint256) {
function computeMedian(uint256[] memory array, uint256 size) internal pure returns (uint256) {
require(size > 0 && array.length >= size);
for (uint256 i = 1; i < size; i++) {
for (uint256 j = i; j > 0 && array[j - 1] > array[j]; j--) {
Expand All @@ -26,7 +24,7 @@ library Select {
if (size % 2 == 1) {
return array[size / 2];
} else {
return array[size / 2].add(array[size / 2 - 1]) / 2;
return (array[size / 2] + array[size / 2 - 1]) / 2;
}
}
}
3 changes: 2 additions & 1 deletion contracts/lib/UInt256Lib.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pragma solidity 0.7.6;
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.4;

/**
* @title Various utilities useful for uint256.
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/ConstructorRebaseCallerContract.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.7.6;
pragma solidity 0.8.4;

import "../Orchestrator.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/GetMedianOracleDataCallerContract.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.4.24;
pragma solidity 0.8.4;

import "../MedianOracle.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/Mock.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.7.6;
pragma solidity 0.8.4;

contract Mock {
event FunctionCalled(string instanceName, string functionName, address caller);
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/MockDownstream.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.7.6;
pragma solidity 0.8.4;

import "./Mock.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/MockOracle.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.7.6;
pragma solidity 0.8.4;

import "./Mock.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/MockUFragments.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.7.6;
pragma solidity 0.8.4;

import "./Mock.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/MockUFragmentsPolicy.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.7.6;
pragma solidity 0.8.4;

import "./Mock.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/RebaseCallerContract.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.7.6;
pragma solidity 0.8.4;

import "../Orchestrator.sol";

Expand Down
Loading