Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OZ, Upgradeable & solidity 0.8.2 #3

Open
wants to merge 12 commits into
base: use-1155
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ out/
cache/
.env
.DS_Store
**/artifacts/**
17 changes: 11 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/solmate"]
path = lib/solmate
url = https://github.com/transmissions11/solmate
[submodule "lib/clones-with-immutable-args"]
path = lib/clones-with-immutable-args
url = https://github.com/wighawag/clones-with-immutable-args
[submodule "lib/openzeppelin-contracts-upgradeable"]
path = lib/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
branch=v4.9.6
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
branch=v4.9.6
[submodule "lib/openzeppelin-foundry-upgrades"]
path = lib/openzeppelin-foundry-upgrades
url = https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades
7 changes: 4 additions & 3 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
verbosity = 0
optimizer = true # enable or disable the solc optimizer
optimizer_runs = 100000 # the number of optimizer runs
solc_version = '0.8.15'
solc_version = '0.8.20'
remappings = [
'solmate/=lib/solmate/src/',
'clones/=lib/clones-with-immutable-args/src/',
'ds-test/=lib/forge-std/lib/ds-test/src/',
'forge-std/=lib/forge-std/src/',
'@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/',
'@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/'
]
1 change: 0 additions & 1 deletion lib/clones-with-immutable-args
Submodule clones-with-immutable-args deleted from 96f785
1 change: 1 addition & 0 deletions lib/openzeppelin-contracts
Submodule openzeppelin-contracts added at dbb610
1 change: 1 addition & 0 deletions lib/openzeppelin-contracts-upgradeable
1 change: 1 addition & 0 deletions lib/openzeppelin-foundry-upgrades
1 change: 0 additions & 1 deletion lib/solmate
Submodule solmate deleted from bff24e
10 changes: 5 additions & 5 deletions src/BondAggregator.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity 0.8.15;

import {ERC20} from "solmate/src/tokens/ERC20.sol";
import {Auth, Authority} from "solmate/src/auth/Auth.sol";
pragma solidity 0.8.20;

import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {Auth} from "./lib/Auth.sol";
import {IAuthority} from "./interfaces/IAuthority.sol";
import {IBondAggregator} from "./interfaces/IBondAggregator.sol";
import {IBondTeller} from "./interfaces/IBondTeller.sol";
import {IBondAuctioneer} from "./interfaces/IBondAuctioneer.sol";
Expand Down Expand Up @@ -56,7 +56,7 @@ contract BondAggregator is IBondAggregator, Auth {
// A 'vesting' param longer than 50 years is considered a timestamp for fixed expiry.
uint48 private constant MAX_FIXED_TERM = 52 weeks * 50;

constructor(address guardian_, Authority authority_) Auth(guardian_, authority_) {}
constructor(address guardian_, IAuthority authority_) Auth(guardian_, authority_) {}

/// @inheritdoc IBondAggregator
function registerAuctioneer(IBondAuctioneer auctioneer_) external requiresAuth {
Expand Down
9 changes: 5 additions & 4 deletions src/BondFixedExpiryFPA.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity 0.8.15;
pragma solidity 0.8.20;

import {ERC20} from "solmate/src/tokens/ERC20.sol";
import {BondBaseFPA, IBondAggregator, Authority} from "./bases/BondBaseFPA.sol";
import {IAuthority} from "./interfaces/IAuthority.sol";
import {IBondAggregator} from "./interfaces/IBondAggregator.sol";
import {IBondTeller} from "./interfaces/IBondTeller.sol";
import {BondBaseFPA} from "./bases/BondBaseFPA.sol";

/// @title Bond Fixed-Expiry Fixed Price Auctioneer
/// @notice Bond Fixed-Expiry Fixed Price Auctioneer Contract
Expand Down Expand Up @@ -33,7 +34,7 @@ contract BondFixedExpiryFPA is BondBaseFPA {
IBondTeller teller_,
IBondAggregator aggregator_,
address guardian_,
Authority authority_
IAuthority authority_
) BondBaseFPA(teller_, aggregator_, guardian_, authority_) {}

/// @inheritdoc BondBaseFPA
Expand Down
8 changes: 5 additions & 3 deletions src/BondFixedExpiryOFDA.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity 0.8.15;
pragma solidity 0.8.20;

import {BondBaseOFDA, IBondAggregator, Authority} from "./bases/BondBaseOFDA.sol";
import {IAuthority} from "./interfaces/IAuthority.sol";
import {IBondAggregator} from "./interfaces/IBondAggregator.sol";
import {IBondTeller} from "./interfaces/IBondTeller.sol";
import {BondBaseOFDA} from "./bases/BondBaseOFDA.sol";

/// @title Bond Fixed-Expiry Fixed Discount Auctioneer
/// @notice Bond Fixed-Expiry Fixed Discount Auctioneer Contract
Expand Down Expand Up @@ -33,7 +35,7 @@ contract BondFixedExpiryOFDA is BondBaseOFDA {
IBondTeller teller_,
IBondAggregator aggregator_,
address guardian_,
Authority authority_
IAuthority authority_
) BondBaseOFDA(teller_, aggregator_, guardian_, authority_) {}

/// @inheritdoc BondBaseOFDA
Expand Down
6 changes: 4 additions & 2 deletions src/BondFixedExpiryOSDA.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.15;

import {BondBaseOSDA, IBondAggregator, Authority} from "./bases/BondBaseOSDA.sol";
import {IAuthority} from "./interfaces/IAuthority.sol";
import {IBondAggregator} from "./interfaces/IBondAggregator.sol";
import {IBondTeller} from "./interfaces/IBondTeller.sol";
import {BondBaseOSDA} from "./bases/BondBaseOSDA.sol";

/// @title Bond Fixed-Expiry Oracle-based Sequential Dutch Auctioneer
/// @notice Bond Fixed-Expiry Oracle-based Sequential Dutch Auctioneer Contract
Expand All @@ -25,7 +27,7 @@ contract BondFixedExpiryOSDA is BondBaseOSDA {
IBondTeller teller_,
IBondAggregator aggregator_,
address guardian_,
Authority authority_
IAuthority authority_
) BondBaseOSDA(teller_, aggregator_, guardian_, authority_) {}

/// @inheritdoc BondBaseOSDA
Expand Down
8 changes: 5 additions & 3 deletions src/BondFixedExpirySDA.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity 0.8.15;
pragma solidity 0.8.20;

import {BondBaseSDA, IBondAggregator, Authority} from "./bases/BondBaseSDA.sol";
import {IAuthority} from "./interfaces/IAuthority.sol";
import {IBondAggregator} from "./interfaces/IBondAggregator.sol";
import {IBondTeller} from "./interfaces/IBondTeller.sol";
import {BondBaseSDA} from "./bases/BondBaseSDA.sol";

/// @title Bond Fixed-Expiry Sequential Dutch Auctioneer v1.1
/// @notice Bond Fixed-Expiry Sequential Dutch Auctioneer Contract
Expand All @@ -25,7 +27,7 @@ contract BondFixedExpirySDA is BondBaseSDA {
IBondTeller teller_,
IBondAggregator aggregator_,
address guardian_,
Authority authority_
IAuthority authority_
) BondBaseSDA(teller_, aggregator_, guardian_, authority_) {}

/// @inheritdoc BondBaseSDA
Expand Down
50 changes: 38 additions & 12 deletions src/BondFixedExpiryTeller.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity 0.8.15;
pragma solidity 0.8.20;

import {ERC20} from "solmate/src/tokens/ERC20.sol";
import {ClonesWithImmutableArgs} from "clones-with-immutable-args/ClonesWithImmutableArgs.sol";

import {BondBaseTeller, IBondAggregator, Authority} from "./bases/BondBaseTeller.sol";
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IAuthority} from "./interfaces/IAuthority.sol";
import {IBondAggregator} from "./interfaces/IBondAggregator.sol";
import {BondBaseTeller} from "./bases/BondBaseTeller.sol";
import {FullMath} from "./lib/FullMath.sol";
import "./bases/BondTeller1155.sol";
import {BondTeller1155Upgradeable} from "./bases/BondTeller1155Upgradeable.sol";

/// @title Bond Fixed Expiry Teller
/// @notice Bond Fixed Expiry Teller Contract
Expand All @@ -24,17 +25,42 @@ import "./bases/BondTeller1155.sol";
/// duplicate tokens with the same name/symbol.
///
/// @author Oighty, Zeus, Potted Meat, indigo
contract BondFixedExpiryTeller is BondTeller1155 {
using TransferHelper for ERC20;
contract BondFixedExpiryTeller is BondTeller1155Upgradeable {
using SafeERC20 for ERC20;

/* ========== CONSTRUCTOR ========== */
constructor(
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}

