Minor changes

This commit is contained in:
Thrilok Kumar 2021-06-10 23:27:27 +05:30
parent 7e6b83e5fe
commit f2d163c8ae
3 changed files with 42 additions and 29 deletions

View File

@ -10,12 +10,14 @@ contract Events {
uint setId uint setId
); );
event LogWithdraw( event LogWithdrawAndClaimedReward(
address indexed stakingToken, address indexed stakingToken,
bytes32 indexed stakingType, bytes32 indexed stakingType,
uint256 amount, uint256 amount,
uint256 rewardAmt,
uint getId, uint getId,
uint setId uint setIdAmount,
uint setIdReward
); );
event LogClaimedReward( event LogClaimedReward(

View File

@ -1,6 +1,11 @@
pragma solidity ^0.7.0; pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2; pragma experimental ABIEncoderV2;
/**
* @title Token Staking.
* @dev Stake ERC20 for earning rewards.
*/
import { TokenInterface } from "../../common/interfaces.sol"; import { TokenInterface } from "../../common/interfaces.sol";
import { Stores } from "../../common/stores.sol"; import { Stores } from "../../common/stores.sol";
@ -11,18 +16,19 @@ import { IStakingRewards, SynthetixMapping } from "./interface.sol";
contract Main { contract Main {
/** /**
* @dev Deposit Token. * @dev Deposit ERC20.
* @param stakingPoolName staking token address. * @notice Deposit Tokens to staking pool.
* @param stakingPoolName staking pool name.
* @param amt staking token amount. * @param amt staking token amount.
* @param getId Get token amount at this ID from `InstaMemory` Contract. * @param getId ID to retrieve amount.
* @param setId Set token amount at this ID in `InstaMemory` Contract. * @param setId ID stores the amount of staked tokens.
*/ */
function deposit( function deposit(
string calldata stakingPoolName, string calldata stakingPoolName,
uint amt, uint amt,
uint getId, uint getId,
uint setId uint setId
) external payable { ) external payable returns (string memory _eventName, bytes memory _eventParam) {
uint _amt = getUint(getId, amt); uint _amt = getUint(getId, amt);
( (
IStakingRewards stakingContract, IStakingRewards stakingContract,
@ -37,16 +43,18 @@ contract Main {
stakingContract.stake(_amt); stakingContract.stake(_amt);
setUint(setId, _amt); setUint(setId, _amt);
emit LogDeposit(address(stakingToken), stakingType, _amt, getId, setId); _eventName = "LogDeposit(address,bytes32,uint256,uint256,uint256)";
_eventParam = abi.encode(address(stakingToken), stakingType, _amt, getId, setId);
} }
/** /**
* @dev Withdraw Token. * @dev Withdraw ERC20.
* @param stakingPoolName staking token address. * @notice Withdraw Tokens from the staking pool.
* @param stakingPoolName staking pool name.
* @param amt staking token amount. * @param amt staking token amount.
* @param getId Get token amount at this ID from `InstaMemory` Contract. * @param getId ID to retrieve amount.
* @param setIdAmount Set token amount at this ID in `InstaMemory` Contract. * @param setIdAmount ID stores the amount of stake tokens withdrawn.
* @param setIdReward Set reward amount at this ID in `InstaMemory` Contract. * @param setIdReward ID stores the amount of reward tokens claimed.
*/ */
function withdraw( function withdraw(
string calldata stakingPoolName, string calldata stakingPoolName,
@ -54,7 +62,7 @@ contract Main {
uint getId, uint getId,
uint setIdAmount, uint setIdAmount,
uint setIdReward uint setIdReward
) external payable { ) external payable returns (string memory _eventName, bytes memory _eventParam) {
uint _amt = getUint(getId, amt); uint _amt = getUint(getId, amt);
( (
IStakingRewards stakingContract, IStakingRewards stakingContract,
@ -74,20 +82,20 @@ contract Main {
setUint(setIdAmount, _amt); setUint(setIdAmount, _amt);
setUint(setIdReward, rewardAmt); setUint(setIdReward, rewardAmt);
emit LogWithdraw(address(stakingToken), stakingType, _amt, getId, setIdAmount); _eventName = "LogWithdrawAndClaimedReward(address,bytes32,uint256,uint256,uint256,uint256,uint256)";
_eventParam = abi.encode(address(stakingToken), stakingType, _amt, rewardAmt, getId, setIdAmount, setIdReward);
emit LogClaimedReward(address(rewardToken), stakingType, rewardAmt, setIdReward);
} }
/** /**
* @dev Claim Reward. * @dev Claim Reward.
* @param stakingPoolName staking token address. * @notice Claim Pending Rewards of tokens staked.
* @param setId Set reward amount at this ID in `InstaMemory` Contract. * @param stakingPoolName staking pool name.
* @param setId ID stores the amount of reward tokens claimed.
*/ */
function claimReward( function claimReward(
string calldata stakingPoolName, string calldata stakingPoolName,
uint setId uint setId
) external payable { ) external payable returns (string memory _eventName, bytes memory _eventParam) {
( (
IStakingRewards stakingContract, IStakingRewards stakingContract,
, ,
@ -102,7 +110,12 @@ contract Main {
uint rewardAmt = sub(finalBal, intialBal); uint rewardAmt = sub(finalBal, intialBal);
setUint(setId, rewardAmt); setUint(setId, rewardAmt);
emit LogClaimedReward(address(rewardToken), stakingType, rewardAmt, setId); _eventName = "LogClaimedReward(address,bytes32,uint256,uint256)";
_eventParam = abi.encode(address(rewardToken), stakingType, rewardAmt, setId);
} }
} }
contract connectV2StakeERC20 is main {
string public constant name = "Stake-ERC20-v1.0";
}

View File

@ -1,8 +1,8 @@
pragma solidity ^0.7.0; pragma solidity ^0.7.0;
/** /**
* @title Uniswap V3 ERC20 Wrapper. * @title G-Uniswap V3 ERC20 Wrapper.
* @dev Uniswap V3 Wrapper to deposit and withdraw. * @dev G-Uniswap V3 Wrapper to deposit and withdraw.
*/ */
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
@ -22,7 +22,7 @@ abstract contract UniswapV3Resolver is Events, Helpers {
* @param amt0Max Amount0 Max amount * @param amt0Max Amount0 Max amount
* @param amt1Max Amount1 Max amount * @param amt1Max Amount1 Max amount
* @param slippage use to calculate minimum deposit. 100% = 1e18 * @param slippage use to calculate minimum deposit. 100% = 1e18
* @param getId ID to retrieve amount. * @param getIds Array of IDs to retrieve amounts.
* @param setId ID stores the amount of pools tokens received. * @param setId ID stores the amount of pools tokens received.
*/ */
function deposit( function deposit(
@ -79,7 +79,7 @@ abstract contract UniswapV3Resolver is Events, Helpers {
* @param minAmtA Min AmountA amount * @param minAmtA Min AmountA amount
* @param minAmtB Min AmountB amount * @param minAmtB Min AmountB amount
* @param getId ID to retrieve liqAmt. * @param getId ID to retrieve liqAmt.
* @param setId ID stores the amount of pools tokens received. * @param setIds Array of IDs tp stores the amounts of pools tokens received.
*/ */
function withdraw( function withdraw(
address pool, address pool,
@ -197,8 +197,6 @@ abstract contract UniswapV3Resolver is Events, Helpers {
} }
contract ConnectV2UniswapV3ERC20 is UniswapV3Resolver { contract ConnectV2GUniswapV3ERC20 is UniswapV3Resolver {
string public constant name = "GUniswap-v3-ERC20-v1.0";
string public constant name = "Uniswap-v3-ERC20";
} }