Inspiration
Build a new protocol that allows you to wrap DBRO tokens into our exclusive NFT's that give the holders access to the utilities.
What it does
The holder can stake their DBRO earn a certain value of DBRO once they do they can claim rewards which will trigger a wrap function on the contract to mint and wrap the rewards earned to the NFT. The user can unwrap the tokens from the NFT at anytime and trade them on the open market. If they user has the amount in tokens already they can just manually wrap & mint the NFT and unwrap it at anytime. They can sell the NFT on the open market with the tokens attacked giving the NFT the value of the token trading on the open market. We use the NFT for token gating to our utilities we are actively building for or DBRO holders.
How I built it
We built this by using hardhat, setting up a staking contract that links to an ERC1155 contract & that links to the wrap protocol contract, once the contracts are deployed the abi gets passed to the frontend then we used that to build out the frontend staking page.
Challenges I ran into
Trying to figure out how to manage the claim rewards, how many can be claimed in one batch, fees for unwrapping, figuring out how to manage the taxes with wrap fees on the token, adding manual wrap without staking using a threshold as a value, reading data of the total wrapped DBRO and total wrapped NFTs per user.
Accomplishments that I'm proud of
The site and new protocol has been tested for almost 2 months on the Base test net and we have finally have the finished product that we will be bringing to main net here soon.
What I learned
Learned about this new protocol so that we can keep building and expanding.
Wrap interface Code
interface IDRYFT {
function wrapByProxy(uint256 tokenId_, uint256 quantity_, address recipient_) external; // This is doing a transfer
function unwrapByProxy(uint256 tokenId_, uint256 quantity_, address recipient_) external; // For unwrapping the tokens from the NFT
function setApprovalForAll(address operator, bool approved) external; // Added function to set approval for all
function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes memory data) external; // Added function to transfer from
}
## Claim DBRO rewards and wrap into NFTs
function claimReward() external nonReentrant {
StakeInfo storage stakeInfo = stakes[msg.sender];
uint256 pendingRewards = calculatePendingRewards(msg.sender);
if (pendingRewards < REQUIRED_DBRO) revert NoRewardsToClaim();
uint256 wrapAmount = (pendingRewards / REQUIRED_DBRO) * REQUIRED_DBRO;
uint256 quantity = wrapAmount / REQUIRED_DBRO;
// Limit claimable NFTs to maxClaimableQuantity
if (quantity > maxClaimableQuantity) {
quantity = maxClaimableQuantity;
wrapAmount = quantity * REQUIRED_DBRO;
}
if (!dbroToken.transferFrom(rewardsWallet, address(this), wrapAmount)) revert TransferFailed();
dbroToken.approve(address(ryftContract), wrapAmount);
ryftContract.wrapByProxy(RYFT_TOKEN_ID, quantity, msg.sender);
stakeInfo.rewardDebt += wrapAmount;
emit ClaimedRewards(msg.sender, wrapAmount);
}
Built With
- hardhat
- node.js
- rainbow
- react
- tailwind
- typescript
- vite
- wagmi
Log in or sign up for Devpost to join the conversation.