Skip to content

Commit

Permalink
Interface changes + allow auction contract to change founders rewards
Browse files Browse the repository at this point in the history
  • Loading branch information
neokry committed Sep 21, 2023
1 parent f5a9450 commit b17e75e
Show file tree
Hide file tree
Showing 17 changed files with 122 additions and 124 deletions.
28 changes: 22 additions & 6 deletions src/auction/Auction.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ contract Auction is IAuction, VersionedContract, UUPS, Ownable, ReentrancyGuard,

/// @notice Initializes a DAO's auction contract
/// @param _token The ERC-721 token address
/// @param _founder The founder responsible for starting the first auction
/// @param _initalOwner The account responsible for starting the first auction
/// @param _treasury The treasury address where ETH will be sent
/// @param _data The encoded auction settings
function initialize(
address _token,
address _founder,
address _initalOwner,
address _treasury,
bytes calldata _data
) external initializer {
Expand All @@ -82,7 +82,7 @@ contract Auction is IAuction, VersionedContract, UUPS, Ownable, ReentrancyGuard,
__ReentrancyGuard_init();

// Grant initial ownership to a founder
__Ownable_init(_founder);
__Ownable_init(_initalOwner);

// Pause the contract until the first auction
__Pausable_init(true);
Expand All @@ -99,8 +99,8 @@ contract Auction is IAuction, VersionedContract, UUPS, Ownable, ReentrancyGuard,
settings.timeBuffer = INITIAL_TIME_BUFFER;
settings.minBidIncrement = INITIAL_MIN_BID_INCREMENT_PERCENT;

// Store the founder rewards recipient
founderRewardsRecipent = _founder;
// Store the founder rewards settings
founderRewardRecipent = params.founderRewardRecipent;
founderRewardBPS = params.founderRewardBPS;
}

