Skip to content

Commit

Permalink
Smart Contract 0.6.9
Browse files Browse the repository at this point in the history
More compile error fixing. Ended up refactoring STEEZFacet.sol for better creator-specific state-management, cleaning up redundancies and shadow declarations. Moved "addLiquidity" to BazaarFacet.sol, which got a quick work, more in the next update.
  • Loading branch information
EdmundBerkmann committed Feb 24, 2024
1 parent dfad179 commit e54a10d
Show file tree
Hide file tree
Showing 8 changed files with 2,655 additions and 583 deletions.
1 change: 1 addition & 0 deletions Package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"express": "^4.18.2",
"express-rate-limit": "^7.1.5",
"firebase-admin": "^12.0.0",
"firebase-tools": "^13.3.1",
"graphql": "^16.8.1",
"helmet": "^7.1.0",
"jsonwebtoken": "^9.0.2",
Expand Down
42 changes: 41 additions & 1 deletion contracts/facets/features/BazaarFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@ pragma solidity ^0.8.10;
import { LibDiamond } from "../../libraries/LibDiamond.sol";
import { IPoolManager } from "../../../lib/Uniswap-v4/src/interfaces/IPoolManager.sol";
import { IBazaarFacet } from "../../interfaces/IFeaturesFacet.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { IERC1155 } from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; // For GBPToken
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; // For GBPToken

contract BazaarFacet {
// State variables for Uniswap interfaces, adjust types and names as per actual interface definitions
IPoolManager uniswap;
IERC20 public gbpt;
IERC20 public STEEL0;

// Event definitions, for example:
event CreatorTokenListed(uint256 indexed tokenId, uint256 initialPrice, uint256 supply, bool isAuction);
event CreatorTokenPurchased(uint256 indexed tokenId, uint256 amount, address buyer);
event BlogPlacementPaid(string content, uint256 amount, address creator);
event CreatorTokenBid(uint256 indexed tokenId, uint256 amount, address bidder);
event LiquidityAdded(uint256 indexed tokenId, uint256 amountToken, uint256 amountSTEEL, uint256 liquidity);

struct Listing {
address seller;
Expand All @@ -26,7 +32,9 @@ contract BazaarFacet {
mapping(uint256 => Listing) public listings;

constructor(address _uniswapAddress) {
uniswap = IPoolManager(_uniswapAddress);
LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();
uniswap = IPoolManager(ds.uniswapAddress);
gbpt = IERC20(ds.gbptAddress);
}

// Initialize BazaarFacet setting the contract owner
Expand All @@ -45,6 +53,13 @@ contract BazaarFacet {
// Direct sale, or listing on UniswapV4 for liquidity pool creation could be handled here
}
emit CreatorTokenListed(tokenId, initialPrice, supply, isAuction);

// Additional logic to create token pool on UniswapV4 with GBPToken
// use marketListing function to store listing details
}

function marketListing(uint256 tokenId) external view returns (Listing memory) {
return listings[tokenId];
}

// Function to bid on CreatorTokens (Steez)
Expand All @@ -61,6 +76,31 @@ contract BazaarFacet {
emit CreatorTokenPurchased(tokenId, amount, msg.sender);
}

function _addLiquidityForToken(uint256 tokenId, uint256 tokenAmount, uint256 steelAmount) internal {
address tokenAddress = steezFacet.convertTokenIdToAddress(tokenId);
IERC20(tokenAddress).approve(address(uniswap), tokenAmount);
IERC20(STEELO).approve(address(uniswap), steelAmount);

(uint amountToken, uint amountSTEEL, uint liquidity) = uniswap.addLiquidity(
tokenAddress,
STEELO,
tokenAmount,
steelAmount,
0, // amountTokenMin: accepting any amount of Token
0, // amountSTEELMin: accepting any amount of STEEL
address(this),
block.timestamp
);

emit LiquidityAdded(tokenId, amountToken, amountSTEEL, liquidity);
}

// Implementation example (adjust according to your logic)
// After the last line of the contract
function _addLiquidity(address uniswapAddress, address tokenAddress, uint256 additionalSteeloAmount, uint256 additionalTokenAmount) internal {
// Your logic here
}

// Function to provide network/taste-based suggestions
// Note: To be developed based on user activity and preferences
function getSuggestions() external view returns (uint256[] memory) {
Expand Down
240 changes: 0 additions & 240 deletions contracts/facets/scripts/contracts/contracts_summary.txt

This file was deleted.

Loading

0 comments on commit e54a10d

Please sign in to comment.