# Withdrawing from v2 Isolated Margin using Optimistic Etherscan

Kwenta v2 Isolated Margin has been deprecated with the release of Smart Margin v2. Users who did not withdraw before Isolated Margin was deprecated may still withdraw from the contracts using the Optimistic Etherscan interface.

### 1. Register on Optimistic Etherscan

To get started, please ensure you have registered for an Optimistic Etherscan account. It's free, and is required to use custom contract interactions.

{% embed url="<https://optimistic.etherscan.io/register>" %}
An Optimistic Etherscan account is required to use a custom ABI.&#x20;
{% endembed %}

<figure><img src="https://2231722757-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MigG4JjHTDtxrb2SknW%2Fuploads%2F2pl0JWqtNJTrwjOyLfud%2FScreen%20Shot%202024-02-16%20at%2011.02.33%20PM.png?alt=media&#x26;token=0943b715-6d45-4998-9c93-4eb8325899d7" alt=""><figcaption></figcaption></figure>

### 2. Locate Your Deposit

Each market has its own a unique proxy contract address. If you know the contract address, simply navigate to the contract on Optimistic Etherscan.

> **Note:** Most users will find their deposit in the ETH market proxy contract:\
> <https://optimistic.etherscan.io/address/0x2B3bb4c683BFc5239B029131EEf3B1d214478d93>

