# Manually Withdraw

## Introduction

If you don't have access to the Gamma Web Application, there are ways to withdraw your funds from the protocol. This guide will review ways to withdraw your assets if you don't have access. This includes withdrawing from LP incentives, any vault, or the GAMMA staking contract.&#x20;

We'll use block explorers like Etherscan to do this action. Make sure you use the proper explorer for the network you have your assets on.

{% content-ref url="research" %}
[research](https://docs.gamma.xyz/gamma/lp-vaults/troubleshooting-help/research)
{% endcontent-ref %}

## Withdraw from Incentives

### 1) Choose an incentive contract

A link to the proper incentive contract is in the incentives section on each incentivized vault page.&#x20;

<figure><img src="https://1445436235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWyc-TFyZIzH7aDRnpp%2Fuploads%2Fa7tA43tZeh8NuCJGSiZc%2Fedit1.png?alt=media&#x26;token=a2f806b5-5dae-4919-93d1-fcdbf828895c" alt=""><figcaption></figcaption></figure>

If you can't access this, navigate to the [**Contracts / Wallets**](https://docs.gamma.xyz/gamma/learn/scans) page and scroll down to the **Infrastructure Contracts** section. There, you'll find our incentive contracts (Masterchef) listed. Find the one that applies to your funds. Ask us for assistance if you do not know which one it is.

{% embed url="<https://docs.gamma.xyz/gamma/learn/scans#incentive-contracts-masterchef>" %}

### 2) Query the PID

You'll need to get the PID number of the vault you want to withdraw from. The PID is a number that ties the vault to the incentive contract. You can query the PID manually below.&#x20;

**First, make sure you know the vault contract address.**  In this example, we're looking for the OP-USDC Narrow vault: 0x2102bef0d9727ea50ba844e7658e38480961835c.

Under "Read Contract" go to Section "3. lptoken".&#x20;

<figure><img src="https://1445436235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWyc-TFyZIzH7aDRnpp%2Fuploads%2FLf3md8AO4qrGX9BsIfqw%2Fquery0.png?alt=media&#x26;token=ceae2e3a-d2ce-47c9-84bb-7b1c47bdbfab" alt=""><figcaption></figcaption></figure>

In the first box "\<input> (uint256)", type in a number from 0 - ∞. Starting from 0.

**Press "Query".**

This action will give you the vault address. The correct number used to query it is the PID. Repeat this query until you find the correct address. In this case, "5".

<mark style="color:red;">**Copy down the number in the red box.**</mark>

<figure><img src="https://1445436235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWyc-TFyZIzH7aDRnpp%2Fuploads%2F3kMIapiYPBbZTyqIDidA%2Fquery5.png?alt=media&#x26;token=be311f0b-f766-4db5-8c22-72e4b429896c" alt=""><figcaption></figcaption></figure>

### 3) Query the amount&#x20;

Under "Read Contract" go to Section "11. userInfo".&#x20;

<figure><img src="https://1445436235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWyc-TFyZIzH7aDRnpp%2Fuploads%2FtoTfwJLCru6xjmNx5gRJ%2Fread%20contract.png?alt=media&#x26;token=1d88957c-3e89-4666-a404-95c8741cf60f" alt=""><figcaption></figcaption></figure>

In the first box "\<input> (uint256)", type in the **PID number** corresponding to the vault you deposited in.

In the second box "\<input> (address)", type your **deposit address**.&#x20;

**Press "Query".**

This action will give you the **amount** you deposited (in wei).&#x20;

<mark style="color:red;">**Copy down the number in the red box.**</mark>&#x20;

<figure><img src="https://1445436235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWyc-TFyZIzH7aDRnpp%2Fuploads%2FG9kRFvfa2adNs8yjd5I5%2Fquery.png?alt=media&#x26;token=efa2591d-b96c-4a00-b50a-5800ec7eac7b" alt=""><figcaption></figcaption></figure>

### 4) Connect your wallet

On "Write Contract", connect the wallet you used to stake the LP tokens.

<figure><img src="https://1445436235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWyc-TFyZIzH7aDRnpp%2Fuploads%2FwQJp1IsZ86XBWDlmppjO%2Fwrite%20contract.png?alt=media&#x26;token=f69ae9a1-3225-44c6-9cd3-9e1c0c1c093c" alt=""><figcaption></figcaption></figure>

### 5) Write the transaction

Under "Write Contract" go to Section " 15. withdraw" or "16. withdrawAndHarvest" (they do the same thing).

<figure><img src="https://1445436235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWyc-TFyZIzH7aDRnpp%2Fuploads%2FphQt8WHSkX5X3U6Ro1EJ%2Fwrite%20contract.png?alt=media&#x26;token=bfc2633c-b466-4d2a-b109-8cda539096dc" alt=""><figcaption></figcaption></figure>

In the first box "pid (uint256)", type in the **PID number** corresponding to the vault you deposited in.

In the second box "amount (uint256)", type in the **amount** you queried in step three.&#x20;

In the third box "to (address)", type your **deposit address**.&#x20;

**Press "Write".**

<figure><img src="https://1445436235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWyc-TFyZIzH7aDRnpp%2Fuploads%2FhnQW2y8mwtTPb1AEUTQh%2Fwrite.png?alt=media&#x26;token=d9e36b70-eac7-4468-940f-f846e6ae121b" alt=""><figcaption></figcaption></figure>

### 6) Verify the  transaction

After completing the transaction, click "View your transaction" to verify everything went through. This action will **withdraw your LP tokens and incentives** from the incentive contract.

You're all done!

## Withdraw from Vaults

### 1) Choose a vault

Usually, there is a link to the vault contract in the main and withdraw sections on each vault detail page.&#x20;

<figure><img src="https://1445436235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWyc-TFyZIzH7aDRnpp%2Fuploads%2FWQRnmEeVq28zp2C0COnf%2Fvault1.png?alt=media&#x26;token=9e0164f2-55cc-44f6-b3dc-8d20bc77fdf3" alt=""><figcaption></figcaption></figure>

If you can't access this, navigate to the[ vault repo](https://docs.google.com/spreadsheets/d/1l278_oVXpbM046WqmO73AaP7wWcRTD5tY8jBbLqbqRs/edit?usp=sharing). There, you'll find our vault contracts listed. Find the one that applies to your funds. Ask us for assistance if you do not know which one it is.

### 2) Query the shares

You'll need to get the amount of LP tokens (shares) of the vault you want to withdraw from. This number is 10^18 \* your LP token value. Confusing! Let's do a contract query and get the right number.&#x20;

Under "Read Contract" go to Section "4. balanceof".&#x20;

<figure><img src="https://1445436235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWyc-TFyZIzH7aDRnpp%2Fuploads%2Fzdw5f89AsP8YcfowVJpf%2Fvault2.png?alt=media&#x26;token=1a36e588-5404-4961-9459-1f3abc379a20" alt=""><figcaption></figcaption></figure>

In the first box, "account (address)", type in the wallet address that holds your LP tokens or the address you deposited funds from.&#x20;

**Press "Query".**

This action will give you "shares" or the amount of LP tokens in the correct format.

<mark style="color:red;">**Copy down the number in the red box.**</mark>

<figure><img src="https://1445436235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWyc-TFyZIzH7aDRnpp%2Fuploads%2FwLX2m3xGMmYULxpSdeqS%2Fvault3.png?alt=media&#x26;token=50eac5f0-8197-4c84-a514-1ca636cd7759" alt=""><figcaption></figcaption></figure>

### 3) Connect your wallet

On "Write Contract", connect the wallet you used to deposit your assets into a vault

<figure><img src="https://1445436235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWyc-TFyZIzH7aDRnpp%2Fuploads%2FxAtPwbJxO0awNzSnVrFs%2Fconnect.png?alt=media&#x26;token=4c8d2006-2f2f-4873-9e65-631639e07eeb" alt=""><figcaption></figcaption></figure>

### 4) Write the transaction

Under "Write Contract" go to Section "18. withdraw"

<figure><img src="https://1445436235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWyc-TFyZIzH7aDRnpp%2Fuploads%2FdZmWqPwpGYCqG59DZCod%2Fvault4.png?alt=media&#x26;token=ac9e449e-ab5d-4f68-8877-c44b249f72b3" alt=""><figcaption></figcaption></figure>

In the first box "shares (uint256)", type in the **shares** number you queried in step two. This is the number of your LP tokens \* 10^18.

In the second box "to (address)", type in your **deposit address.**

In the third box "from (address)", type in your **deposit address**&#x20;

{% hint style="info" %}
Boxes two and three are the same address
{% endhint %}

In the fourth box "minAmounts (uint256\[4])", type in **\[0,0,0,0]**.

**Press "Write".**

<figure><img src="https://1445436235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWyc-TFyZIzH7aDRnpp%2Fuploads%2F3tMlmrbfQmLnpMdt3ANH%2Fvault5.png?alt=media&#x26;token=8bbe8398-f9b1-4e72-ba34-c11dbb5897d7" alt=""><figcaption></figcaption></figure>

### 5) Verify the transaction

After completing the transaction, click "View your transaction" to verify everything went through. This action will **dissolve your LP tokens and withdraw your assets** from the vault.

You're all done!

## Withdraw from V1 NFT Vaults

### 1) Choose a vault

Navigate to the [**Vault Repository**](https://docs.google.com/spreadsheets/d/1l278_oVXpbM046WqmO73AaP7wWcRTD5tY8jBbLqbqRs/edit?usp=sharing). There, you'll find our **V1 NFT vault contracts** listed. Find the one that applies to your funds. Ask us for assistance if you do not know which one it is.

{% hint style="info" %}
For your withdrawal to work, you **must** have your NFT in the wallet that you deposited with.
{% endhint %}

### 2) Query the shares

You'll need to get the amount of LP tokens (shares) of the vault you want to withdraw from. This number is 10^18 \* your LP token value. Confusing! Let's do a contract query and get the right number.&#x20;

Under "Read Contract" go to Section "3. balanceof".&#x20;

<figure><img src="https://1445436235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWyc-TFyZIzH7aDRnpp%2Fuploads%2FB9j1RslOReH52WiiwdIN%2Fnftwithdraw1.png?alt=media&#x26;token=f1d12fec-9ea1-4e53-a084-59076e047f9f" alt=""><figcaption></figcaption></figure>

In the first box, "account (address)", type in the wallet address that holds your LP tokens or the address you deposited funds from.&#x20;

**Press "Query".**

This action will give you "shares" or the amount of LP tokens in the correct format.

<mark style="color:red;">**Copy down the number in the red box.**</mark>

<figure><img src="https://1445436235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWyc-TFyZIzH7aDRnpp%2Fuploads%2FIq830y8p3YJt7q2Ua3qC%2Fvault3.png?alt=media&#x26;token=04b643ff-d0fb-4083-afab-a08488ca106c" alt=""><figcaption></figcaption></figure>

### 3) Connect your wallet

On "Write Contract", connect the wallet you used to deposit your assets into a vault

<figure><img src="https://1445436235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWyc-TFyZIzH7aDRnpp%2Fuploads%2FY8kEMFh72gNrrvQrK1TR%2Fnftwithdraw2.png?alt=media&#x26;token=5d9a3f2e-2583-4f49-bc6d-56cce624ce23" alt=""><figcaption></figcaption></figure>

### 4) Write the transaction

Under "Write Contract" go to Section "17. withdraw"

<figure><img src="https://1445436235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWyc-TFyZIzH7aDRnpp%2Fuploads%2F6j9gyxHyh87UNNI1aqKm%2Fnftwithdraw3.png?alt=media&#x26;token=0099f3e0-4073-451a-9069-befdefd553c6" alt=""><figcaption></figcaption></figure>

In the first box "shares (uint256)", type in the **shares** number you queried in step two. This is the number of your LP tokens \* 10^18.

In the second box "to (address)", type in your **deposit address.**

In the third box "from (address)", type in your **deposit address**&#x20;

{% hint style="info" %}
Boxes two and three are the same address
{% endhint %}

**Press "Write".**

<figure><img src="https://1445436235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWyc-TFyZIzH7aDRnpp%2Fuploads%2FuoaKfDvTpb2ixYVl0boU%2Fnftwithdraw4.png?alt=media&#x26;token=f2fd3d59-9747-4dd4-a283-31321c322680" alt=""><figcaption></figcaption></figure>

### 5) Verify the transaction

After completing the transaction, click "View your transaction" to verify everything went through. This action will **dissolve your LP tokens and withdraw your assets** from the vault.

You're all done!

## Withdraw staked GAMMA

### 1) Choose the staking contract

Navigate to the [**GAMMA staking contract**](https://etherscan.io/address/0x26805021988f1a45dc708b5fb75fc75f21747d8c#code).

{% embed url="<https://etherscan.io/address/0x26805021988f1a45dc708b5fb75fc75f21747d8c#code>" %}

### 2) Query the share

You'll need to get the amount of xGAMMA in the staking contract that you want to withdraw. This number is 10^18 \* your xGAMMA. Confusing! Let's do a contract query and get the right number.&#x20;

Under "Read Contract" go to Section "2. balanceOf".&#x20;

<figure><img src="https://1445436235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWyc-TFyZIzH7aDRnpp%2Fuploads%2FSqBDQL9cCeeFYBbOFTFh%2Fstake1.png?alt=media&#x26;token=ebae3b1e-ed92-4de6-8a4e-32280d842266" alt=""><figcaption></figcaption></figure>

In the first box, "account (address)", type in the wallet address that holds your xGAMMA or the address you deposited funds from.&#x20;

**Press "Query".**

This action will give you "share" or the amount of xGAMMA in the correct format. In this example, about 27.59 xGAMMA is in the wallet.&#x20;

<mark style="color:red;">**Copy down the number in the red box.**</mark>

<figure><img src="https://1445436235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWyc-TFyZIzH7aDRnpp%2Fuploads%2F3MyS1OlqzcIQMUNiKzhz%2Fstake2.png?alt=media&#x26;token=74d2972b-d8fd-451d-87f9-d439c845deac" alt=""><figcaption></figcaption></figure>

### 3) Connect your wallet

On "Write Contract", connect the wallet you used to deposit your GAMMA.

<figure><img src="https://1445436235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWyc-TFyZIzH7aDRnpp%2Fuploads%2FDSTJlQfRwdspIxWcIH0w%2Fconnectstake.png?alt=media&#x26;token=86a20c9a-a15d-49d2-9811-f95e331fcc2e" alt=""><figcaption></figcaption></figure>

### 4) Write the transaction

Under "Write Contract" go to Section "5. leave"

<figure><img src="https://1445436235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWyc-TFyZIzH7aDRnpp%2Fuploads%2FBRHv9V1g49yCahMkKEhI%2Fstake3.png?alt=media&#x26;token=d0eddb2c-d547-42ba-b444-4b267c04db8c" alt=""><figcaption></figcaption></figure>

In the first box "\_share (uint256)", type in the **share** number you queried in step two. This is the number of your xGAMMA tokens \* 10^18.

**Press "Write".**

<figure><img src="https://1445436235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWyc-TFyZIzH7aDRnpp%2Fuploads%2FghWns8JppnhqG5hhKgbj%2Fstake4.png?alt=media&#x26;token=78c2ffea-6e86-40f8-af01-4bf47330e7f1" alt=""><figcaption></figcaption></figure>

### 5) Verify the transaction

After completing the transaction, click "View your transaction" to verify everything went through. This action will **unstake your GAMMA** from the staking contract.

You're all done!
