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.accountControl: initiate
postLimitOrderorpostFillOrderexecution.Constraints: N/A.
Impact: the address of the account who place or fill order.
params.subaccountControl: full control.
Constraints: N/A.
Impact: subaccount.
params.settlementControl: full control.
Constraints: Must be a valid settlement type.
Impact: Defines how the collateral funds will be provided.
params.marginDeltaControl: 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.margindata of the provided account and subaccount will be updated by themarginDelta.
params.collateralDeltaControl: the result of
self.market[asset].postLimitOrder(asset, account, args)/self.market[asset].postFillOrder(asset, account, args)function executionConstraints: N/A.
Impact: this amount is processed by
handleCollateralDeltato be transferred to or from the account or debited/credited, depends on settlement.
params.debtControl: the result of
self.market[asset].postLimitOrder(asset, account, args)/self.market[asset].postFillOrder(asset, account, args)function execution +fundingPaymentResult.debtConstraints: N/A.
Impact:
marginAccount.debtdata of the provided account and subaccount will be updated by thedebt.
params.takerFeeControl: 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,collateralDeltais increased bytakerFeeamount, otherwisedebtis increased bytakerFee.
params.closeControl:
self.positions[account][args.subaccount].length() == 0Constraints: N/A.
Impact: if true,
collateralDeltais increased bydebt.
Branches and code coverage
Intended branches
Positive
marginDeltaincreases available margin.Negative
marginDeltareduces margin correctly.settlement == INSTANT.settlement == ACCOUNT.
Negative behavior
Reverts if position is closed and
collateralDelta < 0after debt deduction.