-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Staking limits in Bitcoin Depositor contract (#253)
This PR enhances #91. Depends on keep-network/tbtc-v2#787 Depends on keep-network/tbtc-v2#791 ### Introduction In this PR we introduce a mechanism for the dApp to throttle stake request initialization. The staking flow for Bitcoin is asynchronous, consisting of a couple of stages between the user entering the staking form in the dApp and the tBTC being deposited in the stBTC vault. Since the stBTC vault introduced a limit for maximum total assets under management, there is a risk that the user will initialize staking that won't be able to finalize in stBTC, due to concurrent other users' stakes. We need to reduce such risk by throttling stake initialization flow in the dApp. ### Soft Cap and Hard Cap Limits #### Hard Cap stBTC contract defines a _maximum total assets limit_, that cannot be exceeded with new tBTC deposits. This is considered a hard limit, that when reached no new deposits can be made, and stake requests in the Bitcoin Depositor contract will be queued. These queued requests will have to wait until the limit is raised or other users withdraw their funds, making room for new users. #### Soft Cap Bitcoin Depositor Contract defines a _maximum total assets soft limit_, which is assumed to be much lower than the _hard cap_. The limit is used to throttle stakes and use a difference between _hard cap_ and _soft cap_ as a buffer for possible async stakes coming from the dApp. ### Stake Amount Limits #### Minimum Stake Limit The Bitcoin Depositor contract defines a _minimum stake limit_, that is used to define a minimum amount of a stake. The limit has to be higher than the _deposit dust threshold_ defined in the tBTC Bridge, which is validated on the deposit reveal. The _minimum stake limit_ has to take into account the _minimum deposit limit_ defined in the stBTC contract, and consider that the amount of tBTC deposited in the stBTC vault on stake finalization will be reduced by tBTC Bridge fees and Depositor fee. #### Maximum Stake Limit The Bitcoin Depositor contract defines a _maximum stake limit_, which is the maximum amount of a single stake request. This limit is used to introduce granularity to the stake amount and reduce the possibility of a big stake request using the whole soft limit shared across other concurrent stake requests. ### Usage in dApp The limits should be validated in the dApp staking flow to reduce the possibility of user stakes being stuck in the queue. The contract exposes two functions to be used in the dApp `minStakeInSatoshi` and `maxStakeInSatoshi`, for convenience the result is returned in the satoshi precision. ### Flow ![image](https://github.com/thesis/acre/assets/10741774/46f699d1-3607-4e27-b07a-de18b6078fbd) [source: Figjam](https://www.figma.com/file/5S8Wa5WudTQGbKMk7ETKq8/Bitcoin-Depositor-Staking-Limits?type=whiteboard&node-id=1-519&t=aCatffRBQpe4BCMn-4)
- Loading branch information
Showing
4 changed files
with
575 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.