hats-finance / Convergence-Finance---IBO-0x0e410e7af8e70fc5bffcdbfbdf1673ee7b3d0777

IBO, Vesting & Bond mecanism repo prepared for Hat finance audit competition
0 stars 0 forks source link

Lack of a logic to `reset` the vesting term of an existing bonding position #65

Open hats-bug-reporter[bot] opened 1 year ago

hats-bug-reporter[bot] commented 1 year ago

Github username: @@0xmuxyz Submission hash (on-chain): 0xee0c47fe9a46f61b12cbf11ad4d3348634f24ac26c92e46aa37cb44f5a6c4d6d Severity: medium

Description: Title:\ Lack of a logic to reset the vesting term of an existing bonding position

Severity:\ Medium

Description:\ The ibo#deposit() can be called by both a new user and an existing IBO NFT holder (of the bond):

Ibo.sol#L142-L220

    /**
     *  @notice deposit into a bond to get an NFT with an underlaying value of CVG
     *  @param tokenId uint256
     *  @param bondId uint256
     *  @param amountIn uint256
     *  @param amountOutMin uint256
     *  @param privilegeType uint256
     *  @param _merkleProof bytes32[]
     */
    function deposit(
        uint256 tokenId, 
        uint256 bondId,  
        uint256 amountIn,
        uint256 amountOutMin,
        uint256 privilegeType,
        bytes32[] calldata _merkleProof
    ) external {
         ...

According to the "Tokenized bonds" in the documentation, the vesting term of the existing position is supposed to be reset when an existing IBO NFT holder try to deposit their assets iteratively like this:

Users may iterate on an existing bonding position or create a new one at any time. However, iterating on an existing position (increase the amount of bonded asset and thus increase the amount of CVG that can be redeemed) will reset the vesting term.

However, within the ibo#deposit() above, there is no logic to reset a vesting term of an existing position when awhen an existing IBO NFT holder call the ibo#deposit() to increase the amount of bonded-asset.

This lead to unintended-behavior of this protocol that a vesting term of an existing bonding position would not be reset when an existing IBO NFT holder call the ibo#deposit() to increase the amount of bonded-asset.

Recommendation:\ Within the ibo#deposit(), consider a logic to reset a vesting term of an existing position when an existing IBO NFT holder deposit the amount of asset to increase the amount of bonded-asset like this:

walk-on-me commented 1 year ago

Hello, Thanks a lot for your attention.

It's more a lack of documentation on the IBO level. This kind of vesting that'll reset will be used in the bonds we'll deploy with the full protocol. For the IBO, the vesting will start at the same time for everyone Also, the vesting of the IBO will start after the end of the IBO, so no collisions are possible.

We have so to consider this issue as Invalid