Assessment reports>GTE -- Perp>Threat Model>settleTakerFill

Function: settleTakerFill(CollateralManager self, SettleTakerFillArgs args)

The settleTakerFill function processes the taker's side of a trade after a limit order is filled. It processes the margin and debt of an account and handles collateralDelta.

Inputs

  • params.account

    • Control: initiate postLimitOrder or postFillOrder execution.

    • Constraints: N/A.

    • Impact: the address of the account who place or fill order.

  • params.subaccount

    • Control: full control.

    • Constraints: N/A.

    • Impact: subaccount.

  • params.settlement

    • Control: full control.

    • Constraints: Must be a valid settlement type.

    • Impact: Defines how the collateral funds will be provided.

  • params.marginDelta

    • Control: the result of self.market[asset].postLimitOrder(asset, account, args)/self.market[asset].postFillOrder(asset, account, args) function execution + fundingPaymentResult.marginDelta.

    • Constraints: N/A.

    • Impact: marginAccount.margin data of the provided account and subaccount will be updated by the marginDelta.

  • params.collateralDelta

    • Control: the result of self.market[asset].postLimitOrder(asset, account, args)/self.market[asset].postFillOrder(asset, account, args) function execution

    • Constraints: N/A.

    • Impact: this amount is processed by handleCollateralDelta to be transferred to or from the account or debited/credited, depends on settlement.

  • params.debt

    • Control: the result of self.market[asset].postLimitOrder(asset, account, args)/self.market[asset].postFillOrder(asset, account, args) function execution + fundingPaymentResult.debt

    • Constraints: N/A.

    • Impact: marginAccount.debt data of the provided account and subaccount will be updated by the debt.

  • params.takerFee

    • Control: the result of self.market[asset].postLimitOrder(asset, account, args)/self.market[asset].postFillOrder(asset, account, args) function execution.

    • Constraints: N/A.

    • Impact: if collateralDelta > 0, collateralDelta is increased by takerFee amount, otherwise debt is increased by takerFee.

  • params.close

    • Control: self.positions[account][args.subaccount].length() == 0

    • Constraints: N/A.

    • Impact: if true, collateralDelta is increased by debt.

Branches and code coverage

Intended branches

  • Positive marginDelta increases available margin.

  • Negative marginDelta reduces margin correctly.

  • settlement == INSTANT.

  • settlement == ACCOUNT.

Negative behavior

  • Reverts if position is closed and collateralDelta < 0 after debt deduction.

Zellic © 2025Back to top ↑