Skip to content

Commit

Permalink
create ArtgenePlatform global config (#100)
Browse files Browse the repository at this point in the history
* create ArtgenePlatform global config

* move proxy implementation address to constants

* check contract not empty before setting

* update vanity deployer

* update salt

* move free functions to artgene utils

* cleanup code

* platform: add vanity constant, rename methods

* remove utils

* platform: transfer ownership after deploy

* add task hh accounts

* platform: check that it's deployed to correct address

* platform: deploy to mainnet

* deploy to mainnet
  • Loading branch information
caffeinum authored Apr 13, 2023
1 parent e9256b9 commit 758f6a2
Show file tree
Hide file tree
Showing 10 changed files with 377 additions and 31 deletions.
6 changes: 2 additions & 4 deletions contracts/Artgene721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ import "./interfaces/IArtgene721.sol";
type StartFromTokenIdOne is bool;

contract Artgene721 is Proxy {
address internal constant proxyImplementation =
0x00000721187b81D0aDac9d1E4D7Fd623ac788559;

StartFromTokenIdOne internal constant START_FROM_ONE =
StartFromTokenIdOne.wrap(true);
Expand All @@ -85,7 +83,7 @@ contract Artgene721 is Proxy {
MintConfig memory configValues
) {
Address.functionDelegateCall(
proxyImplementation,
ARTGENE_PROXY_IMPLEMENTATION,
abi.encodeWithSelector(
IArtgene721Implementation.initialize.selector,
name,
Expand All @@ -104,6 +102,6 @@ contract Artgene721 is Proxy {
}

function _implementation() internal pure override returns (address) {
return address(proxyImplementation);
return address(ARTGENE_PROXY_IMPLEMENTATION);
}
}
20 changes: 11 additions & 9 deletions contracts/Artgene721Base.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./interfaces/INFTExtension.sol";
import "./interfaces/IRenderer.sol";
import "./interfaces/IArtgene721.sol";
import "./interfaces/IArtgenePlatform.sol";
import "./utils/OpenseaProxy.sol";


/**
* @title contract by artgene.xyz
*/
Expand Down Expand Up @@ -90,11 +92,13 @@ contract Artgene721Base is
using SafeERC20 for IERC20;

uint256 internal constant SALE_STARTS_AT_INFINITY = 2**256 - 1;
uint256 internal constant PLATFORM_FEE = 500; // of 10,000 = 5%
uint256 internal constant MAX_PER_MINT_LIMIT = 50; // based on ERC721A limitations
address internal constant OPENSEA_CONDUIT =
0x1E0049783F008A0085193E00003D00cd54003c71;

uint256 public PLATFORM_FEE; // of 10,000
address payable PLATFORM_ADDRESS;

uint256 public startTimestamp = SALE_STARTS_AT_INFINITY;

uint256 public reserved;
Expand Down Expand Up @@ -163,6 +167,8 @@ contract Artgene721Base is
maxPerMint = MAX_PER_MINT_LIMIT;
isOpenSeaProxyActive = true;

(PLATFORM_FEE, PLATFORM_ADDRESS) = IArtgenePlatform(ARTGENE_PLATFORM_ADDRESS).getPlatformInfo();

_configure(
_config.publicPrice,
_config.maxTokensPerMint,
Expand Down Expand Up @@ -569,7 +575,7 @@ contract Artgene721Base is

modifier onlyDeveloper() {
require(
payable(msg.sender) == PLATFORM_ADDRESS(),
payable(msg.sender) == PLATFORM_ADDRESS,
"Caller is not developer"
);
_;
Expand All @@ -580,7 +586,7 @@ contract Artgene721Base is
uint256 amount = (balance * (10000 - PLATFORM_FEE)) / 10000;

address payable receiver = getPayoutReceiver();
address payable dev = PLATFORM_ADDRESS();
address payable dev = PLATFORM_ADDRESS;

Address.sendValue(receiver, amount);
Address.sendValue(dev, balance - amount);
Expand All @@ -600,20 +606,16 @@ contract Artgene721Base is
uint256 amount = (balance * (10000 - PLATFORM_FEE)) / 10000;

address payable receiver = getPayoutReceiver();
address payable dev = PLATFORM_ADDRESS();
address payable dev = PLATFORM_ADDRESS;

token.safeTransfer(receiver, amount);
token.safeTransfer(dev, balance - amount);
}

function DEVELOPER() public pure returns (string memory _url) {
function PLATFORM() public pure returns (string memory _url) {
_url = "https://artgene.xyz";
}

function PLATFORM_ADDRESS() internal pure returns (address payable _dev) {
_dev = payable(0x704C043CeB93bD6cBE570C6A2708c3E1C0310587);
}

// -------- ERC721 overrides --------

function supportsInterface(bytes4 interfaceId)
Expand Down
34 changes: 20 additions & 14 deletions contracts/Artgene721Implementation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./interfaces/INFTExtension.sol";
import "./interfaces/IRenderer.sol";
import "./interfaces/IArtgene721.sol";
import "./interfaces/IArtgenePlatform.sol";
import "./utils/OpenseaProxy.sol";
import "./utils/operator-filterer/upgradable/DefaultOperatorFiltererUpgradeable.sol";

Expand Down Expand Up @@ -92,15 +93,17 @@ contract Artgene721Implementation is
using Address for address;
using SafeERC20 for IERC20;

uint256 internal constant SALE_STARTS_AT_INFINITY = 2**256 - 1;
uint256 internal constant PLATFORM_FEE = 500; // of 10,000 = 5%
uint256 internal constant SALE_STARTS_AT_INFINITY = 2 ** 256 - 1;
uint256 internal constant MAX_PER_MINT_LIMIT = 50; // based on ERC721A limitations
address internal constant OPENSEA_CONDUIT =
0x1E0049783F008A0085193E00003D00cd54003c71;

uint256 public constant VERSION = 3;

uint256 public startTimestamp = SALE_STARTS_AT_INFINITY;
uint256 public startTimestamp;

uint256 public PLATFORM_FEE; // of 10,000
address payable PLATFORM_ADDRESS;

uint256 public reserved;
uint256 public maxSupply;
Expand Down Expand Up @@ -165,6 +168,8 @@ contract Artgene721Implementation is
isOpenSeaProxyActive = true;
isOpenSeaTransferFilterEnabled = true;

(PLATFORM_FEE, PLATFORM_ADDRESS) = IArtgenePlatform(ARTGENE_PLATFORM_ADDRESS).getPlatformInfo();

__ERC721A_init(_name, _symbol);
__ReentrancyGuard_init();
__Ownable_init();
Expand Down Expand Up @@ -231,7 +236,12 @@ contract Artgene721Implementation is
// on the other hand, it's impossible to call this function in proxy,
// so the real initializer is the only initializer
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() initializer {}
constructor() initializer {
// NB: this is run only once per implementation, when it's deployed
// NB: this is NOT run when deploying Proxy
require(address(this) == ARTGENE_PROXY_IMPLEMENTATION, "Only deployable to vanity address");

}

function _baseURI() internal view override returns (string memory) {
return BASE_URI;
Expand Down Expand Up @@ -586,7 +596,7 @@ contract Artgene721Implementation is

modifier onlyDeveloper() {
require(
payable(msg.sender) == PLATFORM_ADDRESS(),
payable(msg.sender) == PLATFORM_ADDRESS,
"Caller is not developer"
);
_;
Expand All @@ -597,10 +607,10 @@ contract Artgene721Implementation is
uint256 amount = (balance * (10000 - PLATFORM_FEE)) / 10000;

address payable receiver = getPayoutReceiver();
address payable dev = PLATFORM_ADDRESS();
address payable platform = PLATFORM_ADDRESS;

Address.sendValue(receiver, amount);
Address.sendValue(dev, balance - amount);
Address.sendValue(platform, balance - amount);
}

function withdraw() public virtual onlyOwner {
Expand All @@ -617,20 +627,16 @@ contract Artgene721Implementation is
uint256 amount = (balance * (10000 - PLATFORM_FEE)) / 10000;

address payable receiver = getPayoutReceiver();
address payable dev = PLATFORM_ADDRESS();
address payable platform = PLATFORM_ADDRESS;

token.safeTransfer(receiver, amount);
token.safeTransfer(dev, balance - amount);
token.safeTransfer(platform, balance - amount);
}

function DEVELOPER() public pure returns (string memory _url) {
function PLATFORM() public pure returns (string memory _url) {
_url = "https://artgene.xyz";
}

function PLATFORM_ADDRESS() internal pure returns (address payable _dev) {
_dev = payable(0x704C043CeB93bD6cBE570C6A2708c3E1C0310587);
}

// -------- ERC721 overrides --------

function _beforeTokenTransfers(
Expand Down
59 changes: 59 additions & 0 deletions contracts/ArtgenePlatform.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/StorageSlot.sol";

import "./interfaces/IArtgenePlatform.sol";

contract ArtgenePlatform is Ownable, IArtgenePlatform {

uint256 platformFee; // in bps
address payable platformAddress;

constructor() {
require(
ARTGENE_PLATFORM_ADDRESS == address(this),
"ArtgenePlatformConfig: platform address mismatch"
);

platformFee = 500;
platformAddress = payable(0x704C043CeB93bD6cBE570C6A2708c3E1C0310587);
}

function setPlatformFee(uint256 _platformFee) public onlyOwner {
require(
_platformFee <= 1000,
"ArtgenePlatformConfig: platform fee cannot be more than 10%"
);

platformFee = _platformFee;
}

function setPlatformAddress(
address payable _platformAddress
) public onlyOwner {
platformAddress = _platformAddress;
}

function getPlatformFee() external view override returns (uint256) {
return platformFee;
}

function getPlatformAddress()
external
view
override
returns (address payable)
{
return platformAddress;
}

function getPlatformInfo()
external
view
returns (uint256, address payable)
{
return (platformFee, platformAddress);
}
}
2 changes: 2 additions & 0 deletions contracts/interfaces/IArtgene721.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

address constant ARTGENE_PROXY_IMPLEMENTATION = 0x000007214f56DaF21c803252cc610360C70C01D5;

struct MintConfig {
uint256 publicPrice;
uint256 maxTokensPerMint;
Expand Down
14 changes: 14 additions & 0 deletions contracts/interfaces/IArtgenePlatform.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

address constant ARTGENE_PLATFORM_ADDRESS = 0xAaaeEee77ED0D0ffCc2813333b796E367f1E12d9;

interface IArtgenePlatform {
function getPlatformFee() external view returns (uint256);
function getPlatformAddress() external view returns (address payable);

function getPlatformInfo() external view returns (uint256, address payable);

function setPlatformFee(uint256 _platformFee) external;
function setPlatformAddress(address payable _platformAddress) external;
}
12 changes: 10 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from "fs";
import { stdout } from "process";
import "dotenv/config";
import { HardhatUserConfig } from "hardhat/config";
import { stdout } from "process";
import { HardhatUserConfig, task } from "hardhat/config";

import { generateMnemonic } from "bip39";

Expand Down Expand Up @@ -72,6 +72,14 @@ const getRemappings = () => {
.map((line) => line.trim().split("="));
};

task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
const accounts = await hre.ethers.getSigners();

for (const account of accounts) {
console.log(account.address);
}
});

const config: HardhatUserConfig = {
networks: {
hardhat: {
Expand Down
Loading

0 comments on commit 758f6a2

Please sign in to comment.