🄷
Samurai Protocol
  • DISCLAIMER
  • Samurai Financial
  • 1. What is Samurai and how does it work ?
    • 1.1 - What is Samurai?
    • 1.2 - What is the total supply of HNR tokens ?
    • 1.3 - Now, how does it actually work ?
    • 1.4 - How does Samurai differ from RING?
    • 1.5 - Why is SAMURAI on the Fantom (FTM) ?
    • 1.6 - Is Metamask the only wallet compatible for now ? What about TrustWallet ?
    • 1.7 - Do I need to install a VPS?
    • 1.8 - Do I need to keep my computer running ?
    • 1.9 - Where can I see the size of the liquidity pool ?
    • 1.10 - Smart Contract Functionality
  • 2. Understanding the NODES
    • 2.1 How does the Lottery system work?
    • 2.2 How does sliding tax work?
    • 2.3 - How much does a node cost ?
    • 2.4 - Can nodes be transferred from one wallet to another ?
    • 2.5 - Are these real nodes ?
    • 2.6 - Why do you call these "nodes" ?
    • 2.7 - I don’t see my rewards every 4 or 8 hours. Is there a problem ?
    • 2.8 - What happens if I don't claim my rewards every time ?
  • Tokenomics
  • Governance
  • Samurai AI
  • Vaults
  • MultiChain ZenGarden
  • Levels
  • Sambot
  • ZenEstate
  • Governance Proposals
    • Samurai Governance
    • Initiate and adopt protocol level governance
    • SIP-1: Adopt and enforce an incentivised LP staking mechanism - Zen Garden
  • [EXTENSION] SIP-1: Adopt and enforce an incentivised LP staking mechanism - Zen Garden
  • SIP-2: Implement a Samurai native OTC NFT solution
  • [EXTENSION] SIP-2: Implement a Samurai native OTC NFT solution
  • SIP-3: Implement, adopt and enforce Samurai Vaults
  • SIP-4: Implement, adopt and enforce Samurai Multichain ZenGarden
  • SIP-5: Implement, adopt and enforce Samurai Levels
  • SIP-6: Replenish Samurai Levels rewards
  • SIP-7: Conduct an OTC NFT acquisition event
  • SIP-8: Retroactive funding
  • SIP-9: Expand MultiChain ZenGarden
  • SIP-10: Conduct an OTC NFT distribution event
  • SIP-11: Temporarily pause Samurai Levels
  • SIP-12: Replenish Samurai Node NFT's rewards
  • SIP-13: Levels v2 Product feature set Ideation
  • SIP-14: Deploy and fund Samurai Governance Vault
  • SIP-15: Implement, adopt and enforce Samurai Levels v2
  • SIP-16: Conduct ā€˜Settlement & Release’ initiative
  • SIP-17: Expand ā€˜Settlement & Release’ initiative
  • SIP-18: Implement, adopt and enforce an update to Samurai Node NFT RPC Endpoints
  • SIP-19: Implement, adopt and enforce Samurai Chat
  • SIP-20: Refine Samurai Levels Parameters and Conditions
  • SIP-21: Retroactive funding 2.0
  • SIP-22: Conduct an OTC NFT acquisition event
  • SIP-23: Conduct an OTC NFT distribution event
  • SIP-24: Enact a Samurai Governance Vault Conversion
  • SIP-25: Refine Samurai Chat Parameters
  • SIP-26: Replenish Samurai Levels v2 rewards
  • Articles / Announcements
    • Samurai is here!
    • Honour
    • News, updates, migration and plans for Honour
    • Clearing the air and moving onwards
    • The path towards sustainability
Powered by GitBook
On this page
  • Motivation
  • Specification
  • The proposed Solidity code / smart contracts

SIP-5: Implement, adopt and enforce Samurai Levels

Motivation

This proposal suggests for the protocol to adopt and enforce a set of smart contracts (specified below) that enable, facilitate and provide access to a proposed feature of the Samurai protocol, called ā€œSamurai Levelsā€

The ā€œSamurai Levelsā€ feature would be enabled by the protocol adopting a set of smart contracts focusing on the facilitation and provision of a gamified education/learning experience, exclusively to Samurai Node NFT holders.

Samurai Levels, with the use of the proposed set of smart contracts, would aim to provide an incentivised way of building habits and encourage individuals to learn and establish a deeper understanding of web3-related concepts and knowledge, through gamification of the learning experience and the Samurai protocol.