If you don't know the contract address, you find it in the Synthetix Github. You can search for the correct address by searching the page for `PerpsV2ProxyETHPERP`. If you were trading another market, you'll need to replace the ticker in your search (for example, `PerpsV2Proxy1INCHPERP` if you were trading 1inch.

Ensure you've located the mainnet address (this should be the first result in your search), and follow the link directly to the contract on Optimistic Etherscan.

{% embed url="<https://github.com/Synthetixio/synthetix-docs/blob/master/content/addresses.md>" %}
Some proxy contracts are mislabeled on Etherscan. Follow the link directly from the Synthetix Github to locate the correct contract.
{% endembed %}

<figure><img src="https://2231722757-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MigG4JjHTDtxrb2SknW%2Fuploads%2F7rRkF7VBfPkg1Qh9N70f%2FScreen%20Shot%202024-02-17%20at%201.01.18%20AM.png?alt=media&#x26;token=abf490b3-b6db-4ab1-bdb5-fb249f2bf161" alt=""><figcaption><p>Search for your market proxy contract</p></figcaption></figure>

### 3. Locate the Custom Contract ABI

The contract code should list a Custom Contract ABI. To speed up the process, the `Custom Contract ABI` for all contracts has been copied below. \
\
Simply copy the text in the Custom ABI box below to your clipboard for use in the next step:

{% code title="Custom ABI" %}

```markup
[{"inputs":[{"internalType":"address payable","name":"_proxy","type":"address"},{"internalType":"address","name":"_marketState","type":"address"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_resolver","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"name","type":"bytes32"},{"indexed":false,"internalType":"address","name":"destination","type":"address"}],"name":"CacheUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"int256","name":"funding","type":"int256"},{"indexed":false,"internalType":"int256","name":"fundingRate","type":"int256"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"FundingRecomputed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"int256","name":"marginDelta","type":"int256"}],"name":"MarginTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerNominated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"trackingCode","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"baseAsset","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"marketKey","type":"bytes32"},{"indexed":false,"internalType":"int256","name":"sizeDelta","type":"int256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"PerpsTracking","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"margin","type":"uint256"},{"indexed":false,"internalType":"int256","name":"size","type":"int256"},{"indexed":false,"internalType":"int256","name":"tradeSize","type":"int256"},{"indexed":false,"internalType":"uint256","name":"lastPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fundingIndex","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"},{"indexed":false,"internalType":"int256","name":"skew","type":"int256"}],"name":"PositionModified","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"proxyAddress","type":"address"}],"name":"ProxyUpdated","type":"event"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"desiredFillPrice","type":"uint256"}],"name":"closePosition","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"desiredFillPrice","type":"uint256"},{"internalType":"bytes32","name":"trackingCode","type":"bytes32"}],"name":"closePositionWithTracking","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"isResolverCached","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"marketState","outputs":[{"internalType":"contract IPerpsV2MarketState","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"messageSender","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"int256","name":"sizeDelta","type":"int256"},{"internalType":"uint256","name":"desiredFillPrice","type":"uint256"}],"name":"modifyPosition","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"int256","name":"sizeDelta","type":"int256"},{"internalType":"uint256","name":"desiredFillPrice","type":"uint256"},{"internalType":"bytes32","name":"trackingCode","type":"bytes32"}],"name":"modifyPositionWithTracking","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"nominateNewOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"nominatedOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"proxy","outputs":[{"internalType":"contract Proxy","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"rebuildCache","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"recomputeFunding","outputs":[{"internalType":"uint256","name":"lastIndex","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"resolver","outputs":[{"internalType":"contract AddressResolver","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"resolverAddressesRequired","outputs":[{"internalType":"bytes32[]","name":"addresses","type":"bytes32[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"setMessageSender","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address payable","name":"_proxy","type":"address"}],"name":"setProxy","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"int256","name":"marginDelta","type":"int256"}],"name":"transferMargin","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"withdrawAllMargin","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]
```

{% endcode %}

<figure><img src="https://2231722757-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MigG4JjHTDtxrb2SknW%2Fuploads%2FSLfLdWcwAqUKovdmjpd4%2FScreen%20Shot%202024-02-17%20at%201.12.20%20AM.png?alt=media&#x26;token=e36021fe-2a52-4ebb-a961-871601281451" alt=""><figcaption><p>You'll copy and paste this data in the next step</p></figcaption></figure>

### 4. Add Custom ABI to Optimistic Etherscan

Using the data found on this contract page, we'll add a custom ABI to Optimistic Etherscan. This allows us to withdraw from the contract. You'll need to be logged in to complete this step.

{% embed url="<https://optimistic.etherscan.io/mycustomabi>" %}
A custom ABI can be added here
{% endembed %}

Click `+Add` to add your Custom Contract ABI, and enter the following information:

* **Name:** Enter a name to identify the contract. Any name may be entered.&#x20;
* **Address:** Copy the proxy contract address from the previous step, and paste it in this field
* **Custom ABI:** `Copy the Custom Contract ABI`to this field

<figure><img src="https://2231722757-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MigG4JjHTDtxrb2SknW%2Fuploads%2FuUaTqWDQffWk5grH7qLQ%2FScreen%20Shot%202024-02-17%20at%201.23.35%20AM.png?alt=media&#x26;token=8df5a29e-7cef-43c6-8c55-c2846c0967c4" alt=""><figcaption><p>Cut and paste the data to ensure accuracy</p></figcaption></figure>

### 5. Withdraw Margin

1. Navigate to the contract page and select **Connect to Web3** to connect your wallet.
2. Once connected, select **Write Custom** at the top of the page.
3. If the ABI was added correctly, you'll have access to the withdraw function. For the ETH market, this can be done at <https://optimistic.etherscan.io/address/0x2B3bb4c683BFc5239B029131EEf3B1d214478d93#writeCustomContract>.
4. Find the function **12. withdrawAllMargin** at the bottom of the page and select **Write** to withdraw all margin.

<figure><img src="https://2231722757-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MigG4JjHTDtxrb2SknW%2Fuploads%2FvkOgAK2KaW8z9uRGA3KG%2FScreen%20Shot%202024-02-17%20at%201.25.12%20AM.png?alt=media&#x26;token=b968d8cf-ac22-4fe4-9b0c-32398d806c9c" alt=""><figcaption><p>Ensue your wallet is connected and Write the function, 12. withdrawAllMargin</p></figcaption></figure>

These steps will guide you through withdrawing your funds from the deprecated Isolated Margin contracts using the Optimistic Etherscan interface. If you need additional assistance please open a ticket in [Discord. ](https://discord.gg/kwentaio)
