- No
amount— close always sells the wallet’s full holding of the basket’s tokens. It is balance-driven: whatever of the basket the wallet holds gets closed, exactly whatpositions.getPositionreports. There is no partial close. - The prepare call is
close.prepare/ the one-call helper isclose.execute.
One-call flow (you hold the keypair)
signTransactions implementation with @solana/web3.js.
Split flow (browser wallet signs)
1
Backend: prepare
prepared.transactions to the browser immediately — the set expires ~60 seconds
after prepare.2
Browser: the user signs
Sign the transactions as-is — any modified byte is rejected at submit. Same signing
code as the open flow.
3
Backend: submit and wait
Method reference
close.prepare(params)
Solana address of the wallet closing the position.
Basket to close, by slug (a product id also works).
{ executionId, transactions, expiresAt }.
positions.submit, getExecution, and waitForExecution are shared with the open flow —
see the method reference there.
Results, errors, and security
Terminal statuses (COMPLETED, PARTIALLY_COMPLETED, FAILED), partial-completion
semantics, the common-error table, and the security model are identical to opening — see
Open a Position. Two close-specific notes:
- A wallet with no holdings of the basket has nothing to sell — check
positions.getPosition(...).hasPositionbefore preparing a close. - A
PARTIALLY_COMPLETEDclose means some legs sold and some didn’t; the remaining holdings are still in the wallet and a freshclose.preparewill target exactly what’s left.