User would liquidate his account to sidestep `takerInvariant` modifier
A single user could open a massive maker position, using the maximum leverage possible(and possibly reach the maker limit), and when a lot of takers open take positions, maker would liquidate his position, effectively bypassing the taker invariant and losing nothing apart from position fees. This would cause takers to be charged extremely high funding fees(at the maxRate), and takers that are not actively monitoring their positions will be greatly affected.\\nIn the closeMakeFor function, there is a modifier called `takerInvariant`.\\n```\\nfunction closeMakeFor(\\n        address account,\\n        UFixed18 amount\\n    )\\n        public\\n        nonReentrant\\n        notPaused\\n        onlyAccountOrMultiInvoker(account)\\n        settleForAccount(account)\\n        takerInvariant\\n        closeInvariant(account)\\n        liquidationInvariant(account)\\n    {\\n        _closeMake(account, amount);\\n    }\\n```\\n\\nThis modifier prevents makers from closing their positions if it would make the global maker open positions to fall below the global taker open positions. A malicious maker can easily sidestep this by liquidating his own account. Liquidating an account pays the liquidator a fee from the account's collateral, and then forcefully closes all open maker and taker positions for that account.\\n```\\nfunction closeAll(address account) external onlyCollateral notClosed settleForAccount(account) {\\n        AccountPosition storage accountPosition = _positions[account];\\n        Position memory p = accountPosition.position.next(_positions[account].pre);\\n\\n        // Close all positions\\n        _closeMake(account, p.maker);\\n        _closeTake(account, p.taker);\\n\\n        // Mark liquidation to lock position\\n        accountPosition.liquidation = true; \\n    }\\n```\\n\\nThis would make the open maker positions to drop significantly below the open taker position, and greatly increase the funding fee and utilization ratio.\\nATTACK SCENARIO\\nA new Product(ETH-Long) is launched on arbitrum with the following configurations:\\n20x max leverage(5% maintenance)\\nmakerFee = 0\\ntakerFee = 0.015\\nliquidationFee = 20%\\nminRate = 4%\\nmaxRate = 120%\\ntargetRate = 12%\\ntargetUtilization = 80%\\nmakerLimit = 4000 Eth\\nETH price = 1750 USD\\nColl Token = USDC\\nmax liquidity(USD) = 4000*1750 = $7,000,000\\nWhale initially supplies 350k USDC of collateral(~200ETH), and opens a maker position of 3000ETH($5.25mn), at 15x leverage.\\nAfter 2 weeks of activity, global open maker position goes up to 3429ETH($6mn), and because fundingFee is low, people are incentivized to open taker positions, so global open taker position gets to 2743ETH($4.8mn) at 80% utilization. Now, rate of fundingFee is 12%\\nNow, Whale should only be able to close up to 686ETH($1.2mn) of his maker position using the `closeMakeFor` function because of the `takerInvariant` modifier.\\nWhale decides to withdraw 87.5k USDC(~50ETH), bringing his total collateral to 262.5k USDC, and his leverage to 20x(which is the max leverage)\\nIf price of ETH temporarily goes up to 1755 USD, totalMaintenance=3000 * 1755 * 5% = $263250. Because his totalCollateral is 262500 USDC(which is less than totalMaintenance), his account becomes liquidatable.\\nWhale liquidates his account, he receives liquidationFee*totalMaintenance = 20% * 263250 = 52650USDC, and his maker position of 3000ETH gets closed. Now, he can withdraw his remaining collateral(262500-52650=209850)USDC because he has no open positions.\\nGlobal taker position is now 2743ETH($4.8mn), and global maker position is 429ETH($750k)\\nWhale has succeeded in bypassing the takerInvaraiant modifier, which was to prevent him from closing his maker position if it would make global maker position less than global taker position.\\nConsequently,\\nFunding fees would now be very high(120%), so the currently open taker positions will be greatly penalized, and takers who are not actively monitoring their position could lose a lot.\\nWhale would want to gain from the high funding fees, so he would open a maker position that would still keep the global maker position less than the global taker position(e.g. collateral of 232750USDC at 15x leverage, open position = ~2000ETH($3.5mn)) so that taker positions will keep getting charged at the funding fee maxRate.
Consider implementing any of these:\\nProtocol should receive a share of liquidation fee: This would disincentivize users from wanting to liquidate their own accounts, and they would want to keep their positions healthy and over-collateralized\\nLet there be a maker limit on each account: In addition to the global maker limit, there should be maker limit for each account which may be capped at 5% of global maker limit. This would decentralize liquidity provisioning.
Issue User would liquidate his account to sidestep `takerInvariant` modifier\\nUser will close his maker position when he shouldn't be allowed to, and it would cause open taker positions to be greatly impacted. And those who are not actively monitoring their open taker positions will suffer loss due to high funding fees.
```\\nfunction closeMakeFor(\\n        address account,\\n        UFixed18 amount\\n    )\\n        public\\n        nonReentrant\\n        notPaused\\n        onlyAccountOrMultiInvoker(account)\\n        settleForAccount(account)\\n        takerInvariant\\n        closeInvariant(account)\\n        liquidationInvariant(account)\\n    {\\n        _closeMake(account, amount);\\n    }\\n```\\n