# GP 20: Migrate BOB pool to USDC on Optimism

{% hint style="success" %}
The proposal was confirmed and executed.&#x20;

* Optimism Safe Transactions [#16](https://app.safe.global/transactions/tx?safe=oeth:0x14fc6a1a996A2EB889cF86e5c8cD17323bC85290\&id=multisig_0x14fc6a1a996A2EB889cF86e5c8cD17323bC85290_0xb5625c2a40311a5a3a727b1a1f81202465f7f3dbcb13ffb41f5398d924d7c6a9) and [#17](https://app.safe.global/transactions/tx?safe=oeth:0x14fc6a1a996A2EB889cF86e5c8cD17323bC85290\&id=multisig_0x14fc6a1a996A2EB889cF86e5c8cD17323bC85290_0x7f9f061bc17ba96faa79ee40a44ab31f693470384c9b1c2985a874dc1370c997)
* Optimism txs:&#x20;
  * 16: [https://optimism.blockscout.com/tx/0xf8734380296530c69571251fce0f61451a165e166f4205e967801e7fa86de4f0](https://optimism.blockscout.com/tx/0xf8734380296530c69571251fce0f61451a165e166f4205e967801e7fa86de4f0?tab=index)
  * 17: <https://optimism.blockscout.com/tx/0xc87ce1f36ecff741d76f921f09fed979f9ab0520acc6d30afe2a5964920ec77b>
    {% endhint %}

## Proposal objective

Following the successful transition from BOB to USDC on Polygon, this proposal replaces the underlying token from BOB to [USDC](https://optimistic.etherscan.io/token/0x7f5c764cbc14f9669b88837ca1490cca17c31607) for the zkBob pool on Optimism.

The migration replaces the zkBob pool implementation to the new contract [`0x8f4127D3131789a9e2f7380AF903F643d0ae721C`](https://optimistic.etherscan.io/address/0x8f4127D3131789a9e2f7380AF903F643d0ae721C#code) and the Direct Deposit Queue implementation to [`0x9bf586ceB3F3C1bebBE8b0262c2AE7D0952ce3B1`](https://optimistic.etherscan.io/address/0x9bf586ceB3F3C1bebBE8b0262c2AE7D0952ce3B1#code). To allow further swaps of USDC to ETH as part of withdrawals, the Token Seller contract is replaced by [`0x48CE9dAb591d737F2fa8955c6283CbcA84A86544`](https://optimistic.etherscan.io/address/0x48CE9dAb591d737F2fa8955c6283CbcA84A86544#code).

During proposal execution all BOB owned by the zkBob pool contract is swapped to USDC using UniswapV3. The amount of BOB tokens paid as fees on Uniswap will be reimbursed with the corresponding amount of USDC from the Governance Safe account. The logic of the tokens swap is defined in the [migrationToUSDC()](https://github.com/zkBob/zkbob-contracts/blob/6a004c154efb4fc18503033647ce0768c5ff2a8c/src/zkbob/ZkBobPoolUSDCMigrated.sol#L34-L54) pool method.

## Proposal breakdown

To avoid undesirable interactions with the zkBob pool prior to the migration the proposal consists of two steps:

**Step 1: Disable direct deposits**

Transaction [#16](https://app.safe.global/transactions/tx?safe=oeth:0x14fc6a1a996A2EB889cF86e5c8cD17323bC85290\&id=multisig_0x14fc6a1a996A2EB889cF86e5c8cD17323bC85290_0xb5625c2a40311a5a3a727b1a1f81202465f7f3dbcb13ffb41f5398d924d7c6a9) in the Safe on Optimism contains two `setLimits` calls to disallow users to transfer tokens directly to the pool by setting limits for tier 0 and 1 to zero for direct deposits. New interim limits are:

| Tier           | Single deposit | Daily user deposit | Daily deposit | Daily withdrawal | Pool size      | Single DD | Daily user DD |
| -------------- | -------------- | ------------------ | ------------- | ---------------- | -------------- | --------- | ------------- |
| Default, id 0  | 10,000 BOB     | 10,000 BOB         | 300,000 BOB   | 300,000 BOB      | 10,000,000 BOB | 0 BOB     | 0 BOB         |
| Partners, id 1 | 100,000 BOB    | 100,000 BOB        | 300,000 BOB   | 300,000 BOB      | 10,000,000 BOB | 0 BOB     | 0 BOB         |

This step is executed 20 minutes prior to step 2.

**Step 2: Migrate the pool from BOB to USDC**

Transaction [#17](https://app.safe.global/transactions/tx?safe=oeth:0x14fc6a1a996A2EB889cF86e5c8cD17323bC85290\&id=multisig_0x14fc6a1a996A2EB889cF86e5c8cD17323bC85290_0x7f9f061bc17ba96faa79ee40a44ab31f693470384c9b1c2985a874dc1370c997) in the Safe executes the following calls:

* Increase allowance of the pool contract [`0x1CA8C2B9B20E18e86d5b9a72370fC6c91814c97C`](https://www.notion.so/44-Migration-BOB-pool-on-Optimism-to-USDC-05f5dbae4aa4457f9738cb5b233329b1?pvs=21) to transfer USDC from Governance Safe by `approve` made to the USDC token contract [`0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85`](https://optimistic.etherscan.io/address/0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85).
* Upgrade the pool implementation with the  `upgradeToAndCall` method. The method `migrationToUSDC()` (selector `c4a688b8`) is invoked after the upgrade.
* Remove allowance of the pool contract to transfer USDC from the Governance Safe by `approve` made to the USDC token contract [`0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85`](https://optimistic.etherscan.io/address/0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85).
* Upgrade the implementation of the direct deposit queue [`0x15B8C75c024acba8c114C21F42eb515A762c0014`](https://optimistic.etherscan.io/address/0x15B8C75c024acba8c114C21F42eb515A762c0014) by `upgradeTo` .
* Configure new Token Seller contract on the pool by `setTokenSeller`.
* The remaining two calls invoke `setLimits` for tier 0 and 1 users. The reinstated limits are:

| Tier           | Single deposit | Daily user deposit | Daily deposit | Daily withdrawal | Pool size       | Single DD  | Daily user DD |
| -------------- | -------------- | ------------------ | ------------- | ---------------- | --------------- | ---------- | ------------- |
| Default, id 0  | 10,000 USDC    | 10,000 USDC        | 300,000 USDC  | 300,000 USDC     | 10,000,000 USDC | 1,000 USDC | 10,000 USDC   |
| Partners, id 1 | 100,000 USDC   | 100,000 USDC       | 300,000 USDC  | 300,000 USDC     | 10,000,000 USDC | 1,000 USDC | 10,000 USDC   |

## Additional verification

The migration procedure has been verified by using [the following Foundry-script](https://github.com/zkBob/zkbob-contracts/blob/6a004c154efb4fc18503033647ce0768c5ff2a8c/script/scripts/BOBPoolMigration.s.sol).

To check the safe contract execution run the following script: <https://gist.github.com/akolotov/9e70b43a75426c8276c061d9176b0968>

1. `forge test --match-path ./script/scripts/VerifySafeTx_Gov44.t.sol --ffi -vvvv`
2. Make sure `jq` CLI is installed
