diff --git a/contracts/connectors/synthetix.sol b/contracts/connectors/synthetix.sol index adc3854..4dbdd2f 100644 --- a/contracts/connectors/synthetix.sol +++ b/contracts/connectors/synthetix.sol @@ -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); }