PartyB Account
The PartyB Account Facet manages collateral allocation, deallocation, and reserve vault operations for PartyB (solvers/hedgers). It also provides the self-activation path for cross PartyB mode. The underlying logic is implemented in the PartyBAccountFacetImpl library.
Note: In v0.8.5, the following key changes apply:
Cross PartyB Mode: When cross mode is active for a PartyB,
allocateForPartyBanddeallocateForPartyBrequirepartyA = address(0)(the cross bucket). Calling with any other PartyA address reverts. Similarly,transferAllocationreverts entirely in cross mode since moving funds between per-PartyA buckets is meaningless when everything is pooled.Self-Activation of Cross Mode: A new
activateCrossPartyBfunction allows PartyB to opt into cross mode themselves, provided the global feature flag is enabled and the locked-values migration is complete. Alternatively, an admin can activate cross mode viaControlFacet.setCrossPartyB.Reserve Vault: The reserve vault functions remain unchanged. The reserve vault serves as a last-resort fallback during force close for isolated-mode PartyBs. In cross mode, the reserve vault is not used during force close (the "ignore uPnL" fallback is used instead).
Overview
The PartyB Account Facet provides the following key functionalities:
Allocate for PartyB: Moves funds from PartyB's free balance into an allocated balance for a specific PartyA (or the cross bucket in cross mode).
Deallocate for PartyB: Returns allocated funds back to PartyB's free balance, requiring a Muon uPnL signature for solvency verification.
Transfer Allocation: Moves allocated funds from one PartyA bucket to another (isolated mode only).
Reserve Vault: Deposit to and withdraw from an emergency reserve vault used during force close operations.
Activate Cross Mode: PartyB self-activates cross mode after migration is complete.
allocateForPartyB()
Allocates collateral from PartyB's free balance to the allocated balance for a specific PartyA. In cross mode, partyA must be address(0).
Function Signature:
Parameters:
amount: The collateral amount to allocate (in 18 decimals).partyA: The PartyA address to allocate for. Useaddress(0)in cross mode.
Access: Only callable by PartyB.
Example:
Events Emitted:
AllocateForPartyB(address partyB, address partyA, uint256 amount, uint256 newAllocatedBalance)BalanceChangePartyB(address partyB, address partyA, uint256 amount, BalanceChangeType.ALLOCATE)
deallocateForPartyB()
Deallocates collateral from the PartyB's allocated balance back to free balance. Requires a Muon SingleUpnlSig to verify PartyB remains solvent after deallocation. In cross mode, partyA must be address(0).
Function Signature:
Parameters:
amount: The collateral amount to deallocate (in 18 decimals).partyA: The PartyA address to deallocate from. Useaddress(0)in cross mode.upnlSig: The Muon signature containing PartyB's uPnL for solvency verification. In cross mode, the nonce in the signature uses the actual cross nonce (not zero).
Access: Only callable by PartyB. Neither party can be in liquidation. PartyB must not be suspended.
Events Emitted:
DeallocateForPartyB(address partyB, address partyA, uint256 amount, uint256 newAllocatedBalance)BalanceChangePartyB(address partyB, address partyA, uint256 amount, BalanceChangeType.DEALLOCATE)
transferAllocation()
Transfers allocated funds from one PartyA bucket to another within the same PartyB. This allows PartyB to rebalance capital across counterparties without going through deallocation and reallocation (which would reset cooldown timers). Requires a Muon SingleUpnlSig to verify solvency after the transfer.
Important: This function reverts in cross mode since all funds are pooled in a single bucket — transferring between per-PartyA buckets is meaningless.
Function Signature:
Parameters:
amount: The collateral amount to transfer (in 18 decimals).origin: The PartyA address to transfer from.recipient: The PartyA address to transfer to.upnlSig: The Muon signature for solvency verification.
Access: Only callable by PartyB.
Events Emitted:
TransferAllocation(uint256 amount, address origin, uint256 newOriginBalance, address recipient, uint256 newRecipientBalance)BalanceChangePartyB(address partyB, address origin, uint256 amount, BalanceChangeType.DEALLOCATE)BalanceChangePartyB(address partyB, address recipient, uint256 amount, BalanceChangeType.ALLOCATE)
depositToReserveVault()
Deposits funds from the caller's free balance into a PartyB's emergency reserve vault. The reserve vault serves as a last-resort fallback during force close. If PartyB becomes insolvent after a force close, the deficit can be covered from the reserve vault before triggering liquidation.
The caller does not need to be the PartyB itself; anyone can deposit into a PartyB's reserve vault.
Function Signature:
Parameters:
amount: The collateral amount to deposit (in 18 decimals).partyB: The PartyB whose reserve vault will receive the deposit.
Example:
Events Emitted:
DepositToReserveVault(address sender, address partyB, uint256 amount)
withdrawFromReserveVault()
Withdraws funds from the caller's own reserve vault back to their free balance. Only the PartyB that owns the vault can withdraw.
Function Signature:
Parameters:
amount: The collateral amount to withdraw (in 18 decimals).
Events Emitted:
WithdrawFromReserveVault(address partyB, uint256 amount)
activateCrossPartyB()
Allows a PartyB to self-activate cross mode. Once activated, all per-PartyA allocated balances are accessed through the unified cross bucket (address(0)), enabling pooled capital management across all PartyA relationships.
Prerequisites:
The global cross mode feature flag must be enabled (
crossPartyBModeActivated = true).The PartyB's locked-values migration must be complete (
partyBLockedValuesMigrated[partyB] = true), meaningMigrationFacet.migrateCrossLockedValueshas been called for this PartyB.
Alternatively, an admin with MIGRATION_ROLE can activate cross mode for a PartyB via ControlFacet.setCrossPartyB without the migration check.
Function Signature:
Access: Only callable by a registered PartyB. PartyB must not be suspended.
Example:
Events Emitted:
ActivateCrossPartyB(address partyB)
Last updated

