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

make EasyAuction address a detail of the GnosisTrade plugin #1192

Merged
merged 12 commits into from
Sep 10, 2024
Merged
6 changes: 2 additions & 4 deletions common/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ interface INetworkConfig {
COMPTROLLER?: string
FLUX_FINANCE_COMPTROLLER?: string
GNOSIS_EASY_AUCTION?: string
EASY_AUCTION_OWNER?: string
MORPHO_AAVE_CONTROLLER?: string
MORPHO_REWARDS_DISTRIBUTOR?: string
MORPHO_AAVE_LENS?: string
Expand Down Expand Up @@ -295,8 +294,7 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
AAVE_DATA_PROVIDER: '0x057835Ad21a177dbdd3090bB1CAE03EaCF78Fc6d',
FLUX_FINANCE_COMPTROLLER: '0x95Af143a021DF745bc78e845b54591C53a8B3A51',
COMPTROLLER: '0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B',
GNOSIS_EASY_AUCTION: '0x0b7fFc1f4AD541A4Ed16b40D8c37f0929158D101',
EASY_AUCTION_OWNER: '0x0da0c3e52c977ed3cbc641ff02dd271c3ed55afe',
GNOSIS_EASY_AUCTION: '0x462302752B63Ee7c207459112CA8D38498Fb54f2', // our deployment
MORPHO_AAVE_LENS: '0x507fA343d0A90786d86C7cd885f5C49263A91FF4',
MORPHO_AAVE_CONTROLLER: '0x777777c9898D384F785Ee44Acfe945efDFf5f3E0',
MORPHO_REWARDS_DISTRIBUTOR: '0x3b14e5c73e0a56d607a8688098326fd4b4292135',
Expand Down Expand Up @@ -396,7 +394,7 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
AAVE_DATA_PROVIDER: '0x057835Ad21a177dbdd3090bB1CAE03EaCF78Fc6d',
FLUX_FINANCE_COMPTROLLER: '0x95Af143a021DF745bc78e845b54591C53a8B3A51',
COMPTROLLER: '0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B',
GNOSIS_EASY_AUCTION: '0x0b7fFc1f4AD541A4Ed16b40D8c37f0929158D101',
GNOSIS_EASY_AUCTION: '0x462302752B63Ee7c207459112CA8D38498Fb54f2', // our deployment
MORPHO_AAVE_LENS: '0x507fA343d0A90786d86C7cd885f5C49263A91FF4',
MORPHO_AAVE_CONTROLLER: '0x777777c9898D384F785Ee44Acfe945efDFf5f3E0',
MORPHO_REWARDS_DISTRIBUTOR: '0x3b14e5c73e0a56d607a8688098326fd4b4292135',
Expand Down
4 changes: 0 additions & 4 deletions contracts/interfaces/IBroker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ struct TradeRequest {
* the continued proper functioning of trading platforms.
*/
interface IBroker is IComponent {
event GnosisSet(IGnosis oldVal, IGnosis newVal);
event BatchTradeImplementationSet(ITrade oldVal, ITrade newVal);
event DutchTradeImplementationSet(ITrade oldVal, ITrade newVal);
event BatchAuctionLengthSet(uint48 oldVal, uint48 newVal);
Expand All @@ -45,7 +44,6 @@ interface IBroker is IComponent {
// Initialization
function init(
IMain main_,
IGnosis gnosis_,
ITrade batchTradeImplemention_,
uint48 batchAuctionLength_,
ITrade dutchTradeImplemention_,
Expand Down Expand Up @@ -86,8 +84,6 @@ interface TestIBroker is IBroker {

function dutchAuctionLength() external view returns (uint48);

function setGnosis(IGnosis newGnosis) external;

function setBatchTradeImplementation(ITrade newTradeImplementation) external;

function setBatchAuctionLength(uint48 newAuctionLength) external;
Expand Down
2 changes: 0 additions & 2 deletions contracts/interfaces/IDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ interface TestIDeployer is IDeployer {

function rsr() external view returns (IERC20Metadata);

function gnosis() external view returns (IGnosis);

function rsrAsset() external view returns (IAsset);

function implementations() external view returns (Implementations memory);
Expand Down
14 changes: 1 addition & 13 deletions contracts/p0/Broker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ contract BrokerP0 is ComponentP0, IBroker {
ITrade public batchTradeImplementation;
ITrade public dutchTradeImplementation;

IGnosis public gnosis;

mapping(address => bool) private trades;

uint48 public batchAuctionLength; // {s} the length of a Gnosis EasyAuction
Expand All @@ -43,14 +41,12 @@ contract BrokerP0 is ComponentP0, IBroker {

function init(
IMain main_,
IGnosis gnosis_,
ITrade batchTradeImplementation_, // Added for Interface compatibility with P1
uint48 batchAuctionLength_,
ITrade dutchTradeImplementation_, // Added for Interface compatibility with P1
uint48 dutchAuctionLength_
) public initializer {
__Component_init(main_);
setGnosis(gnosis_);
setBatchTradeImplementation(batchTradeImplementation_);
setBatchAuctionLength(batchAuctionLength_);
setDutchTradeImplementation(dutchTradeImplementation_);
Expand Down Expand Up @@ -133,14 +129,6 @@ contract BrokerP0 is ComponentP0, IBroker {

// === Setters ===

/// @custom:governance
function setGnosis(IGnosis newGnosis) public governance {
require(address(newGnosis) != address(0), "invalid Gnosis address");

emit GnosisSet(gnosis, newGnosis);
gnosis = newGnosis;
}

/// @custom:governance
function setBatchTradeImplementation(ITrade newTradeImplementation) public governance {
require(
Expand Down Expand Up @@ -220,7 +208,7 @@ contract BrokerP0 is ComponentP0, IBroker {
req.sellAmount
);

trade.init(this, caller, gnosis, batchAuctionLength, req);
trade.init(this, caller, batchAuctionLength, req);
return trade;
}

Expand Down
3 changes: 1 addition & 2 deletions contracts/p0/Deployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@

main.broker().init(
main,
gnosis,
ITrade(address(new GnosisTrade())),
ITrade(address(new GnosisTrade(gnosis))),
params.batchAuctionLength,
ITrade(address(new DutchTrade())),
params.dutchAuctionLength
Expand Down Expand Up @@ -177,5 +176,5 @@
}

/// @dev Just to make solc happy.
function implementations() external view returns (Implementations memory) {}

Check warning on line 179 in contracts/p0/Deployer.sol

View workflow job for this annotation

GitHub Actions / Lint Checks

Code contains empty blocks
}
18 changes: 4 additions & 14 deletions contracts/p1/Broker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@
// The Batch Auction Trade contract to clone on openTrade(). Governance parameter.
ITrade public batchTradeImplementation;

// The Gnosis contract to init batch auction trades with. Governance parameter.
IGnosis public gnosis;
/// @custom:oz-renamed-from gnosis
// Deprecated in 4.0.0
IGnosis public gnosis_DEPRECATED;

Check warning on line 40 in contracts/p1/Broker.sol

View workflow job for this annotation

GitHub Actions / Lint Checks

Variable name must be in mixedCase

/// @custom:oz-renamed-from auctionLength
// {s} the length of a Gnosis EasyAuction. Governance parameter.
Expand Down Expand Up @@ -72,7 +73,6 @@
// effects: initial parameters are set
function init(
IMain main_,
IGnosis gnosis_,
ITrade batchTradeImplementation_,
uint48 batchAuctionLength_,
ITrade dutchTradeImplementation_,
Expand All @@ -81,8 +81,6 @@
__Component_init(main_);
cacheComponents();

setGnosis(gnosis_);

require(
address(batchTradeImplementation_) != address(0),
"invalid batchTradeImplementation address"
Expand Down Expand Up @@ -174,14 +172,6 @@

// === Setters ===

/// @custom:governance
function setGnosis(IGnosis newGnosis) public governance {
require(address(newGnosis) != address(0), "invalid Gnosis address");

emit GnosisSet(gnosis, newGnosis);
gnosis = newGnosis;
}

/// @custom:main
function setBatchTradeImplementation(ITrade newTradeImplementation) public onlyMain {
require(
Expand Down Expand Up @@ -261,7 +251,7 @@
address(trade),
req.sellAmount
);
trade.init(this, caller, gnosis, batchAuctionLength, req);
trade.init(this, caller, batchAuctionLength, req);
return trade;
}

Expand Down
6 changes: 1 addition & 5 deletions contracts/p1/Deployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import "../plugins/assets/Asset.sol";
import "../plugins/assets/RTokenAsset.sol";
import "./Main.sol";
import "../libraries/String.sol";
import "../plugins/trading/GnosisTrade.sol";

/**
* @title DeployerP1
Expand All @@ -31,7 +32,6 @@ contract DeployerP1 is IDeployer, Versioned {
string public constant ENS = "reserveprotocol.eth";

IERC20Metadata public immutable rsr;
IGnosis public immutable gnosis;
IAsset public immutable rsrAsset;

// Implementation contracts for Upgradeability
Expand All @@ -41,13 +41,11 @@ contract DeployerP1 is IDeployer, Versioned {
// effects: post, all contract-state values are set
constructor(
IERC20Metadata rsr_,
IGnosis gnosis_,
IAsset rsrAsset_,
Implementations memory implementations_
) {
require(
address(rsr_) != address(0) &&
address(gnosis_) != address(0) &&
address(rsrAsset_) != address(0) &&
address(implementations_.main) != address(0) &&
address(implementations_.trading.gnosisTrade) != address(0) &&
Expand All @@ -66,7 +64,6 @@ contract DeployerP1 is IDeployer, Versioned {
);

rsr = rsr_;
gnosis = gnosis_;
rsrAsset = rsrAsset_;
_implementations = implementations_;
}
Expand Down Expand Up @@ -216,7 +213,6 @@ contract DeployerP1 is IDeployer, Versioned {

components.broker.init(
main,
gnosis,
_implementations.trading.gnosisTrade,
params.batchAuctionLength,
_implementations.trading.dutchTrade,
Expand Down
4 changes: 0 additions & 4 deletions contracts/plugins/mocks/InvalidBrokerMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ contract InvalidBrokerMock is ComponentP0, IBroker {
using EnumerableSet for EnumerableSet.AddressSet;
using SafeERC20 for IERC20Metadata;

IGnosis public gnosis;

mapping(address => bool) private trades;

uint48 public batchAuctionLength; // {s} the length of a batch auction
Expand All @@ -28,14 +26,12 @@ contract InvalidBrokerMock is ComponentP0, IBroker {

function init(
IMain main_,
IGnosis gnosis_,
ITrade,
uint48 batchAuctionLength_,
ITrade,
uint48 dutchAuctionLength_
) public initializer {
__Component_init(main_);
gnosis = gnosis_;
batchAuctionLength = batchAuctionLength_;
dutchAuctionLength = dutchAuctionLength_;
}
Expand Down
3 changes: 1 addition & 2 deletions contracts/plugins/mocks/upgrades/DeployerV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ contract DeployerP1V2 is DeployerP1 {

constructor(
IERC20Metadata rsr_,
IGnosis gnosis_,
IAsset rsrAsset_,
Implementations memory implementations_
) DeployerP1(rsr_, gnosis_, rsrAsset_, implementations_) {}
) DeployerP1(rsr_, rsrAsset_, implementations_) {}

function setNewValue(uint256 newValue_) external {
newValue = newValue_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import "./vendor/EasyAuction.sol";

// ==== From https://etherscan.io/address/0x0b7ffc1f4ad541a4ed16b40d8c37f0929158d101 ====

// solhint-disable

// Used in production since 3.4.0
contract EasyAuction is Ownable {
using SafeERC20 for IERC20;
using SafeMath for uint64;
Expand Down
10 changes: 6 additions & 4 deletions contracts/plugins/trading/GnosisTrade.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ contract GnosisTrade is ITrade, Versioned {
// raw "/" for compile-time const
uint192 public constant DEFAULT_MIN_BID = FIX_ONE / 100; // {tok}

IGnosis public immutable gnosis; // Gnosis Auction contract

// ==== status: This contract's state-machine state. See TradeStatus enum, above
TradeStatus public status;

// ==== The rest of contract state is all parameters that are immutable after init()
// == Metadata
IGnosis public gnosis; // Gnosis Auction contract
IGnosis public gnosis_DEPRECATED; // made immutable in 4.0.0; left in for testing compatibility
uint256 public auctionId; // The Gnosis Auction ID returned by gnosis.initiateAuction()
IBroker public broker; // The Broker that cloned this contract into existence

Expand All @@ -63,7 +65,9 @@ contract GnosisTrade is ITrade, Versioned {
status = end;
}

constructor() {
constructor(IGnosis _gnosis) {
require(address(_gnosis) != address(0), "gnosis address zero");
gnosis = _gnosis;
status = TradeStatus.CLOSED;
}

Expand All @@ -84,7 +88,6 @@ contract GnosisTrade is ITrade, Versioned {
function init(
IBroker broker_,
address origin_,
IGnosis gnosis_,
uint48 batchAuctionLength,
TradeRequest calldata req
) external stateTransition(TradeStatus.NOT_STARTED, TradeStatus.OPEN) {
Expand All @@ -102,7 +105,6 @@ contract GnosisTrade is ITrade, Versioned {

broker = broker_;
origin = origin_;
gnosis = gnosis_;
endTime = uint48(block.timestamp) + batchAuctionLength;

// D27{qBuyTok/qSellTok}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ pragma solidity 0.6.12;

// ==== From https://etherscan.io/address/0x0b7ffc1f4ad541a4ed16b40d8c37f0929158d101#code ====

// solhint-disable

library AllowListVerifierHelper {
/// @dev Value returned by a call to `isAllowed` if the check
/// was successful. The value is defined as:
Expand Down
1 change: 0 additions & 1 deletion scripts/deployment/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { ITokens, IComponents, IImplementations, IPools } from '../../common/con
export interface IPrerequisites {
RSR: string
RSR_FEED: string
GNOSIS_EASY_AUCTION: string
}

export interface IFacets {
Expand Down
11 changes: 2 additions & 9 deletions scripts/deployment/phase1-core/0_setup_deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,20 @@ async function main() {
throw new Error(`RSR Feed contract not found in network ${hre.network.name}`)
}

// Get Gnosis EasyAuction Address
const gnosisAddr = networkConfig[chainId].GNOSIS_EASY_AUCTION
if (!gnosisAddr) {
throw new Error(`Missing address for GNOSIS_EASY_AUCTION in network ${hre.network.name}`)
} else if (!(await isValidContract(hre, gnosisAddr))) {
throw new Error(`GNOSIS_EASY_AUCTION contract not found in network ${hre.network.name}`)
}
// ********************* Output Configuration******************************
const deployments: IDeployments = {
prerequisites: {
RSR: rsrAddr,
RSR_FEED: rsrFeedAddr,
GNOSIS_EASY_AUCTION: gnosisAddr,
},
tradingLib: '',
facade: '',
facets: {
actFacet: '',
readFacet: '',
maxIssuableFacet: '',
backingBufferFacet: '',
revenueFacet: '',
},
facadeWriteLib: '',
basketLib: '',
Expand Down Expand Up @@ -90,7 +84,6 @@ async function main() {
console.log(`Deployment file created for ${hre.network.name} (${chainId}):
RSR: ${rsrAddr}
RSR FEED: ${rsrFeedAddr}
GNOSIS_EASY_AUCTION: ${gnosisAddr}
Deployment file: ${deploymentFilename}`)
}

Expand Down
4 changes: 3 additions & 1 deletion scripts/deployment/phase1-core/2_deploy_implementations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ async function main() {
// ******************** Deploy GnosisTrade ********************************/

const GnosisTradeImplFactory = await ethers.getContractFactory('GnosisTrade')
gnosisTradeImpl = <GnosisTrade>await GnosisTradeImplFactory.connect(burner).deploy()
gnosisTradeImpl = <GnosisTrade>(
await GnosisTradeImplFactory.connect(burner).deploy(networkConfig[chainId].GNOSIS_EASY_AUCTION!)
)
await gnosisTradeImpl.deployed()

// Write temporary deployments file
Expand Down
1 change: 0 additions & 1 deletion scripts/deployment/phase1-core/5_deploy_deployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ async function main() {
deployer = <DeployerP1>(
await DeployerFactory.connect(burner).deploy(
deployments.prerequisites.RSR,
deployments.prerequisites.GNOSIS_EASY_AUCTION,
deployments.rsrAsset,
deployments.implementations
)
Expand Down
Loading
Loading