Orbitlending

Orbitlending: SpaceStation Collateral Checks

Within Orbit Protocol's lending markets on Blast, SpaceStation checks how proposed borrowing or collateral withdrawals affect an account's borrowing capacity. The published SpaceStation.sol implementation separates account collateral checks from market borrow caps and applies a different liquidation rule to deprecated markets.

Updated:

Collateral factors, borrow caps, and borrowing pauses are market settings. The source code alone does not establish their current deployed values.

Market Membership and Account Liquidity

OTokens represent lending-pool shares. SpaceStation separately records the markets included in each account's liquidity calculation, and enterMarkets requests entry into listed markets.

The liquidity calculation values OToken balances using stored exchange rates, oracle prices, and each market's collateral factor. It compares that adjusted collateral with oracle-valued borrow balances. Proposed borrowing adds debt, while proposed redemption accounts for the collateral capacity being removed. A positive shortfall means debt and the proposed effects exceed adjusted collateral.

The liquidity view uses stored balances and exchange rates without accruing fresh interest itself. A failed account snapshot or a zero oracle price returns an error; the error code must indicate success before a zero shortfall can be interpreted as a valid result.

Borrowing Permission

The borrowAllowed function requires a listed market, unpaused borrowing, and a nonzero oracle price for the borrowed asset. If the borrower has not entered that market, this branch requires the call to come from the market's OToken contract, which can register the borrower.

Account collateral
The proposed borrow must produce no account shortfall, and the liquidity calculation must return without an error.
Market borrow cap
For a nonzero cap, existing total market borrows plus the requested underlying amount must be strictly below the cap. Equality fails. A cap of zero disables this cap check while leaving the other borrowing conditions in place.

Worked Example: Sufficient Collateral With a Market Cap

The market cap can prevent a borrow even when the account has sufficient collateral. All amounts and account or market states in this example are hypothetical: assume a listed USDB market, unpaused borrowing, valid oracle pricing, and enough account collateral capacity for either proposed request.

Market borrow cap: 6,785 USDB. Existing total market borrowing: 6,505 USDB. The check uses nextTotalBorrows = totalBorrows + borrowAmount and requires the result to remain strictly below the cap.

Worked Example: Sufficient Collateral With a Market Cap
Proposed Borrow (USDB) Resulting Market Total (USDB) Cap Result
275 6,780 Below the cap; continues to the account-liquidity check
280 6,785 Equals the cap; reverts at the cap check

Increasing existing market borrowing reduces the amount a new request can add below the same cap, even if the account's collateral is unchanged. Passing the cap check still leaves the account-liquidity and OToken transaction checks in force.


Redemption, Transfers, and Market Exit

Redemption
SpaceStation first requires the market to be listed. For an account entered in that market, it tests the proposed redemption and rejects an error or a resulting shortfall. An account outside that market bypasses this account-liquidity test; the OToken's separate redemption checks still apply.
OToken transfers
The transferAllowed hook checks whether transfers are paused and applies the redemption-permission logic to the sender's proposed transfer amount. Moving shares can therefore be restricted by the collateral they support.
Market exit
The exitMarket function requires no outstanding borrow balance in the market being exited and permission to redeem all the account's OTokens there. Debt in another market can prevent exit when it needs that collateral. Exit removes market membership without withdrawing underlying assets.

The published OToken implementation separately checks available underlying cash after controller permission for borrowing and redemption. A permitted collateral reduction can still encounter insufficient cash for the requested withdrawal.

Visual outline: Orbitlending: Redemption, Transfers, and Market Exit

Open full-size image

Liquidation and Deprecated Markets

SpaceStation's liquidateBorrowAllowed hook requires both the borrowed market and the collateral market to be listed. For a borrowed market the code does not classify as deprecated, it requires a positive account shortfall and limits repayment to the configured close factor multiplied by the borrower's recorded debt in that borrowed market.

The deprecated-market branch skips those shortfall and close-factor tests and instead requires repayment not to exceed the recorded borrow balance. In this implementation, isDeprecated requires all three conditions together: the market's collateral factor is zero, borrowing is paused for that market, and its reserve factor is 100%. A borrowing pause alone does not meet that definition.