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
Borrowed
8 USDC
PnL
+1 USDC
Conversion (USDC, 6 decimals):
Borrowed =
8,000,000PnL =
1,000,000Return =
9,000,000
Execution
Transfer:
Call:
2. Borrowed Capital with Loss
Borrowed
8 USDC
PnL
-2 USDC
Conversion (USDC, 6 decimals):
Borrowed =
8,000,000PnL =
-2,000,000Return =
6,000,000
Execution
Transfer:
Call:
3. No Borrowing with Profit
Borrowed
0
PnL
+1 USDC
Conversion (USDC, 6 decimals):
Borrowed =
0PnL =
1,000,000Return =
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.
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
Initial Borrowed
0 USDC
Realized PnL
-1 USDC
Since Borrowed = 0, calling settle(-1 USDC) directly is invalid.
Required process:
Borrow the required amount
Approve the vault
Call settlement with the negative PnL
Conversion (USDC, 6 decimals):
Borrow =
1000000PnL =
-1000000Return 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

