Proposal to Upgrade FiRM Borrow Controller to v2: Enhanced Security and Bug Fixes
Summary
This proposal seeks to upgrade the borrow controller on FiRM to a new version which has additional features added.
Background
The borrow controller is a crucial component of FiRM, with all new borrow transactions needing to be approved by the controller. This contract controls aspects crucial for security such as daily borrow limits and the smart contract allowlist.
Improvements
The updated borrow controller adds new features as well as new logic that fixes an edge case bug found in DBR.
New features added:
- Ability to set a minimum debt on a borrow transaction for each market
- Ability to check a staleness threshold for each market
The minimum debt threshold requires the debt of a borrower in a specific market to be over a certain amount, after completing a borrow operation, with the transaction failing if the user’s end debt is below the minimum set for the market. Currently, users are able borrow any amount from FiRM up to the daily borrow limit, including very small amounts; this is a problem as high gas costs on the Ethereum network may make liquidations with a liquidation incentive below the transaction cost unprofitable, resulting in bad debt accruing more easily for small positions. The minimum debt limit will mitigate this scenario. By increasing the size of borrow positions, we will be able to reduce the liquidation factor on many of the FiRM markets, causing less of a loss for the borrower in case of a liquidation event. This makes FiRM a far more attractive venue to borrow on. Analysis is currently underway to determine the optimum minimum debt to be set for each market, and will be presented in a later proposal.
While the minimum debt threshold might make FiRM less accessible on Ethereum for users with smaller capital, this change is deemed essential for enhancing the protocol. However, these users can look forward to more affordable options when FiRM expands to chains with lower gas costs, such as L2s, in the future. It should also be noted that small positions make up a very small percentage of total borrows on FiRM currently.
The staleness check compares how recently the chainlink price feed was updated with a staleness threshold, with the feed being classified stale if (now - lastUpdate > stalenessThreshold). This is important as using an outdated feed to value collateral would put the protocol at risk of potentially incurring bad debt if the asset loses value which isn’t represented by the price feed. When a feed is stale all borrows on that market will revert. Liquidations will still be possible to be executed. The staleness threshold for each market will be set to 30 seconds greater than the chainlink price feeds heartbeat.
If either the minimum debt or staleness threshold is 0, then the corresponding check is disregarded.
Bug Fix:
The current DBR contract contains a minor bug that meant the lastUpdate for a user would not update for a user that had previously repaid their global FiRM debt to 0, and then later made a new borrow. This would lead to the user being overcharged DBR as if they had this new borrow position open for the entire time since they repaid initially. All accounts impacted by this bug have been identified and fully reimbursed the DBR they were overcharged.
The v2 borrow controller identifies if a user is about to trigger this edge case bug, and if so calculates what the overcharge will be, and immediately mints this DBR as a refund to the impacted user, completely negating the impact of the bug. In order for this to work, the v2 borrow controller will need to be set as a DBR minter.
Smart Contracts
Borrow Controller v1: Inverse Finance: Borrow Controller | Address 0x20C7349f6D6A746a25e66f7c235E96DAC880bc0D | Etherscan
Borrow Controller v2: BorrowController | Address 0x44b7895989bc7886423f06deaa844d413384b0d6 | Etherscan
On-Chain Actions
- Add Borrow Controller v2 as a DBR minter
- Set Borrow Controller of st-yCRV market to Borrow Controller v2
- Set Borrow Controller of CRV market to Borrow Controller v2
- Set Borrow Controller of cvxCRV market to Borrow Controller v2
- Set Borrow Controller of gOHM market to Borrow Controller v2
- Set Borrow Controller of cvxFXS market to Borrow Controller v2
- Set Borrow Controller of WETH market to Borrow Controller v2
- Set Borrow Controller of stETH market to Borrow Controller v2
- Set Staleness Threshold of st-yCRV market to 86430
- Set Staleness Threshold of CRV market to 86430
- Set Staleness Threshold of cvxCRV market to 86430
- Set Staleness Threshold of gOHM market to 86430
- Set Staleness Threshold of cvxFXS market to 86430
- Set Staleness Threshold of WETH market to 3630
- Set Staleness Threshold of stETH market to 3630