Summary
Currently, collateral and PnL from a closed position are always sent to the original position owner (env.invoker()). Add a recipient: Option<Address> field to decrease and withdrawal orders so traders can direct funds to a different wallet (e.g., a cold storage address or a multi-sig vault).
Proposed Design
- Add
recipient: Option<Address> to CreateOrderParams and CreateWithdrawalParams
- If
Some(addr), final token transfer goes to addr instead of env.invoker()
- If
None, behaviour unchanged
recipient address is not auth-checked — position owner has full discretion
Security Note
The recipient cannot use this to steal funds from a different owner. The position auth check still applies to the invoker, not the recipient.
Acceptance Criteria
Affected Contracts
exchange_router, order_handler, withdrawal_handler
Summary
Currently, collateral and PnL from a closed position are always sent to the original position owner (
env.invoker()). Add arecipient: Option<Address>field to decrease and withdrawal orders so traders can direct funds to a different wallet (e.g., a cold storage address or a multi-sig vault).Proposed Design
recipient: Option<Address>toCreateOrderParamsandCreateWithdrawalParamsSome(addr), final token transfer goes toaddrinstead ofenv.invoker()None, behaviour unchangedrecipientaddress is not auth-checked — position owner has full discretionSecurity Note
The recipient cannot use this to steal funds from a different owner. The position auth check still applies to the invoker, not the recipient.
Acceptance Criteria
CreateOrderParamsandCreateWithdrawalParamsincluderecipient: Option<Address>Affected Contracts
exchange_router,order_handler,withdrawal_handler