Skip to main content

ERC20Base

Git Source

Inherits: ERC20Hooks, Ownable, ERC20Permit, IAmmalgamERC20

State Variables

pair

ITransferValidator public immutable pair;

hookRegistry

IHookRegistry private immutable hookRegistry;

tokenType

uint256 public immutable tokenType;

ownerTransferSkipValidation

This boolean is reserved for moving collateral to liquidators. And we reuse it to transfer debt from the pair to a borrower. Since the borrower might already be in trouble if this is called during a liquidation, we do not call validateOnUpdate to avoid failing on the loan to value check. This also means that saturation is not updated for this penalty owed. we think this is an acceptable discrepancy since it is only the penalty for over saturation that is not being included in the saturation update, which should be a negligible amount with respect to the total debt. Once a position is updated either by the users actions, or by a saturation liquidation reset, this penalty will be adjusted to the correct value in the Saturation State.

bool transient ownerTransferSkipValidation;

Functions

constructor

constructor(
ERC20BaseConfig memory config
) ERC20(config.name, config.symbol) ERC20Hooks(10, 500_000) ERC20Permit(config.name) Ownable(config.pair);

nonces

function nonces(
address owner
) public view virtual override(ERC20Permit, IERC20Permit) returns (uint256);

ownerMint

function ownerMint(address sender, address to, uint256 assets, uint256 shares) public virtual onlyOwner;

ownerTransfer

function ownerTransfer(address from, address to, uint256 amount) public virtual onlyOwner;

balanceOf

function balanceOf(
address account
) public view virtual override(ERC20, ERC20Hooks, IERC20) returns (uint256);

decimals

function decimals() public view virtual override(ERC20, IERC20Metadata) returns (uint8);

_update

Updates the pair state based on the transfer.

Triggers pair state updates for DEPOSIT_L and debt token transfers to avoid potential L token accumulation in the pair during burn operations.

function _update(address from, address to, uint256 amount) internal virtual override(ERC20, ERC20Hooks);

Parameters

NameTypeDescription
fromaddressThe address of the sender.
toaddressThe address of the recipient.
amountuint256The amount of tokens transferred.

addHook

function addHook(
address hook
) public override;

Errors

HookIsNotAllowed

error HookIsNotAllowed();