Closed crypto-vincent closed 11 months ago
Ok makes sense
On Sat, 9 Dec 2023 at 11:05 AM, uxd-vincent @.***> wrote:
@.**** commented on this pull request.
In programs/uxd/src/instructions/rebalance_alloyx_vault_depository.rs https://github.com/UXDProtocol/uxd-program/pull/319#discussion_r1421231034 :
- let identity_depository_underflow_value = identity_depository_target_redeemable_amount
- .saturating_sub(identity_depository_redeemable_amount_under_management);
- let alloyx_vault_depository_underflow_value = alloyx_vault_depository_target_redeemable_amount
- .saturating_sub(alloyx_vault_depository_redeemable_amount_under_management);
- let identity_depository_overflow_value = identity_depository_redeemable_amount_under_management
- .saturating_sub(identity_depository_target_redeemable_amount);
- let alloyx_vault_depository_overflow_value =
- alloyx_vault_depository_redeemable_amount_under_management
- .saturating_sub(alloyx_vault_depository_target_redeemable_amount);
- let deposit_redeemable_amount = std::cmp::min(
- identity_depository_overflow_value,
- alloyx_vault_depository_underflow_value,
- );
- let withdraw_redeemable_amount = std::cmp::max(
If there is somehow a conflict, the deposited value will be used, then the withdraw value will not be used (a single rebalancing will only do a single withdraw/deposit, not both)
In all cases however, one of the two value will always be zero:
- if the overflow value > 0, then the underflow value == 0
- So there is always 2 values set to zero in the min/max expressions
- So there is always one of the two deposit/withdraw value that is zero
— Reply to this email directly, view it on GitHub https://github.com/UXDProtocol/uxd-program/pull/319#discussion_r1421231034, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJTOZY2BCQ3WHLFOEZ2LFO3YIPIPRAVCNFSM6AAAAABAHKQPFCVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTONZTGQ2TQMRSGU . You are receiving this because your review was requested.Message ID: @.***>
The TLDR of the change is to make the rebalancing flows computed by:
This is the case so that:
when the alloyx_vault_depository is underflowing, we deposit only if the identity_depository is overflowing
The reasoning is that when the identity depository becomes underflowing, we need the alloyx depository to come to the rescue and help fill up the missing liquidity