Check out our website and please join our community!
Check out our website and please join our community!
function mintNFT(bytes memory _signature) public payable {
require(mintActive, 'Not active');
require(mintPrice <= msg.value, "Insufficient payable value");
require(totalSupply().add(1).add(partnerMintAmount) <= TOTAL_NFT, "Can't mint more than 10000");
require(whitelist[msg.sender], "Not whitelisted User")
require(!addressMinted[msg.sender], "Address has minted");
_safeMint(msg.sender, totalSupply() + 1);
addressMinted[msg.sender] = true;
}
function mintTokens(uint256 tokenCount_, VoucherParams memory params_) external payable whenNotPaused {
require(tokenCount_ * params_.pricePerToken == msg.value, "Not enough ETH Received");
require(
_verifyVoucher(
abi.encode(
keccak256(
"Voucher(address buyer,uint256 issueTime,uint256 expirationDuration,uint256 pricePerToken,uint256 nonce,string functionABI)"
),
_msgSender(),
params_.issueTime,
params_.expirationDuration,
params_.pricePerToken,
params_.nonce,
keccak256(bytes("mintTokens(uint256,VoucherParams)"))
),
params_,
VOUCHER_SIGNER_ROLE
),
"Verification Failed"
);
for (uint256 i = 1; i <= tokenCount_; i++) {
_safeMint(_msgSender(), _tokenIdCounter.current());
_tokenIdCounter.increment();
}
}
function _verifyVoucher(
bytes memory stuff_,
VoucherParams memory params_,
bytes32 role_
) internal returns (bool) {
require(!_voucherNonces[params_.nonce], "The nonce has been used");
_voucherNonces[params_.nonce] = true;
require(
params_.issueTime <= block.timestamp && block.timestamp <= (params_.issueTime + params_.expirationDuration),
"Not correct time to mint"
);
// Verify Signer
require(hasRole(role_, ECDSA.recover(_hashTypedDataV4(keccak256(stuff_)), params_.signature)), "Not minter roles");
return true;
}
function mint(
MintTrade memory _mintTrade
) external onlyMinter {
uint newTokenID = _tokenIds.current();
Trade storage newTrade = _trades[newTokenID];
newTrade.margin = _mintTrade.margin;
newTrade.leverage = _mintTrade.leverage;
newTrade.asset = _mintTrade.asset;
newTrade.direction = _mintTrade.direction;
newTrade.price = _mintTrade.price;
newTrade.tpPrice = _mintTrade.tp;
newTrade.slPrice = _mintTrade.sl;
newTrade.orderType = _mintTrade.orderType;
newTrade.id = newTokenID;
newTrade.tigAsset = _mintTrade.tigAsset;
_safeMint(_mintTrade.account, newTokenID); // make external call because of safeMint() usage
if (_mintTrade.orderType > 0) { // update the values of some storage functions
_limitOrders[_mintTrade.asset].push(newTokenID);
_limitOrderIndexes[_mintTrade.asset][newTokenID] = _limitOrders[_mintTrade.asset].length-1;
} else {
initId[newTokenID] = accInterestPerOi[_mintTrade.asset][_mintTrade.tigAsset][_mintTrade.direction]*int256(_mintTrade.margin*_mintTrade.leverage/1e18)/1e18;
_openPositions.push(newTokenID);
_openPositionsIndexes[newTokenID] = _openPositions.length-1;
_assetOpenPositions[_mintTrade.asset].push(newTokenID);
_assetOpenPositionsIndexes[_mintTrade.asset][newTokenID] = _assetOpenPositions[_mintTrade.asset].length-1;
}
_tokenIds.increment();
}
function setApprovalForERC20(
IERC20 erc20Contract,
address to,
uint256 amount
) external onlyClubOwner {
erc20Contract.approve(to, amount);
}
/**
* @notice Sets approval for ERC721 tokens.
* @param erc721Contract ERC721 contract address.
* @param to The address of token spender.
* @param approved Boolean flag indicating whether approved or not.
* @dev only the club owner address allowed.
*/
function setApprovalForERC721(
IERC721 erc721Contract,
address to,
bool approved
) external onlyClubOwner {
erc721Contract.setApprovalForAll(to, approved);
}
function createToken(NFTMint calldata nft) external
{
require( _owner = _verifyNFT(nft), "Created NFT is not verified by owner");
uint256 tokenID = tokenCounter;
tokenCounter++;
_mint(nft.issuer, tokenID, nft.totalSupply, ""); // Assign fractional tokens to the issuer
_setTokenURI(
tokenID,
nft.deedNo,
nft.assetID,
nft.issuerID,
nft.projectID
);
details[tokenID].tokenID = tokenID;
details[tokenID].issuer = nft.issuer;
details[tokenID].tokens = nft.totalSupply;
emit CreatedNFT(tokenID, nft.issuer);
}
function _verifyNFT(NFTMint calldata nft)
public
view
returns (address)
{
bytes32 digest = _hashNFT(nft);
return ECDSA.recover(digest, nft.signature);
}
function enterBid(uint _id) external payable {
require(NFT.ownerOf(_id) != address(0x0), "Cannot bid on NFT assigned to the 0x0 address.");
require(msg.value > 0, "Must offer a nonzero amount for bidding.");
Bid memory existingBid = bids[_id];
require(msg.value > existingBid.value, "A higher bid has already been made for this NFT.");
// Refund the existing bid to the original bidder and overwrite with the higher bid.
if (existingBid.value > 0) {
pendingWithdrawals[existingBid.bidder] += existingBid.value;
}
bids[_id] = Bid(msg.sender, msg.value);
}
function acceptBid(uint _id, uint _minPrice) external onlyNFTOwner(_id) {
Bid memory existingBid = bids[_id];
require(existingBid.value > 0, "Cannot accept a 0 bid.");
require(existingBid.value >= _minPrice, "Existing bid is lower than the specified _minPrice.");
NFT.safeTransferFrom(msg.sender, existingBid.bidder, _id);
delete bids[_id];
pendingWithdrawals[msg.sender] += existingBid.value;
}
function withdrawBid(uint _id) external nonReentrant {
require(bids[_id].bidder == msg.sender, "Cannot withdraw a bid not made by the sender.");
uint amount = bids[_id].value;
Address.sendValue(payable(msg.sender), amount);
delete bids[_id];
}
function withdrawPendingFunds() external nonReentrant {
Address.sendValue(payable(msg.sender), pendingWithdrawals[msg.sender]);
delete pendingWithdrawals[msg.sender];
}
function buyItem(
address _nftAddress,
uint256 _tokenId,
address _owner,
uint256 _quantity,
uint256 _pricePerItem
) external {
(, uint256 pricePerItem,) = marketplace.listings(_nftAddress, _tokenId, _owner);
require(pricePerItem == _pricePerItem, "pricePerItem changed!");
uint256 totalPrice = _pricePerItem * _quantity;
IERC20(marketplace.paymentToken()).safeTransferFrom(msg.sender, address(this), totalPrice);
IERC20(marketplace.paymentToken()).safeApprove(address(marketplace), totalPrice);
...
}
function buyItem(
address _nftAddress,
uint256 _tokenId,
address _owner,
uint256 _quantity
)
external
nonReentrant
isListed(_nftAddress, _tokenId, _owner)
validListing(_nftAddress, _tokenId, _owner)
{
require(_msgSender() != _owner, "Cannot buy your own item");
Listing memory listedItem = listings[_nftAddress][_tokenId][_owner];
require(listedItem.quantity >= _quantity, "not enough quantity");
// Transfer NFT to buyer
if (IERC165(_nftAddress).supportsInterface(INTERFACE_ID_ERC721)) {
IERC721(_nftAddress).safeTransferFrom(_owner, _msgSender(), _tokenId);
} else {
IERC1155(_nftAddress).safeTransferFrom(_owner, _msgSender(), _tokenId, _quantity, bytes(""));
}
...
}
function register(uint256 _cidNFTID) external {
if (ERC721(cidNFT).ownerOf(_cidNFTID) != msg.sender)
// We only guarantee that a CID NFT is owned by the user at the time of registration
// ownerOf reverts if non-existing ID is provided
revert NFTNotOwnedByUser(_cidNFTID, msg.sender);
cidNFTs[msg.sender] = _cidNFTID;
emit CIDNFTAdded(msg.sender, _cidNFTID);
}
function withdrawFromGauge(uint256 _NFTId, address[] memory _tokens) public {
uint256 amount = depositReceipt.pooledTokens(_NFTId);
depositReceipt.burn(_NFTId);
gauge.getReward(address(this), _tokens);
gauge.withdraw(amount);
//AMMToken adheres to ERC20 spec meaning it reverts on failure, no need to check return
//slither-disable-next-line unchecked-transfer
AMMToken.transfer(msg.sender, amount);
}
Check out our website and please join our community!