Expand Down Expand Up @@ -239,7 +239,7 @@ contract Auction is IAuction, VersionedContract, UUPS, Ownable, ReentrancyGuard,
if (split.totalRewards != 0) {
// Deposit rewards
rewards.depositRewards{ value: split.totalRewards }(
founderRewardsRecipent,
founderRewardRecipent,
split.founderReward,
currentBidReferral,
split.refferalReward,
Expand Down Expand Up @@ -411,6 +411,22 @@ contract Auction is IAuction, VersionedContract, UUPS, Ownable, ReentrancyGuard,
emit MinBidIncrementPercentageUpdated(_percentage);
}

/// @notice Updates the founder reward recipent address
/// @param _founder The new founder
function setFounderRewardsRecipent(address _founder) external onlyOwner whenPaused {
founderRewardRecipent = _founder;

emit FounderRewardRecipentUpdated(_founder);
}

/// @notice Updates the founder reward percentage in BPS
/// @param _founderRewardBPS The new percentage in BPS
function setFounderRewardBPS(uint256 _founderRewardBPS) external onlyOwner whenPaused {
founderRewardBPS = _founderRewardBPS;

emit FounderRewardBPSUpdated(_founderRewardBPS);
}

/// ///
/// TRANSFER UTIL ///
/// ///
Expand Down
16 changes: 13 additions & 3 deletions src/auction/IAuction.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ interface IAuction is IUUPS, IOwnable, IPausable {
/// @param duration The new auction duration
event DurationUpdated(uint256 duration);

/// @notice Emitted when the reserve price is updated
/// @notice Emitted when the reserve price is updatedq
/// @param reservePrice The new reserve price
event ReservePriceUpdated(uint256 reservePrice);

Expand All @@ -49,6 +49,14 @@ interface IAuction is IUUPS, IOwnable, IPausable {
/// @param timeBuffer The new time buffer
event TimeBufferUpdated(uint256 timeBuffer);

/// @notice Emitted when the founder reward recipient is updated
/// @param founderRewardRecipient The new time buffer
event FounderRewardRecipentUpdated(address founderRewardRecipient);

/// @notice Emitted when the founder reward BPS is updated
/// @param founderRewardBPS The new time buffer
event FounderRewardBPSUpdated(uint256 founderRewardBPS);

/// ///
/// ERRORS ///
/// ///
Expand Down Expand Up @@ -99,6 +107,8 @@ interface IAuction is IUUPS, IOwnable, IPausable {
uint256 duration;
/// @notice The reserve price of each auction
uint256 reservePrice;
/// @notice The address to recieve founders rewards
address founderRewardRecipent;
/// @notice The percent of rewards a founder receives in BPS for each auction
uint256 founderRewardBPS;
}
Expand All @@ -109,12 +119,12 @@ interface IAuction is IUUPS, IOwnable, IPausable {

/// @notice Initializes a DAO's auction house
/// @param token The ERC-721 token address
/// @param founder The founder responsible for starting the first auction
/// @param initialOwner The account responsible for starting the first auction
/// @param treasury The treasury address where ETH will be sent
/// @param data The encoded auction initialization data
function initialize(
address token,
address founder,
address initialOwner,
address treasury,
bytes calldata data
) external;
Expand Down
2 changes: 1 addition & 1 deletion src/auction/storage/AuctionStorageV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ contract AuctionStorageV2 {
address public currentBidReferral;

/// @notice The DAO founder collecting protocol rewards
address public founderRewardsRecipent;
address public founderRewardRecipent;

/// @notice The rewards to be paid to the DAO founder in BPS
uint256 public founderRewardBPS;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/token/ERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ abstract contract ERC721 is IERC721, Initializable {

/// @notice If the contract implements an interface
/// @param _interfaceId The interface id
function supportsInterface(bytes4 _interfaceId) external pure returns (bool) {
function supportsInterface(bytes4 _interfaceId) public pure virtual returns (bool) {
return
_interfaceId == 0x01ffc9a7 || // ERC165 Interface ID
_interfaceId == 0x80ac58cd || // ERC721 Interface ID
Expand Down
8 changes: 4 additions & 4 deletions src/manager/Manager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ERC1967Proxy } from "../lib/proxy/ERC1967Proxy.sol";
import { ManagerStorageV1 } from "./storage/ManagerStorageV1.sol";
import { ManagerStorageV2 } from "./storage/ManagerStorageV2.sol";
import { IManager } from "./IManager.sol";
import { IToken } from "../token/default/IToken.sol";
import { IBaseToken } from "../token/interfaces/IBaseToken.sol";
import { IBaseMetadata } from "../metadata/interfaces/IBaseMetadata.sol";
import { IAuction } from "../auction/IAuction.sol";
import { ITreasury } from "../governance/treasury/ITreasury.sol";
Expand Down Expand Up @@ -109,15 +109,15 @@ contract Manager is IManager, VersionedContract, UUPS, Ownable, ManagerStorageV1
daoAddressesByToken[token] = DAOAddresses({ metadata: metadata, auction: auction, treasury: treasury, governor: governor });

// Initialize each instance with the provided settings
IToken(token).initialize({
IBaseToken(token).initialize({
founders: _founderParams,
metadataRenderer: metadata,
auction: auction,
initialOwner: founder,
data: _implData[IMPLEMENTATION_TYPE_TOKEN]
});
IBaseMetadata(metadata).initialize({ token: token, data: _implData[IMPLEMENTATION_TYPE_METADATA] });
IAuction(auction).initialize({ token: token, founder: founder, treasury: treasury, data: _implData[IMPLEMENTATION_TYPE_AUCTION] });
IAuction(auction).initialize({ token: token, initialOwner: founder, treasury: treasury, data: _implData[IMPLEMENTATION_TYPE_AUCTION] });
ITreasury(treasury).initialize({ governor: governor, data: _implData[IMPLEMENTATION_TYPE_TREASURY] });
IGovernor(governor).initialize({ treasury: treasury, token: token, data: _implData[IMPLEMENTATION_TYPE_GOVERNOR] });

Expand All @@ -143,7 +143,7 @@ contract Manager is IManager, VersionedContract, UUPS, Ownable, ManagerStorageV1
IBaseMetadata(metadata).initialize(_setupRenderer, _token);
}

IToken(_token).setMetadataRenderer(IBaseMetadata(metadata));
IBaseToken(_token).setMetadataRenderer(IBaseMetadata(metadata));

emit MetadataRendererUpdated({ sender: msg.sender, renderer: metadata });
}
Expand Down
4 changes: 2 additions & 2 deletions src/minters/MerkleReserveMinter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.8.16;

import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import { IOwnable } from "../lib/interfaces/IOwnable.sol";
import { IToken } from "../token/default/IToken.sol";
import { IBaseToken } from "../token/interfaces/IBaseToken.sol";
import { IManager } from "../manager/IManager.sol";
import { IMintStrategy } from "./interfaces/IMintStrategy.sol";

Expand Down Expand Up @@ -151,7 +151,7 @@ contract MerkleReserveMinter is IMintStrategy {
}

// Only allowing reserved tokens to be minted for this strategy
IToken(tokenContract).mintFromReserveTo(claim.mintTo, claim.tokenId);
IBaseToken(tokenContract).mintFromReserveTo(claim.mintTo, claim.tokenId);
}
}

Expand Down
48 changes: 0 additions & 48 deletions src/token/default/IToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { IManager } from "../../manager/IManager.sol";
import { IBaseToken } from "../interfaces/IBaseToken.sol";
import { TokenTypesV1 } from "./types/TokenTypesV1.sol";
import { TokenTypesV2 } from "./types/TokenTypesV2.sol";
import { IBaseMetadata } from "../../metadata/interfaces/IBaseMetadata.sol";

/// @title IToken
/// @author Rohan Kulkarni
Expand Down Expand Up @@ -102,29 +101,6 @@ interface IToken is IUUPS, IERC721Votes, IBaseToken, TokenTypesV1, TokenTypesV2
address initialOwner
) external;

/// @notice Mints tokens to the caller and handles founder vesting
function mint() external returns (uint256 tokenId);

/// @notice Mints tokens to the recipient and handles founder vesting
function mintTo(address recipient) external returns (uint256 tokenId);

/// @notice Mints the specified amount of tokens to the recipient and handles founder vesting
function mintBatchTo(uint256 amount, address recipient) external returns (uint256[] memory tokenIds);

/// @notice Mints the specified token from the reserve to the recipent
function mintFromReserveTo(address recipient, uint256 tokenId) external;

/// @notice Burns a token owned by the caller
/// @param tokenId The ERC-721 token id
function burn(uint256 tokenId) external;

/// @notice The URI for a token
/// @param tokenId The ERC-721 token id
function tokenURI(uint256 tokenId) external view returns (string memory);

/// @notice The URI for the contract
function contractURI() external view returns (string memory);

/// @notice The number of founders
function totalFounders() external view returns (uint256);

Expand All @@ -142,35 +118,11 @@ interface IToken is IUUPS, IERC721Votes, IBaseToken, TokenTypesV1, TokenTypesV2
/// @param newFounders the full list of FounderParam structs
function updateFounders(IManager.FounderParams[] calldata newFounders) external;

/// @notice The founder scheduled to receive the given token id
/// NOTE: If a founder is returned, there's no guarantee they'll receive the token as vesting expiration is not considered
/// @param tokenId The ERC-721 token id
function getScheduledRecipient(uint256 tokenId) external view returns (Founder memory);

/// @notice The total supply of tokens
function totalSupply() external view returns (uint256);

/// @notice The token's auction house
function auction() external view returns (address);

/// @notice The token's metadata renderer
function metadataRenderer() external view returns (address);

/// @notice The owner of the token and metadata renderer
function owner() external view returns (address);

/// @notice Update minters
/// @param _minters Array of structs containing address status as a minter
function updateMinters(MinterParams[] calldata _minters) external;

/// @notice Check if an address is a minter
/// @param _minter Address to check
function isMinter(address _minter) external view returns (bool);

/// @notice Set a new metadata renderer
/// @param newRenderer new renderer address to use
function setMetadataRenderer(IBaseMetadata newRenderer) external;

/// @notice Callback called by auction on first auction started to transfer ownership to treasury from founder
function onFirstAuctionStarted() external;
}
6 changes: 3 additions & 3 deletions src/token/default/Token.sol
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,12 @@ contract Token is IToken, VersionedContract, UUPS, Ownable, ReentrancyGuard, ERC

/// @notice The URI for a token
/// @param _tokenId The ERC-721 token id
function tokenURI(uint256 _tokenId) public view override(IToken, ERC721) returns (string memory) {
function tokenURI(uint256 _tokenId) public view override(IBaseToken, ERC721) returns (string memory) {
return settings.metadataRenderer.tokenURI(_tokenId);
}

/// @notice The URI for the contract
function contractURI() public view override(IToken, ERC721) returns (string memory) {
function contractURI() public view override(IBaseToken, ERC721) returns (string memory) {
return settings.metadataRenderer.contractURI();
}

Expand Down Expand Up @@ -466,7 +466,7 @@ contract Token is IToken, VersionedContract, UUPS, Ownable, ReentrancyGuard, ERC
}

/// @notice The contract owner
function owner() public view override(IToken, Ownable) returns (address) {
function owner() public view override(IBaseToken, Ownable) returns (address) {
return super.owner();
}

Expand Down
20 changes: 17 additions & 3 deletions src/token/interfaces/IBaseToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity 0.8.16;
import { IERC721 } from "../../lib/interfaces/IERC721.sol";
import { IERC721Votes } from "../../lib/interfaces/IERC721Votes.sol";
import { IManager } from "../../manager/IManager.sol";
import { IBaseMetadata } from "../../metadata/interfaces/IBaseMetadata.sol";

/// @title IBaseToken
/// @author Neokry
Expand All @@ -13,6 +14,19 @@ interface IBaseToken is IERC721, IERC721Votes {
/// FUNCTIONS ///
/// ///

/// @notice Initializes a DAO's ERC-721 token
/// @param founders The founding members to receive vesting allocations
/// @param data The encoded token and metadata initialization strings
/// @param metadataRenderer The token's metadata renderer
/// @param auction The token's auction house
function initialize(
IManager.FounderParams[] calldata founders,
bytes calldata data,
address metadataRenderer,
address auction,
address initialOwner
) external;

/// @notice Mints tokens to the caller and handles founder vesting
function mint() external returns (uint256 tokenId);

Expand Down Expand Up @@ -48,9 +62,9 @@ interface IBaseToken is IERC721, IERC721Votes {
/// @notice The owner of the token and metadata renderer
function owner() external view returns (address);

/// @notice Check if an address is a minter
/// @param _minter Address to check
function isMinter(address _minter) external view returns (bool);
/// @notice Set a new metadata renderer
/// @param newRenderer new renderer address to use
function setMetadataRenderer(IBaseMetadata newRenderer) external;

/// @notice Callback called by auction on first auction started to transfer ownership to treasury from founder
function onFirstAuctionStarted() external;
Expand Down
11 changes: 11 additions & 0 deletions src/token/interfaces/IMirrorToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;

/// @title IMirrorToken
/// @author Neokry
/// @notice A token that allows mirroring another token's ownership
interface IMirrorToken {
/// @notice Mirrors the ownership of a given tokenId from {tokenToMirror}
/// @param _tokenId The ERC-721 token to mirror
function mirror(uint256 _tokenId) external;
}
39 changes: 2 additions & 37 deletions src/token/partial-mirror/IPartialMirrorToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ interface IPartialMirrorToken is IUUPS, IERC721Votes, IBaseToken, PartialMirrorT
string symbol;
/// @notice The tokenId that a DAO's auctions will start at
uint256 reservedUntilTokenId;
/// @notice The token contract this token will mirror
address mirroredToken;
/// @notice The token contract to be mirrored
address tokenToMirror;
/// @notice The minter a DAO enables by default
address initalMinter;
/// @notice The initilization data for the inital minter
Expand All @@ -104,29 +104,6 @@ interface IPartialMirrorToken is IUUPS, IERC721Votes, IBaseToken, PartialMirrorT
address initialOwner
) external;

/// @notice Mints tokens to the caller and handles founder vesting
function mint() external returns (uint256 tokenId);

/// @notice Mints tokens to the recipient and handles founder vesting
function mintTo(address recipient) external returns (uint256 tokenId);

/// @notice Mints the specified amount of tokens to the recipient and handles founder vesting
function mintBatchTo(uint256 amount, address recipient) external returns (uint256[] memory tokenIds);

/// @notice Mints the specified token from the reserve to the recipent
function mintFromReserveTo(address recipient, uint256 tokenId) external;

/// @notice Burns a token owned by the caller
/// @param tokenId The ERC-721 token id
function burn(uint256 tokenId) external;

/// @notice The URI for a token
/// @param tokenId The ERC-721 token id
function tokenURI(uint256 tokenId) external view returns (string memory);

/// @notice The URI for the contract
function contractURI() external view returns (string memory);

/// @notice The number of founders
function totalFounders() external view returns (uint256);

Expand All @@ -149,18 +126,6 @@ interface IPartialMirrorToken is IUUPS, IERC721Votes, IBaseToken, PartialMirrorT
/// @param tokenId The ERC-721 token id
function getScheduledRecipient(uint256 tokenId) external view returns (Founder memory);

/// @notice The total supply of tokens
function totalSupply() external view returns (uint256);

/// @notice The token's auction house
function auction() external view returns (address);

/// @notice The token's metadata renderer
function metadataRenderer() external view returns (address);

/// @notice The owner of the token and metadata renderer
function owner() external view returns (address);

/// @notice Update minters
/// @param _minters Array of structs containing address status as a minter
function updateMinters(MinterParams[] calldata _minters) external;
Expand Down
Loading

0 comments on commit b17e75e

Please sign in to comment.