Skip to main content

IV1Migrator

Git Source

Inherits: IEnabler, IVersioned

Title: IV1Migrator

forge-lint: disable-start(mixed-case-function,mixed-case-variable)

Interface for the V1Migrator policy that allows OHM v1 holders to migrate to OHM v2 via merkle proof verification

Functions

ohmV1

The OHM v1 token contract

function ohmV1() external view returns (IERC20 ohmV1_);

Returns

NameTypeDescription
ohmV1_IERC20The OHM v1 token

ohmV2

The OHM v2 token contract

function ohmV2() external view returns (IERC20 ohmV2_);

Returns

NameTypeDescription
ohmV2_IERC20The OHM v2 token

gOHM

The gOHM token contract used for conversion calculations

Used to calculate OHM v2 amount via balanceTo/balanceFrom to match production flow

function gOHM() external view returns (address gOHM_);

Returns

NameTypeDescription
gOHM_addressThe gOHM token

merkleRoot

The current merkle root for verifying eligible claims

function merkleRoot() external view returns (bytes32 merkleRoot_);

Returns

NameTypeDescription
merkleRoot_bytes32The current merkle root

migratedAmounts

The amount a user has migrated under the current root

function migratedAmounts(address account_) external view returns (uint256 migratedAmount_);

Parameters

NameTypeDescription
account_addressThe account to check

Returns

NameTypeDescription
migratedAmount_uint256The amount migrated by the user

remainingMintApproval

The remaining amount of OHM that can be minted by this contract

Returns the actual MINTR mint approval, not a stored value. This is the remaining amount available for migration and is always in sync with MINTR state.

function remainingMintApproval() external view returns (uint256 remaining_);

Returns

NameTypeDescription
remaining_uint256The remaining OHM that can be minted

totalMigrated

The total amount of OHM v1 migrated so far

function totalMigrated() external view returns (uint256 totalMigrated_);

Returns

NameTypeDescription
totalMigrated_uint256The total migrated amount

previewMigrate

Preview the OHM v2 amount that will be received for a given OHM v1 amount

Performs the same gOHM conversion as migrate() without state changes. Users migrating multiple times will lose dust on each transaction. Recommended: migrate full allocation in one transaction.

function previewMigrate(uint256 amount_) external view returns (uint256 ohmV2Amount_);

Parameters

NameTypeDescription
amount_uint256The amount of OHM v1 to preview (9 decimals)

Returns

NameTypeDescription
ohmV2Amount_uint256The amount of OHM v2 that would be received (9 decimals), or 0 if conversion rounds to zero

migrate

Migrate OHM v1 to OHM v2

User must approve this contract to transfer their OHM v1 Users can migrate any amount up to their allocated amount in multiple transactions

function migrate(uint256 amount_, bytes32[] calldata proof_, uint256 allocatedAmount_) external;

Parameters

NameTypeDescription
amount_uint256The amount of OHM v1 to migrate (9 decimals)
proof_bytes32[]The merkle proof proving the user is eligible
allocatedAmount_uint256The user's allocated amount from the merkle tree

setMerkleRoot

Update the merkle root for eligible claims

function setMerkleRoot(bytes32 merkleRoot_) external;

Parameters

NameTypeDescription
merkleRoot_bytes32The new merkle root

setRemainingMintApproval

Set the remaining MINTR mint approval for migration

This sets the remaining amount that can be minted, NOT a lifetime total. If you want 1000 OHM v2 to be available for migration and 600 has already been minted, call this with 1000 (not 400). Queries the current MINTR approval and adjusts it to the target approval.

function setRemainingMintApproval(uint256 approval_) external;

Parameters

NameTypeDescription
approval_uint256The target remaining mint approval (9 decimals)

rescue

Rescue accidentally sent tokens

Only callable by admin or legacy migration admin. Sweeps entire balance to caller.

function rescue(IERC20 token_) external;

Parameters

NameTypeDescription
token_IERC20The ERC20 token to rescue

verifyClaim

Verify if a claim is valid for a given account and allocated amount

function verifyClaim(address account_, uint256 allocatedAmount_, bytes32[] calldata proof_)
external
view
returns (bool valid_);

Parameters

NameTypeDescription
account_addressThe account to verify
allocatedAmount_uint256The allocated amount to verify
proof_bytes32[]The merkle proof

Returns

NameTypeDescription
valid_boolTrue if the claim is valid

Events

Migrated

Emitted when a user successfully migrates OHM v1 to OHM v2

event Migrated(address indexed user, uint256 ohmV1Amount, uint256 ohmV2Amount);

Parameters

NameTypeDescription
useraddressThe address of the user migrating
ohmV1Amountuint256The amount of OHM v1 burned
ohmV2Amountuint256The amount of OHM v2 minted

MerkleRootUpdated

Emitted when the merkle root is updated

event MerkleRootUpdated(bytes32 indexed newRoot, address indexed updater);

Parameters

NameTypeDescription
newRootbytes32The new merkle root
updateraddressThe address that updated the root

RemainingMintApprovalUpdated

Emitted when the remaining mint approval is updated

event RemainingMintApprovalUpdated(uint256 indexed newApproval, uint256 indexed oldApproval);

Parameters

NameTypeDescription
newApprovaluint256The new remaining mint approval
oldApprovaluint256The old remaining mint approval

Rescued

Emitted when tokens are rescued from the contract

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

Parameters

NameTypeDescription
tokenaddressThe rescued token address
toaddressThe recipient address
amountuint256The amount rescued

Errors

InvalidProof

Thrown when the provided merkle proof is invalid

error InvalidProof();

AmountExceedsAllowance

Thrown when the amount exceeds the user's allocation

error AmountExceedsAllowance(uint256 requested, uint256 allocated, uint256 migrated);

Parameters

NameTypeDescription
requesteduint256The amount requested to migrate
allocateduint256The user's allocated amount from the merkle tree
migrateduint256The amount already migrated by the user

CapExceeded

Thrown when the migration cap would be exceeded

error CapExceeded(uint256 amount, uint256 remaining);

Parameters

NameTypeDescription
amountuint256The amount requested to migrate
remaininguint256The remaining MINTR approval for the migrator contract

ZeroAmount

Thrown when the OHM v2 amount after gOHM conversion is zero

This can happen when the input OHM v1 amount is very small and gOHM conversion rounds down to zero

error ZeroAmount();

ZeroAddress

Thrown when an address parameter is zero

error ZeroAddress();

SameMerkleRoot

Thrown when attempting to set the same merkle root that is already set

error SameMerkleRoot();