Open aoikurokawa opened 2 months ago
@buffalu Can you review this PR? Thank you so much!
Hey @aoikurokawa! Thanks for the contribution!
We've had some discussions around this and need the solution to #3 to be as follows:
The vault
struct needs the following: epoch_withdraw_cap_bps
, last_slot_updated
, epoch_withdraw_amount
, epoch_snapshot_amount
along with the function is_update_needed
epoch_withdraw_cap_bps
- the percentage 25% - 100% (2500 - 10000) that is the max that can be withdrawn from the vault based on a snapshot of assets in the vault at the beginning of an epochlast_slot_updated
- The slot when process_update_vault
is called at the beginning of an epochepoch_withdraw_amount
- The tally of assets withdrawn on that epoch, this cannot be above epoch_snapshot_amount
x epoch_withdraw_cap_bps
epoch_snapshot_amount
- The amount of assets in the vault at the time of calling process_update_vault
is_update_needed
- Check that Clock.slots
/ config.epoch_length
( Seeis_update_needed
in VaultDelegationList )Flow:
At the beginning of the epoch ( When vault.is_update_needed
is true ) we run process_update_vault
this will:
last_slot_updated
to Clock.slot
epoch_withdraw_amount
to 0epoch_snapshot_amount
to whatever is available to withdraw from the vaultWhen a burn or enqueue withdrawal ticket happens:
vault.is_update_needed
is falseepoch_withdraw_amount
+ amount_to_withdraw
<= epoch_snapshot_amount
* epoch_withdraw_cap_bps
epoch_withdraw_amount
by amount_to_withdraw
Hope this all makes sense!
@buffalu @coachchucksol Thank you for explanation! Ready for review it! Thank you!
Hi! I'll take a look at it today!
@coachchucksol Thank you for reviewing!!
Attention: Patch coverage is 82.44275%
with 23 lines
in your changes missing coverage. Please review.
Project coverage is 83.51%. Comparing base (
4af6d94
) to head (fde61e1
).
Files with missing lines | Patch % | Lines |
---|---|---|
vault_core/src/vault.rs | 79.27% | 23 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Motivation
Solution
epoch_withdraw_cap
,current_epoch
,epoch_withdrawn_amount
inVault
struct.epoch_withdraw_cap