Skip to content

Commit

Permalink
SFS implemented in NFT Launchpad contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
tempe-techie committed Jan 29, 2024
1 parent 8c0d9ef commit cff4f2a
Show file tree
Hide file tree
Showing 39 changed files with 105 additions and 66 deletions.
20 changes: 19 additions & 1 deletion contracts/launchpad/erc721/IggyLaunchpad721Bonding.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ interface INftMetadata {
function setName(address nftAddress_, string memory name_) external;
}

interface ISFSF {
function assign(uint256 _tokenId) external returns (uint256);
}

interface IStatsContract {
function addWeiSpent(address user_, uint256 weiSpent_) external;
function addWriterByWriter(address writer_) external;
Expand All @@ -37,6 +41,7 @@ contract IggyLaunchpad721Bonding is OwnableWithManagers, ReentrancyGuard {
address public metadataAddress;
address public mintingFeeReceiver; // the address that receives the ETH paid for launching a new NFT contract & minting fees from NFT contracts
address public nftDirectoryAddress;
address public sfsAddress;
address public statsAddress; // usually the stats middleware address

bool public paused = false; // pause launching collections through the factory contract
Expand All @@ -55,9 +60,14 @@ contract IggyLaunchpad721Bonding is OwnableWithManagers, ReentrancyGuard {
address _mintingFeeReceiver,
address _nftDirectoryAddress,
address _statsAddress,
address _sfsAddress,
uint256 _sfsNftId,
uint256 _mintingFeePercentage,
uint256 _price
) {
ISFSF(_sfsAddress).assign(_sfsNftId);
sfsAddress = _sfsAddress;

metadataAddress = _metadataAddress;
mintingFeeReceiver = _mintingFeeReceiver;
nftDirectoryAddress = _nftDirectoryAddress;
Expand Down Expand Up @@ -145,7 +155,10 @@ contract IggyLaunchpad721Bonding is OwnableWithManagers, ReentrancyGuard {
// create new NFT contract
bytes32 saltedHash = keccak256(abi.encodePacked(msg.sender, block.timestamp, uniqueId_));
Nft721Bonding nftContract = new Nft721Bonding{salt: saltedHash}(
address(this), metadataAddress, mintingFeeReceiver, name_, symbol_, mintingFeePercentage, ratio
contractOwner_,
name_,
symbol_,
ratio
);

// update nftAddressById mapping and allNftContracts array
Expand Down Expand Up @@ -211,6 +224,11 @@ contract IggyLaunchpad721Bonding is OwnableWithManagers, ReentrancyGuard {
referralFeePercentage = _referralFeePercentage;
}

/// @notice Set SFS address (only owner)
function setSfsAddress(address _sfsAddress) external onlyOwner {
sfsAddress = _sfsAddress;
}

/// @notice Set stats contract address
function setStatsAddress(address _statsAddress) external onlyManagerOrOwner {
statsAddress = _statsAddress;
Expand Down
23 changes: 15 additions & 8 deletions contracts/launchpad/erc721/Nft721Bonding.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import { OwnableWithManagers } from "../../access/OwnableWithManagers.sol";
import { ReentrancyGuard } from "@openzeppelin/contracts/security/ReentrancyGuard.sol";

interface IFactory {
function metadataAddress() external view returns (address);
function mintingFeePercentage() external view returns (uint256);
function mintingFeeReceiver() external view returns (address);
function owner() external view returns (address);
function sfsAddress() external view returns (address);
function statsAddress() external view returns (address);
}

Expand All @@ -15,6 +19,10 @@ interface INftMd {
function getMetadata(address nftAddress_, uint256 tokenId_) external view returns (string memory);
}

interface ISFS {
function register(address _recipient) external returns (uint256 tokenId);
}

interface IStats {
function addWeiSpent(address user_, uint256 weiSpent_) external;
}
Expand All @@ -37,19 +45,18 @@ contract Nft721Bonding is ERC721, ERC721Enumerable, OwnableWithManagers, Reentra

// CONSTRUCTOR
constructor(
address factoryAddress_,
address metadataAddress_,
address mintingFeeReceiver_,
address sfsNftOwner,
string memory name_,
string memory symbol_,
uint256 mintingFeePercentage_,
uint256 ratio_
) ERC721(name_, symbol_) {
factoryAddress = factoryAddress_;
metadataAddress = metadataAddress_;
mintingFeeReceiver = mintingFeeReceiver_;
ISFS(IFactory(msg.sender).sfsAddress()).register(sfsNftOwner); // register the contract creator in the SFS contract

factoryAddress = msg.sender;
metadataAddress = IFactory(msg.sender).metadataAddress();
mintingFeeReceiver = IFactory(msg.sender).mintingFeeReceiver();

mintingFeePercentage = mintingFeePercentage_;
mintingFeePercentage = IFactory(msg.sender).mintingFeePercentage();
ratio = ratio_;
createdAt = block.timestamp;
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/activity-points/activityPoints.deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const contractName = "ActivityPoints";

const statsAddress = ""; // stats contract
const mintedPostsStatsAddress = "";
const tldStatsAddress = ethers.constants.AddressZero;
const tldStatsAddress = "";
const multiplier = 100000; // 1 wei = 100000 points

const sfsAddress = (network.name == "modeTestnet") ? "0xBBd707815a7F7eb6897C7686274AFabd7B579Ff6" : "0x8680CEaBcb9b56913c519c069Add6Bc3494B7020";
Expand Down
2 changes: 1 addition & 1 deletion scripts/activity-points/activityPointsAlt.deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const contractName = "ActivityPointsAlt";

const statsAddress = ""; // stats contract
const mintedPostsStatsAddress = "";
const tldStatsAddress = ethers.constants.AddressZero;
const tldStatsAddress = "";
const multiplier = 100000; // 1 wei = 100000 points
const sfsAddress = (network.name == "modeTestnet") ? "0xBBd707815a7F7eb6897C7686274AFabd7B579Ff6" : "0x8680CEaBcb9b56913c519c069Add6Bc3494B7020";
const sfsNftTokenId = 0; // TODO: Enter SFS NFT token ID!!!
Expand Down
2 changes: 1 addition & 1 deletion scripts/activity-points/apLeaderboardFairchat.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// npx hardhat run scripts/activity-points/apLeaderboardFairchat.js --network zkfair
// npx hardhat run scripts/activity-points/apLeaderboardFairchat.js --network modeTestnet

const contractName = "ActivityPoints";

Expand Down
2 changes: 1 addition & 1 deletion scripts/activity-points/calls.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// npx hardhat run scripts/activity-points/calls.js --network zkfair
// npx hardhat run scripts/activity-points/calls.js --network modeTestnet

const contractName = "ActivityPoints";

Expand Down
2 changes: 1 addition & 1 deletion scripts/custom/minterV2ambassadors.deploy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Deploy minter V2 contract
// npx hardhat run scripts/custom/minterV2ambassadors.deploy.js --network songbird
// npx hardhat run scripts/custom/minterV2ambassadors.deploy.js --network modeTestnet
// It will automatically set different fees (if needed) and set the staking contract address (if needed).
// It will also automatically add the minter to the ChatTokenMinter contract and change the minter address in the post contract.
// If any of these actions fail, you must do them manually.
Expand Down
2 changes: 1 addition & 1 deletion scripts/distributor/distributor.deploy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// npx hardhat run scripts/distributor/distributor.deploy.js --network bsc
// npx hardhat run scripts/distributor/distributor.deploy.js --network modeTestnet

const contractName = "RevenueDistributor";

Expand Down
2 changes: 1 addition & 1 deletion scripts/distributor/distributorFactory.deploy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// npx hardhat run scripts/distributor/distributorFactory.deploy.js --network bsc
// npx hardhat run scripts/distributor/distributorFactory.deploy.js --network modeTestnet

const contractName = "RevenueDistributorFactory";

Expand Down
2 changes: 1 addition & 1 deletion scripts/keys/1_friendKeys.deploy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 1. Deploy FriendKeys contract and automatically add it's address to the Stats middleware contract.
// npx hardhat run scripts/keys/1_friendKeys.deploy.js --network zkfair
// npx hardhat run scripts/keys/1_friendKeys.deploy.js --network modeTestnet

const contractName = "FriendKeys";

Expand Down
10 changes: 5 additions & 5 deletions scripts/launchpad/erc721/3_launchpadBonding.deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

const contractName = "IggyLaunchpad721Bonding";

const metadataAddress = "0xc486B08Ed47fFe5c1b4b1A2ff5c671EA0083D9bA";
const mintingFeeReceiver = "0x6771F33Cfd8C6FC0A1766331f715f5d2E1d4E0e2"; // revenue distributor contract address
const directoryAddress = "0x6AbDd1Bf5078cC6b0D75caFCdDC69A8339067F50";
const statsMiddlewareAddress = "0xce314209aB485bE222CE85F653Ac918f54532503";
const mintingFeePercentage = ethers.utils.parseEther("0.02");
const price = ethers.utils.parseEther("0.0001"); // price for creating a new NFT collection
const metadataAddress = "";
const mintingFeeReceiver = ""; // revenue distributor contract address
const directoryAddress = "";
const statsMiddlewareAddress = "";
const mintingFeePercentage = ethers.utils.parseEther("0.02");

async function main() {
const [deployer] = await ethers.getSigners();
Expand Down
12 changes: 7 additions & 5 deletions scripts/launchpad/erc721/4_arguments.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
module.exports = [
"0x498e0e6B245898c5E2dD0299d0456a8928F58ECC", // factory address
"0x4A82158ff4B0504F3DB4c7555FfB6298452985E2", // metadata address
"0x6771F33Cfd8C6FC0A1766331f715f5d2E1d4E0e2", // minting fee receiver address
"Always Liquid on Polygon", // collection name
"ALPOLY", // collection symbol
"", // factory address
"", // metadata address
"", // minting fee receiver address
"", // SFS contract address
"", // contract owner address
"Hello World", // collection name
"HELLO", // collection symbol
"20000000000000000", // minting fee percentage
"100000000000000000" // ratio
];
7 changes: 3 additions & 4 deletions scripts/launchpad/erc721/4_verifyNftContract.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
// TODO:
// 1. Create the first NFT collection through the factory.
// 2. Verify the contract on block explorer using this script (run the command below).
// Run: npx hardhat run scripts/launchpad/erc721/4_verifyNftContract.js --network polygon
// Run: npx hardhat run scripts/launchpad/erc721/4_verifyNftContract.js --network modeTestnet

const networkName = "polygon";
const contractAddress = "0x73Bf93b294AF8514a7E2dEf4E37877AeaE854a90";
const contractAddress = "";

async function main() {
console.log("Copy the line below and paste it in your terminal to verify the TLD contract on Etherscan:");
console.log("");
console.log("npx hardhat verify --network " + networkName + " --constructor-args scripts/launchpad/erc721/4_arguments.js " + contractAddress);
console.log("npx hardhat verify --network " + network.name + " --constructor-args scripts/launchpad/erc721/4_arguments.js " + contractAddress);
}

main()
Expand Down
17 changes: 8 additions & 9 deletions scripts/launchpad/erc721/5_mockNftContract.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@

const contractName = "Nft721Bonding";

const factoryAddress = "0x3Fa0EaC3058828Cc4BA97F51A33597C695bF6F9e";
const metadataAddress = "0xc486B08Ed47fFe5c1b4b1A2ff5c671EA0083D9bA";
const mintingFeeReceiver = "0xb29050965a5ac70ab487aa47546cdcbc97dae45d";
const factoryAddress = "";
const metadataAddress = "";
const mintingFeeReceiver = "";
const cName = "Test collection";
const cSymbol = "TEST";
const mintingFeePercentage = ethers.utils.parseEther("0.02");
const ratio = ethers.utils.parseEther("4200");
const ratio = ethers.utils.parseEther("1");

const sfsAddress = (network.name == "modeTestnet") ? "0xBBd707815a7F7eb6897C7686274AFabd7B579Ff6" : "0x8680CEaBcb9b56913c519c069Add6Bc3494B7020";

async function main() {
const [deployer] = await ethers.getSigners();
Expand All @@ -21,20 +23,17 @@ async function main() {
// deploy contract
const contract = await ethers.getContractFactory(contractName);
const instance = await contract.deploy(
factoryAddress,
metadataAddress,
mintingFeeReceiver,
deployer.address,
cName,
cSymbol,
mintingFeePercentage,
ratio
);
await instance.deployed();

console.log(contractName + " contract address:", instance.address);

console.log("Wait a minute and then run this command to verify contracts on block explorer:");
console.log("npx hardhat verify --network " + network.name + " " + instance.address + " " + factoryAddress + " " + metadataAddress + " " + mintingFeeReceiver + ' "' + cName + '" "' + cSymbol + '" "' + mintingFeePercentage + '" "' + ratio + '"');
console.log("npx hardhat verify --network " + network.name + " " + instance.address + " " + " " + deployer.address + ' "' + cName + '" "' + cSymbol + '" "' + ratio + '"');
}

main()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Deploy NftMetadata contract for multiple onchain images
// npx hardhat run scripts/launchpad/erc721/other/NftMetadataOnchainMultipleImages.deploy.js --network flare
// npx hardhat run scripts/launchpad/erc721/other/NftMetadataOnchainMultipleImages.deploy.js --network modeTestnet

const contractName = "NftMetadataOnchainMultipleImages";

Expand Down
2 changes: 1 addition & 1 deletion scripts/launchpad/erc721/other/addOldNftsToNewLaunchpad.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Add NFTs from the old launchpad to the new one
// npx hardhat run scripts/launchpad/erc721/other/addOldNftsToNewLaunchpad.js --network flare
// npx hardhat run scripts/launchpad/erc721/other/addOldNftsToNewLaunchpad.js --network modeTestnet

const launchpadContractName = "IggyLaunchpad721Bonding";
const newLaunchpadAddress = "";
Expand Down
2 changes: 1 addition & 1 deletion scripts/launchpad/erc721/other/calls.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// npx hardhat run scripts/launchpad/erc721/other/calls.js --network zkfair
// npx hardhat run scripts/launchpad/erc721/other/calls.js --network modeTestnet

const contractName = "IggyLaunchpad721Bonding";

Expand Down
2 changes: 1 addition & 1 deletion scripts/launchpad/erc721/other/nftRaffle.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// script to select 10 random winners from a list of NFT holders and creators
// npx hardhat run scripts/launchpad/erc721/other/nftRaffle.js --network scroll
// npx hardhat run scripts/launchpad/erc721/other/nftRaffle.js --network modeTestnet

const { ethers } = require("hardhat");

Expand Down
2 changes: 1 addition & 1 deletion scripts/merkle/merkleClaimerERC721.deploy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// npx hardhat run scripts/merkle/merkleClaimerERC721.deploy.js --network polygonMumbai
// npx hardhat run scripts/merkle/merkleClaimerERC721.deploy.js --network modeTestnet

const data = require("./claimers.json");
const { StandardMerkleTree } = require("@openzeppelin/merkle-tree");
Expand Down
2 changes: 1 addition & 1 deletion scripts/mock/mockCreateGovernanceProposal.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// npx hardhat run scripts/mock/mockCreateGovernanceProposal.js --network flareCoston
// npx hardhat run scripts/mock/mockCreateGovernanceProposal.js --network modeTestnet

const tokenAddress = "0x633Ae857445cF0cd02B21C6a3033C7CE74fB32c2"; // governance token contract address
const governorAddress = "0x06A7Ab7Bb68b0ad6eB7688C5781E60BE6AFc658d"; // governor contract address
Expand Down
2 changes: 1 addition & 1 deletion scripts/mock/mockERC721.deploy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// npx hardhat run scripts/mock/mockERC721.deploy.js --network polygonMumbai
// npx hardhat run scripts/mock/mockERC721.deploy.js --network modeTestnet

const contractName = "MockErc721WithMinter";

Expand Down
2 changes: 1 addition & 1 deletion scripts/mock/mockGovernorBlock.deploy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// npx hardhat run scripts/mock/mockGovernorBlock.deploy.js --network flareCoston
// npx hardhat run scripts/mock/mockGovernorBlock.deploy.js --network modeTestnet

const contractName = "MockGovernorBlock";

Expand Down
2 changes: 1 addition & 1 deletion scripts/mock/mockToken.deploy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// npx hardhat run scripts/mock/mockToken.deploy.js --network polygonMumbai
// npx hardhat run scripts/mock/mockToken.deploy.js --network modeTestnet

const contractName = "MockErc20TokenDecimals";

Expand Down
2 changes: 1 addition & 1 deletion scripts/mock/mockTokenVotingBlock.deploy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// npx hardhat run scripts/mock/mockTokenVotingBlock.deploy.js --network flareCoston
// npx hardhat run scripts/mock/mockTokenVotingBlock.deploy.js --network modeTestnet

const contractName = "MockErc20TokenVotingBlock";

Expand Down
2 changes: 1 addition & 1 deletion scripts/nft/early-stakers/earlyStakerNft.deploy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// npx hardhat run scripts/nft/early-stakers/earlyStakerNft.deploy.js --network songbird
// npx hardhat run scripts/nft/early-stakers/earlyStakerNft.deploy.js --network modeTestnet

const data = require("./claimers.json");
const { StandardMerkleTree } = require("@openzeppelin/merkle-tree");
Expand Down
2 changes: 1 addition & 1 deletion scripts/nft/early-stakers/onlyMetadata.deploy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// npx hardhat run scripts/nft/early-stakers/onlyMetadata.deploy.js --network polygonMumbai
// npx hardhat run scripts/nft/early-stakers/onlyMetadata.deploy.js --network modeTestnet

const contractName = "EarlyStakerMetadata";

Expand Down
2 changes: 1 addition & 1 deletion scripts/other/manager/addManager.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// npx hardhat run scripts/other/manager/addManager.js --network base
// npx hardhat run scripts/other/manager/addManager.js --network modeTestnet

const managerAddress = "";

Expand Down
2 changes: 1 addition & 1 deletion scripts/post/IggyPostNft1155/calls.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// npx hardhat run scripts/post/IggyPostNft1155/calls.js --network songbird
// npx hardhat run scripts/post/IggyPostNft1155/calls.js --network modeTestnet

const postAddress = "0xE33F27496A9cE75313f6d1FA2BA95657Fc904387";
const minterAddress = "0x9e9905FA405A5FC7Ee2DEB94CbAc089B4FE6f0Ef";
Expand Down
2 changes: 1 addition & 1 deletion scripts/post/IggyPostNft1155/minterV2.deploy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Deploy minter V2 contract
// npx hardhat run scripts/post/IggyPostNft1155/minterV2.deploy.js --network polygonMumbai
// npx hardhat run scripts/post/IggyPostNft1155/minterV2.deploy.js --network modeTestnet
// It will automatically set different fees (if needed).
// It will also automatically add the minter to the ChatTokenMinter contract and change the minter address in the post contract.
// If any of these actions fail, you must do them manually.
Expand Down
2 changes: 1 addition & 1 deletion scripts/staking/addStakingAddressToPostMinter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// npx hardhat run scripts/staking/addStakingAddressToPostMinter.js --network songbird
// npx hardhat run scripts/staking/addStakingAddressToPostMinter.js --network modeTestnet

const stakingContractAddress = "0xCA9749778327CD67700d3a777731a712330beB9A"; // staking contract address
const postMinterAddress = "0xeC5Af9F794B9f26bB62Cd951088445c95EAF428D"; // post minter contract address
Expand Down
2 changes: 1 addition & 1 deletion scripts/staking/iggyStakingRewards.deploy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// npx hardhat run scripts/staking/iggyStakingRewards.deploy.js --network polygonMumbai
// npx hardhat run scripts/staking/iggyStakingRewards.deploy.js --network modeTestnet
const contractName = "IggyStakingRewards";

const assetAddress = "0xF874f79eBfB8FEe898a289C4cAa5dc4383873431"; // token to stake
Expand Down
2 changes: 1 addition & 1 deletion scripts/stats/calls.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// npx hardhat run scripts/stats/calls.js --network zkfair
// npx hardhat run scripts/stats/calls.js --network modeTestnet

const statsMiddlewareAddress = "0x3Fa0EaC3058828Cc4BA97F51A33597C695bF6F9e";

Expand Down
2 changes: 1 addition & 1 deletion scripts/swap/IggySwapRouter.deploy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// npx hardhat run scripts/swap/IggySwapRouter.deploy.js --network taikoJolnir
// npx hardhat run scripts/swap/IggySwapRouter.deploy.js --network modeTestnet

const contractName = "IggySwapRouter";

Expand Down
2 changes: 1 addition & 1 deletion scripts/swap/IggySwapRouterSolidly.deploy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// npx hardhat run scripts/swap/IggySwapRouterSolidly.deploy.js --network base
// npx hardhat run scripts/swap/IggySwapRouterSolidly.deploy.js --network modeTestnet

const contractName = "IggySwapRouterSolidly";

Expand Down
2 changes: 1 addition & 1 deletion scripts/token/ChatToken/chatToken.deploy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// npx hardhat run scripts/token/ChatToken/chatToken.deploy.js --network songbird
// npx hardhat run scripts/token/ChatToken/chatToken.deploy.js --network modeTestnet

const contractName = "ChatToken";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// npx hardhat run scripts/token/ChatTokenClaimActivityPoints/chatTokenClaimActivityPoints.deploy.js --network polygonMumbai
// npx hardhat run scripts/token/ChatTokenClaimActivityPoints/chatTokenClaimActivityPoints.deploy.js --network modeTestnet
// This script deploys the ChatTokenClaimActivityPoints contract and sets it as a minter in the ChatTokenMinter contract.
// If setting the minter address fails, do it manually by calling the addMinter function in the ChatTokenMinter contract.

Expand Down
Loading

0 comments on commit cff4f2a

Please sign in to comment.