Migrate from V2 to V3

This migration guide is intended for developers working with our smart contract. This document outlines the key changes between the current and upcoming versions, including function parameter renames,


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

    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():

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

For withdraw():

- 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.

- // 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:

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

Example for withdraw request check:

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

Last updated