mirror of
https://github.com/Instadapp/dsa-connectors-old.git
synced 2024-07-29 22:47:46 +00:00
adding withdraw and getReward;
This commit is contained in:
parent
c22ffbf20d
commit
785a91b758
|
@ -8,6 +8,8 @@ import { TokenInterface } from "../common/interfaces.sol";
|
|||
interface IStakingRewards {
|
||||
function stake(uint256 amount) external;
|
||||
function exit() external;
|
||||
function withdraw(uint256 amount) external;
|
||||
function getReward() external;
|
||||
}
|
||||
|
||||
contract Helper is Stores {
|
||||
|
@ -29,10 +31,13 @@ contract SynthetixStakingRewardsProtocol is Helper {
|
|||
// Events
|
||||
event LogStake(
|
||||
address stakeAddr,
|
||||
uint256 stakeAmt
|
||||
uint256 stakeAmt,
|
||||
uint getId
|
||||
);
|
||||
event LogExit(
|
||||
address stakeAddr
|
||||
address stakeAddr,
|
||||
uint256 stakeAmt,
|
||||
uint getId
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -54,25 +59,37 @@ contract SynthetixStakingRewardsProtocol is Helper {
|
|||
|
||||
rewardPool.stake(_stakeAmt);
|
||||
|
||||
emit LogStake(address(this), _stakeAmt);
|
||||
bytes32 _eventCode = keccak256("LogStake(address,uint256)");
|
||||
bytes memory _eventParam = abi.encode(stakeAddr, _stakeAmt);
|
||||
emit LogStake(stakeAddr, _stakeAmt, getId);
|
||||
bytes32 _eventCode = keccak256("LogStake(address,uint256, uint256)");
|
||||
bytes memory _eventParam = abi.encode(stakeAddr, _stakeAmt, getId);
|
||||
emitEvent(_eventCode, _eventParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Exit Token.
|
||||
* @param stakeAddr staking token address.
|
||||
* @param stakeAmt staking token amount.
|
||||
* @param getId Get token amount at this ID from `InstaMemory` Contract.
|
||||
*/
|
||||
function exit(
|
||||
address stakeAddr
|
||||
address stakeAddr,
|
||||
uint stakeAmt,
|
||||
uint getId
|
||||
) external {
|
||||
uint _stakeAmt = getUint(getId, stakeAmt);
|
||||
IStakingRewards rewardPool = IStakingRewards(getSynthetixStakingAddr(stakeAddr));
|
||||
|
||||
rewardPool.exit();
|
||||
if(_stakeAmt == uint(-1)){
|
||||
rewardPool.exit();
|
||||
}
|
||||
else{
|
||||
rewardPool.withdraw(_stakeAmt);
|
||||
rewardPool.getReward();
|
||||
}
|
||||
|
||||
emit LogExit(stakeAddr);
|
||||
bytes32 _eventCode = keccak256("LogExit(address)");
|
||||
bytes memory _eventParam = abi.encode(stakeAddr);
|
||||
emit LogExit(stakeAddr, _stakeAmt, getId);
|
||||
bytes32 _eventCode = keccak256("LogExit(address, uint256, uint256)");
|
||||
bytes memory _eventParam = abi.encode(stakeAddr, _stakeAmt, getId);
|
||||
emitEvent(_eventCode, _eventParam);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user