-
Notifications
You must be signed in to change notification settings - Fork 36
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
Make deposit dust threshold configurable in MockBridge #787
Merged
Conversation
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
Integrators using the MockBridge contract implementation may be interested in configuring the deposit dust threshold, to test their implementation.
Solidity API documentation preview available in the artifacts of the https://github.com/keep-network/tbtc-v2/actions/runs/7933506487 check. |
Solidity API documentation preview available in the artifacts of the https://github.com/keep-network/tbtc-v2/actions/runs/8016316701 check. |
lukasz-zimnoch
approved these changes
Feb 23, 2024
nkuba
added a commit
to thesis/acre
that referenced
this pull request
Feb 27, 2024
This version contains changes from keep-network/tbtc-v2#787
dimpar
added a commit
to thesis/acre
that referenced
this pull request
Mar 6, 2024
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)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Integrators using the MockBridge contract implementation may be interested in configuring the deposit dust threshold, to test their implementation.