Skip to main content

MigrationProposalHelper

Git Source

Inherits: Owned

Single-use contract to execute OHM v1 migration to OHM v2 and burn

Constants​

TREASURY​

address public constant TREASURY = 0x31F8Cc382c9898b273eff4e0b7626a6987C846E8;

MIGRATOR​

address public constant MIGRATOR = 0x184f3FAd8618a6F458C16bae63F70C426fE784B3;

STAKING​

address public constant STAKING = 0xB63cac384247597756545b500253ff8E607a8020;

GOHM​

address public constant GOHM = 0x0ab87046fBb341D058F17CBC4c1133F25a20a52f;

OHMV1​

address public constant OHMV1 = 0x383518188C0C6d7730D91b2c03a03C837814a899;

OHMV2​

address public constant OHMV2 = 0x64aa3364F17a4D01c6f1751Fd97C2BD3D7e7f1D5;

BURNER​

address public immutable BURNER;

TEMPOHM​

address public immutable TEMPOHM;

ADMIN​

Admin address that can update the OHM v1 migration limit

address public immutable ADMIN;

MIGRATION_CATEGORY​

bytes32 public constant MIGRATION_CATEGORY = "migration";

State Variables​

OHMv1ToMigrate​

Maximum amount of OHM v1 to migrate (1e9 decimals)

uint256 public OHMv1ToMigrate;

isActivated​

True if the activation has been performed

bool public isActivated = false;

Functions​

constructor​

constructor(
address owner_,
address admin_,
address burner_,
address tempOHM_,
uint256 OHMv1ToMigrate_
) Owned(owner_);

Parameters

NameTypeDescription
owner_address
admin_address
burner_address
tempOHM_address
OHMv1ToMigrate_uint256

_onlyOwnerOrAdmin​

function _onlyOwnerOrAdmin() internal view;

onlyOwnerOrAdmin​

Modifier to restrict access to owner or admin

modifier onlyOwnerOrAdmin();

setOHMv1ToMigrate​

Set the maximum OHM v1 to migrate

Only callable by owner or admin. Updates the migration limit.

function setOHMv1ToMigrate(uint256 maxOHMv1_) external onlyOwnerOrAdmin;

Parameters

NameTypeDescription
maxOHMv1_uint256The new maximum OHM v1 amount (1e9 decimals)

rescue​

Rescue accidentally sent tokens

Only callable by owner or admin. Sweeps entire token balance to caller.

function rescue(IERC20 token_) external onlyOwnerOrAdmin;

Parameters

NameTypeDescription
token_IERC20The ERC20 token to rescue

getTempOHMToDeposit​

Calculate the amount of tempOHM to deposit

This is based on the OHMv1ToMigrate amount, converted to 1e18 decimals

function getTempOHMToDeposit() public view returns (uint256);

Returns

NameTypeDescription
<none>uint256

activate​

Executes the migration process

This function assumes:

  • The "burner_admin" role has been granted to this contract
  • The caller (owner) has approved tempOHM to this contract
  • The caller (owner) has tempOHM balance

Any tempOHM in excess of OHMv1ToMigrate * 1e9 will be burned. This is intentional: tempOHM has no utility after migration completes.

This function reverts if:

  • The caller is not the owner
  • The function has already been run
function activate() external onlyOwner;

_depositTempOHMToTreasury​

Transfer all tempOHM from owner and deposit the calculated amount to treasury

Transfers ALL tempOHM from owner but deposits only getTempOHMToDeposit(). Excess is burned by _burnExcess() (tempOHM has no post-migration utility).

function _depositTempOHMToTreasury() internal returns (uint256 ohmV1Minted);

Returns

NameTypeDescription
ohmV1Minteduint256The amount of OHM v1 minted from the deposit

_migrateOHMv1ToGOHM​

Migrate OHMv1 to gOHM via migrator

function _migrateOHMv1ToGOHM(uint256 ohmV1Amount) internal;

Parameters

NameTypeDescription
ohmV1Amountuint256The amount of OHM v1 to migrate

_burnExcess​

Burn any excess tempOHM and OHM v1 remaining after migration

Intentional cleanup: tempOHM has no utility after gOHM migration. Also burns any OHM v1 left from partial migration failures.

function _burnExcess() internal;

_unstakeAndBurn​

Unstake gOHM to OHMv2 and burn

function _unstakeAndBurn() internal;

Events​

Activated​

event Activated(address caller);

Parameters

NameTypeDescription
calleraddress

OHMv1ToMigrateUpdated​

event OHMv1ToMigrateUpdated(uint256 newMax);

Parameters

NameTypeDescription
newMaxuint256

Rescued​

event Rescued(address indexed token, address indexed to, uint256 amount);

Parameters

NameTypeDescription
tokenaddress
toaddress
amountuint256

Errors​

AlreadyActivated​

error AlreadyActivated();

InvalidParams​

error InvalidParams(string reason);

Parameters

NameTypeDescription
reasonstring

Unauthorized​

error Unauthorized();