Any realized and unrealized PnL accrued from open or closed positions needs to be “Settled” into the USDC balance of the account. PnL settlement can happen anytime for any account if other users trigger a settlement. Any user can also trigger PnL settlement of their own account by following these steps:

1

Get a Settle PnL nonce

Get a nonce from Get settle PnL nonce.

2

Obtain signature from EIP-712

Sign an EIP-712 message in the following format:

{
    "brokerId": "woofi_dex",
    "chainId": 80001,
    "settleNonce": 1,
    "timestamp": 1685973017064
}

where:

NameTypeRequiredDescription
brokerIdstringYBroker ID, the valid list can be found [here]
chainIdintYChain ID of the connected chain where the message was signed
settleNonceintYValid withdrawal nonce from Get settle PnL nonce
timestamptimestampYcurrent timestamp in UNIX milliseconds
3

Request PnL settlement

Request a PnL settlement through Request Pnl settlement API.

Example

The example code is very similar to the Orderly key registration, except it uses the EIP-712 on-chain domain and the signed message is different.