Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saadSarwar28/41049e4aae232c9df6e5605fa9c7f907 to your computer and use it in GitHub Desktop.
Save saadSarwar28/41049e4aae232c9df6e5605fa9c7f907 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.4+commit.c7e474f2.js&optimize=true&runs=200&gist=
pragma solidity >=0.7.0 <0.9.0;
import "./interfaces/IZombieToken.sol";
// SPDX-License-Identifier: MIT
/**
* @title RugZombieAuthenticator
* @author Saad Sarwar
*/
interface DrFrankenstein {
struct UserInfoDrFrankenstien {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
uint256 tokenWithdrawalDate; // Date user must wait until before early withdrawal fees are lifted.
// User grave info
uint256 rugDeposited; // How many rugged tokens the user deposited.
bool paidUnlockFee; // true if user paid the unlock fee.
uint256 nftRevivalDate; // Date user must wait until before harvesting their nft.
}
function poolLength() external view returns (uint256);
function userInfo(uint tokenId, address userAddress) external view returns (UserInfoDrFrankenstien memory);
}
contract RugZombieAuthenticator{
uint256 public totalCatacombs = 0;
address public burnAddr = 0x000000000000000000000000000000000000dEaD; // Burn address
uint256 public burnAmount; // Burn amount
address public drFrankensteinAddress; // Dr Frankenstein contract address
address public tokenContractAddress; // zombie token contract address
IZombieToken public zombie;
constructor (uint256 _burnAmount, address _drFrankenstein, address _tokenContractAddress) {
burnAmount = _burnAmount;
drFrankensteinAddress = _drFrankenstein;
tokenContractAddress = _tokenContractAddress;
}
// Info of each user.
struct UnlockedCatacombsInfo {
uint256 amount; // How many Zombie tokens the user has provided.
uint256 burnDate; // Date burned.
uint256 catacombId; // id of the catacomb unlocked.
}
mapping (address => UnlockedCatacombsInfo) public unlockedCatacombsInfo;
function getPools (address userAddress) public view returns(uint256) {
uint256 totalAmount = 0;
uint256 poolLength = DrFrankenstein(drFrankensteinAddress).poolLength();
for (uint256 index = 0; index < poolLength; index++) {
DrFrankenstein.UserInfoDrFrankenstien memory usrInfo = DrFrankenstein(drFrankensteinAddress).userInfo(index + 1, userAddress);
totalAmount = totalAmount + usrInfo.amount;
}
return totalAmount;
}
function UnlockCatacombs () public returns (bool){
// just one per wallet
require(unlockedCatacombsInfo[msg.sender].catacombId == 0, "Only one catacomb allowed per address.");
IZombieToken(tokenContractAddress).transferFrom(msg.sender, burnAddr, burnAmount);
unlockedCatacombsInfo[msg.sender] = UnlockedCatacombsInfo(burnAmount, block.timestamp, totalCatacombs + 1);
totalCatacombs = totalCatacombs + 1;
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment