Skip to main content

Exit position

Create an exit action with POST /v1/actions/exit. The API returns ordered unsigned transactions, submitted the same way as an enter action.

When to use

  • Unstake tokens (for example, “Unstake my ETH from Lido”)
  • Withdraw from a lending market or vault
  • Remove liquidity
  • Leave a position entirely or partially

Authentication and host

Send the project API key in the x-api-key header.

Step 1: Check the yield allows exits

Confirm status.exit is true. Read mechanics.cooldownPeriod ({ seconds }) for any waiting period, and mechanics.arguments.exit.fields[] for the arguments.
Balance type values are active, entering, exiting, withdrawable, claimable, and locked. Exit from active balances.

Step 3: Create the exit action

POST /v1/actions/exit. yieldId and address are required. Pass the fields the exit schema lists.
amount is a human-readable decimal string. amountRaw is the smallest-unit alternative; send one, not both. Other arguments, when the schema lists them: Optionally call POST /v1/actions/exit/simulate first to estimate gas. The response is 201 with an ActionDto: id, intent: "exit", type, status, executionPattern, and transactions[].

Step 4: Sign and submit

Same as enter-position: process transactions[] in stepIndex order, sign each unsignedTransaction, then use one path per transaction.
  • POST /v1/transactions/{transactionId}/submit with { "signedTransaction": "..." } for yield.xyz to broadcast.
  • PUT /v1/transactions/{transactionId}/submit-hash with { "hash": "0x..." } if you broadcast.
executionPattern is synchronous or batch on current actions. asynchronous is also a declared value, but current actions return synchronous or batch.

Step 5: Cooldowns and claiming

Many staking yields hold funds through a cooldown after the exit. The exiting amount shows as an exiting balance, then a withdrawable balance when it is ready. Claim it with manage-position using the pending action on that balance (for example CLAIM_UNSTAKED or WITHDRAW). Cooldown length is yield-specific: read mechanics.cooldownPeriod. Track the action with GET /v1/actions/{actionId} until SUCCESS, FAILED, or CANCELED.

Errors

Edge cases

  • Partial exits: Most yields accept an exact amount. Check the exit schema.
  • Existing cooldowns: Some protocols allow further unstake requests during a cooldown; others do not. Read the exiting balances first.
  • Vault shares: Vault exits convert shares at the current price per share, which can differ from the deposit amount.
  • Closed exits: If status.exit is false, do not create the action.