Skip to content

Instantly share code, notes, and snippets.

View redmont's full-sized avatar
📚
Learning, optimising and securing Smart Contracts

Deepanshu Singh redmont

📚
Learning, optimising and securing Smart Contracts
View GitHub Profile
@redmont
redmont / contracts...Staking...RealStaking.sol
Created November 20, 2024 04:05
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.26+commit.8a97fa7a.js&optimize=false&runs=200&gist=
// ** Todo: **
// Remove _updateCurrentEpoch, not need to update state variable
// In unstaking combine reward + staked amount and transfer in one go
// Add a function to set rewards for next n epochs in 1 txn. (e.g; if we want to set rewards for next 4 weeks)
// When setting rewards for epochs, the contract must have enough equivalent REAL tokens to distribute ? @kristian
// Add view function to get unlock timestamp for a user stake
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
@redmont
redmont / contracts...Staking...RealStaking.sol
Created November 19, 2024 23:26
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.26+commit.8a97fa7a.js&optimize=false&runs=200&gist=
// ** Todo: **
// Remove _updateCurrentEpoch, not need to update state variable
// In unstaking combine reward + staked amount and transfer in one go
// Add a function to set rewards for next n epochs in 1 txn. (e.g; if we want to set rewards for next 4 weeks)
// When setting rewards for epochs, the contract must have enough equivalent REAL tokens to distribute ? @kristian
// Add view function to get unlock timestamp for a user stake
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
@redmont
redmont / contracts...Staking...RealStaking.sol
Created November 19, 2024 22:51
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.26+commit.8a97fa7a.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
//import "hardhat/console.sol";
contract RWGStakingRewards is ReentrancyGuard, Ownable {
@redmont
redmont / contracts...Staking...RealStaking.sol
Created November 18, 2024 20:52
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.26+commit.8a97fa7a.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
//import "hardhat/console.sol";
contract RWGStakingRewards is ReentrancyGuard, Ownable {
IERC20 public immutable STAKING_TOKEN;
@redmont
redmont / contracts...Staking...RealStaking.sol
Created November 18, 2024 20:17
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.26+commit.8a97fa7a.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
//import "hardhat/console.sol";
contract RWGStakingRewards is ReentrancyGuard, Ownable {
IERC20 public immutable STAKING_TOKEN;
@redmont
redmont / contracts...Staking...RWGStaking.sol
Created November 18, 2024 17:12
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.26+commit.8a97fa7a.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "hardhat/console.sol";
contract RWGStakingRewards is ReentrancyGuard, Ownable {
IERC20 public immutable stakingToken;