Settlement Reference

If PnL ≥ 0:
    Amount Returned = Borrowed + PnL

If PnL < 0:
    Amount Returned = Borrowed - |PnL|

Settlement call:

settle(int256 pnl)

Settlement Checklist

Before calling settle():


Settlement Scenarios

1. Borrowed Capital with Profit

Parameter
Value

Borrowed

8 USDC

PnL

+1 USDC

Conversion (USDC, 6 decimals):

  • Borrowed = 8,000,000

  • PnL = 1,000,000

  • Return = 9,000,000

Execution

Transfer:

Call:


2. Borrowed Capital with Loss

Parameter
Value

Borrowed

8 USDC

PnL

-2 USDC

Conversion (USDC, 6 decimals):

  • Borrowed = 8,000,000

  • PnL = -2,000,000

  • Return = 6,000,000

Execution

Transfer:

Call:

circle-exclamation

3. No Borrowing with Profit

Parameter
Value

Borrowed

0

PnL

+1 USDC

Conversion (USDC, 6 decimals):

  • Borrowed = 0

  • PnL = 1,000,000

  • Return = 1,000,000

Execution

Transfer:

Call:


4. No Borrowing with Loss

This scenario is not permitted as-is.

If no capital was borrowed during the epoch, the trader cannot settle with a negative PnL directly, since the contract enforces that losses cannot exceed borrowed capital.

triangle-exclamation

Resolution

If the strategy resulted in a loss but no capital had previously been borrowed, the trader must first borrow the required amount from the vault, then settle using the negative PnL value.

Example

Parameter
Value

Initial Borrowed

0 USDC

Realized PnL

-1 USDC

Since Borrowed = 0, calling settle(-1 USDC) directly is invalid.

Required process:

  1. Borrow the required amount

  2. Approve the vault

  3. Call settlement with the negative PnL

Conversion (USDC, 6 decimals):

  • Borrow = 1000000

  • PnL = -1000000

  • Return amount at settlement = 0

Execution

Borrow:

Approve:

Call:


Summary

  • Settlement enforces final PnL onchain

  • Return amount must reflect borrowed capital ± PnL

  • All values must be provided in base units

  • settle(pnl) finalizes the epoch

Last updated