Unstaking & Withdrawals

The unstaking process is a three-stage process:

  • user requests an exit or unstake (user tx)

  • exit request is processed and ETH is sourced to pay for the exit

  • user claims exited ETH (user tx)

When user request an exit, they burn their shares (receipt tokens in their wallet) in exchange for one or exit queue tickets.

These tickets have a status based on wether or not they can be claimed (user is able to claim their ETH), which depends on the liquidity provided to the exit queues by the vPools.

You can find more details about tickets and casks here.


How to initiate an unstake request

Used to request an exit (unstake) of any amount of ETH, up to the maximum user balance.

When initiating an exit, you must specify the quantity of integration tokens to exit. Subsequently, the integration contract will generate one or several tickets in the associated vPool exit queues.

This can only be executed by calling a smart contract method:

cast send $INTEGRATION_CONTRACT_ADDRESS "requestExit(uint256)" $AMOUNT_OF_TOKENS_TO_EXIT

Get the status of all exit queue tickets for a user

Used to retrieve all exit queue tickets for a user, providing the status of each ticket. This information enables you to inform the user about the availability of their exited ETH for claiming. Additionally, you have the option to permit users to claim a portion of their exit request if it is partially fulfilled, with the ability to claim the remainder once it becomes available.

Using The Graph

Query

{
  tickets(where:{owner:"0x8f025e74df96551a5437a50666d39709b0e044bd"}) {
    owner
    index
    ticketId 
    size
    maxExitable
    fulfillableAmount
    fulfillableBy(orderBy:createdAt,orderDirection:desc) {
      caskId
    }
    exitQueue {
      address
    }
  }
}

Example results

{
  "data": {
    "tickets": [
      {
        "owner": "0x8f025e74df96551a5437a50666d39709b0e044bd",
        "index": "0",
        "ticketId": "1",
        "size": "1",
        "maxExitable": "2",
        "fulfillableAmount": "0",
        "fulfillableBy": [],
        "exitQueue": {
          "address": "0x64f65a1e58dcb6d95b3843ab905c6dcc30ea0056"
        }
      },
      {
        "owner": "0x8f025e74df96551a5437a50666d39709b0e044bd",
        "index": "1",
        "ticketId": "340282366920938463463374607441766218638",
        "size": "9998007182",
        "maxExitable": "10017969686",
        "fulfillableAmount": "0",
        "fulfillableBy": [],
        "exitQueue": {
          "address": "0x64f65a1e58dcb6d95b3843ab905c6dcc30ea0056"
        }
      },
      {
        "owner": "0x8f025e74df96551a5437a50666d39709b0e044bd",
        "index": "2",
        "ticketId": "680564733841876926926749214873534353150",
        "size": "9997930238",
        "maxExitable": "10018663614",
        "fulfillableAmount": "0",
        "fulfillableBy": [],
        "exitQueue": {
          "address": "0x64f65a1e58dcb6d95b3843ab905c6dcc30ea0056"
        }
      }
    ]
  }
}

Here you will retrieve all the different exit tickets of an account.

  • ticketId is the id of the ticket, and also the id of the NFT representing this ticket

  • size is the size of the ticket in vPool Shares (not ETH !)

  • maxExitable is the maximum amount of eth that can be retrieved by the ticket. Shares locked inside tickets are not earning rewards anymore.

  • fulfillableAmount is the amount of vPool shares that are currently fulfillable

  • fulfillableBy is a list of casks that fulfill a ticket

  • exitQueue.address is the address of the exit queue contract where the ticket is held

To retrieve the status of the ticket, it's pretty simple:

  • unfulfillable when fulfillableAmount is 0

  • partially fulfillable when fulfillableAmount < size

  • fulfillable when fulfillableAmount = size

Claim tickets once their fulfillable

Used to claim the ETH of a user who has requested to exit the pool.


cast send $INTEGRATION_CONTRACT_ADDRESS \
    "multiClaim(address[],uint256[][],uint32[][])" \
    $ARRAY_OF_EXIT_QUEUE_ADDRESSES \
    $ARRAY_OF_ARRAYS_OF_TICKET_IDS \
    $ARRAY_OF_ARRAYS_OF_CASK_IDS

You can use TheGraph query above to retrieve all the required information. In the case where we would want to claim all the tickets from the example query above (assuming we would have a new cask with id 1 that fulfills all the tickets), the transaction would look like

You must pass only one cask ID per ticket, if the ticket is matched by more than one cask, pass the lowest cask id and the code will automatically claim on all the casks matching the ticket


cast send $INTEGRATION_CONTRACT_ADDRESS \
    "multiClaim(address[],uint256[][],uint32[][])" \
    "[0x64f65a1e58dcb6d95b3843ab905c6dcc30ea0056]" \
    "[[1,340282366920938463463374607441766218638,680564733841876926926749214873534353150]]" \
    "[[1,1,1]]"

Last updated