The Soft Vault contract allows users to lend and borrow tokens from/to Blueberry Money Market. SoftVault communicates with bTokens to lend and borrow underlying tokens from/to Blueberry Money Market. Underlying tokens can be ERC20 tokens listed by the Blueberry team, such as USDC, USDT, DAI, WETH, etc.
The contract has the following variables:
bToken: An instance of a cToken contract.
uToken: An instance of an underlying token contract.
config: An instance of Blueberry Protocol configuration contract.
The contract has the following events:
Deposited: Emits when a user deposits an underlying token and receives share tokens.
Withdrawn: Emits when a user withdraws an underlying token by redeeming share tokens.
function initialize(IProtocolConfig _config, ICErc20 _bToken, string memory _name, string memory _symbol) external initializer
initializefunction initializes the contract. It sets the contract owner, ERC20 name, ERC20 symbol, Blueberry Protocol configuration, bToken contract, and uToken contract.
function decimals() public view override returns (uint8)
decimalsfunction returns the number of decimals of the bToken contract
function deposit(uint256 amount) external override nonReentrant returns (uint256 shareAmount);
depositfunction allows users to deposit an underlying token and receive share tokens in exchange. It transfers the underlying token to the SoftVault contract, approves the transfer of the underlying token to the bToken contract, mints bTokens, and issues share tokens to the user. The function returns the amount of share tokens issued.
function withdraw(uint256 shareAmount) external override nonReentrant returns (uint256 withdrawAmount);
withdrawfunction allows users to withdraw an underlying token by redeeming share tokens. It burns the share tokens from the user, redeems bTokens for the underlying token, cuts the vault withdraw fee if it's within the window (2 months), and transfers the underlying token to the user. The function returns the amount of underlying tokens transferred to the user.