-
Notifications
You must be signed in to change notification settings - Fork 21
Pad validator withdrawals with a reward accrual buffer #846
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
48d268d
Pad validator withdrawals with a reward accrual buffer
cyc60 e324d43
Skip buffer-only partials after a covering full exit
cyc60 7065496
Make min withdrawal amount configurable, capped at oracle exit threshold
cyc60 0b9aa38
Set min withdrawal amount via env, validate cap at startup
cyc60 3fd37de
Drop wei to gwei round-up, reword min withdrawal description
cyc60 a0cba6c
Polish min withdrawal amount wording
cyc60 4440696
Replace dynamic withdrawal buffer with fixed ratio and env floor
cyc60 f955a3b
Read whole exit queue value from vault state
cyc60 55857f8
Value queued exit shares with OsTokenConverter
cyc60 9ff2f8e
Fix ExitQueueAssets.total comment
cyc60 c65eb26
Use bps buffer and missing assets threshold naming
cyc60 7b7004e
Cap withdrawal buffer at 1 ETH
cyc60 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| from unittest import mock | ||
|
|
||
| from eth_abi import abi as eth_abi | ||
| from hexbytes import HexBytes | ||
| from web3 import AsyncWeb3, Web3 | ||
| from web3.types import BlockNumber, Wei | ||
|
|
||
| from src.common.contracts import VaultContract | ||
| from src.common.typings import HarvestParams | ||
|
|
||
| VAULT_ADDRESS = Web3.to_checksum_address('0x' + '11' * 20) | ||
|
|
||
|
|
||
| class TestGetQueuedExitAssets: | ||
| async def test_without_harvest_params(self): | ||
| vault = _vault_contract() | ||
| exit_queue_data = eth_abi.encode( | ||
| ['uint128', 'uint128', 'uint128', 'uint128', 'uint256'], [10, 1, 2, 3, 4] | ||
| ) | ||
| response = [exit_queue_data, (25).to_bytes(32, 'big'), (100).to_bytes(32, 'big')] | ||
|
|
||
| with mock.patch.object(vault.contract.functions, 'multicall') as multicall_mock: | ||
| multicall_mock.return_value.call = mock.AsyncMock(return_value=response) | ||
| result = await vault.get_queued_exit_assets(None, BlockNumber(123)) | ||
|
|
||
| assert result == Wei(2) # 10 * 25 // 100 | ||
| multicall_mock.return_value.call.assert_awaited_once_with(block_identifier=BlockNumber(123)) | ||
| assert len(multicall_mock.call_args.args[0]) == 3 | ||
|
|
||
| async def test_with_harvest_params(self): | ||
| vault = _vault_contract() | ||
| harvest_params = HarvestParams( | ||
| rewards_root=HexBytes(b'\x00' * 32), | ||
| reward=Wei(0), | ||
| unlocked_mev_reward=Wei(0), | ||
| proof=[], | ||
| ) | ||
| exit_queue_data = eth_abi.encode( | ||
| ['uint128', 'uint128', 'uint128', 'uint128', 'uint256'], [10, 1, 2, 3, 4] | ||
| ) | ||
| response = [b'', exit_queue_data, (25).to_bytes(32, 'big'), (100).to_bytes(32, 'big')] | ||
|
|
||
| with mock.patch.object(vault.contract.functions, 'multicall') as multicall_mock: | ||
| multicall_mock.return_value.call = mock.AsyncMock(return_value=response) | ||
| result = await vault.get_queued_exit_assets(harvest_params, BlockNumber(123)) | ||
|
|
||
| assert result == Wei(2) # 10 * 25 // 100 | ||
| assert len(multicall_mock.call_args.args[0]) == 4 | ||
|
|
||
| async def test_zero_total_shares(self): | ||
| vault = _vault_contract() | ||
| exit_queue_data = eth_abi.encode( | ||
| ['uint128', 'uint128', 'uint128', 'uint128', 'uint256'], [10, 1, 2, 3, 4] | ||
| ) | ||
| response = [exit_queue_data, (0).to_bytes(32, 'big'), (0).to_bytes(32, 'big')] | ||
|
|
||
| with mock.patch.object(vault.contract.functions, 'multicall') as multicall_mock: | ||
| multicall_mock.return_value.call = mock.AsyncMock(return_value=response) | ||
| result = await vault.get_queued_exit_assets(None, BlockNumber(123)) | ||
|
|
||
| assert result == Wei(0) | ||
|
|
||
|
|
||
| def _vault_contract() -> VaultContract: | ||
| # A bare AsyncWeb3() avoids hitting the not-set-up ``execution_client`` singleton; | ||
| # eth.contract() only builds a local contract object, no network call is made. | ||
| return VaultContract(address=VAULT_ADDRESS, execution_client=AsyncWeb3()) |
This file contains hidden or 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 hidden or 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.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.