> For the complete documentation index, see [llms.txt](https://docs.xy.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.xy.finance/single-bridge-integration/ybridge-contract-integration/integrate-ybridgevault-contract/migrate-from-v2-to-v3.md).

# Migrate from V2 to V3

## Overview

### Function Parameter Renaming

The `deposit` and `withdraw` functions have had their parameter names updated to better represent their purpose. The interfaces for these functions remain the same; only the parameter names have changed.

* `function deposit(uint256 amount)` has been changed to

  `function deposit(uint256 vaultTokenAmount)`
* `function withdraw(uint256 xyWrappedTokenAmount)` has been changed to&#x20;

  `function withdraw(uint256 shareAmount)`

### Deprecated State Variables

The following state variables are deprecated and will no longer be used to calculate remaining liquidity:

* `uint256 public closeSwapGasFees`
* `uint256 public depositAndWithdrawFees`

### New State Variables and Mappings

New state variables and mappings have been added to provide more detailed control and tracking:

* `bool public acceptDepositRequest` indicates if the contract currently accepts deposit requests.
* `bool public acceptWithdrawRequest` indicates if the contract currently accepts withdraw requests.
* `mapping (uint256 => bool) public isDepositCompleted` tracks the completion status of deposit requests by their ID.
* `mapping (uint256 => bool) public isWithdrawCompleted` tracks the completion status of withdraw requests by their ID.

***

## Migration Steps

### Updating Function Calls

Review and update all instances where `deposit()` and `withdraw()` functions are called with the new parameter names:

For `deposit()`:

```diff
- contract.deposit(amount);
+ contract.deposit(vaultTokenAmount);
```

For `withdraw()`:

```diff
- contract.withdraw(xyWrappedTokenAmount);
+ contract.withdraw(shareAmount);
```

### Handling Deprecated Variables

Remove or refactor any code segments that reference `closeSwapGasFees` and `depositAndWithdrawFees`. Determine alternative methods to calculate liquidity, if necessary.

```diff
- // Deprecated: The following variables are no longer supported
- uint256 gasFees = contract.closeSwapGasFees;
- uint256 fees = contract.depositAndWithdrawFees;
+ // Implement new logic for liquidity calculation here
```

### Incorporating New Variables

Incorporate logic to handle the new state variables and mappings according to your contract's requirements. Ensure that you check the acceptance of deposit and withdraw requests before proceeding with the operations. Also, verify the completion status of requests using the new mappings.

Example for deposit request check:

```solidity
solidityCopy coderequire(contract.acceptDepositRequest, "Deposit requests are currently not accepted.");
```

Example for withdraw request check:

```solidity
solidityCopy coderequire(contract.acceptWithdrawRequest, "Withdraw requests are currently not accepted.");
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.xy.finance/single-bridge-integration/ybridge-contract-integration/integrate-ybridgevault-contract/migrate-from-v2-to-v3.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
