# Migration from v2 to v4

### Deployed contracts

#### Base

<table><thead><tr><th width="283.109375">Name</th><th>Address</th></tr></thead><tbody><tr><td><code>BuildersV4 (impl)</code> </td><td><a href="https://basescan.org/address/0x18FAEf315b40A6D9cf49628f1133B1Aa507513B0">0x18FAEf315b40A6D9cf49628f1133B1Aa507513B0</a></td></tr><tr><td><code>BuildersTreasuryV2 (impl)</code> </td><td><a href="https://basescan.org/address/0xe71eB0b69bbD4207e2cB10DF929d1311D2ad57e5">0xe71eB0b69bbD4207e2cB10DF929d1311D2ad57e5</a></td></tr><tr><td><code>RewardPool</code></td><td><a href="https://basescan.org/address/0xDC99a8596e395E52aba2BD08C623E1e428Dc3980">0xDC99a8596e395E52aba2BD08C623E1e428Dc3980</a></td></tr></tbody></table>

#### Arbitrum

<table><thead><tr><th width="283.109375">Name</th><th>Address</th></tr></thead><tbody><tr><td><code>BuildersV4 (impl)</code> </td><td><a href="https://arbiscan.io/address/0x6cCE082851Add4c535352f596662521B4De4750E">0x6cCE082851Add4c535352f596662521B4De4750E</a></td></tr><tr><td><code>BuildersTreasuryV2 (impl)</code> </td><td><a href="https://arbiscan.io/address/0x031075f7A853E8d4BF0B525466A78374aFAA9308">0x031075f7A853E8d4BF0B525466A78374aFAA9308</a></td></tr><tr><td><code>RewardPool</code></td><td><a href="https://arbiscan.io/address/0x281bc6F84952Abe53F6921dcD76c879d3C4b6375">0x281bc6F84952Abe53F6921dcD76c879d3C4b6375</a></td></tr></tbody></table>

### Upgrade the `BuildersTreasury` to `BuildersTreasuryV2`

Use the UUPS upgrade pattern to update the `BuildersTreasury` proxy contract to the new `BuildersTreasuryV2` implementation with `upgradeTo()` function. Once upgraded, perform the necessary configuration steps below.

See the `BuildersTreasuryV2 (impl)` address on the deployed section.

### Upgrade the `BuildersV2` to `BuildersV4`

Use the UUPS upgrade pattern to update the `BuildersV2` proxy contract to the new `BuildersV4` implementation with `upgradeTo()` function. Once upgraded, perform the necessary configuration steps below.

See the `BuildersV4 (impl)` address on the deployed section.

### Set the `RewardPool` address

Call `setRewardPool()` on the `BuildersV4` contract to assign the newly deployed `RewardPool` contract.

See the `RewardPool` address on the deployed section.

### Set the `networkShare`

Call `setNetworkShare()` to configure the percentage of MOR rewards that should be distributed to Subnets. This value is specified in precision units, where 1 \* 10<sup>25</sup> = 100%, 0.2 \* 10<sup>25</sup> = 20%...

The sum of shares for all networks must be 100% or 10<sup>25</sup>.

### Set the `networkShareOwner` (optional)

Call `setNetworkShareOwner()` to assign the address that is allowed to update the `networkShare` value in the future. This allows dynamic tuning of rewards per network if needed.

### Configure fee (optional)

If you want to add a fee for creating subnets:

* Сonfigure the `FeeConfig` contract by calling `setFeeForOperation(address sender_, bytes32 operation_, uint256 fee_)` where:
  * `sender_` : `BuildersV4` contract address (the same as `BuildersV2`);
  * `operation_` : `0x6275696c6465727356342e6665652e7375626e65742e63726561746500000000` ;
  * `fee_` : any value less then 10<sup>25</sup>;
* Then call `setSubnetCreationFeeAmount` on the `BuildersV4` contract with the fee amount in wei.

If you want to add a fee for claim operation

* Сonfigure the `FeeConfig` contract by calling `setFeeForOperation(address sender_, bytes32 operation_, uint256 fee_)` where:
  * `sender_` : `BuildersV4` contract address (the same as `BuildersV2`);
  * `operation_` : `0x636c61696d000000000000000000000000000000000000000000000000000000` ;
  * `fee_` : value, where 1 \* 10<sup>25</sup> = 100%, 0.2 \* 10<sup>25</sup> = 20%..

### Fund the Treasury

Transfer the required amount of MOR tokens to the `BuildersTreasuryV2` contract. This contract will be responsible for sending rewards to subnet admins during the `claim()` process.


---

# Agent Instructions: 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://gitbook.mor.org/smart-contracts/documentation/builders-protocol/v4-protocol/guides/migration-from-v2-to-v4.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.