function initialize(
address protocol_,
IBondAggregator aggregator_,
address guardian_,
Authority authority_
) BondTeller1155(protocol_, aggregator_, guardian_, authority_) {}
IAuthority authority_
) public initializer {
__BondFixedExpiryTeller_init(
protocol_,
aggregator_,
guardian_,
authority_
);
}

function __BondFixedExpiryTeller_init(
address protocol_,
IBondAggregator aggregator_,
address guardian_,
IAuthority authority_
) public onlyInitializing {
__BondTeller1155_init(
protocol_,
aggregator_,
guardian_,
authority_
);
}
/* ========== PURCHASE ========== */

/// @notice Handle payout to recipient
Expand Down Expand Up @@ -77,7 +103,7 @@ contract BondFixedExpiryTeller is BondTeller1155 {
} else {
// If no expiry, then transfer payout directly to user
if (address(payoutToken_) == address(0)) {
bool sent = payable(recipient_).send(payout_);
(bool sent,) = payable(address(recipient_)).call{value: payout_}("");
require(sent, "Failed to send native tokens");
} else {
payoutToken_.safeTransfer(recipient_, payout_);
Expand Down
10 changes: 6 additions & 4 deletions src/BondFixedTermFPA.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity 0.8.15;
pragma solidity 0.8.20;

import {BondBaseFPA, IBondAggregator, Authority} from "./bases/BondBaseFPA.sol";
import {IAuthority} from "./interfaces/IAuthority.sol";
import {IBondAggregator} from "./interfaces/IBondAggregator.sol";
import {IBondTeller} from "./interfaces/IBondTeller.sol";
import {BondBaseFPA} from "./bases/BondBaseFPA.sol";

/// @title Bond Fixed-Term Fixed Price Auctioneer
/// @notice Bond Fixed-Term Fixed Price Auctioneer Contract
Expand Down Expand Up @@ -32,8 +34,8 @@ contract BondFixedTermFPA is BondBaseFPA {
IBondTeller teller_,
IBondAggregator aggregator_,
address guardian_,
Authority authority_
) BondBaseFPA(teller_, aggregator_, guardian_, authority_) {}
IAuthority authority_
) BondBaseFPA(teller_, aggregator_,guardian_, authority_) {}

/* ========== MARKET FUNCTIONS ========== */
/// @inheritdoc BondBaseFPA
Expand Down
8 changes: 5 additions & 3 deletions src/BondFixedTermOFDA.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity 0.8.15;
pragma solidity 0.8.20;

import {BondBaseOFDA, IBondAggregator, Authority} from "./bases/BondBaseOFDA.sol";
import {IAuthority} from "./interfaces/IAuthority.sol";
import {IBondAggregator} from "./interfaces/IBondAggregator.sol";
import {IBondTeller} from "./interfaces/IBondTeller.sol";
import {BondBaseOFDA} from "./bases/BondBaseOFDA.sol";

/// @title Bond Fixed-Term Fixed Discount Auctioneer
/// @notice Bond Fixed-Term Fixed Discount Auctioneer Contract
Expand Down Expand Up @@ -33,7 +35,7 @@ contract BondFixedTermOFDA is BondBaseOFDA {
IBondTeller teller_,
IBondAggregator aggregator_,
address guardian_,
Authority authority_
IAuthority authority_
) BondBaseOFDA(teller_, aggregator_, guardian_, authority_) {}

/* ========== MARKET FUNCTIONS ========== */
Expand Down
8 changes: 5 additions & 3 deletions src/BondFixedTermOSDA.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.15;
pragma solidity 0.8.20;

import {BondBaseOSDA, IBondAggregator, Authority} from "./bases/BondBaseOSDA.sol";
import {IAuthority} from "./interfaces/IAuthority.sol";
import {IBondAggregator} from "./interfaces/IBondAggregator.sol";
import {IBondTeller} from "./interfaces/IBondTeller.sol";
import {BondBaseOSDA} from "./bases/BondBaseOSDA.sol";

/// @title Bond Fixed-Term Oracle-based Sequential Dutch Auctioneer
/// @notice Bond Fixed-Term Oracle-based Sequential Dutch Auctioneer Contract
Expand All @@ -25,7 +27,7 @@ contract BondFixedTermOSDA is BondBaseOSDA {
IBondTeller teller_,
IBondAggregator aggregator_,
address guardian_,
Authority authority_
IAuthority authority_
) BondBaseOSDA(teller_, aggregator_, guardian_, authority_) {}

/* ========== MARKET FUNCTIONS ========== */
Expand Down
8 changes: 5 additions & 3 deletions src/BondFixedTermSDA.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity 0.8.15;
pragma solidity 0.8.20;

import {BondBaseSDA, IBondAggregator, Authority} from "./bases/BondBaseSDA.sol";
import {IAuthority} from "./interfaces/IAuthority.sol";
import {IBondAggregator} from "./interfaces/IBondAggregator.sol";
import {IBondTeller} from "./interfaces/IBondTeller.sol";
import {BondBaseSDA} from "./bases/BondBaseSDA.sol";

/// @title Bond Fixed-Term Sequential Dutch Auctioneer
/// @notice Bond Fixed-Term Sequential Dutch Auctioneer Contract
Expand All @@ -25,7 +27,7 @@ contract BondFixedTermSDA is BondBaseSDA {
IBondTeller teller_,
IBondAggregator aggregator_,
address guardian_,
Authority authority_
IAuthority authority_
) BondBaseSDA(teller_, aggregator_, guardian_, authority_) {}

/* ========== MARKET FUNCTIONS ========== */
Expand Down
Loading