Gravita-Protocol / Gravita-SmartContracts

GNU General Public License v3.0
49 stars 31 forks source link

No fee to borrower while redemption. #311

Closed pavankv241 closed 1 year ago

pavankv241 commented 1 year ago

Affected Smart contracts VesselManagerOperations.sol

Impact No fee to borrower

Severity Low

code snippet:- https://github.com/Gravita-Protocol/Gravita-SmartContracts/blob/main/contracts/VesselManagerOperations.sol#L214-L306

Description :-

According to Documentation Redemptions are always honoured such that 1 GRAI equals $0.97 USD worth of collateral minus the current redemption fee. This means that there is currently a 3% fee in place for redemptions that is paid out to the borrower you are redeeming against

But there is no function to transfer 3% fee to borrower from redeemer .

redeemCollateral() which use redeem collateral to GRAI .

_validateRedemptionRequirements() This function checks redemptionBlockTimestamp > block.timestamp , _debtTokenAmount == 0 and redeemerBalance < _debtTokenAmount .

isValidFirstRedemptionHint() This function checks whether it's first redemption hint .

applyPendingRewards() This function add rewards earned by their stakes.

_redeemCollateralFromVessel() this function calculates debtToken lot of equivalent value in USD , 1 GRAI equals $0.97 USD worth of collateral and update SingleRedemptionValues struct .

updateBaseRateFromRedemption() This function calculates and update decay the base rate from redemption .

getRedemptionFee() This function get's the collateral fee from collateralParams struct

_requireUserAcceptsFee() Which checks feePercentage is less than or equal to maxFeePercentage .

finalizeRedemption() In this function which calls sendAsset() which transfer the assetFee to feeCollector contract .

There is no code to send borrower from redeemer .

Recommedation :- Add code to payout the borrower .

0xfornax commented 1 year ago

We appreciate the submission but the redemption design does not require an explicit transfer to the person who was redeemed. The way it works is that the redeemer will receive the equivalent to 0.97 of collateral for each 1 GRAI. This means that the borrower is left with the remaining 0.03 collateral instead of a GRAI payment.