Lend or mint after maturity
The protocol does not forbid lending or minting after the maturity leaving the possibility to profit from early users.\\nLet's take the mint function as an example:\\n```\\n    function mint(\\n        uint8 p,\\n        address u,\\n        uint256 m,\\n        uint256 a\\n    ) external unpaused(u, m, p) returns (bool) {\\n        // Fetch the desired principal token\\n        address principal = IMarketPlace(marketPlace).token(u, m, p);\\n\\n        // Transfer the users principal tokens to the lender contract\\n        Safe.transferFrom(IERC20(principal), msg.sender, address(this), a);\\n\\n        // Mint the tokens received from the user\\n        IERC5095(principalToken(u, m)).authMint(msg.sender, a);\\n\\n        emit Mint(p, u, m, a);\\n\\n        return true;\\n    }\\n```\\n\\nIt is a simple function that accepts the principal token and mints the corresponding ERC5095 tokens in return. There are no restrictions on timing, the user can mint even after the maturity. Malicious actors can take this as an advantage to pump their bags on behalf of legitimate early users.\\nScenario:\\nLegitimate users lend and mint their ERC5095 tokens before maturity.\\nWhen the maturity kicks in, lender tokens are redeemed and holdings are updated.\\nLegitimate users try to redeem their ERC5095 for the underlying tokens. The formula is `(amount * holdings[u][m]) / token.totalSupply();`\\nA malicious actor sandwiches legitimate users, and mints the ERC5095 thus increasing the totalSupply and reducing other user shares. Then redeem principals again and burn their own shares for increased rewards.\\nExample with concrete values:\\nuserA deposits `100` tokens, user B deposits `200` tokens. The total supply minted is `300` ERC5095 tokens.\\nAfter the maturity the redemption happens and now let's say `holdings[u][m]` is `330` (+30).\\nuserA tries to redeem the underlying. The expected amount is: `100` * `330` / `300` = 110. However, this action is frontrunned by userC (malicious) who mints yet another `500` tokens post-maturity. The total supply becomes `800`. The real value userA now receives is: 110 * `330` / `800` = 45.375.\\nAfter that the malicious actor userC invokes the redemption again, and the `holdings[u][m]` is now `330` - 45.375 + `550` = 834.625.\\nuserC redeems the underlying: `500` * 834.625 / 700 ~= 596.16 (expected was 550).\\nNow all the remaining users will also slightly benefit, e.g. in this case userB redeems what's left: `200` * 238.46 / `200` = 238.46 (expected was 220).
Issue Lend or mint after maturity\\nLend/mint should be forbidden post-maturity.
The amount legitimate users receive will be devaluated, while malicious actor can increase their ROI without meaningfully contributing to the protocol and locking their tokens.
```\\n    function mint(\\n        uint8 p,\\n        address u,\\n        uint256 m,\\n        uint256 a\\n    ) external unpaused(u, m, p) returns (bool) {\\n        // Fetch the desired principal token\\n        address principal = IMarketPlace(marketPlace).token(u, m, p);\\n\\n        // Transfer the users principal tokens to the lender contract\\n        Safe.transferFrom(IERC20(principal), msg.sender, address(this), a);\\n\\n        // Mint the tokens received from the user\\n        IERC5095(principalToken(u, m)).authMint(msg.sender, a);\\n\\n        emit Mint(p, u, m, a);\\n\\n        return true;\\n    }\\n```\\n