withdraw function updated

This commit is contained in:
CodeNinja04 2022-03-09 09:33:27 +05:30
parent d0a5b5f0dc
commit bfa4b49a10
2 changed files with 21 additions and 28 deletions

View File

@ -13,8 +13,8 @@ contract Events {
event LogSupplyItoken( event LogSupplyItoken(
address indexed token_, address indexed token_,
address indexed itoken_,
uint256 amount_, uint256 amount_,
address itoken_,
uint256 itokenAmount_, uint256 itokenAmount_,
uint256 getId, uint256 getId,
uint256 setId uint256 setId
@ -23,6 +23,7 @@ contract Events {
event LogWithdraw( event LogWithdraw(
address indexed token_, address indexed token_,
uint256 amt_, uint256 amt_,
address itoken_,
uint256 itokenAmount_, uint256 itokenAmount_,
uint256 getId, uint256 getId,
uint256 setId uint256 setId
@ -30,9 +31,9 @@ contract Events {
event LogWithdrawItoken( event LogWithdrawItoken(
address indexed token, address indexed token,
address indexed itoken_,
uint256 amt_, uint256 amt_,
uint256 amount_, address itoken_,
uint256 itokenAmount_,
uint256 getId, uint256 getId,
uint256 setId uint256 setId
); );

View File

@ -26,7 +26,7 @@ abstract contract FluidityResolver is Events, Helpers {
uint256 setId uint256 setId
) public returns (string memory _eventName, bytes memory _eventParam) { ) public returns (string memory _eventName, bytes memory _eventParam) {
uint256 amt_ = getUint(getId, amt); uint256 amt_ = getUint(getId, amt);
address itoken_ = protocolModule.tokenToItoken(token_);
TokenInterface tokenContract = TokenInterface(token_); TokenInterface tokenContract = TokenInterface(token_);
amt_ = amt_ == type(uint256).max amt_ = amt_ == type(uint256).max
? tokenContract.balanceOf(address(this)) ? tokenContract.balanceOf(address(this))
@ -37,10 +37,11 @@ abstract contract FluidityResolver is Events, Helpers {
setUint(setId, amt_); setUint(setId, amt_);
_eventName = "LogSupply(address,uint256,uint256,uint256,uint256)"; _eventName = "LogSupply(address,uint256,address,uint256,uint256,uint256)";
_eventParam = abi.encode( _eventParam = abi.encode(
token_, token_,
amt_, amt_,
itoken_,
itokenAmount_, itokenAmount_,
getId, getId,
setId setId
@ -51,7 +52,7 @@ abstract contract FluidityResolver is Events, Helpers {
* @dev * @dev
* @notice * @notice
* @param token_ Token Address. * @param token_ Token Address.
* @param amtount Token Amount. * @param amount_ Token Amount.
* @param getId ID to retrieve amt * @param getId ID to retrieve amt
* @param setId ID stores the amount of tokens withdrawn * @param setId ID stores the amount of tokens withdrawn
*/ */
@ -61,19 +62,17 @@ abstract contract FluidityResolver is Events, Helpers {
uint256 getId, uint256 getId,
uint256 setId uint256 setId
) public returns (string memory _eventName, bytes memory _eventParam) { ) public returns (string memory _eventName, bytes memory _eventParam) {
uint256 amt = getUint(getId, amount_); uint256 amt_ = getUint(getId, amount_);
uint256 itokenAmount_; uint256 itokenAmount_;
address itoken_ = protocolModule.tokenToItoken(token_);
if (amt == type(uint256).max) { if (amt_ == type(uint256).max) {
address itoken_ = protocolModule.tokenToItoken(token_);
TokenInterface tokenContract = TokenInterface(itoken_); TokenInterface tokenContract = TokenInterface(itoken_);
itokenAmount_ = tokenContract.balanceOf(address(this)); itokenAmount_ = tokenContract.balanceOf(address(this));
amt_ = protocolModule.withdrawItoken(token_, itokenAmount_); amt_ = protocolModule.withdrawItoken(token_, itokenAmount_);
} else { } else {
itokenAmount_ = protocolModule.withdraw(token_, amt); itokenAmount_ = protocolModule.withdraw(token_, amt_);
} }
setUint(setId, amt_); setUint(setId, amt_);
@ -108,12 +107,7 @@ abstract contract FluidityResolver is Events, Helpers {
} }
_eventName = "LogClaimReward(address,address,uint256[],uint256[])"; _eventName = "LogClaimReward(address,address,uint256[],uint256[])";
_eventParam = abi.encode( _eventParam = abi.encode(user_, token_, updatedRewards_, setId);
user_,
token_,
updatedRewards_,
setId
);
} }
/** /**
@ -132,7 +126,7 @@ abstract contract FluidityResolver is Events, Helpers {
uint256 setId uint256 setId
) public returns (string memory _eventName, bytes memory _eventParam) { ) public returns (string memory _eventName, bytes memory _eventParam) {
uint256 amt_ = getUint(getId, amt); uint256 amt_ = getUint(getId, amt);
address itoken_ = protocolModule.tokenToItoken(token_);
TokenInterface tokenContract = TokenInterface(token_); TokenInterface tokenContract = TokenInterface(token_);
amt_ = amt_ == type(uint256).max amt_ = amt_ == type(uint256).max
? tokenContract.balanceOf(address(this)) ? tokenContract.balanceOf(address(this))
@ -143,11 +137,11 @@ abstract contract FluidityResolver is Events, Helpers {
setUint(setId, itokenAmount_); setUint(setId, itokenAmount_);
_eventName = "LogSupplyItoken(address,address,uint256,uint256,uint256,uint256)"; _eventName = "LogSupplyItoken(address,uint256,address,uint256,uint256,uint256)";
_eventParam = abi.encode( _eventParam = abi.encode(
token_, token_,
itoken_,
amt_, amt_,
itoken_,
itokenAmount_, itokenAmount_,
getId, getId,
setId setId
@ -158,7 +152,7 @@ abstract contract FluidityResolver is Events, Helpers {
* @dev * @dev
* @notice * @notice
* @param token_ Token Address. * @param token_ Token Address.
* @param amtount Token Amount. * @param amount_ Token Amount.
* @param getId ID to retrieve amt * @param getId ID to retrieve amt
* @param setId ID stores the amount of itokens * @param setId ID stores the amount of itokens
*/ */
@ -171,10 +165,8 @@ abstract contract FluidityResolver is Events, Helpers {
) public returns (string memory _eventName, bytes memory _eventParam) { ) public returns (string memory _eventName, bytes memory _eventParam) {
uint256 amt_ = getUint(getId, amount_); uint256 amt_ = getUint(getId, amount_);
uint256 itokenAmount_; uint256 itokenAmount_;
address itoken_ = protocolModule.tokenToItoken(token_);
if (amt_ == type(uint256).max) { if (amt_ == type(uint256).max) {
address itoken_ = protocolModule.tokenToItoken(token_);
TokenInterface tokenContract = TokenInterface(itoken_); TokenInterface tokenContract = TokenInterface(itoken_);
itokenAmount_ = tokenContract.balanceOf(address(this)); itokenAmount_ = tokenContract.balanceOf(address(this));
@ -186,11 +178,11 @@ abstract contract FluidityResolver is Events, Helpers {
setUint(setId, itokenAmount_); setUint(setId, itokenAmount_);
_eventName = "LogWithdrawItoken(address,address,uint256,uint256,uint256,uint256)"; _eventName = "LogWithdrawItoken(address,uint256,address,uint256,uint256,uint256)";
_eventParam = abi.encode( _eventParam = abi.encode(
token, token_,
itoken_,
amt_, amt_,
itoken_,
itokenAmount_, itokenAmount_,
getId, getId,
setId setId