sherlock-audit / 2023-04-blueberry-judging

8 stars 5 forks source link

deadrxsezzz - Only 1 bank can be added to a certain token #90

Closed sherlock-admin closed 1 year ago

sherlock-admin commented 1 year ago

deadrxsezzz

medium

Only 1 bank can be added to a certain token

Summary

A token might be linked to one bank only

Vulnerability Detail

When creating a bank, an instance of it is created in the mapping banks[token]. Since the key value to the mapping is the token, a single token can only be linked to a single bank. This heavily limits the project functionality for popularly used tokens. If another bank is attempted to be created for the same token it will revert on the following line https://github.com/sherlock-audit/2023-04-blueberry/blob/main/blueberry-core/contracts/BlueBerryBank.sol#L257

Impact

Only one bank can be created to a token, limiting its possibilities

Code Snippet

https://github.com/sherlock-audit/2023-04-blueberry/blob/main/blueberry-core/contracts/BlueBerryBank.sol#L257

Tool used

Manual Review

Recommendation

Add functionality to be possible to create multiple banks to a token => instead of using the token as key value to the banks mapping, use an id