The implementation of this proposal shall further bolster the utility of the Samurai Node NFTs but also educate and explain fundamental concepts from the web3 industry, in a meaningful and gamified manner with the use of features and tech at the disposal of the Samurai protocol.

ā€œSamurai Levelsā€ would represent a Samurai Node NFT holder exclusive feature that gamifies, incentivises and rewards accurate understanding and knowledge of web3-related concepts with xHNR governance tokens.

3 000 000 xHNR governance tokens shall be minted for the purposes of facilitating the proposed Samurai Levels feature.

Specification

Samurai Levels is a smart contract aimed at providing an incentivised way of building habits and encouraging learning along the way. The core feature of this smart contract is available only to Samurai Node NFT holders. Hence, to participate, users must own at least one NFT.

The contract keeps track of two primary objectives for each wallet: Experience and Streaks.

When a user completes the daily questions on levels.samurai.financial, the levelUp function will become immediately available. Depending on the number of questions which the user answered correctly, the reward rate and experience will be calculated based on the number of correct answers and the current streak.

How to earn the streak multiplier?

Each user can earn the streak multiplier, by participating in the daily learning objectives once in every 24 hours cycle. Each user technically starts with a multiplier of 0. By completing your first 20 questions, you will initialise your wallet with multiplier 1. If the next task is completed between the following range of time:

24 hours since last completion < current time < 48 hours since last completion

Then the user’s streak will increase by 1 until the streak cap of 20 is reached. The streak of 20 can be maintained by completing questions daily until the streak is broken by the boundary limits stated above.

How are rewards and experience calculated?

The reward is calculated using the following formula:

Reward = Reward Rate * Number of Correct Answers * (Current Streak / 2)

The experience is calculated using the following formula:

Experience = Number of Correct Answers * 50 * Current Streak

The proposed Solidity code / smart contracts

SamuraiLevels.sol

// SPDX-License-Identifier: MIT pragma solidity 0.8.13;

import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/interfaces/IERC721.sol"; import "@openzeppelin/contracts/interfaces/IERC20.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/security/Pausable.sol";

contract SamuraiLevels is Ownable, Pausable, ReentrancyGuard { struct UserInfo { uint256 experience; uint256 lastClaimed; uint256 streak; } mapping(address => UserInfo) public users; uint256 public rewardRate; uint256 public streakCap;

IERC20 public xhnr; IERC721 public hnrNodes;

using SafeMath for uint256;

constructor( address _xhnr, address _hnrNodes, uint256 _rewardRate, uint256 _streakCap ) { xhnr = IERC20(_xhnr); hnrNodes = IERC721(_hnrNodes); rewardRate = _rewardRate; streakCap = _streakCap; }

function levelUp(uint256 _data) external whenNotPaused nonReentrant { require(_data <= 20, "Contract: too many questions!");

address sender = msg.sender;
require(hnrNodes.balanceOf(sender) >= 1, "Contract: not a holder!");

UserInfo storage user = users[sender];

uint256 blockTimeNow = block.timestamp;
uint256 oneDay = 24 * 60 * 60;
uint256 twoDays = oneDay * 2;
uint256 timeDiff = blockTimeNow - user.lastClaimed;

require(timeDiff >= oneDay, "Contract: not refreshed yet!");

if (user.streak == 0) {
  user.streak = 1;
} else {
  if (timeDiff <= twoDays && (user.streak + 1 <= streakCap)) {
    user.streak += 1;
  } else if (timeDiff > twoDays && user.streak > 1) {
    user.streak = 1;
  }
}

// 50 is the xp gain rate
uint256 newXp = _data * 50 * user.streak;
// multiply before divide
uint256 reward = (rewardRate * _data * user.streak) / 2;

user.experience += newXp;
user.lastClaimed = blockTimeNow;

xhnr.transfer(sender, reward);

}

function getUserInfo() external view returns ( uint256, uint256, uint256 ) { UserInfo memory user = users[msg.sender]; return (user.experience, user.lastClaimed, user.streak); }

function setRewardRate(uint256 _rewardRate) external onlyOwner { rewardRate = _rewardRate; }

function setStreakCap(uint256 _streakCap) external onlyOwner { streakCap = _streakCap; }

function pause(bool en) external onlyOwner { en ? _pause() : _unpause(); } }

PreviousSIP-4: Implement, adopt and enforce Samurai Multichain ZenGardenNextSIP-6: Replenish Samurai Levels rewards

Last updated 2 years ago