Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

MarginClearinghouseAccountingLib

Git Source

Functions

buildAccountUsdcBuckets

function buildAccountUsdcBuckets(
    uint256 settlementBalanceUsdc,
    uint256 positionMarginUsdc,
    uint256 committedOrderMarginUsdc,
    uint256 reservedSettlementUsdc
) internal pure returns (IMarginClearinghouse.AccountUsdcBuckets memory buckets);

buildPartialCloseUsdcBuckets

function buildPartialCloseUsdcBuckets(
    uint256 settlementBalanceUsdc,
    uint256 positionMarginUsdc,
    uint256 committedOrderMarginUsdc,
    uint256 reservedSettlementUsdc
) internal pure returns (IMarginClearinghouse.AccountUsdcBuckets memory buckets);

planFundingLossConsumption

function planFundingLossConsumption(
    IMarginClearinghouse.AccountUsdcBuckets memory buckets,
    uint256 lossUsdc
) internal pure returns (SettlementConsumption memory consumption);

getTerminalReachableUsdc

function getTerminalReachableUsdc(
    IMarginClearinghouse.AccountUsdcBuckets memory buckets
) internal pure returns (uint256 reachableUsdc);

getSettlementReachableUsdc

function getSettlementReachableUsdc(
    IMarginClearinghouse.AccountUsdcBuckets memory buckets,
    uint256 protectedLockedMarginUsdc
) internal pure returns (uint256 reachableUsdc);

planTerminalLossConsumption

function planTerminalLossConsumption(
    IMarginClearinghouse.AccountUsdcBuckets memory buckets,
    uint256 protectedLockedMarginUsdc,
    uint256 lossUsdc
) internal pure returns (SettlementConsumption memory consumption);

applyFundingLossMutation

function applyFundingLossMutation(
    IMarginClearinghouse.AccountUsdcBuckets memory,
    SettlementConsumption memory consumption
) internal pure returns (BucketMutation memory mutation);

applyTerminalLossMutation

function applyTerminalLossMutation(
    IMarginClearinghouse.AccountUsdcBuckets memory,
    uint256,
    SettlementConsumption memory consumption
) internal pure returns (BucketMutation memory mutation);

planLiquidationResidual

function planLiquidationResidual(
    IMarginClearinghouse.AccountUsdcBuckets memory buckets,
    int256 residualUsdc
) internal pure returns (LiquidationResidualPlan memory plan);

Structs

SettlementConsumption

struct SettlementConsumption {
    uint256 freeSettlementConsumedUsdc;
    uint256 activeMarginConsumedUsdc;
    uint256 otherLockedMarginConsumedUsdc;
    uint256 totalConsumedUsdc;
    uint256 uncoveredUsdc;
}

BucketMutation

struct BucketMutation {
    uint256 settlementDebitUsdc;
    uint256 positionMarginUnlockedUsdc;
    uint256 otherLockedMarginUnlockedUsdc;
}

LiquidationResidualPlan

struct LiquidationResidualPlan {
    uint256 settlementRetainedUsdc;
    uint256 settlementSeizedUsdc;
    uint256 freshTraderPayoutUsdc;
    uint256 badDebtUsdc;
    BucketMutation mutation;
}