-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose deposit amounts in AbstractDepositorContract (#791)
In this PR we introduce two changes to the AbstractDepositorContract around the deposit amounts. ### Expose minimum deposit amount Integrators may need a minimum deposit amount to introduce validation if the amount the user wants to deposit meets the Bridge requirement of a deposit to exceed the dust threshold. Originally proposed in thesis/acre#253 (comment). ### Return initial deposit amount from _initializeDeposit function The amount may be useful for integrators for validations of the deposit amount. Originally proposed in thesis/acre#253 (comment). It turns out that this version where we read from the storage: ```solidity initialDepositAmount = bridge.deposits(depositKey).amount * SATOSHI_MULTIPLIER; ``` costs `117 366` gas. Which is less than an alternative approach: ```solidity initialDepositAmount = fundingTx .outputVector .extractOutputAtIndex(reveal.fundingOutputIndex) .extractValue() * SATOSHI_MULTIPLIER; ``` which costs `117 601` gas. We return `initialDepositAmount` from two functions: `_initializeDeposit` and `_finalizeDeposit`. I tried to introduce a getter function: ```solidity function _getInitialDepositAmount( uint256 depositKey ) internal view returns (uint256) { IBridgeTypes.DepositRequest memory deposit = bridge.deposits( depositKey ); require(deposit.revealedAt != 0, "Deposit not initialized"); return deposit.amount * SATOSHI_MULTIPLIER; } ``` and removed `initialDepositAmount` return from `_initializeDeposit` and `_finalizeDeposit` functions. Unfortunately, the overall cost in the reference BitcoinDepositor implementation from thesis/acre#253 wasn't improved: BEFORE: ``` + initializeStake --> 143 004 + finalizeStake --> 195 178 = total --> 338 182 ``` AFTER: ``` + initializeStake --> 142 912 + finalizeStake --> 197 960 = total --> 340 872 ```
- Loading branch information
Showing
3 changed files
with
57 additions
and
9 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
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