hats-finance / Possum-Labs--Portals--0xed8965d49b8aeca763447d56e6da7f4e0506b2d3

GNU General Public License v2.0
0 stars 2 forks source link

Add a minimum threshold that must be met before activating the portal. #32

Open hats-bug-reporter[bot] opened 9 months ago

hats-bug-reporter[bot] commented 9 months ago

Github username: @pavankv241 Twitter username: @PavanKumarKv2 Submission hash (on-chain): 0x5524e6c63e1e561caf9b9c45f0892be269c8b6dc41e4bf50fde8d15e54bbcecd Severity: medium

Description: Description\ Before activate the portol the funding rewards must met the minimum thershold or else it will directly affects the depositer(stakers). In doc this section :- Continuing the above scenario, imagine that time has now passed and there are 100k PSM in the funding pool. The depositor with 5 million bTokens decides to redeem them for 50k PSM, or 50% of the pool total. for example they had taken 100k. What if the funds collected doesn't met minimum to activate portol. In activatePortol() function only checks whether the funding phase ended or not , possum must implement miniMum thershold to avoid the unintenstional acts.

Impact

Before activate the portol the funding rewards must met the minimum thershold or else it will directly affects the depositer(stakers) may they received unintentional returns.

Recommendation

Add minimum thershold check before activate the portol in activatePortal() function

uint256 fundingMinRewards; // set this while deploying.

    function activatePortal() external nonActivePortalCheck {
        /// @dev Require that the funding phase is over
        if(block.timestamp < CREATION_TIME + FUNDING_PHASE_DURATION) {revert FundingPhaseOngoing();}

        if( fundingRewardsCollected < fundingMinRewards){ 
                revert("Needs more fund")
        } //@audit changed here

        /// @dev Calculate the amount of portalEnergy to match the funding amount in the internal liquidity pool
        uint256 requiredPortalEnergyLiquidity = fundingBalance * FUNDING_EXCHANGE_RATIO;

        /// @dev Set the constant product K, which is used in the calculation of the amount of assets in the liquidity pool
        constantProduct = fundingBalance * requiredPortalEnergyLiquidity;

        /// @dev Calculate the maximum rewards to be collected in PSM tokens over time
        fundingMaxRewards = bToken.totalSupply();

        /// @dev Activate the portal  
        isActivePortal = true;

        /// @dev Emit the PortalActivated event with the address of the contract and the funding balance
        emit PortalActivated(address(this), fundingBalance);
    }
PossumLabsCrypto commented 9 months ago

Invalid because it is a feature request not a bug.

The current funding logic works as intended. If we added a minimum funding requirement like suggested, it could lead to permanently stuck funds. If the minimum threshold is not met, the Portal cannot be activated but bToken holders also cannot get their funds back.

To properly implement this feature, an additional function must be implemented that allows funders to withdraw their funding under certain conditions. This is on our roadmap for the next generation of Portals.

pavankv241 commented 9 months ago

Hai @PossumLabsCrypto, I appreciate your words and I'm not pointing that possum must add minimum funds to activate portol . Funds will grow by contributors. In docs they has taken 100k as example what if portol funds have below 1k or 5k as funding. Portol has function called burnBtokens() to burn Btokens to receive PSM only after portol activated bcz it have modifier of activePortalCheck() it means contributor should aware of that once deposited it can only be withdraw after activate. Likely if portol have minimum threshold user won't deposit even dust amount. I would like to mention this lines Each new portal discovered required an initial energy surge to become functional. With a sharp spike in economic power, the Portals began facilitating new and exciting outcomes while rewarding those who helped bring them to life." -Epigraph of the Traveler mentioned in docs. So what if initial funding is not have sufficient funding (PSM tokens). Arbitrageurs only participates if slight changes of prices compares to market , if portol doesn't have enough PSM to generate yield USDC on Aave it won't make proper economic activities. :)

PossumLabsCrypto commented 9 months ago

Sorry but it´s hard to follow your line of argument. Giving some effort in spelling and grammar would help a lot, perhaps run it by GPT first. 🤝 The quoted lines are just fluff text to make the actual documentation content of that page lore friendly so it´s better to not regard it for technical issues.

To clarify, if the Portal launches with a low amount of funding, it will still work as intended but the price in the internal LP will be more volatile. This generally reduces the efficiency of the Portal yet doesn´t make it unusable. We handle this economic concern outside of the code by using PSM from the treasury to ensure a useful funding amount if the public does not engage sufficiently.

pavankv241 commented 9 months ago

Got it. Thanks .