Trading
Open, close, add margin, and claim from a single-use clone funded by the shielded pool.
A position belongs to a clone, not to an account. The clone is the Opertus
caller contract that runs an unshield's external call, so the vault sees the
clone as msg.sender and never the user's wallet. Each position uses a fresh
clone, and every action on it is a call from that clone.
Where the funds come from
A position is opened by an unshield with calldata, routed through the executor and caller:
- the unshield sends USDC from the user's notes to a clone with a nonzero salt;
- the clone approves the vault for that amount and calls
requestOpen; - the vault pulls
collateralfrom the clone.
Later calls on the same position, such as requestClose and claim, come from
the same clone, which the wallet derives again from the same diversifier. Payouts
land on the clone, and the pool shields them back into a note as a return.
Open
Request, block N
The clone calls requestOpen(sizeDelta, collateral, acceptablePrice). A
positive sizeDelta is a long and a negative one a short. The collateral is
pulled and locked. At the current mark, notional must be between $10 and
maxPositionNotionalUsdc, and collateral at most notional, or the call reverts.
Execute, block N+1 or N+2
Anyone calls execute(ids) with up to 100 request ids. The price is the mark
plus the spread for a long, or minus it for a short. The fee is tradeFeeBps of
notional, and the rest of the collateral becomes margin, so leverage is notional
divided by margin.
Fill or refund
The request is cancelled with a full refund to claimable when the price is
worse than acceptablePrice, the vault is paused, leverage is above the tier,
or a cap fails. See risk controls.
Two-block window
A request executes only in block N+1 or N+2. From block N+3, execute cancels
it instead, and anyone can call cancelExpired(id). Both refund in full. The
window is short so a requester cannot wait to see whether the price moves their
way before the fill.
Close
Request
The clone calls requestClose(closeSize, acceptablePrice) for all or part of
the position. It must wait MIN_HOLD_TIME (10 seconds) after opening, unless
the position is already liquidatable. A clone has at most one pending request.
Execute
execute settles at the mark, with the spread against the closer. Released
margin plus PnL, minus the trade fee and any accrued borrow fee, is credited to
claimable. A partial close that would leave less than $10 is cancelled.
Add margin
addMargin(amount) takes effect immediately. It first charges any accrued
borrow fee, and margin can never exceed entry notional, which is 1x leverage.
It works while the vault is paused.
Claim
claim() pays the clone the smaller of its claimable and the vault's free
USDC on HyperEVM, which is its balance minus open margin and locked collateral.
Whatever cannot be paid yet stays claimable until HyperCore USDC is bridged
back. A user sees a delay, not a loss.
| Action | Paused | Notes |
|---|---|---|
requestOpen | Blocked | A clone opens once; a cancelled open frees it to try again |
requestClose | Allowed | After MIN_HOLD_TIME, or sooner when liquidatable |
addMargin | Allowed | Up to entry notional |
claim | Allowed | Pays only USDC that does not back margin or locked collateral |
Closes, added margin, liquidations, and claims never fail because of a cap or a pause.
Continue with pricing and fees for what a trade costs, or the vault reference for exact signatures and errors.