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

Remove deposits maximum total assets limit #332

Merged
merged 16 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
279 changes: 6 additions & 273 deletions core/contracts/AcreBitcoinDepositor.sol

Large diffs are not rendered by default.

77 changes: 7 additions & 70 deletions core/contracts/stBTC.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ contract stBTC is ERC4626Fees, Ownable2StepUpgradeable {
/// before depositing in the Acre contract.
uint256 public minimumDepositAmount;

/// Maximum total amount of tBTC token held by Acre protocol.
uint256 public maximumTotalAssets;

/// Entry fee basis points applied to entry fee calculation.
uint256 public entryFeeBasisPoints;

Expand All @@ -49,11 +46,7 @@ contract stBTC is ERC4626Fees, Ownable2StepUpgradeable {

/// Emitted when deposit parameters are updated.
/// @param minimumDepositAmount New value of the minimum deposit amount.
/// @param maximumTotalAssets New value of the maximum total assets amount.
event DepositParametersUpdated(
uint256 minimumDepositAmount,
uint256 maximumTotalAssets
);
event MinimumDepositAmountUpdated(uint256 minimumDepositAmount);

/// Emitted when the dispatcher contract is updated.
/// @param oldDispatcher Address of the old dispatcher contract.
Expand Down Expand Up @@ -97,7 +90,6 @@ contract stBTC is ERC4626Fees, Ownable2StepUpgradeable {

// TODO: Revisit the exact values closer to the launch.
minimumDepositAmount = 0.001 * 1e18; // 0.001 tBTC
maximumTotalAssets = 25 * 1e18; // 25 tBTC
entryFeeBasisPoints = 0; // TODO: tbd
exitFeeBasisPoints = 0; // TODO: tbd
}
Expand All @@ -117,26 +109,16 @@ contract stBTC is ERC4626Fees, Ownable2StepUpgradeable {
emit TreasuryUpdated(newTreasury);
}

/// @notice Updates deposit parameters.
/// @dev To disable the limit for deposits, set the maximum total assets to
/// maximum (`type(uint256).max`).
/// @param _minimumDepositAmount New value of the minimum deposit amount. It
/// @notice Updates minimum deposit amount.
/// @param newMinimumDepositAmount New value of the minimum deposit amount. It
/// is the minimum amount for a single deposit operation.
/// @param _maximumTotalAssets New value of the maximum total assets amount.
/// It is the maximum amount of the tBTC token that the Acre protocol
/// can hold.
function updateDepositParameters(
uint256 _minimumDepositAmount,
uint256 _maximumTotalAssets
function updateMinimumDepositAmount(
uint256 newMinimumDepositAmount
) external onlyOwner {
// TODO: Introduce a parameters update process.
minimumDepositAmount = _minimumDepositAmount;
maximumTotalAssets = _maximumTotalAssets;
minimumDepositAmount = newMinimumDepositAmount;

emit DepositParametersUpdated(
_minimumDepositAmount,
_maximumTotalAssets
);
emit MinimumDepositAmountUpdated(newMinimumDepositAmount);
}

// TODO: Implement a governed upgrade process that initiates an update and
Expand Down Expand Up @@ -243,51 +225,6 @@ contract stBTC is ERC4626Fees, Ownable2StepUpgradeable {
return convertToAssets(balanceOf(account));
}

/// @notice Returns the maximum amount of the tBTC token that can be
/// deposited into the vault for the receiver through a deposit
/// call. It takes into account the deposit parameter, maximum total
/// assets, which determines the total amount of tBTC token held by
/// Acre. This function always returns available limit for deposits,
/// but the fee is not taken into account. As a result of this, there
/// always will be some dust left. If the dust is lower than the
/// minimum deposit amount, this function will return 0.
/// @return The maximum amount of tBTC token that can be deposited into
/// Acre protocol for the receiver.
function maxDeposit(address) public view override returns (uint256) {
if (maximumTotalAssets == type(uint256).max) {
return type(uint256).max;
}

uint256 currentTotalAssets = totalAssets();
if (currentTotalAssets >= maximumTotalAssets) return 0;

// Max amount left for next deposits. If it is lower than the minimum
// deposit amount, return 0.
uint256 unusedLimit = maximumTotalAssets - currentTotalAssets;

return minimumDepositAmount > unusedLimit ? 0 : unusedLimit;
}

/// @notice Returns the maximum amount of the vault shares that can be
/// minted for the receiver, through a mint call.
/// @dev Since the stBTC contract limits the maximum total tBTC tokens this
/// function converts the maximum deposit amount to shares.
/// @return The maximum amount of the vault shares.
function maxMint(address receiver) public view override returns (uint256) {
uint256 _maxDeposit = maxDeposit(receiver);

// slither-disable-next-line incorrect-equality
return
_maxDeposit == type(uint256).max
? type(uint256).max
: convertToShares(_maxDeposit);
}

/// @return Returns deposit parameters.
function depositParameters() public view returns (uint256, uint256) {
return (minimumDepositAmount, maximumTotalAssets);
}

/// @return Returns entry fee basis point used in deposits.
function _entryFeeBasisPoints() internal view override returns (uint256) {
return entryFeeBasisPoints;
Expand Down
4 changes: 0 additions & 4 deletions core/contracts/test/AcreBitcoinDepositorHarness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ contract AcreBitcoinDepositorHarness is AcreBitcoinDepositor {
) external returns (uint256 amountToStake, address staker) {
return finalizeBridging(depositKey);
}

function exposed_setQueuedStakesBalance(uint256 amount) external {
queuedStakesBalance = amount;
}
}

/// @dev A test contract to stub tBTC Bridge contract.
Expand Down
Loading
Loading