WarrenToken
WarrenToken is an ERC20 token contract that represents a user's Liquidity Provider (LP) position in the Warren ecosystem. It extends the standard ERC20 functionality with additional features such as account locking and metadata management.
Inheritance
WarrenToken inherits from the following interfaces:
- IERC20: Standard ERC20 interface
- IERC20Lockable: Interface for account locking, which is useful for implementing transferless staking contracts
- IOwnable: Interface for ownership management
- IUnlockCallback: Uniswap v4 unlock callback interface
State Variables
metadataURI
string public metadataURI;
A URI pointing to the metadata associated with this token.
Functions
hub
function hub() external view returns (IWarrenHub);
Returns the address of the WarrenHub contract associated with this token.
token0
function token0() external view returns (Currency);
Returns the address of the first token in the pair.
token1
function token1() external view returns (Currency);
Returns the address of the second token in the pair.
poolManager
function poolManager() external view returns (IPoolManager);
Returns the address of the Uniswap v4 PoolManager contract associated with this token.
mint
function mint(address to, uint256 amount) external;
Mints new tokens to the specified address. Can only be called by the WarrenHub contract.
| Parameter | Type | Description |
|---|---|---|
| to | address | The address to receive the minted tokens |
| amount | uint256 | The amount of tokens to mint |
burn (from WarrenHub)
function burn(address from, uint256 amount) external;
Burns tokens from a specified address. Can only be called by the WarrenHub contract.
| Parameter | Type | Description |
|---|---|---|
| from | address | The address to burn tokens from |
| amount | uint256 | The amount of tokens to burn |
burn (from user)
function burn(uint256 amount) external;
Burns tokens from the caller's address.
| Parameter | Type | Description |
|---|---|---|
| amount | uint256 | The amount of tokens to burn |
initialize
function initialize(address owner_, string calldata metadataURI_) external;
Initializes the WarrenToken contract. Can only be called once, typically by the WarrenHub contract during deployment.
| Parameter | Type | Description |
|---|---|---|
| owner_ | address | The initial owner of the contract |
| metadataURI_ | string | The initial metadata URI for the token |
setMetadataURI
function setMetadataURI(string calldata metadataURI_) external;
Sets the metadata URI for the token. Can only be called by the contract owner.
| Parameter | Type | Description |
|---|---|---|
| metadataURI_ | string | The new URI for token metadata |
lock
function lock(IERC20Unlocker unlocker, bytes calldata data) external;
Locks the caller's account, preventing any transfers from the account until it's unlocked.
| Parameter | Type | Description |
|---|---|---|
| unlocker | IERC20Unlocker | The address that will be able to unlock the account |
| data | bytes | Additional data with no specified format |
unlock
function unlock(address account) external;
Unlocks a previously locked account. Can only be called by the designated unlocker for the account.
| Parameter | Type | Description |
|---|---|---|
| account | address | The account to unlock |
isLocked
function isLocked(address account) external view returns (bool);
Checks if an account is locked.
| Parameter | Type | Description |
|---|---|---|
| account | address | The account to check |
Returns:
bool: True if the account is locked, false otherwise
unlockerOf
function unlockerOf(address account) external view returns (IERC20Unlocker unlocker);
Returns the unlocker of an account.
| Parameter | Type | Description |
|---|---|---|
| account | address | The account whose unlocker is to be returned |
Returns:
unlocker: The unlocker of the account
Events
SetMetadataURI
event SetMetadataURI(string newURI);
Emitted when the metadata URI is updated.
| Parameter | Type | Description |
|---|---|---|
| newURI | string | The new metadata URI |
Lock
event Lock(address indexed account, IERC20Unlocker indexed unlocker);
Emitted when an account is locked.
| Parameter | Type | Indexed | Description |
|---|---|---|---|
| account | address | Yes | The account that was locked |
| unlocker | IERC20Unlocker | Yes | The address designated as the unlocker for the account |
Unlock
event Unlock(address indexed account, IERC20Unlocker indexed unlocker);
Emitted when an account is unlocked.
| Parameter | Type | Indexed | Description |
|---|---|---|---|
| account | address | Yes | The account that was unlocked |
| unlocker | IERC20Unlocker | Yes | The address that performed the unlock operation |