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

Tweaks to AbstractTBTCDepositor contract #779

Merged
merged 12 commits into from
Feb 2, 2024

Conversation

nkuba
Copy link
Member

@nkuba nkuba commented Feb 1, 2024

Refs: #750

In this PR I propose some modifications to the initial implementation of AbstractTBTCDepositor contract (#778).

Return initial deposit amount from _initializeDeposit function

Integrators may be interested in adding more fees to the deposit amount. For this reason, it may be cleanest to calculate it based on the initial deposit amount. By returning the value here they will avoid the need to read the funding deposit amount from the storage again.

Mock contracts tweaks

I added modifications to the MockBridge and MockTBTCVault contracts, that were useful in tests of the integrator's implementation (thesis/acre#91).

nkuba added 8 commits February 1, 2024 14:47
Integrators may be interested in adding more fees to the deposit amount.
For this reqson it may be cleanest to calculate im based on the initial
deposit amount. By returning the value here they will avoid reading from
the storage again.
By changing these functions to public the mock contract can be used by
integrators to tweak the contracts to their expectations.
The fee being configurable may be useful for integrators using the stub
contract in tests.
Using the value set in the transaction gives integrator a flexibility to
test with different deposit values than 10 BTC.
New return parameter was covered in the mock to test the value.
Update calculations of amounts to match the changes made in the mock
contracts.

The biggest difference is that the funding transaction is no longer
hardcoded in the MockBridge contract, but the value in the fixture
transaction is used.
The file helps with switching expected node version between the
workspaces.
lts/hydrogen is node v18, which is the highest node version suported by
this module.
Copy link

github-actions bot commented Feb 1, 2024

Solidity API documentation preview available in the artifacts of the https://github.com/keep-network/tbtc-v2/actions/runs/7743108653 check.

Result of running `yarn format:fix` command.
Copy link

github-actions bot commented Feb 1, 2024

Solidity API documentation preview available in the artifacts of the https://github.com/keep-network/tbtc-v2/actions/runs/7743179668 check.

@nkuba nkuba self-assigned this Feb 1, 2024
@nkuba nkuba mentioned this pull request Feb 1, 2024
Copy link
Member

@lukasz-zimnoch lukasz-zimnoch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Left one minor comment.

@@ -204,6 +211,8 @@ abstract contract TBTCDepositorProxy {
// slither-disable-next-line reentrancy-no-eth
delete pendingDeposits[depositKey];

initialDepositAmount = deposit.amount * SATOSHI_MULTIPLIER;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's update the usage example from the contract's docstring accordingly. Right now, there is an obsolete version with _finalizeDeposit returning two parameters.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lukasz-zimnoch lukasz-zimnoch changed the title Tweaks to TBTCDepositorProxy contract Tweaks to AbstractTBTCDepositor contract Feb 1, 2024
Copy link

github-actions bot commented Feb 1, 2024

Solidity API documentation preview available in the artifacts of the https://github.com/keep-network/tbtc-v2/actions/runs/7745366725 check.

Base automatically changed from abstract-depositor-proxy to main February 1, 2024 17:41
@nkuba nkuba requested a review from lukasz-zimnoch February 1, 2024 17:41
Copy link

github-actions bot commented Feb 2, 2024

Solidity API documentation preview available in the artifacts of the https://github.com/keep-network/tbtc-v2/actions/runs/7753096823 check.

@lukasz-zimnoch lukasz-zimnoch merged commit 301497d into main Feb 2, 2024
37 checks passed
@lukasz-zimnoch lukasz-zimnoch deleted the abstract-depositor-proxy-addons branch February 2, 2024 08:11
@lukasz-zimnoch lukasz-zimnoch added the ⛓️ solidity Solidity contracts label Feb 2, 2024
nkuba added a commit that referenced this pull request Feb 2, 2024
Here we remove the rule we added to exclude test contracts from
published NPM package. In
#779 we prepared a
`TestTBTCDepositor` contract to be used by the integrators in tests for
mocking the tBTC Bridge contracts. It is useful to include this file in
the package, so the integrators can leverage it.
lukasz-zimnoch added a commit that referenced this pull request Feb 2, 2024
Here we remove the rule we added to exclude test contracts from
published NPM package. In
#779 we prepared a
`TestTBTCDepositor` contract to be used by the integrators in tests for
mocking the tBTC Bridge contracts. It is useful to include this file in
the package, so the integrators can leverage it.
@lukasz-zimnoch lukasz-zimnoch added this to the solidity/v1.6.0 milestone Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⛓️ solidity Solidity contracts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants