Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature suggestion] A general bitmap to define which asset can be borrowed for a particular reserve to replace isAssetBorrowableInIsolation #915

Open
MuesliW opened this issue Sep 24, 2023 · 0 comments

Comments

@MuesliW
Copy link

MuesliW commented Sep 24, 2023

Context

Currently the protocol has defined isolated asset, which can only 1.) be used as the only collateral, 2.) can only borrow assets that defined under borrowableInIsolation=true. However, when there are more assets being added as isolated asset, making an asset borrowable to this increasing amount of higher risk set of asset becomes an intricate and tricky risk assessment task. Secondly, each isolated asset has different risk properties and having the same set of borrowable is also a limiting factor, preventing the protocol from onboarding new and different new assets to the lending market using this feature

Solution

Add a mapping of bitmap to Pool/PoolStorage, that defines each reserveIndex to all the other reserveIndex (uint16 => uint128) using the bit as representation (since there are max 128 reserves). If the bit is flipped then the reserve is not borrowable. So a reserve with a bitmap value of 0, means it can borrow any asset just like an open asset now. A current isolated asset would have a bitmap with all bits flipped to 1, except the index of assets with borrowableInIsolation set to true.

mapping(uint16 => uint128) internal _reservesBlacklistBitmap;

Setting this bitmap is quite easy and gas efficient, just pre-compute the needed number by flipping bit on the required reserveIndex.

Checking this bitmap is also easy, just do a bit-wise operation to see if the collateral's bitmap has flipped the bit on the borrowed asset index

require( _reservesBlacklistBitmap[collateralIndex] &  1 << toBorrowReserveIndex > 0, "the collateral is forbidden to borrow this asset");

Benefit

This provides a much more granular control over isolated asset, and thus enable the protocol to onboard more isolated asset to capture TVL and market shares.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant